Skip to content

fix(cli): handle CJK wide chars in TUI input height - #5539

Closed
qaqcvc wants to merge 1 commit into
NousResearch:mainfrom
qaqcvc:fix/tui-cjk-input-height
Closed

qaqcvc wants to merge 1 commit into
NousResearch:mainfrom
qaqcvc:fix/tui-cjk-input-height

Conversation

@qaqcvc

@qaqcvc qaqcvc commented Apr 6, 2026

Copy link
Copy Markdown

Summary

  • fix multiline TUI input height calculation for CJK / East Asian wide characters
  • use prompt_toolkit.utils.get_cwidth() instead of len() when estimating wrapped input rows
  • prefer prompt_toolkit's live terminal width over shutil when the TUI app is running
  • add regression tests covering wide-character wrapping behavior

Root cause

The TUI input box estimated visual line count using Python character length, but prompt_toolkit renders many CJK characters as double-width terminal cells. Once the input wrapped, Hermes undercounted the number of visual rows, so the first row could get visually overwritten/disappear.

Testing

  • python3 -m pytest tests/test_cli_status_bar.py -q -o addopts=''
  • python3 -m pytest tests/test_cli_status_bar.py tests/test_cli_init.py tests/test_cli_loading_indicator.py -q -o addopts=''

Closes #5221

@teknium1

teknium1 commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Merged via PR #5665. Your commit was cherry-picked with authorship preserved. Thanks @qaqcvc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants