Skip to content

fix(cli): preserve startup scrollback on resize#23294

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:codex/22999-cli-resize-banner
Closed

fix(cli): preserve startup scrollback on resize#23294
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:codex/22999-cli-resize-banner

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

What does this PR do?

Preserve the classic CLI startup banner and tool summary during terminal resize recovery by resetting prompt_toolkit's renderer instead of wiping the physical terminal scrollback.

Related Issue

Fixes #22999

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • update /Users/leongong/Desktop/LeonProjects/worktrees/hermes-agent/hermes-22999-cli-resize-banner/cli.py so resize recovery calls the original prompt_toolkit resize path first, then resets the renderer and invalidates for a clean repaint
  • stop clearing physical scrollback during resize recovery so startup banner/tool summary content survives maximize and resize events
  • update /Users/leongong/Desktop/LeonProjects/worktrees/hermes-agent/hermes-22999-cli-resize-banner/tests/cli/test_cli_force_redraw.py to assert the resize path preserves scrollback and still repaints the prompt chrome

How to Test

  1. Run uv run --frozen pytest -q -o addopts='' tests/cli/test_cli_force_redraw.py
  2. Start classic CLI mode in a narrow terminal and confirm the startup banner/tool summary are visible
  3. Maximize or resize the terminal and confirm the startup area stays visible instead of being wiped away

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15.x

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • uv run --frozen pytest -q -o addopts='' tests/cli/test_cli_force_redraw.py9 passed
  • uv run --frozen ruff check cli.py tests/cli/test_cli_force_redraw.py → passed

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels May 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #23048 — same approach (renderer.reset()+invalidate() instead of erase_screen+clear_scrollback) to preserve startup banner on terminal resize. Both fix #22999.

@liw71750-dotcom

Copy link
Copy Markdown

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:

#24164

@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded — the same fix landed via #25227 / commit e2b2d48 "fix(cli): preserve startup banner on terminal resize" before this PR could be reviewed. Current _recover_after_resize in cli.py:2710 already does the exact thing you proposed: drop the _clear_prompt_toolkit_screen(rebuild_scrollback=True) + _replay_output_history() sequence in favor of just resetting prompt_toolkit's renderer cache and letting original_on_resize recompute the layout. The docstring even cites the same reasoning. Thanks @LeonSGP43 — your other resize fix (the ANSI-preservation one) just landed via #25974.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classic CLI resize clears startup banner/tool summary after terminal maximize

4 participants