You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Classic prompt_toolkit CLI resize recovery could leave stale prompt/input glyphs after narrowing the terminal. The artifacts were visual terminal cells, not text inserted into the prompt buffer.
This patch keeps prompt_toolkit's renderer cursor cache intact until its original resize handler runs, and factors the input-height estimate into a tested helper that matches prompt_toolkit's prompt wrapping behavior.
Problem
Hermes wrapped prompt_toolkit's resize handler to recover from footer/input artifacts. The wrapper reset the renderer and invalidated the app before calling prompt_toolkit's original resize handler.
That order is unsafe: prompt_toolkit's Application._on_resize() begins by erasing the current rendered screen from the renderer's cached cursor position. If Hermes resets that renderer state first, prompt_toolkit can lose the live prompt origin and stale prompt glyphs can remain after a narrow resize.
The input-height estimator had a related narrow-terminal issue: it subtracted prompt width from every wrapped row and replaced very small widths with a fake wide fallback. prompt_toolkit's BeforeInput prompt only consumes cells on logical line 0; wrapped continuation rows use the full terminal width.
What changed
Let prompt_toolkit's original resize handler run with renderer cursor state intact.
Keep resize status-bar suppression so footer/status chrome does not get redrawn into scrollback immediately after column shrink.
Add _estimate_tui_input_height() for classic CLI input-height calculation.
Use prompt_toolkit cell widths for wide characters.
Count prompt width only on logical line 0.
Clamp transient zero-column terminal reports to one cell instead of substituting a fake wide width.
Replace duplicated test-local input-height logic with direct regression tests for the shared helper.
Compatibility notes
This is scoped to the classic prompt_toolkit CLI path.
The Ink/React hermes --tui path is not changed.
Explicit full-screen redraw behavior remains unchanged; _force_full_redraw() still resets renderer state after clearing the screen.
Resize recovery still avoids clearing the physical screen or scrollback, preserving the startup banner and prior output.
Test plan
RED check: with only the new tests applied, targeted tests failed as expected:
resize test observed renderer_reset, invalidate, original_resize instead of only original_resize
input-height tests failed because _estimate_tui_input_height() did not exist
Launch the classic CLI, type or paste a long single-line prompt without submitting, resize the terminal narrow enough that the input wraps, then resize wider/narrower again.
Expected:
no duplicated prompt glyphs or separators;
input remains visible and wraps normally;
bottom input area is not clipped;
startup banner/scrollback is not cleared by resize.
So this looks like inherited upstream metadata/test drift: the test expects MiniMax-M3 to re-resolve to 1_000_000, while the current provider-aware models.dev path returns 512000 for MiniMax-M3. The PR branch itself is rebased onto current main and only changes the classic CLI resize files:
cli.py
tests/cli/test_cli_force_redraw.py
tests/cli/test_cli_status_bar.py
Local focused verification for this resize change passed:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comp/cliCLI entry point, hermes_cli/, setup wizardP3Low — cosmetic, nice to havetype/bugSomething isn't working
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Classic prompt_toolkit CLI resize recovery could leave stale prompt/input glyphs after narrowing the terminal. The artifacts were visual terminal cells, not text inserted into the prompt buffer.
This patch keeps prompt_toolkit's renderer cursor cache intact until its original resize handler runs, and factors the input-height estimate into a tested helper that matches prompt_toolkit's prompt wrapping behavior.
Problem
Hermes wrapped prompt_toolkit's resize handler to recover from footer/input artifacts. The wrapper reset the renderer and invalidated the app before calling prompt_toolkit's original resize handler.
That order is unsafe: prompt_toolkit's
Application._on_resize()begins by erasing the current rendered screen from the renderer's cached cursor position. If Hermes resets that renderer state first, prompt_toolkit can lose the live prompt origin and stale prompt glyphs can remain after a narrow resize.The input-height estimator had a related narrow-terminal issue: it subtracted prompt width from every wrapped row and replaced very small widths with a fake wide fallback. prompt_toolkit's
BeforeInputprompt only consumes cells on logical line 0; wrapped continuation rows use the full terminal width.What changed
_estimate_tui_input_height()for classic CLI input-height calculation.Compatibility notes
hermes --tuipath is not changed._force_full_redraw()still resets renderer state after clearing the screen.Test plan
renderer_reset,invalidate,original_resizeinstead of onlyoriginal_resize_estimate_tui_input_height()did not existpython -m py_compile cli.py4 passedscripts/run_tests.sh tests/cli/test_cli_force_redraw.py tests/cli/test_cli_status_bar.py tests/cli/test_cli_terminal_response_sanitizer.py63 tests passed, 0 failedgit diff --checkManual smoke test
Launch the classic CLI, type or paste a long single-line prompt without submitting, resize the terminal narrow enough that the input wraps, then resize wider/narrower again.
Expected: