fix(scroll): preserve user position during live stream reattach on session return - #3045
Closed
starship-s wants to merge 4 commits into
Closed
starship-s wants to merge 4 commits into
starship-s wants to merge 4 commits into
Conversation
…h on session return Recent SSE reattach improvements (8408a3d et al.) increased live render frequency when returning to conversations with active generations. Two active-stream paths in loadSession were still calling renderMessages() without the preserveScroll contract. This caused the viewport to reset to bottom (or near-bottom) right as token-driven scrollIfPinned() calls fired, producing the "jumps back while scrolling up" symptom. This change makes the remaining call site consistent with the other two (using the mature {preserveScroll:true} + snapshot/restore path) and ensures the existing upward-intent guards in scrollIfPinned() remain authoritative during live token delivery. The ui.js strengthening for _recentMessageUpwardIntent() was already present on current master. Cleanly based on origin/master (5528e2c). Refs: 8408a3d, hermes-webui-operations skill (live-stream-reattach-scroll-pinning-regressions.md)
…oad path
The previous change had over-scoped the preserveScroll:true updates
to the non-live historical path in loadSession (the }else{ branch).
This path has long intentionally forced scrollToBottom() for finished
conversations on normal session switches. Changing it was outside the
scope of the live reattach scroll-jump regression fix.
Kept the two live/reattach paths (INFLIGHT reattach + activeStreamId)
with preserveScroll:true, plus the ui.js upward intent guard.
This addresses the scoping concern from code review.
… preserveScroll change
The tests were doing brittle string searches for the literal
'renderMessages();' call in the INFLIGHT branch.
Updated them to expect the new (correct) call with
{preserveScroll:true} that is now used for live reattach paths.
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.
Thinking Path
loadSession→renderMessages()+attachLiveStream({reconnecting:true})when returning to sessions that still have an active generation.loadSessionwere still callingrenderMessages()without the existingpreserveScrollcontract.scrollIfPinned()without consulting the upward scroll intent window that the scroll listener was already tracking.What Changed
static/sessions.js, the two live/reattach render sites insideloadSessionnow pass{preserveScroll:true}so the established snapshot/restore logic in_scrollAfterMessageRendercan preserve the user’s position.static/ui.js,scrollIfPinned()now also short-circuits when_recentMessageUpwardIntent()is true. This makes the intent tracking (already computed by the wheel/scroll listener) authoritative for live token delivery.Net change: 3 lines. No new state, no timeouts, no reattach-specific branches.
Why It Matters
Users can scroll up to review earlier turns while a response is generating, even after switching sessions. The previous behavior made this unreliable when returning to an in-progress chat.
Verification
origin/masterand pushed for review.renderMessages({preserveScroll:true})call sites and the strengthenedscrollIfPinned()guard were confirmed present.Risks / Follow-ups
preserveScroll,_recentMessageUpwardIntent,_scrollAfterMessageRender).Model Used
xAI / Grok Build 0.1