Skip to content

fix(ui): let a touch flick's fling escape follow without repinning - #1555

Open
heunghingwan wants to merge 1 commit into
NeuralNomadsAI:devfrom
heunghingwan:fix/touch-fling-follow-escape
Open

heunghingwan wants to merge 1 commit into
NeuralNomadsAI:devfrom
heunghingwan:fix/touch-fling-follow-escape

Conversation

@heunghingwan

Copy link
Copy Markdown
Contributor

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:

  • Chrome throttles passive touchmove during an active scroll — as little as one event per 200ms (chromium issue 40146920). A fast flick's brief contact frequently delivers no directional touchmove at all; only its unthrottled pointermove stream and the final touchend arrive.
  • The fling itself scrolls for 1–3s after liftoff, delivering scroll events alone, well past the 600ms user-intent window.

Root cause

  1. VirtualFollowList mapped 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 immediate scroll-bottom write that killed the momentum and yanked the reader back to the bottom.
  2. The same stale-intent write hit flings that reached the list late: momentum chained from a nested scroller (tool output, code block) arrives after the intent window with no transcript gesture on record at all.

Fix

packages/ui/src/components/virtual-follow-list.tsx:

  • Drag-direction intent tracking is now mouse-only (pointerType === "mouse"). Touch and pen panning marks intent solely through the touch path, whose direction mapping is correct.
  • A touchend whose 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

  • Two new browser tests in message-scroll.test.ts replay the Android event pattern (unthrottled touch pointer stream, no directional touchmove, unowned upward momentum past the intent window). Both fail on the previous code with following where escaped is 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-behavior unit 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.md documents the new ownership rule in the scroll-ownership section.
  • No help-page changes: no labels, controls, steps or defaults change.

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 pascalandr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants