Repository navigation
fix(ui-chat): prevent downward wheel scroll snapback in long virtualized transcripts - #1288
Merged
Merged
Conversation
|
Caution Review failedThe pull request is closed. Summary
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Purpose
Fixes cross-engine (WebKit/WKWebView + Chromium) scroll snapback where scrolling downward with the mouse wheel in a long virtualized conversation repeatedly snaps
scrollTopback upward and prevents reaching the bottom.No visual changes: this change fixes scroll ownership, virtualization height stability, and container-query layout boundaries without altering visual design; wide-table geometry (
1136px / left 15pxin WebKit,1121px / left 15pxin Chromium) andTurnNavigatorpreview layout are pixel-identical before and after.Root Causes & Fixes
ChatView.module.css,AssistantMarkdown.module.css,use-chat-viewport.ts):container-type: inline-sizefrom.frameso the virtualized.root -> .scroll -> .columnflow is completely outside container-query interleaved layout (avoiding WebKit Bug 308027 transient scroll-range clamping in reading mode)..md-table-wide's100cqwlookup with--dsh-chat-viewport-widthpublished on.scroll(list) byChatViewport(synced on attach and resize).TurnNavigatoralready owns an independentheight: 0sibling.slotcontainer and stays unaffected.preserve()reverting reader downward scroll & composer wheel intent (use-chat-viewport.ts,use-chat-reading.ts,use-chat-scroll.ts):ChatViewport.preserve()andonScrollwithisPagingDisplaced(metrics)so reader displacement immediately releases paging ownership instead of writing the oldscrollTopback or clobberingobservation.top, while preserving pure prepend history anchoring (both with and without native scroll anchoring).ChatViewport.onIntentsoWheelEventover[data-composer-seat](including edge-forwarded editor wheel events fromview-binding.ts) releases retained paging anchors whenever no inner scrollport consumesdeltaY, while preserving non-wheel composer input guards.movedByReaderacrossChatReading's 500ms sampling window so intermediate baseline updates cannot erase confirmed reader motion.ChatViewport.shiftObservation(delta)(useChatScroll.adjustBaseline) so virtualization's geometric scroll compensation never gets misattributed as reader motion or upwardautoLoadEarliertriggers.overflow-anchorfighting virtualization (use-transcript-virtualization.ts,ChatView.tsx,ChatView.module.css):0.01px) right before commit inplaceholderHeight()whenever a mounted row transitions out of the mounted set, avoiding stale cache collapse and cumulativeMath.rounddrift.overflow-anchor: noneto active virtualized sessions (data-chat-virtualizing) so both Chromium and WebKit share one deterministic geometric compensation path.nearTailvsfollowingTailAttrcheck, and guarded compensation with a passivescrollVersioncounter so synchronous layout clamps recover cleanly without conflicting with asynchronous scrolls.Affected Scope
apps/web-ui/packages/client/ui-chat/(src/client/chat/*andtest/*).Validation
npx vitest run --config tests/vitest.config.js apps/web-ui/packages/client/ui-chat/test/— 2 files, 20/20 passed (including 6 new regression tests that all failed before the fix).npx tsc --noEmit -p apps/web-ui/tsconfig.json— passed.npx prettier --checkon all changed files — passed.npm run build:web:ui— passed.2000 -> 2046,snappedBack2: true) and subpixel floor drift (43274 -> 43271).scrollTop = 1200to bottom (43310 / 43310,snapbacks: 0,0pxdrift),snappedBack2: false(2000 -> 2300WebKit,2000 -> 2346Chromium),frameContainerType: "normal",scrollerOverflowAnchor: "none", and wide-table geometry unchanged (1136px/15pxWebKit,1121px/15pxChromium).