story-kit: create 158_bug_pty_debug_log_panics_on_multi_byte_utf_8_characters
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
name: "PTY debug log panics on multi-byte UTF-8 characters"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Bug 158: PTY debug log panics on multi-byte UTF-8 characters
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
The PTY debug logging in `claude_code.rs` uses byte-level string slicing (`&trimmed[..trimmed.len().min(120)]`) which panics when byte 120 falls inside a multi-byte UTF-8 character like an em dash (`—`, 3 bytes: E2 80 94).
|
||||||
|
|
||||||
|
## How to Reproduce
|
||||||
|
|
||||||
|
1. Start an agent on a story
|
||||||
|
2. Have the agent process a log file or content that causes Claude to output an em dash (`—`) near the 120-byte boundary of a JSON stream event line
|
||||||
|
3. The PTY task panics with "byte index 120 is not a char boundary"
|
||||||
|
|
||||||
|
## Actual Result
|
||||||
|
|
||||||
|
WebSocket error: PTY task panicked with "byte index 120 is not a char boundary; it is inside '—' (bytes 118..121)"
|
||||||
|
|
||||||
|
## Expected Result
|
||||||
|
|
||||||
|
The debug log should safely truncate the string at a valid UTF-8 char boundary without panicking.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] Replace `&trimmed[..trimmed.len().min(120)]` with `&trimmed[..trimmed.floor_char_boundary(120)]` in `server/src/llm/providers/claude_code.rs:251`
|
||||||
|
- [ ] Agent sessions no longer panic when Claude outputs multi-byte UTF-8 characters near the truncation boundary
|
||||||
Reference in New Issue
Block a user