fix(chat): preserve scroll anchor when user toggles collapsible thinking/subagent sections (#274731)#310966
Open
maruthang wants to merge 1 commit intomicrosoft:mainfrom
Open
Conversation
…ing/subagent sections (microsoft#274731)
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 — Manually expanding or collapsing a thinking/subagent/hook/markdown section in the chat list no longer snaps the viewport to the bottom. Previously-visible content stays visually put; the expand grows downward into unused space.
Why —
ChatListWidget._updateElementHeightauto-scrolls the list to the bottom whenever a row grows and the user was already pinned to the bottom. That's correct during streaming (content growing from below must stay visible) but wrong when the user clicks to expand a collapsed section: the expanded content appears above the anchor, so every added pixel shifts everything else upward (#274731).How — Distinguish user-driven from programmatic height changes.
ChatCollapsibleContentPartfires a bubblingCustomEvent('chatCollapsibleUserToggle')from its click handler;ChatListWidgetrecords the timestamp on receive and skips_withPersistedAutoScrollwithin a 250 ms window. ProgrammaticsetExpanded(used during streaming) doesn't dispatch the event, so auto-scroll during streaming is unchanged.Test plan — Manual (from the issue): agent-mode prompt "Look at the git changes in the last 24 hours…", wait for streaming, scroll to bottom, click to expand the thinking section. Pre-fix: viewport jumps upward. Post-fix: content above stays put. Also verified streaming auto-scroll still works. Added 2 unit tests in
chatThinkingContentPart.test.tsasserting the click dispatches exactly one bubbling event.Applies to every
ChatCollapsibleContentPartsubclass, not just thinking.Fixes #274731