Repository navigation
fix(ui): let a touch flick's fling escape follow without repinning - #1555
heunghingwan wants to merge 1 commit into
Conversation
On Android Chrome a fast upward flick that relies on momentum rarely delivers a directional touchmove (passive touchmove is throttled during scrolling, to as little as one event per 200ms), so the pointer-drag mapping was the only live signal — and it reads the finger's own direction, the inverse of a mouse drag-select. Finger down marked "down", which rejoined follow at the bottom and owned the gesture; the fling's scroll events then kept follow alive until the 600ms user-intent window expired, and the first stale-intent observation issued an immediate scroll-bottom write that killed the momentum and yanked the reader back to the bottom. A fling reaching the list late — chained from a nested scroller past the same window — hit the same write with no gesture involved at all. Fast upward flicks on touch now escape follow and keep their momentum; taps, slow drags, mouse, wheel and key behavior are unchanged. Drag-direction intent tracking is mouse-only (pointerType): touch and pen panning marks intent through the touch path. A touchend whose finger moved at least 8px claims the following 2.5s: with no fresh user intent and no programmatic write owning the scroll, an upward offset delta renews the user intent, so the observation escapes follow instead of repinning. Programmatic writes and native thumb drags are excluded; a tap arms nothing. Replayed by two new browser tests (unthrottled touch pointer stream, no directional touchmove, unowned upward momentum past the intent window) that fail on the old code; typecheck and the follow-behavior unit tests pass.
pascalandr
left a comment
There was a problem hiding this comment.
@heunghingwan I reviewed 0b873ca5. One P2:
Layout clamping during the fling claim escapes follow (virtual-follow-list.tsx:634–637). With trusted Chromium touch input, I panned toward the bottom, waited 700 ms, then shrank a mounted tail row from 400 to 48 px and grew it back the next frame. The browser clamps the offset from 9252 to 8900, and the renewal reads that as upward intent: the list leaves follow with a 352 px gap while streaming continues. Base, and HEAD with renewal disabled, stay following. Please exclude geometry-driven displacement from fling inference, and clear the claim on explicit navigation (Latest currently leaves it armed).
P3: removing the upward-only condition still passes both new tests; an expired-intent downward displacement check that keeps an escaped list escaped would cover it.
Both new tests fail on base and pass here; message-scroll passes 140/140 twice and typecheck passes. The pruning CI failures are inherited and fixed on current dev.
Problem
On Android Chrome, a fast upward flick that relies on momentum often "slides a little, then jumps back to the bottom" of the transcript. The faster the flick (the shorter the finger contact), the more reliably it snaps back.
Two platform facts collide with the transcript's follow logic:
touchmoveduring an active scroll — as little as one event per 200ms (chromium issue 40146920). A fast flick's brief contact frequently delivers no directionaltouchmoveat all; only its unthrottledpointermovestream and the finaltouchendarrive.Root cause
VirtualFollowListmapped pointer drag movement to scroll intent with mouse text-drag semantics: finger moving down marks"down". For a touch pan that direction is inverted (finger down scrolls the content up), so the unthrottled pointer stream rejoined follow at the bottom and owned the gesture direction as downward. The fling's scroll observations then kept follow alive until the intent window expired, and the first stale-intent observation issued an immediatescroll-bottomwrite that killed the momentum and yanked the reader back to the bottom.Fix
packages/ui/src/components/virtual-follow-list.tsx:pointerType === "mouse"). Touch and pen panning marks intent solely through the touch path, whose direction mapping is correct.touchendwhose finger moved at least 8px claims the following 2.5s of fling: while no fresh user intent and no programmatic write owns the scroll, an upward offset delta renews the user intent, so the observation escapes follow instead of repinning. A tap arms nothing; programmatic writes and native thumb drags are excluded.User-visible: fast upward flicks on touch escape follow and keep their momentum. Taps, slow drags, mouse, wheel and keyboard behavior are unchanged.
Testing
message-scroll.test.tsreplay the Android event pattern (unthrottled touch pointer stream, no directionaltouchmove, unowned upward momentum past the intent window). Both fail on the previous code withfollowingwhereescapedis required; the mouse-only guard alone greens the throttled-flick case while the late-fling case stays red until the fling claim lands, isolating the two mechanisms.virtual-follow-behaviorunit tests (56),typecheck, and the targeted browser subset (message-scroll, history-navigation, timeline-sync, session-search, session-status-clear, mobile-interruption) pass, except four history-navigation tests that fail identically on the base commit on this machine (load-sensitive UI waits) — verified by re-running them against the parent commit. Full suite via CI.Notes
dev-docs/SESSION_HISTORY_NAVIGATION.mddocuments the new ownership rule in the scroll-ownership section.