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:
@@ -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}...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user