#18540 · @ndaemy · opened Mar 21, 2026 at 5:03 PM UTC · last updated Mar 21, 2026 at 5:03 PM UTC
fix(app): prevent scroll jump during history backfill
Score breakdown
Impact
Clarity
Urgency
Ease Of Review
Guidelines
Readiness
Size
Trust
Traction
Summary
This PR fixes a chat history scroll jump bug caused by stale scrollTop values during backfill. The solution changes scroll restoration from absolute to relative adjustment, reading scrollTop at the moment of restoration. Verification includes both Playwright tests and manual QA with a custom scroll monitor.
Description
Issue for this PR
Fixes #17996
Type of change
- [x] Bug fix
- [ ] New feature
- [ ] Refactor / code improvement
- [ ] Documentation
What does this PR do?
When scrolling up quickly through chat history, the viewport jumps because preserveScroll captures scrollTop before the DOM update but restores it inside requestAnimationFrame. Native scroll events that fire between the capture and the rAF callback make the captured value stale, so the viewport snaps to a wrong position.
This change switches from absolute scroll restoration (scrollTop = beforeTop + delta) to relative adjustment (scrollTop += delta). Reading scrollTop at rAF time instead of capture time keeps the value fresh regardless of user scrolling in the interim.
How did you verify your code works?
- Playwright test with synthetic scrollable container — confirmed 0px visual shift with both
overflow-anchor: autoandoverflow-anchor: none - Manual QA in headed Chromium connected to a live sidecar with real session data — injected a scroll monitor overlay that tracked every
scrollHeightchange and flagged jumps above 80px threshold. 0 jumps detected across multiple backfill cycles.
Checklist
- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR
Linked Issues
#17996 [BUG] Desktop app chat scroll jumps/skips content during fast upward scrolling
View issueComments
No comments.
Changed Files
packages/app/src/pages/session.tsx
+3−5