From ce95148232d5cd9c5cf8acba7cae7689851f6326 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Wed, 1 Apr 2026 17:29:01 +0800 Subject: [PATCH] fix: truncate_title panic on multi-byte UTF-8 strings Co-Authored-By: Claude Opus 4.6 (1M context) --- src-tauri/src/chat_channel/session_commands.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/chat_channel/session_commands.rs b/src-tauri/src/chat_channel/session_commands.rs index 04923dd..5545c36 100644 --- a/src-tauri/src/chat_channel/session_commands.rs +++ b/src-tauri/src/chat_channel/session_commands.rs @@ -928,9 +928,10 @@ fn resolve_agent_type( } fn truncate_title(s: &str) -> String { - if s.len() <= 80 { + if s.chars().count() <= 80 { s.to_string() } else { - format!("{}...", &s[..77]) + let truncated: String = s.chars().take(77).collect(); + format!("{truncated}...") } }