2 Commits

Author SHA1 Message Date
teknium1
7f21c7dcc7 fix: keep cli_footer_split importable under the prompt_toolkit test stubs
tests/hermes_cli/test_prompt_stash_cli.py builds HermesCLI with a fixed
list of prompt_toolkit submodules replaced by MagicMocks; importing
prompt_toolkit.layout.screen for a type annotation fell outside that list
and raised ModuleNotFoundError at cli_tui_mixin import time.
2026-09-20 13:35:09 -07:00
teknium1
3b51213c03 fix(cli): footer no longer collapses into "Window too small..." mid-turn (#57393)
Symptom: the classic CLI's whole footer (status bar, rules, composer) is
replaced by prompt_toolkit's " Window too small... " placeholder on
terminals that are plainly large enough — a 199x48 tmux pane, Windows 10,
a fullscreen 14" Mac.

Root cause: in non-full-screen mode prompt_toolkit renders the footer into
exactly the height it measured a moment earlier (Renderer.render ->
HSplit.preferred_height), then HSplit._divide_heights measures every child
again while painting. Every footer row has a callable height that the agent
thread flips at turn start (_agent_running -> spacer, _spinner_text ->
spinner), so a row appearing between the two passes makes sum(min) exceed
the budget by one and stock HSplit gives up on the whole container.
Hermes's throttled _invalidate can then drop the healing repaint for the
length of a tool call, so the placeholder sits there looking like a
geometry problem. Terminal size never mattered.

Fix: the footer root is a FooterSplit — an HSplit whose overflow path
allocates the children's minimums bottom-up (composer, rules, status bar
first) so only the row that arrived late loses its row for that one frame,
and schedules an unthrottled redraw so the next frame measures and paints
against the same state.

Live repro (real `hermes chat` in a 200x50 tmux pane against a fake
provider, measure->paint window widened via a sitecustomize shim):
before 3/3 turns hit the placeholder in the renderer and it reached the
screen; after 3/3 still trip the base-class check and 0/3 reach the screen.
2026-09-20 13:35:09 -07:00