extract truncation helpers, fix clippy warnings, dedup batching loop
Add util::truncate() and util::first_n_chars() to replace 16 call sites doing the same floor_char_boundary or chars().take().collect() patterns. Deduplicate the batching loop in consolidate.rs (4 copies → 1 loop over an array). Fix all clippy warnings: redundant closures, needless borrows, collapsible if, unnecessary cast, manual strip_prefix. Net: -44 lines across 16 files.
This commit is contained in:
parent
e24dee6bdf
commit
52523403c5
16 changed files with 85 additions and 129 deletions
|
|
@ -165,11 +165,7 @@ pub fn split_on_compaction(messages: Vec<(usize, String, String, String)>) -> Ve
|
|||
fn format_conversation(messages: &[(usize, String, String, String)]) -> String {
|
||||
messages.iter()
|
||||
.map(|(line, role, text, ts)| {
|
||||
let text = if text.len() > 2000 {
|
||||
format!("{}...[truncated]", &text[..text.floor_char_boundary(1800)])
|
||||
} else {
|
||||
text.clone()
|
||||
};
|
||||
let text = crate::util::truncate(text, 1800, "...[truncated]");
|
||||
if ts.is_empty() {
|
||||
format!("L{} [{}]: {}", line, role, text)
|
||||
} else {
|
||||
|
|
@ -424,13 +420,8 @@ pub fn experience_mine(
|
|||
let _ = store.upsert_node(node);
|
||||
count += 1;
|
||||
|
||||
let preview = if content.len() > 80 {
|
||||
let end = content.floor_char_boundary(77);
|
||||
&content[..end]
|
||||
} else {
|
||||
content
|
||||
};
|
||||
println!(" + [{}] {}...", ts, preview);
|
||||
let preview = crate::util::truncate(content, 77, "...");
|
||||
println!(" + [{}] {}", ts, preview);
|
||||
}
|
||||
|
||||
// Record this transcript/segment as mined (even if count == 0, to prevent re-runs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue