Panic when truncating UTF-8 Chinese characters in status display

Resolved 💬 3 comments Opened Jan 9, 2026 by AsiaOstrich Closed Jan 12, 2026

Bug Description

Claude Code CLI panics when displaying status text containing Chinese characters. The string truncation logic does not properly handle UTF-8 character boundaries.

Error Message

thread '<unnamed>' (24839166) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 11 is not a char boundary; it is inside '援' (bytes 9..12) of `工具支援 `
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

The string 工具支援 (meaning "tool support" in Chinese) is being truncated at byte index 11, which falls in the middle of the character (bytes 9-12). In UTF-8 encoding, Chinese characters occupy 3 bytes each. The truncation logic is cutting at a byte offset that is not a valid UTF-8 character boundary.

Expected Behavior

String truncation should respect UTF-8 character boundaries and only cut at valid positions.

Environment

  • OS: macOS (Darwin 24.6.0)
  • Shell: zsh

Suggested Fix

When truncating strings for display, use character-aware methods like str.char_indices() to find valid truncation points, or use a crate like unicode-segmentation for proper grapheme cluster handling.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗