Skip to content

fix(cli): batch resize history replay#25007

Closed
1000Delta wants to merge 1 commit into
NousResearch:mainfrom
1000Delta:fix/batch-resize-history-replay
Closed

fix(cli): batch resize history replay#25007
1000Delta wants to merge 1 commit into
NousResearch:mainfrom
1000Delta:fix/batch-resize-history-replay

Conversation

@1000Delta

@1000Delta 1000Delta commented May 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR reduces visible “waterfall” redraw during classic CLI terminal resize/redraw recovery.

Before this change, _replay_output_history() replayed recent output history one rendered line at a time. During terminal resize recovery, that meant every history line was sent through prompt_toolkit separately, causing the previous conversation output to visibly reappear line-by-line. This looked like the conversation was being streamed from the beginning again, and it also forced prompt_toolkit to restore/redraw the prompt chrome repeatedly.

This change keeps the existing output-history data model and recording semantics unchanged, but changes the replay transport: replay lines are rendered first, joined into a single ANSI payload, and printed once. That preserves the existing resize/redraw recovery behavior while avoiding the repeated per-line print/redraw loop.

This is intentionally scoped to the most disruptive UX symptom: output-history replay waterfall during classic CLI resize/redraw recovery. It does not attempt to solve full width-aware semantic reflow, ghost-line cleanup, live assistant streaming smoothness, toolbar flicker, or Ink TUI (--tui) resize behavior.

Related Issue

Addresses the output-history rapid replay symptom discussed in:

Related umbrella tracking issue:

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

  • cli.py

    • Batch _replay_output_history() output into one joined ANSI payload instead of printing each replay line separately.
    • Preserve the existing output-history entries and callable-entry rendering behavior.
    • Keep replay output disabled while replaying, as before, so replayed content is not re-recorded into history.
  • tests/cli/test_cprint_bg_thread.py

    • Update the replay test expectation from multiple per-line prints to one batched print.
    • Add coverage for batching rendered output-history lines into a single prompt_toolkit print call.

How to Test

  1. Run the targeted regression tests:

    uv run pytest tests/cli/test_cprint_bg_thread.py tests/cli/test_resume_display.py -q -o 'addopts='

    Expected result from local verification:

    49 passed in 1.90s
    
  2. Manually reproduce the original UX issue in the classic CLI:

    uv run hermes

    Then generate enough output to fill several lines, and resize the terminal window wider/narrower or trigger a redraw/recovery path.

  3. Verify that recent history is restored as a single redraw rather than visibly replaying line-by-line like a waterfall.

  4. Confirm that normal live assistant streaming is unchanged. This PR only changes output-history replay during resize/redraw recovery; it does not batch normal model streaming output.

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.7.3

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

Targeted tests run locally:

uv run pytest tests/cli/test_cprint_bg_thread.py tests/cli/test_resume_display.py -q -o 'addopts='
.................................................                        [100%]
49 passed in 1.90s

Local manual verification:

  • In classic CLI mode, terminal resize after long output restores recent output in one redraw instead of line-by-line waterfall replay.
  • Normal live assistant response streaming remains separate and unchanged.

@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 13, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #21972 and #24403 (both open) address the same resize-replay symptom with different approaches. This PR batches replay into a single print rather than skipping replay entirely (#21972) or delegating to prompt_toolkit (#24403). Umbrella tracking: #24164.

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.

2 participants