fix(desktop): stop pinning stale message at top on chat switch / compaction (#39959) - #39995
Closed
victorftrdba wants to merge 1 commit into
Closed
fix(desktop): stop pinning stale message at top on chat switch / compaction (#39959)#39995victorftrdba wants to merge 1 commit into
victorftrdba wants to merge 1 commit into
Conversation
…ssion (NousResearch#39959) The conversation virtualizer keyed inner turn rows by array index, so switching chats while busy — or context compaction rotating the session id — reused row DOM/state across sessions. Combined with the sticky user bubble (position: sticky), the wrong/stale message stayed pinned at the top and shifted while scrolling. Key inner rows by stable message id (turn groups now carry per-message ids), and remount the Thread on session/threadKey change so leaked scroll-anchor and sticky state reset cleanly. The AssistantRuntimeProvider stays mounted above Thread, so in-flight streams are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 task
This was referenced Jul 26, 2026
This was referenced Aug 3, 2026
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.
Fixes #39959
Problem
After switching chats while a session is busy — or when automatic context compaction rotates to a successor session — the last sent message becomes pinned to the top of the viewport, and the pinned item changes while scrolling up. Classic virtualization row-reuse.
Root cause
thread-virtualizer.tsxkeyed the inner turn rows with the array index (key={index}), not the message id. On a session swap the new messages occupy the same indices, so React/@tanstack/react-virtualreuse the previous session's row DOM and state. (The outer virtual rows were already correctly keyed viagetItemKey.)position: sticky(StickyHumanMessageContainer), so a reused/stale row is what visibly sticks to the top.<Thread>was never remounted per session — only passedsessionKeyas a prop — so scroll-anchor / sticky state leaked across sessions.Fix
turngroups now carry{ index, id }[]instead ofnumber[];buildGroupspopulates both (iteration is unchanged).key={threadKey}to<Thread>so it fully remounts on session switch/compaction, resetting leaked scroll-anchor and sticky state.AssistantRuntimeProviderstays mounted above it, so in-flight streams are unaffected.Verification
npx tsc -binapps/desktoppasses (exit 0).