fix: truncate_title panic on multi-byte UTF-8 strings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-01 17:29:01 +08:00
parent d76dc716e4
commit ce95148232

View File

@@ -928,9 +928,10 @@ fn resolve_agent_type(
} }
fn truncate_title(s: &str) -> String { fn truncate_title(s: &str) -> String {
if s.len() <= 80 { if s.chars().count() <= 80 {
s.to_string() s.to_string()
} else { } else {
format!("{}...", &s[..77]) let truncated: String = s.chars().take(77).collect();
format!("{truncated}...")
} }
} }