Environment
- Spacebot Version: v0.3.3
- OS: macOS (Apple Silicon M1, 8GB RAM)
Description
Issue #273 fixed a UTF-8 char boundary panic in cortex_chat.rs, but the same unsafe &s[..200] pattern exists in two other files, causing runtime panics when truncating strings containing multi-byte characters (em dashes, CJK, emoji, etc.).
Panic observed
thread 'tokio-runtime-worker' (14991) panicked at src/agent/channel.rs:2907:45:
byte index 200 is not a char boundary; it is inside '—' (bytes 199..202) of
`Here's today's meetings (America/Phoenix local time, 2026-03-31)...`
This crash prevented Spacebot from delivering a calendar summary response via Slack — the calendar data was fetched successfully but the worker result truncation panicked.
Affected locations
src/agent/channel.rs:2834 — branch conclusion truncation for working memory
src/agent/channel.rs:2907 — worker result truncation for working memory
src/messaging/signal.rs:900 — Signal typing indicator error body truncation
Fix
Replace &s[..200] with char-boundary-safe truncation:
let end = s.floor_char_boundary(200);
&s[..end]
floor_char_boundary is stable since Rust 1.82.
Related
Environment
Description
Issue #273 fixed a UTF-8 char boundary panic in
cortex_chat.rs, but the same unsafe&s[..200]pattern exists in two other files, causing runtime panics when truncating strings containing multi-byte characters (em dashes, CJK, emoji, etc.).Panic observed
This crash prevented Spacebot from delivering a calendar summary response via Slack — the calendar data was fetched successfully but the worker result truncation panicked.
Affected locations
src/agent/channel.rs:2834— branch conclusion truncation for working memorysrc/agent/channel.rs:2907— worker result truncation for working memorysrc/messaging/signal.rs:900— Signal typing indicator error body truncationFix
Replace
&s[..200]with char-boundary-safe truncation:floor_char_boundaryis stable since Rust 1.82.Related
cortex_chat.rs