mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-26 06:01:49 +00:00
#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:
parent
cbd1f8e4be
commit
965ae7fa97
2 changed files with 29 additions and 20 deletions
24
cli.py
24
cli.py
|
|
@ -3235,25 +3235,27 @@ class HermesCLI:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _scrollback_box_width(width: Optional[int] = None) -> int:
|
def _scrollback_box_width(width: Optional[int] = None) -> int:
|
||||||
"""Return a resize-safe width for printed scrollback box rules.
|
"""Return the full viewport width for printed scrollback box rules.
|
||||||
|
|
||||||
Lines already printed to terminal scrollback are reflowed by the
|
Previously this clamped to ``max(32, min(width, 56))`` as a defense
|
||||||
terminal emulator when the column count shrinks. A full-width response
|
against terminal-emulator reflow on column-shrink (#25975, salvaging
|
||||||
border drawn at, say, 200 columns will wrap into two or three rows of
|
#24403). That clamp made response/reasoning borders look stubby on
|
||||||
dashes after the user resizes to 80 columns, looking like duplicated
|
any modern wide terminal. We now trust the prompt_toolkit
|
||||||
separator lines (the family of bugs tracked by #18449, #19280, #22976).
|
``_output_screen_diff`` monkey-patch landed in #26137 (salvaging
|
||||||
|
#25981) to keep chrome out of scrollback in the first place, and
|
||||||
|
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.
|
||||||
|
|
||||||
Keep decorative scrollback boxes intentionally narrower than the
|
A small floor (32 cols) is kept so the box still renders on tiny
|
||||||
viewport so a moderate resize never triggers reflow. The live TUI
|
terminals without negative ``'─' * (w - 2)`` math.
|
||||||
footer (status bar, input rule) still uses the full width — only
|
|
||||||
content that is *stamped into scrollback* needs this clamp.
|
|
||||||
"""
|
"""
|
||||||
if width is None:
|
if width is None:
|
||||||
try:
|
try:
|
||||||
width = shutil.get_terminal_size((80, 24)).columns
|
width = shutil.get_terminal_size((80, 24)).columns
|
||||||
except Exception:
|
except Exception:
|
||||||
width = 80
|
width = 80
|
||||||
return max(32, min(int(width or 80), 56))
|
return max(32, int(width or 80))
|
||||||
|
|
||||||
def _tui_input_rule_height(self, position: str, width: Optional[int] = None) -> int:
|
def _tui_input_rule_height(self, position: str, width: Optional[int] = None) -> int:
|
||||||
"""Return the visible height for the top/bottom input separator rules."""
|
"""Return the visible height for the top/bottom input separator rules."""
|
||||||
|
|
|
||||||
|
|
@ -349,20 +349,27 @@ class TestCLIStatusBar:
|
||||||
assert cli_obj._tui_input_rule_height("top", width=90) == 1
|
assert cli_obj._tui_input_rule_height("top", width=90) == 1
|
||||||
assert cli_obj._tui_input_rule_height("bottom", 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):
|
def test_scrollback_box_width_returns_viewport_width(self):
|
||||||
"""Decorative scrollback boxes clamp to a width small enough that
|
"""Decorative scrollback boxes use the full viewport width.
|
||||||
moderate terminal shrinks don't cause reflow into scrollback."""
|
|
||||||
|
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
|
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(20) == 32
|
||||||
assert HermesCLI._scrollback_box_width(32) == 32
|
assert HermesCLI._scrollback_box_width(32) == 32
|
||||||
# Cap at 56 — wide terminals don't get full-width boxes.
|
# Above the floor, return the actual viewport width — no cap.
|
||||||
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.
|
|
||||||
assert HermesCLI._scrollback_box_width(48) == 48
|
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):
|
def test_agent_spacer_reclaimed_on_narrow_terminals(self):
|
||||||
cli_obj = _make_cli()
|
cli_obj = _make_cli()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue