fix(scroll): an overscroll bounce at the edge is not movement

Merged
OK
2mo ago
+171-12

Summary

Closes #2884.

observeScrollMovement credits moved on the first capture that differs from the pre-gesture baseline. At the end of a list iOS rubber-bands past the edge, so that first capture lands mid-bounce with every row shifted by a few points, reads as changed, and the content then springs back to exactly the pre-gesture tree. The next command's stabilization sees the surface identical to its baseline (post_gesture_snapshot_stale_accept, matchedPreGestureBaseline: true) while the scroll had already answered moved, and an agent scrolling until at-edge never stops.

The baseline now carries its nodes, and a changed reading against a baseline that already ended in the scrolled direction (readScrollEdgeState(baseline.nodes, edge): a container with no hidden content) is credited only once the surface holds still and still differs. A bounce that settles back to the baseline takes the existing settled path and answers at-edge; a bounce that never settles expires as surface-unsettled. A scroll whose baseline still hid content keeps paying one read, so the one-capture cost claim holds everywhere except at the edge. Keyed on typed edge state and the shared at-rest comparator, not on diagnostics text. The decision is logged as scroll_movement_edge_rest_required.

Touched: 2 source files, 1 test file.

Validation

Tested commit 4549d4006 (review follow-up: edge state resolved at the swipe point through readScrollEdgeState's target; nested-list cases pinned).

  • pnpm check:affected --run: passed (an earlier run flagged the poll loop's complexity; the per-reading verdict is now its own function).
  • New tests: bounce that springs back is at-edge in 3 reads; content that changes at the edge and holds still is moved in 2 reads; a bounce that never settles is unobserved / surface-unsettled. The existing one-read moved case (baseline with hidden content) is unchanged.
  • Live, iPhone 17 Pro / iOS 26.2 simulator, CLI at this head, --debug: open com.apple.Preferences, scroll bottom, then twice snapshot + scroll down 0.75. Both scrolls answered movement: at-edge with scroll_movement_edge_rest_required then scroll_movement_observed attempts: 3 in the request log, i.e. the first read differed from the baseline and the surface settled back. On main that first read is the moved answer the issue reports.