fix(cli): prevent duplicated prompt rows after terminal resize#6766
fix(cli): prevent duplicated prompt rows after terminal resize#6766g-guthrie wants to merge 1 commit into
Conversation
- replace the coarse shrink reflow multiplier with row-by-row estimation - prevent duplicated prompt/input rows after repeated terminal resizes - add a regression test covering resize reflow math
|
This PR addresses one specific symptom of a broader issue: the CLI/TUI does not reflow content on terminal resize. There are 34+ open bugs about various manifestations of this problem. I've opened a tracking feature request (#24164) that proposes a comprehensive solution — a SIGWINCH handler triggering full re-render at new viewport dimensions, comparable to how opencode and Claude Code handle resize smoothly. If this PR gets merged, please consider whether the underlying architecture supports full reflow, or if we still need a systematic fix. The tracking issue consolidates all related work: |
|
Closing — the helper math is good but unanchored on current main. This PR was built on the old If a follow-up shrink-reflow drift appears that the current debounced path can't catch, we can extract the helper from this closed PR for a fresh implementation against the new architecture. Thanks @g-guthrie! |
Summary
Problem
The current resize workaround in
cli.pyestimates extra reflowed rows aslast_height * (reflow_factor - 1). That coarse estimate can under/over-shoot when rendered rows have different widths, leaving old prompt/input rows behind after repeated shrink/expand cycles.Fix
Use the actual widths of the previously rendered physical rows from
renderer._last_screen.data_bufferto estimate how many extra rows narrowing will create, then inflaterenderer._cursor_pos.yby that exact extra-row count before prompt_toolkit erases/redraws.Test Plan
~/.hermes/Hermes-Agent/venv/bin/python -m py_compile cli.py tests/cli/test_cli_resize_reflow.py~/.hermes/Hermes-Agent/venv/bin/python -m pytest tests/cli/test_cli_resize_reflow.py tests/cli/test_cli_loading_indicator.py -qNotes