Repository navigation
fix(native-chat): stop following the end when the reader scrolls over a visual - #29116
Conversation
… a visual A wheel over a visual's frame scrolls the transcript without ever reaching it as a wheel event, so the view snapped back to the bottom on the next content change.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e91f10f4-21bd-4038-9fa5-6a1ba6e872c0
📒 Files selected for processing: 11
src/renderer/src/components/native-chat/NativeChatInlineVisual.reader-scroll.test.tsxsrc/renderer/src/components/native-chat/NativeChatInlineVisual.tsxsrc/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatTranscriptItems.tsxsrc/renderer/src/components/native-chat/NativeChatVisualFrame.test.tsxsrc/renderer/src/components/native-chat/NativeChatVisualFrame.tsxsrc/renderer/src/components/native-chat/native-chat-reader-scroll-input.test.tsxsrc/renderer/src/components/native-chat/native-chat-reader-scroll-input.tssrc/shared/native-chat-visual-shell.reader-scroll.test.tssrc/shared/native-chat-visual-shell.test.tssrc/shared/native-chat-visual-shell.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Heard at the window after the page's handlers, so a chart's own wheel zoom no longer reads as the reader leaving the end.
…he composed path A chart that cancels the wheel from a window listener does so after the shell's own; scrollers inside shadow roots are hidden from the retargeted target; an overflow:hidden root chains to the transcript whatever offset it holds. Chromium confirmed all three.
91e8ec6 to
f0b368e
Compare
…bubbling The transcript scrolls for that wheel all the same. Also drops the inline visual scroll test; the transcript-level test covers the same wiring.
abbe778 to
a546dab
Compare
Iframe reports arrive asynchronously and can describe scrolling contained inside a visual.
ELI5
When an agent reply includes a chart or another HTML visual, scrolling up with the mouse over that visual kept snapping the chat back to the bottom. The chat now notices that scroll like any other and stays where you put it.
What Changed
Before: with the pointer over an inline visual, the mouse wheel moved the transcript, but the transcript still believed the reader was at the end. The next time anything changed height (streamed text, the visual reporting its size, a row expanding) it scrolled back to the bottom, and the "Jump to latest" button never appeared. Large visuals made this almost certain, because they fill the viewport and the pointer is nearly always over them.
After: scrolling up over a visual detaches the view the same way scrolling over the text does. The jump button appears and the transcript stays put until the reader returns to the end.
Mechanism: the visual runs in a sandboxed iframe. Chromium gives the wheel event to the frame's document and chains the leftover scroll to the transcript at the compositor level, so the transcript scrolls without ever receiving a
wheelevent. The follow logic only lets go of the end on a reader gesture, so it never let go. The frame's bootstrap script now listens forwheelandtouchmove, and when nothing inside the page can scroll in that direction it posts a message to the host. The host feeds that into the same path the message rail already uses for the wheel it forwards.Why
The follow logic deliberately ignores scroll events and only trusts gestures, because layout and the virtualizer produce scroll events of their own. Teaching it to treat unexplained scrolls as the reader would undo that design. Forwarding the gesture from the one surface that swallows it keeps the model intact and reuses the rail's path. The shell reports only a wheel the page cannot consume, mirroring the transcript's rule for nested scrollers, so a visual taller than the 2000px frame cap keeps its own internal scroll until it hits an edge.
Mobile builds the same shell document and will receive the new message; its frame ignores kinds it does not handle.
Linked Issue
No dedicated issue. Related: #23797.
Visual Proof
N/A: no visual change. The cause was confirmed with a headless Chromium probe: a wheel over an iframe inside a scroller moved the scroller with no
wheelevent on the parent document, until the iframe scrolled out from under the pointer.Testing
The frame's bootstrap script runs for real in a fresh happy-dom window: it reports only when nothing in the page can scroll that way, treats a page taller than the frame as its own scroller, ignores zoom, zero and contained wheels, and reports a touch drag.
The frame, the reader-input hook and the inline visual wiring each have a test for the new path.
Typecheck, full lint and the native-chat suites pass locally on macOS. Not exercised in the running app.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
The chained scroll event reaches the host a frame before the frame's message does. Following is still true for that one event, then drops when the message lands. Worth a close look at
scrollsWithinin the shell script and at the ordering inuse-native-chat-transcript-scroll.ts.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)