From 8fbdfe80b358d5be94ec61f1641fb88fbd190a17 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 24 Feb 2026 16:22:17 +0000 Subject: [PATCH] story-kit: create 158_bug_pty_debug_log_panics_on_multi_byte_utf_8_characters --- ...g_panics_on_multi_byte_utf_8_characters.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .story_kit/work/1_upcoming/158_bug_pty_debug_log_panics_on_multi_byte_utf_8_characters.md diff --git a/.story_kit/work/1_upcoming/158_bug_pty_debug_log_panics_on_multi_byte_utf_8_characters.md b/.story_kit/work/1_upcoming/158_bug_pty_debug_log_panics_on_multi_byte_utf_8_characters.md new file mode 100644 index 0000000..0967edc --- /dev/null +++ b/.story_kit/work/1_upcoming/158_bug_pty_debug_log_panics_on_multi_byte_utf_8_characters.md @@ -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