Repository navigation
Conversation
Switching away from a session tab and back forced the chat to the bottom. The session page cleared the shared auto-scroll "user scrolled" flag on every switch, and the per-session MessageTimeline remount could only start at the bottom or the top, so every anchor path (initial offset, mount scrollToEnd, follow-on-append, resize anchoring, maybeAnchorBottom) pulled the reader down. The outgoing timeline could also be scrolled to the bottom during the switch, since it still saw the cleared flag. - scroll-posture.ts: a per-session posture store (saved scrollTop while off the bottom, cleared at the bottom) and a bounded restore loop that re-applies the position while late measurement settles; a user gesture ends it at once. - message-timeline.tsx: route every bottom-pull through one anchorBottom() that is vetoed while restoring and once the route has moved to another session; restore from the measurement snapshot; record posture on scroll for the owning session only; drop a posture when its snapshot is evicted. - session.tsx: on switch, hold bottom-follow off for a session with a saved posture instead of clearing it; pass the hold to the timeline. - createAutoScroll: add holdUserScrolled(), which (unlike pause()) works with the scroll element detached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
jacktrnr
marked this pull request as ready for review
November 23, 2026 22:08
Contributor
Author
|
Verified hands-on in the combined 0.4.1-beta test build ( |
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.
Closes #1251
Important
Needs a hands-on UI check before merge. The DOM-coupled timeline (virtualizer + auto-scroll hook + resize observer) cannot be rendered in the unit suite, so the fix is covered by behavior tests on the extracted pieces plus source-wiring assertions. Please verify in the app:
Root cause
Two things combined:
session.tsxcleared the sharedautoScroll.userScrolledflag on every session switch, soshouldAnchorBottom()was true for the incoming session.MessageTimelineremounts per session (keyedShow) and could only start at the bottom or the top. Every anchor path (initial offset, mountscrollToEnd, follow-on-append, resize anchoring,maybeAnchorBottom) readshouldAnchorBottom(), so the reader was pulled down. The outgoing timeline also saw the cleared flag and could be scrolled to the bottom during the switch, which erased any position it held.Earlier attempts (see the issue) failed because they used
pause()(bails with a detached scroll element), raced the remount, or guarded only some of the anchor paths.Fix
scroll-posture.ts(new): a per-session posture store (scrollTop saved while the reader is off the bottom, cleared at the bottom) and a bounded restore loop that re-applies the position for a few frames while late measurement settles. A user gesture ends it at once.message-timeline.tsx: every bottom-pull now goes through oneanchorBottom()that is vetoed while a posture is being restored and once the route has moved to another session. The saved posture seedsinitialOffsetand is restored on mount, only when the measurement snapshot survived. Posture is recorded on scroll for the owning session only, and is dropped when its snapshot is evicted fromtimelineCache.session.tsx: on switch, a session with a saved posture gets bottom-follow held off (holdUserScrolled) instead of cleared; the timeline re-asserts the hold on mount and when the restore finishes, so effect ordering does not matter.createAutoScroll: newholdUserScrolled(), which unlikepause()works with no live scroll element.New-message behavior is unchanged: a held reader has
userScrolled = true, so streaming follow, follow-on-append and resize anchoring stay off; a reader at the bottom has no saved posture and follows as before.Not addressed: the reload-oscillation variant from the Sep 21 comment (a different mechanism, on a cold mount with no saved posture). Postures live in memory, so a window reload reopens at the bottom as before.
Relation to #2031: I read it as input only. This PR is cut from
mainand keeps the same broad shape (posture store, restore veto, bounded restore). It differs in three ways: it uses a hold that works without a scroll element instead ofpause(), it adds the owner-session guard so the outgoing timeline can't erase its posture, and it makes the session page hold on switch rather than relying only on the remounted timeline.Tests
Overlay app tests, run from the materialized tree (
bun test --conditions=solid --preload ./happydom.ts):scroll-posture.test.ts: 9 pass (per-session save/clear, bottom and no-overflow cases, re-apply after a late bottom-pull, bounded window, user gesture wins, cancel on unmount)auto-scroll-hold.test.ts: 2 pass (hold with no scroll element; a held reader is not pulled down by streaming follow)message-timeline-scroll-posture.test.ts: 6 pass (wiring)main(2120 pass / 23 fail, identical failing set: i18n parity, rows-current, observe-element-offset and others unrelated to this change).overlay_typecheck_gate.sh: clean across 7 packagesrefresh_manifest+drift_gate: PASS🤖 Generated with Claude Code