From 1cce9ea5499f211cc195037175edbca4527f058d Mon Sep 17 00:00:00 2001 From: Heejae Kim Date: Thu, 9 Oct 2025 11:28:27 +0900 Subject: [PATCH] fix: use `truncate_safe` for safer string truncation in `chat/checkpoint.rs`. --- crates/chat-cli/src/cli/chat/checkpoint.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/chat-cli/src/cli/chat/checkpoint.rs b/crates/chat-cli/src/cli/chat/checkpoint.rs index bbe36be08c..cfe76635ca 100644 --- a/crates/chat-cli/src/cli/chat/checkpoint.rs +++ b/crates/chat-cli/src/cli/chat/checkpoint.rs @@ -28,6 +28,7 @@ use serde::{ use tracing::debug; use crate::cli::ConversationState; +use super::util::truncate_safe; use crate::cli::chat::conversation::HistoryEntry; use crate::os::Os; @@ -370,7 +371,7 @@ pub fn truncate_message(s: &str, max_len: usize) -> String { return s.to_string(); } - let truncated = &s[..max_len]; + let truncated = truncate_safe(s, max_len); if let Some(pos) = truncated.rfind(' ') { format!("{}...", &truncated[..pos]) } else {