diff --git a/src-tauri/src/db.rs b/src-tauri/src/db.rs index 98bc5d2..71df5e3 100644 --- a/src-tauri/src/db.rs +++ b/src-tauri/src/db.rs @@ -717,7 +717,13 @@ impl Database { let mut summary_parts: Vec = Vec::new(); for (_, role, content) in &old_messages { let preview = if content.len() > 200 { - format!("{}...", &content[..200]) + // Sicher an Char-Boundary abschneiden (Multi-Byte wie ─, ä, ü) + let end = content.char_indices() + .take_while(|(i, _)| *i < 200) + .last() + .map(|(i, c)| i + c.len_utf8()) + .unwrap_or(200.min(content.len())); + format!("{}...", &content[..end]) } else { content.clone() }; diff --git a/src-tauri/src/knowledge.rs b/src-tauri/src/knowledge.rs index 3461b6e..4565573 100644 --- a/src-tauri/src/knowledge.rs +++ b/src-tauri/src/knowledge.rs @@ -993,9 +993,14 @@ pub async fn format_tool_hints( for entry in entries { hints.push(format!("\n**{}** ({})", entry.title, entry.category)); - // Content auf ~300 Zeichen kürzen + // Content auf ~300 Zeichen kürzen (sicher an Char-Boundary) let content = if entry.content.len() > 300 { - format!("{}...", &entry.content[..300]) + let end = entry.content.char_indices() + .take_while(|(i, _)| *i < 300) + .last() + .map(|(i, c)| i + c.len_utf8()) + .unwrap_or(300.min(entry.content.len())); + format!("{}...", &entry.content[..end]) } else { entry.content };