Skip to content

[Bug]: TUI input box renders incorrectly for Chinese / East Asian wide characters #5221

@qaqcvc

Description

@qaqcvc

Bug Description

In the Hermes TUI/CLI input box, typing Chinese characters (and likely other East Asian wide characters such as Japanese/Korean) renders incorrectly.

The input area appears to calculate layout/cursor/line width as if the characters were single-width, which causes the input box to become visually wrong when entering CJK text.

This looks related to a previous Hermes TUI/input-box rendering bug around line layout / segmentation / width calculation that was fixed for normal English/ASCII input, but the fix does not appear to fully handle East Asian wide characters.

Expected Behavior

When typing Chinese / Japanese / Korean characters in the TUI input box:

  • cursor position should stay aligned with the actual text
  • wrapped lines should break at the correct visible columns
  • the input box border/layout should remain visually correct
  • editing should work the same way as with ASCII text

Actual Behavior

When typing Chinese characters in the TUI input box:

  • the input box becomes visually wrong / misaligned
  • cursor and/or wrapping appears incorrect
  • the issue seems specific to East Asian wide characters rather than English text

Steps to Reproduce

  1. Start Hermes in the TUI / CLI interface
  2. Focus the normal input box
  3. Type Chinese text (for example: 你好你好你好你好 or a longer Chinese sentence)
  4. Continue typing until the line should wrap or the cursor moves across the input region
  5. Observe that the input box layout/cursor/rendering is incorrect

Example Repro Text

You can reproduce with something like:

你好,这是一个用于测试 Hermes TUI 输入框宽度计算的中文句子。

Or shorter repeated wide characters:

你好你好你好你好你好你好

Expected Root Cause Area

Likely related to terminal/TUI width calculation for wide Unicode characters:

  • East Asian width / fullwidth character handling
  • wcwidth / wcswidth behavior
  • prompt_toolkit integration for cursor positioning / wrapping
  • any custom line segmentation logic added in earlier TUI fixes

Why this may be related to an earlier bug

There was previously a Hermes TUI/input-box rendering bug involving line layout/segmentation that appears to have been fixed for English characters.

This report is specifically that the problem still exists for CJK/East Asian characters, suggesting the previous fix may have assumed single-column characters.

Environment

  • Product: Hermes CLI / TUI
  • Input language: Chinese (likely affects other East Asian scripts too)
  • Character class likely involved: wide Unicode / East Asian width characters

Notes

This issue is about the local TUI input box rendering/editing experience, not model output.

It would be ideal to verify against:

  • Chinese input
  • Japanese kana/kanji
  • Korean Hangul
  • mixed ASCII + CJK input
  • line wrapping and backspacing near wrap boundaries

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/tuiTerminal UI (ui-tui/ + tui_gateway/)sweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions