revert(cli): drop scrollback box width clamp (#25975), restore full-width borders (#26163)

#25975 (salvaging #24403) clamped decorative scrollback Panels and
streaming box rules to `max(32, min(width, 56))` as a defense against
terminal-emulator reflow when columns shrink. On any modern wide
terminal this made the response/reasoning borders look stubby — 56
cols inside a 200-col viewport.

#26137 (salvaging #25981, by @OutThisLife) landed a more fundamental
fix: prompt_toolkit's `_output_screen_diff` is monkey-patched so its
reserve-vertical-space cursor move no longer pushes chrome into
scrollback at all. With that in place, the clamp is no longer
load-bearing for the chrome-into-scrollback class of bugs — the
remaining risk is purely cosmetic reflow of *already stamped*
Panel borders during an aggressive column shrink, which we now
accept as a tradeoff for restoring proper full-width rendering.

Changes:
- `_scrollback_box_width()` returns `max(32, width)` (just the floor,
  no upper cap). All 10 call sites stay valid.
- Updated `test_scrollback_box_width_caps_to_resize_safe_value` to
  the new `test_scrollback_box_width_returns_viewport_width` asserting
  full-width passthrough above the 32-col floor.

Floor of 32 is kept so `'─' * (w - 2)` math stays positive on tiny
terminals.

Refs #18449 #19280 #22976 (the original reflow class) and #25975
(the clamp this reverts).
This commit is contained in:
Teknium 2026-05-14 23:30:16 -07:00 committed by GitHub
parent cbd1f8e4be
commit 965ae7fa97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 20 deletions

View file

@ -349,20 +349,27 @@ class TestCLIStatusBar:
assert cli_obj._tui_input_rule_height("top", width=90) == 1
assert cli_obj._tui_input_rule_height("bottom", width=90) == 1
def test_scrollback_box_width_caps_to_resize_safe_value(self):
"""Decorative scrollback boxes clamp to a width small enough that
moderate terminal shrinks don't cause reflow into scrollback."""
def test_scrollback_box_width_returns_viewport_width(self):
"""Decorative scrollback boxes use the full viewport width.
The previous clamp (max 56 cols) was reverted in favour of the
prompt_toolkit ``_output_screen_diff`` monkey-patch landed in
#26137, which keeps chrome out of scrollback at the source.
We accept that an aggressive column-shrink may visually reflow
already printed Panel borders that's a cosmetic artifact of
stamped scrollback history, not a live-render bug.
"""
from cli import HermesCLI
# Floor at 32 — narrow terminals still get something usable.
# Floor at 32 — narrow terminals still get something usable
# (avoids negative ``'─' * (w - 2)`` math).
assert HermesCLI._scrollback_box_width(20) == 32
assert HermesCLI._scrollback_box_width(32) == 32
# Cap at 56 — wide terminals don't get full-width boxes.
assert HermesCLI._scrollback_box_width(80) == 56
assert HermesCLI._scrollback_box_width(120) == 56
assert HermesCLI._scrollback_box_width(200) == 56
# Mid-range passes through up to the cap.
# Above the floor, return the actual viewport width — no cap.
assert HermesCLI._scrollback_box_width(48) == 48
assert HermesCLI._scrollback_box_width(80) == 80
assert HermesCLI._scrollback_box_width(120) == 120
assert HermesCLI._scrollback_box_width(200) == 200
def test_agent_spacer_reclaimed_on_narrow_terminals(self):
cli_obj = _make_cli()