fix(desktop): stop chat scroll jumping by disabling native scroll anchoring#37866
Merged
Conversation
…horing The thread renders virtualized turns in natural document flow with padding spacers, and @tanstack/react-virtual already adjusts scrollTop itself when an off-screen turn is measured and its real height differs from the 220px estimate. With the browser default `overflow-anchor: auto`, native scroll anchoring corrects that SAME size delta too, so the two double-correct and the view lurches — most visibly with Windows mouse wheels, whose coarse notches mount/measure several under-estimated turns per tick (Mac trackpads scroll ~1-3px/frame, keeping it sub-perceptual). Set `overflow-anchor: none` on the thread viewport so only the virtualizer compensates. Also adds `diag-scroll-reset.mjs`, a CDP wheel-up repro that A/B tests the anchor behavior at runtime to confirm the fix.
Contributor
🔎 Lint report:
|
5 tasks
1 task
davidgut1982
pushed a commit
to davidgut1982/hermes-agent
that referenced
this pull request
Jun 5, 2026
…roll-anchor fix(desktop): stop chat scroll jumping by disabling native scroll anchoring
1 task
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
Fixes the reported bug where the chat scroll position "resets randomly" while scrolling up to read — reproducible on Windows with a mouse wheel, invisible on a Mac trackpad.
Root cause: the thread (
apps/desktop/src/components/assistant-ui/thread-virtualizer.tsx) renders virtualized turns in natural document flow (padding spacers, not transforms, so theposition: stickyhuman bubble works).@tanstack/react-virtualuses a flatestimateSize: () => 220and then dynamically measures each turn, adjustingscrollTopitself to keep content stable. The scroller had the browser defaultoverflow-anchor: auto(it was set nowhere in the app), so native scroll anchoring corrected the same size delta a second time → double-correction → the view lurches.A Mac trackpad scrolls ~1–3px/frame so the over-correction is sub-perceptual. A Windows mouse wheel delivers ~120px notches that mount/measure several under-estimated turns per tick, so the double-correction becomes a visible "reset" you have to fight.
The custom sticky-bottom anchor and the incremental external-store runtime were ruled out:
runStartonly fires on a realisRunningfalse→true transition, and the upward-scroll disarm logic is sound.Changes
apps/desktop/src/styles.css— setoverflow-anchor: noneon[data-slot='aui_thread-viewport']so only the virtualizer compensates (one-line fix, with a comment to prevent regression).apps/desktop/scripts/diag-scroll-reset.mjs— CDP diagnostic that drives synthetic mouse-wheel-up scrolling and A/B testsoverflow-anchor: autovsnoneat runtime, tracking a mid-thread turn's on-screen position. Matches the existingscripts/diag-jump.mjs/measure-jump.mjstooling.Test plan
node apps/desktop/scripts/diag-scroll-reset.mjsagainst the app (launched with--remote-debugging-port=9222); confirm "reverse jumps" / "big lurches" / "native scroll moves" drop sharply in theoverflow-anchor: nonerun vsauto.scrollTopwrites, unaffected by disabling native anchoring).🤖 Generated with Cursor