fix(chat): handle multi-byte character truncation in tool result preview
This commit is contained in:
parent
5c2369ff47
commit
c48f7319ca
@ -791,7 +791,13 @@ impl ChatService {
|
|||||||
crate::tool::ToolResult::Error(msg) => msg.clone(),
|
crate::tool::ToolResult::Error(msg) => msg.clone(),
|
||||||
};
|
};
|
||||||
let preview = if text.len() > 300 {
|
let preview = if text.len() > 300 {
|
||||||
format!("{}...", &text[..300])
|
let end = text
|
||||||
|
.char_indices()
|
||||||
|
.map(|(i, _)| i)
|
||||||
|
.take_while(|&i| i <= 300)
|
||||||
|
.last()
|
||||||
|
.unwrap_or(300);
|
||||||
|
format!("{}...", &text[..end])
|
||||||
} else {
|
} else {
|
||||||
text.clone()
|
text.clone()
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user