Skip to content

fix(desktop): stop chat scroll jumping by disabling native scroll anchoring#37866

Merged
OutThisLife merged 1 commit into
mainfrom
bb/desktop-scroll-anchor
Jun 3, 2026
Merged

fix(desktop): stop chat scroll jumping by disabling native scroll anchoring#37866
OutThisLife merged 1 commit into
mainfrom
bb/desktop-scroll-anchor

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

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 the position: sticky human bubble works). @tanstack/react-virtual uses a flat estimateSize: () => 220 and then dynamically measures each turn, adjusting scrollTop itself to keep content stable. The scroller had the browser default overflow-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: runStart only fires on a real isRunning false→true transition, and the upward-scroll disarm logic is sound.

Changes

  • apps/desktop/src/styles.css — set overflow-anchor: none on [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 tests overflow-anchor: auto vs none at runtime, tracking a mid-thread turn's on-screen position. Matches the existing scripts/diag-jump.mjs / measure-jump.mjs tooling.

Test plan

  • On a long thread (lots of code/tool blocks), scroll up with a mouse wheel and confirm the position no longer jumps.
  • Run node apps/desktop/scripts/diag-scroll-reset.mjs against the app (launched with --remote-debugging-port=9222); confirm "reverse jumps" / "big lurches" / "native scroll moves" drop sharply in the overflow-anchor: none run vs auto.
  • Verify sticky-bottom behavior during streaming and "jump to bottom" on submit/new-session still work (auto-pin is manual scrollTop writes, unaffected by disabling native anchoring).
  • Sanity-check trackpad scrolling on macOS is unchanged.

🤖 Generated with Cursor

…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.
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: bb/desktop-scroll-anchor vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9707 on HEAD, 9707 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5029 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@OutThisLife OutThisLife merged commit a92cbca into main Jun 3, 2026
27 of 28 checks passed
@OutThisLife OutThisLife deleted the bb/desktop-scroll-anchor branch June 3, 2026 04:19
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant