TUI: keep thinking blocks collapsed while streaming so the transcript doesn't jump - #14757
Open
warp-agent-staging[bot] wants to merge 1 commit into
Open
TUI: keep thinking blocks collapsed while streaming so the transcript doesn't jump#14757warp-agent-staging[bot] wants to merge 1 commit into
warp-agent-staging[bot] wants to merge 1 commit into
Conversation
A thinking block auto-expanded while reasoning streamed and then auto-collapsed once `finished_duration` landed. The transcript viewport follows the content end, so that one-frame height shrink rewrote `scroll_top` by the whole thinking body and jumped every visible row instead of scrolling smoothly. Thinking blocks now default to collapsed regardless of streaming state, matching conversation summaries (#14226). A manual override recorded in `CollapsibleSectionStates` still wins, so an expanded block stays expanded across finish. Co-Authored-By: Warp Agent <agent@warp.dev>
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.
Summary
While an agent-mode conversation streamed in the TUI, the transcript would suddenly jump instead of scrolling smoothly. The reporter noticed it was worse around thinking blocks, and that scrolling to the bottom did not fix it.
Root cause.
render_thinking_sectionderived its collapse default fromfinished_duration.is_some(), so a thinking block auto-expanded for the whole reasoning phase and then auto-collapsed the instant reasoning finished. The transcript viewport is aTuiViewportedListState::new_at_end()+GrowFromBottomlist, so while it follows the content endscroll_topis recomputed ascontent_height - viewport_heightevery frame. Collapsing the block shrinkscontent_heightby the entire thinking body in a single frame, which rewritesscroll_topby that same amount and snaps every visible row at once. Scrolling to the bottom can't help — the viewport is already atEnd, which is exactly why the reporter saw no recovery.Fix. Thinking blocks now default to collapsed regardless of streaming state, so no height flip ever reaches the viewport. This mirrors the identical fix applied to conversation summaries in #14226. A manual override recorded in
CollapsibleSectionStatesstill wins, so a user who expands a thinking block keeps it expanded across the finish transition.The now-unconditional
finishedparameter was removed from the sharedrender_collapsible_message_sectionhelper, and the doc comments that described the old "collapse on finish" default were corrected.Verification
Live before/after reproduction (the reporter asked for a repro first)
Reproduced hands-on against a real streaming agent session in an authenticated TUI, per
tui-verify-change(release build undertmux, driven withsend-keys, read back withcapture-pane, recorded withasciinema). The same prompt was run against a build ofmasterand a build of this branch.Before — the transcript snaps backwards when thinking collapses. Consecutive polled frames, ~0.3s apart:
Tracking the user's prompt row across every frame makes the discontinuity explicit. Before the fix it scrolls up off the screen and then reappears:
After — monotonic upward motion, no jump:
The
Thinking... ▸->Thought for 21 seconds ▸transition changes only the header text, not the section's height, so the viewport never discontinuously rewritesscroll_top.Regression test
Added
reasoning_block_height_is_unchanged_when_reasoning_finishesincrates/warp_tui/src/agent_block_tests.rs. It measures the same agent block while reasoning streams and again once it finishes, and asserts the height is identical. Before this change it failed with 6 rows while streaming vs 2 rows after finish — the exact multi-row shrink the viewport turns into a jump.Also added
manual_expand_override_shows_streaming_reasoning_body(a mid-stream manual expand still renders the body), rewrotestreaming_reasoning_renders_thinking_header_with_bodyintostreaming_reasoning_renders_collapsed_thinking_header, and updatedmultiple_reasoning_blocks_render_independent_collapse_stateto assert per-block override independence now that both blocks share a default.Repository checks
./script/format— clean.cargo clippy -p warp_tui --all-targets --tests -- -D warnings— clean.cargo nextest run -p warp_tui— 953/954 pass. The single failure,session::tests::accepts_startup_without_resume, reproduces identically on unmodifiedmasterin this sandbox (the runner's environment supplies a workspace key the test expects to be absent) and is unrelated to this change.Scope is a single crate with no shared-core or build-system edits, so the touched-package run above is the local gate and CI covers the full suite.
CHANGELOG-TUI: Thinking blocks no longer expand while streaming and collapse when done, which made the transcript jump mid-response.
Originating thread: https://warpdev.slack.com/archives/C0BDQDW8V5E/p1785968817242549
Screen recordings of the live before/after TUI sessions (2)
BEFORE fix — watch the transcript snap back down when the thinking block auto-collapses
AFTER fix — the thinking block stays collapsed and the transition into the streamed answer scrolls smoothly
Conversation: https://staging.warp.dev/conversation/998ad1b4-c603-41cd-a3d8-fbe81d0e1a2f
Run: https://oz.staging.warp.dev/runs/019fd42f-ce46-78dd-99bf-e48ad9f92c94
This PR was generated with Oz.