Fix UTF-8 slicing panics: use floor_char_boundary for all truncation

Byte-position truncation (&s[..s.len().min(N)]) panics when position
N lands inside a multi-byte character. Fixed in parser debug logging,
API error messages, oneshot response logging, and CLI agent display.

Also fixed tool dispatch permissions (removed global fallback).

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-08 19:33:05 -04:00
parent 1776222b07
commit fba8fcc587
6 changed files with 12 additions and 10 deletions

View file

@ -606,7 +606,7 @@ fn resolve_conversation(budget: Option<usize>) -> String {
if total_bytes >= max_bytes { break; }
let name = if role == "user" { &cfg.user_name } else { &cfg.assistant_name };
let formatted = if !ts.is_empty() {
oldest_ts = ts[..ts.len().min(19)].to_string();
oldest_ts = ts[..ts.floor_char_boundary(ts.len().min(19))].to_string();
format!("**{}** {}: {}", name, &oldest_ts, content)
} else {
format!("**{}:** {}", name, content)