Panic: UTF-8 char boundary error when displaying Korean text in status line
Description
Claude Code crashes with a Rust panic when displaying Korean (한글) characters in the status line or animation output.
Error Message
thread '<unnamed>' (750941) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 2 is not a char boundary; it is inside '어' (bytes 0..3) of `어 × 0.12s + spring)`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
zsh: abort claude
Root Cause Analysis
The Korean character '어' is a 3-byte UTF-8 character (bytes 0..3). The code attempts to slice the string at byte index 2, which falls inside the multi-byte character boundary, causing the panic.
This appears to occur when the CLI truncates or formats text for display (possibly in status bar or animation output), without properly handling multi-byte UTF-8 characters.
Environment
- Claude Code Version: 2.1.1
- OS: macOS (Darwin 24.6.0)
- Platform: darwin
- Shell: zsh
Steps to Reproduce
- Use Claude Code CLI with Korean language responses enabled
- Perform operations that trigger status line animations or text output containing Korean characters
- The crash occurs when the CLI attempts to truncate or format the Korean text for display
Expected Behavior
The CLI should properly handle UTF-8 multi-byte characters when truncating or formatting text for display, ensuring string operations only occur at valid character boundaries.
Suggested Fix
When truncating strings for display, use character-aware methods instead of byte-based slicing:
- Use
str.chars()iterator for character-based operations - Use
str.char_indices()to find valid split points - Consider using the
unicode-widthcrate for proper display width calculations
Additional Context
The error message 어 × 0.12s + spring) suggests this occurs in animation/timing display code, possibly when showing operation duration or spring animation parameters.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗