fix(cli): batch resize history replay#25007
Closed
1000Delta wants to merge 1 commit into
Closed
Conversation
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
_OUTPUT_HISTORYbeing replayed after resize, making recent output look like it is “re-streaming from the beginning”._replay_output_history()rapidly reprints recent output lines after SIGWINCH.Related umbrella tracking issue:
Type of Change
Changes Made
cli.py_replay_output_history()output into one joined ANSI payload instead of printing each replay line separately.tests/cli/test_cprint_bg_thread.pyHow to Test
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:
Manually reproduce the original UX issue in the classic CLI:
Then generate enough output to fill several lines, and resize the terminal window wider/narrower or trigger a redraw/recovery path.
Verify that recent history is restored as a single redraw rather than visibly replaying line-by-line like a waterfall.
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
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Targeted tests run locally:
Local manual verification: