fix(client): split-view scroll sync tearing in Firefox - #93
Merged
Conversation
The synced-scroll toggle suppressed mirrored-pane echoes with a flag reset in a fresh requestAnimationFrame. Chromium dispatches the mirrored pane's scroll event before that frame, but Firefox delivers it after the reset: the echo then passes the guard and the next genuine update is swallowed, so the preview trails and snaps back continuously while scrolling. Replace the timing flag with position-based echo suppression (an event at the last-written offset is an echo) and batch mirror writes to one per animation frame. Handlers are now stable callbacks, so listeners stop resubscribing on every render. Covered by interaction stories: baseline mirroring both directions plus a deterministic late-echo regression test.
Chromium coalesces same-frame scroll events, so no existing story failed on the old guard when two updates landed in one frame. Deliver the first update, then add a second within the same frame (Firefox's per-write delivery): the old code swallows the second and the mirror settles stale; the new batched mirror converges on the latest position.
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.
Problem
With synced scrolling enabled (the link toggle) in split view, Firefox users saw constant tearing: the preview pane trailed the editor and snapped forward repeatedly while scrolling. Chromium was unaffected.
Root cause
The old suppression flag (
isSyncingRef, reset in a freshrequestAnimationFrame) races with the mirrored pane's own scroll event:Fix
New
useScrollSynchook replaces the timing flag:Testing
Storybook interaction tests (run via
pnpm --filter client test), each verified to fail on the old implementation and pass on the new:SplitSyncMirrorsScroll— baseline mirroring both directions.SplitSyncSurvivesLateEcho— mirrored-pane echo arriving after the guard window must not swallow the next update.SplitSyncMirrorsLatestUnderBurst— two updates delivered separately within one frame must converge on the latest (old code settles stale).Full client suite: 138 passed. Lint + typecheck clean.
Live validation: Firefox burst-drive went from 62/122 mirrored events and ~330px misalignment to 108/109 events and 0px settled error; Chromium CDP wheel harness shows no regression (0 backward jumps, 0 settled error).
Closes #23