Skip to content

feat(scroll): add scroll refresh for pull-to-refresh - #4770

Merged
thymikee merged 21 commits into
mainfrom
t3/add-pull-to-refresh
Nov 20, 2026
Merged

thymikee merged 21 commits into
mainfrom
t3/add-pull-to-refresh

Conversation

@thymikee

@thymikee thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

scroll refresh adds pull-to-refresh to scroll. It is the existing directional scroll with two defaults changed: scroll up 0.4 --duration-ms 1200, sent through the same scrollDirection operation. Before the pull it reads the top edge off one fresh capture and refuses with scroll_refresh_not_at_top while content is hidden above, because a list that is not at its top only scrolls.

A slow scroll up that starts on the list already commits a refresh control, so the earlier design is gone: no touch-scroll admission fact, no pull planner, no pull-container narrowing or clipping, no gesture-plan dispatch, no native change. Net non-test delta is about 180 lines (was about 700): about 110 in the packages and CLI help, the rest is the Refresh lab screen in the test app.

agent-device scroll refresh --json          # CLI
# MCP: scroll with direction "refresh"
  • An amount, --pixels or --duration-ms overrides the defaults.
  • --until is rejected: the mode pulls once.
  • Admission is the existing verified-pass use (scrollDirection + captureSnapshot), so an owner without a capture refuses before any device work.
  • movement never answers at-edge for the pull; an unchanged surface answers unchanged.
  • Android aims the pull inside the scroll container. On iOS it runs down the middle of the screen. The CLI help and commands.md say so, and say that movement: unchanged is not proof of a refresh.

Validation

Branch-built CLI at b3dd1659 (the head adds one comment fix on top), Refresh lab in the test app (refresh-count increments per refresh).

Target scroll refresh Counter
iPhone 17 Pro simulator, iOS 27.0 5/5, movement: moved, pull y 262 → 612, 1200 ms 6 → 11
Android 17 emulator 5/5, movement: moved, pull y 727 → 1697, 1200 ms 8 → 13

After scroll down, scroll refresh refused with scroll_refresh_not_at_top on both and the counter did not change. scroll refresh --until … answered INVALID_ARGS.

Why the defaults: on iOS a 400 ms pull that starts on the list did not refresh (1 run here, 0/5 in the earlier measurement on this PR), and 800 ms and 1200 ms pulls did (6/6 with plain scroll up on the released CLI, plus the 5/5 above). Android refreshed at every speed tried with plain scroll up (8/8).

Typecheck and lint pass; 388 affected test files (3524 tests) pass locally.

Known limit

The Apple scroll path does not aim inside the scroll container: its lane is centred on the viewport. The default 0.4 pull covers the middle 40% of the screen, so it lands on any list that reaches the middle of the screen. A list confined to the top or bottom edge of the screen is not covered.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.43 MB 6.43 MB +2.0 kB
Package (unpacked) 6.43 MB 6.43 MB +2.0 kB
Package (download) 1.95 MB 1.95 MB +708 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 36.2 ms 26.9 ms -9.3 ms
CLI --help 76.6 ms 60.3 ms -16.3 ms

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the PR. At 354c3e9 the head does not typecheck, so it cannot merge yet, and there are two behavior defects and one docs problem to fix first.

The Android hold branch in input-actions.ts spreads the output of buildGesturePlan and overrides pointers and durationMs with a hand-built 3-sample trajectory. tsc rejects the result at line 406 because it is not an AndroidTouchPlan. This is the error behind the failing Lint, Typecheck & Package, Numeric Ranges and Integration Tests checks. The rule: the trailing hold belongs in the owning planner (a final stationary sample or hold option on the buildGesturePlan pan, aligned with #4767), not in an override of a lowered plan. This fix changes the Android pull construction, so the reported Android run no longer covers the code that will merge.

The touch gate in scroll-runtime.ts checks appleOs === 'ios' only. An iPad carries ipados, so scroll refresh fails there with scroll_refresh_unsupported_platform, even though pull-to-refresh is a main iPad gesture and the help says "touch platforms only". Android TV passes because only platform === 'android' is checked. The rule: refresh is admitted exactly where the platform declares a touch scroll surface. Please declare that as a runtime-operation fact in the platform packages and admit it through plan.use, instead of an inline daemon check. Please add an ipados test.

In metadata.ts, the new sentence "The top-edge mode commits re-fetch, never at-edge." does not name refresh. "Top-edge mode" already means scroll top, and "commits re-fetch" promises an outcome the code cannot observe. MCP agents read this text, so they may call scroll top expecting a refresh. Suggested wording: "refresh pulls down once from the top of the scroll container (pull-to-refresh); it refuses with scroll_refresh_not_at_top when content is hidden above and never reports at-edge."

Not blocking, and you can take or leave these: the new test at scroll-runtime.test.ts:1108 fails typecheck (call possibly undefined) and pushes the file over max-lines, so the refresh tests could move to a sibling file; RefreshLabScreen.tsx:42-43 fails oxlint; Repo Guards reports two new jscpd clones (RunnerSynthesizedGesture.m 364-375 vs 392-408, and RunnerTests+ScrollGestureTests.swift 75-89 vs 99-112) and complexity on scrollAndroid and formatScrollEdgeMessage; scroll-gesture.ts:286 re-implements the band and cross selection of keepSwipeInContainer with a different fallback, so one shared helper would be safer; in RunnerTests+ScrollGesture.swift:108 the container is treated as plan-frame-relative while the daemon sends absolute snapshot coordinates, so a non-zero window origin (iPad split view) would offset the pull and needs a conversion plus a fixture; the scroll_refresh_not_at_top hint says "scroll up" while help says scroll top, so "Run scroll top, then scroll refresh" is more reliable; and for refresh, amount is clamped to 320-520px, so 0.9 and 0.1 land on the same value while the result echoes the requested one, so either reject amount there or document the clamp.

One question on size: the 400 ms hold (DEFAULT_REFRESH_HOLD_MS in scroll-command.ts) is justified as making the refresh control commit, yet Step 0 shows a slow swipe and gesture pan ... 1500 with no hold firing 5/5 on iOS and Android. Could you run the lab 5 times with holdMs 0 at the same slow pull on both? If it still fires, the hold and its wire field can go. Then could the daemon keep the valuable part (fresh top-edge read, typed not-at-top and no-container refusals, never at-edge), compute the pull endpoints once in TS with a top-anchored lane through keepSwipeInContainer, and dispatch them through the existing gesture pan runtime operation with the slow duration? That would remove the Swift port and fixtures, the scrollPullContainer and scrollHoldMs wire fields, the ObjC/Swift hold plumbing and the Android override, which looks like about half of the 625 net production lines. It would need the hold evidence above, and the platform touch fact from the iPad item.

On evidence, the iOS and Android results in the PR body are author-reported and ran on a head that does not typecheck. After the Android fix, please re-run the Android emulator refresh lab at the top: scroll refresh three times, showing the refresh counter increment, refresh: true in the response, holdMs, and a movement other than at-edge. Please also run the iOS lab three times if the runner or hold path changes. After the iPad fix, please run scroll refresh once on an iPad simulator at the top and show the counter increment instead of scroll_refresh_unsupported_platform.

CI is red mainly because of this PR: the type errors above, oxlint, max-lines, the two new jscpd clones and the complexity findings. Smoke and Coverage were still pending. There are no conflicts. Before merge, fix the Android type error through the gesture planner, admit iPad through a declared touch fact, rewrite the MCP sentence, get CI green, then re-run Android and iPad live.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 6 new findings on e655a34. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At e655a34 the earlier typecheck, lint, max-lines, jscpd and complexity failures are fixed, and 20 checks pass. Four items from the earlier review still stand, so this is not ready to merge yet. There are no conflicts.

Refresh admission still checks appleOs === 'ios' inline in scroll-runtime.ts:164. An iPad session (ipados) gets scroll_refresh_unsupported_platform, and any Android device, including Android TV, is admitted. Pull-to-refresh is a primary gesture on iPad, and a pull on TV does nothing. The rule should be: refresh is admitted exactly where the platform declares a touch scroll surface. Please declare that on the platform runtime operations (platform-apple for iOS and iPadOS, platform-android for phone and tablet, not TV), admit through plan.use, and delete the inline check. An iPadOS admit test and an Android TV refuse test would cover it.

The MCP text at metadata.ts:81 says 'The top-edge mode commits re-fetch, never at-edge.' It never names refresh. 'Top-edge mode' already means scroll top, which reports at-edge, and no code observes a re-fetch. Agents may call scroll top expecting a refresh. Suggested text: 'refresh pulls down once from the top of the scroll container (pull-to-refresh); it refuses with scroll_refresh_not_at_top when content is hidden above and never reports at-edge.'

withHoldBeforeRelease in input-actions.ts:430 still replaces the lowered pan pointers with a hand-built hold trajectory. That repeats the destination-hold branch of withContactHolds in gesture-plan.ts:185. The typecheck now passes only through a new topology !== 'single' guard, which would silently drop the hold for any other plan. A stationary hold before release should be built only by the contracts gesture planner. Please expose a destination hold on the pan path (for example holdMs through withContactHolds(move, 0, holdMs), aligned with #4767), call buildGesturePlan with it, and delete withHoldBeforeRelease and the guard. If a holdMs 0 run shows the hold is not needed, drop it instead.

There is no iPad live run, and the iPad fix is not in this head. The Android x5 result in the PR body is author-reported, with no raw output, and it will not cover the code that lands once the hold moves. After the two changes above, on an iPad simulator at the Refresh lab top, please run scroll refresh once and show the counter increment, refresh: true, and a movement other than at-edge (not scroll_refresh_unsupported_platform). On the Android emulator, run it 3 times at the top and show the counter increment, refresh: true, holdMs if kept, and the movement. Re-run iOS x3 only if the runner or hold path changes.

Could the change be smaller? Keep the daemon refresh plan: fresh top-edge read, typed refusals, never at-edge, and the platform touch fact. Compute the top-anchored pull endpoints once in TS through keepSwipeInContainer, and dispatch through the existing gesture pan operation with the slow duration. If a hold proves necessary, add it once as a planner destination hold. That would remove withHoldBeforeRelease, the Swift pull port and fixtures, scrollPullContainer/scrollHoldMs, and the ObjC hold plumbing. The earlier version of this question has no reply yet, and the new topology guard is more patch growth around the hold. What would decide it is a holdMs 0 run (5x, same slow pull, iOS and Android) showing whether the hold exists.

@thymikee

Copy link
Copy Markdown
Member Author

Addressed the review of e655a34 in 489e22e: the ms/s hold bug in the fallback drag path is fixed (holdMs / 1000), the Android hold now appends one stationary sample to the interpolated pan instead of replacing it, refresh --pixels is clamped into the 320-520px band, an unreadable capture refuses with scroll_refresh_capture_unreadable rather than no_container, and the runner converts scrollPullContainer into plan-frame space (iPad split view), pinned by a unit test. Re-ran the labs on 489e22e: iOS 3/3 (counter 36-39), Android 3/3 (counter 21-24, holdMs 400, pixels 520), all refresh:true and never at-edge. On the hold question: Step 0's 5/5 no-hold runs were the fling/pan release paths; scroll refresh uses the controlled-release path, which lifts the contact at the last sample, so the parked 400ms hold is what commits the control there - kept, and the wire field stays.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. This is the third round where the admission, hold-ownership and MCP-text items below are unchanged, and the size question has no reply yet, so please answer that one first. At 489e22e the Swift hold unit, the trajectory sample handling, the unreadable-capture refusal and the --pixels clamp from the earlier review (#4770 (comment)) are fixed. Four items remain, so this is not ready to merge. The branch has merge conflicts with main. 20 checks pass. After the rebase, CI and the live evidence must be re-run on the new head.

packages/daemon/src/execution/scroll-runtime.ts:162 is unchanged from the earlier reviews. The inline check platform === 'android' || (isApplePlatform && appleOs === 'ios') refuses an iPadOS session with scroll_refresh_unsupported_platform. It also admits every Android device, including Android TV, where a pull does nothing. The scroll-runtime-refresh tests have no iPadOS or TV case. So scroll refresh fails on iPad, where pull-to-refresh is a primary gesture, and the iPad split-view conversion in this delta cannot run. The rule: refresh is admitted exactly where the platform runtime declares a touch scroll surface. Declare that on the platform runtime operations (platform-apple for iOS and iPadOS, platform-android for phone and tablet, not TV), admit through plan.use, and delete the inline check. Please add an iPadOS admit test and an Android TV refuse test.

packages/platform-android/src/input-actions.ts:430: withHoldBeforeRelease still builds a destination hold outside the contracts planner. It appends a stationary sample at durationMs + holdMs, which is the destination-hold branch of withContactHolds (gesture-plan.ts:185-207), and buildDragGesturePlan already exposes it as destinationHoldMs. The new lastSample === undefined guard sits next to the topology !== 'single' guard, and either guard silently drops the hold for any other plan shape. Now two owners build a stationary hold before release, so a hold change in the planner (#4767) will not reach Android refresh. The rule: only the contracts gesture planner builds contact holds. Expose a destination hold on the pan path, or plan the pull with destinationHoldMs, then delete withHoldBeforeRelease and both guards. A 5x scroll refresh run with holdMs 0 on the controlled-release path would also settle it. If the pull commits without the hold, drop the hold, scrollHoldMs and the ObjC hold plumbing.

packages/command-surface/src/interaction/metadata.ts:81: 'The drag-at-top mode commits re-fetch and never reports at-edge.' still does not name refresh. It uses a mode name no input accepts, and it promises a re-fetch that no code observes. The same text still calls amount 'the finger-path fraction of the viewport axis', but for refresh it is the container-height fraction. MCP agents read only this text, so they cannot tell which input triggers pull-to-refresh and may treat the result as proof that data re-fetched. Suggested text: 'refresh pulls down once from the top of the scroll container (pull-to-refresh); it refuses with scroll_refresh_not_at_top when content is hidden above and never reports at-edge.' Please also state that for refresh, amount is the container-height fraction.

packages/daemon/src/execution/scroll-runtime.ts:159: there is no iPad run, and iPad is still refused at this head. The Android x3 and iOS x3 results at 489e22e are author-reported, with no raw output, and the Android hold code changed in this delta and will change again. Once the platform admission and the hold ownership are settled, please run scroll refresh once on an iPad simulator at the Refresh lab top. Paste the raw output showing the refresh-count increment, refresh: true, and a movement other than at-edge, not scroll_refresh_unsupported_platform. On the Android emulator, run it 3x at the top and paste the raw outputs: the counter increments, refresh: true, holdMs if kept, pixels and movement. Re-run iOS x3 only if the runner or hold path changes again.

Whether scrollPullContainer and the runner planFrame share a screen-coordinate space on a split-view iPad is not shown yet; the unit test pins only the subtraction, so the iPad run should cover split view.

Not blocking: index.ts:608 says 'clamped into the measured-safe 320-520px band' but omits that buildPullRefreshGesturePlan also bounds travel by the container height, so you can append 'and bounded by the container height' or leave it.

Could the change be smaller? Keep the daemon refresh plan: the fresh top-edge read, the typed refusals, never at-edge, and a platform-declared touch-surface fact admitted through plan.use. Compute the top-anchored pull endpoints once in TS (buildPullRefreshGesturePlan, sharing keepSwipeInContainer's banding). Then dispatch through the existing pan or drag planner with a planner-owned destination hold, or with no hold if a holdMs 0 run shows it is not needed. That would remove withHoldBeforeRelease and its guards, the Swift pull port and parity fixtures, scrollPullContainer and scrollHoldMs, runnerContainerInPlanFrame, and the ObjC hold plumbing. The production delta is 710 net lines, over the 700 threshold. What would have to change first is a planner-owned destination hold on the pan path (aligned with #4767) or a holdMs 0 run that removes the hold, plus the touch-scroll-surface declaration on the platform runtimes.

Of the open inline threads, four threads are fixed and can be resolved: the Swift hold division (#4770 (comment)), the trajectory samples are kept with the hold sample appended (#4770 (comment), the planner-ownership question stays under the hold finding above), the unreadable-capture refusal is added with a test (#4770 (comment)), and the explicit --pixels clamp is added with a test (#4770 (comment)). Two threads still apply: the MCP text at metadata.ts:81 never names refresh (#4770 (comment)) and it still says viewport axis (#4770 (comment)).

@thymikee

Copy link
Copy Markdown
Member Author

holdMs 0 experiment (step 1 of the size question)

Same slow pull (pixels clamped into the 320-520px band, durationMs 1200, controlled release) with holdMs 0 — DEFAULT_REFRESH_HOLD_MS temporarily set to 0 in the branch build, 5 runs per platform at the Refresh lab top. Raw --json outputs below.

Result: iOS 5/5, Android 5/5 fired with no hold (counter 39→44 on iOS, 25→30 on Android).

iOS raw output (iPhone 17 Pro, BC54AC11-CD86-4C10-8C4E-5101C773FFEB, session hold0)
=== run 1 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "referenceWidth": 402,
    "referenceHeight": 874,
    "durationMs": 1200,
    "movement": "moved",
    "message": "Pulled to refresh at the top edge; the surface changed"
  }
}
=== run 2 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "referenceWidth": 402,
    "referenceHeight": 874,
    "durationMs": 1200,
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== run 3 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "referenceWidth": 402,
    "referenceHeight": 874,
    "durationMs": 1200,
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== run 4 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "referenceWidth": 402,
    "referenceHeight": 874,
    "durationMs": 1200,
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== run 5 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "referenceWidth": 402,
    "referenceHeight": 874,
    "durationMs": 1200,
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== counter after ===
  @e5 [text] "Refreshed 44 times"
Android raw output (emulator-5556, session hold0)
=== run 1 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "referenceWidth": 1080,
    "referenceHeight": 2400,
    "durationMs": 1200,
    "backend": "android-helper",
    "helperVersion": "0.21.40-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1454,
    "helperTransport": "persistent-session",
    "movement": "moved",
    "message": "Pulled to refresh at the top edge; the surface changed"
  }
}
=== run 2 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "referenceWidth": 1080,
    "referenceHeight": 2400,
    "durationMs": 1200,
    "backend": "android-helper",
    "helperVersion": "0.21.40-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1304,
    "helperTransport": "persistent-session",
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== run 3 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "referenceWidth": 1080,
    "referenceHeight": 2400,
    "durationMs": 1200,
    "backend": "android-helper",
    "helperVersion": "0.21.40-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1339,
    "helperTransport": "persistent-session",
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== run 4 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "referenceWidth": 1080,
    "referenceHeight": 2400,
    "durationMs": 1200,
    "backend": "android-helper",
    "helperVersion": "0.21.40-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 2605,
    "helperTransport": "persistent-session",
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== run 5 ===
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "referenceWidth": 1080,
    "referenceHeight": 2400,
    "durationMs": 1200,
    "backend": "android-helper",
    "helperVersion": "0.21.40-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 4694,
    "helperTransport": "persistent-session",
    "movement": "unobserved",
    "message": "Pulled to refresh at the top edge"
  }
}
=== counter after ===
              @e34 [text] "Refreshed 30 times"

Conclusion: the pull commits on the controlled-release path without a parked hold on both platforms, so the hold (DEFAULT_REFRESH_HOLD_MS, scrollHoldMs wire field, the ObjC/Swift hold plumbing, withHoldBeforeRelease) is dropped, and scroll refresh is dispatched through the existing pan planner from TypeScript.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 3 new findings and 1 moved to a new line on 489e22e. The verdict and the full list are in the summary comment.

thymikee and others added 7 commits November 19, 2026 20:21
scroll refresh dispatches one slow downward pull anchored just inside the
top of the resolved vertical scroll container, holds briefly before release
so the refresh control commits, and finishes with the existing post-gesture
stabilization. It reads the top edge from a fresh capture (the stored tree is
stale after any earlier gesture), anchors at the innermost nested scroller,
refuses with typed reasons scroll_refresh_not_at_top / scroll_refresh_no_container
/ scroll_refresh_unsupported_platform, and never reports movement at-edge for
this mode. 'refresh' joins SCROLL_INPUT_DIRECTIONS, the CLI positional, the
MCP enum, scroll's search hint and help. Adds a Refresh lab to the test app.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The runner-requests contract fixture gains the pull request carrying
scrollHoldMs and scrollPullContainer, so every new Command field has a
production request (testEveryRunnerRequestFieldHasAProductionRequest).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
- pin the refresh-pull runner request in contracts/fixtures/runner-requests.json
  (new Command fields need a production request)
- split the refresh tests into scroll-runtime-refresh.test.ts (max-lines cap)
- extract androidScrollLane/withHoldBeforeRelease and formatRefreshEdgeMessage/
  edgeSideWord so fallow complexity thresholds hold
- share the parity-table assertion helper in the Swift XCTest (native-dupes)
- lint the Refresh lab screen (String keyExtractor, prop order)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…est export

The shared alloc/init-path block in RunnerSynthesizedGesture.m was a new
native clone; it now lives in RunnerNewPointerPath. scroll-runtime.test.ts
no longer exports bindings, which only it uses (fallow dead code).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
- RunnerTests+ScrollDragExecution.swift: holdMs is milliseconds, so the
  fallback holdDuration now converts it to seconds (was ~400s)
- Android withHoldBeforeRelease keeps the pan's interpolated samples and
  appends one stationary sample for the hold instead of replacing them
  with a straight line
- refresh --pixels is clamped into the measured-safe 320-520px band like
  the default fraction; an unreadable capture refuses with
  scroll_refresh_capture_unreadable instead of no_container
- the runner converts scrollPullContainer from screen coordinates into
  the plan frame's space, so a non-zero window origin (iPad split view)
  no longer offsets the pull; pinned by a unit test
- MCP scroll description names the drag-at-top mode and its never-at-edge
  movement report

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
… pan planner

The holdMs-0 run (5/5 on iOS and Android, posted on the PR) shows the pull
commits on the controlled-release path with no parked hold, so the hold is
dropped entirely: DEFAULT_REFRESH_HOLD_MS, the scrollHoldMs/scrollPullContainer
wire fields, the Swift pull port, and the ObjC/Android hold plumbing are
deleted. The daemon computes the top-anchored pull once in TypeScript
(buildPullRefreshGesturePlan, now in viewport space) and dispatches it as one
slow pan through the bound performGesturePlan operation.

Refresh admission moves off the inline appleOs/android check onto a declared
touchScrollSurface runtime-operation fact: platform-apple admits it on iOS and
iPadOS, platform-android on phone/tablet (not TV), and every other owner
refuses it, admitted through the refresh plan's use. The MCP description names
refresh with the reviewed sentence and states the container-height amount.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Addresses the review round on 489e22e at the owning layer.

`scroll refresh 0` reached the pull planner, which runs after the pre-pull
capture, so a bad input answered as a post-capture COMMAND_FAILED. The same
non-positive rule now holds at the input parse, before admission or any device
work.

The refresh use mixes one capability fact with two execution operations, so
admission names the cell that failed: the touch-scroll fact, the capture, or the
gesture plan. A leaf that reads the screen but synthesizes no gesture plan was
told it lacked snapshot support.

A container shorter than the measured-safe floor shortens the pull below the
travel that commits a refresh, so the pull is refused with
scroll_refresh_container_too_short rather than reported as a refresh the gesture
provably cannot trigger.

The runner computes no pull lane, so the pull planner's vectors move from the
cross-language parity table to the file that owns the planner's tests, and the
dead Swift inset helper goes with them.

Co-Authored-By: Apex <noreply@callstack.com>
@thymikee
thymikee force-pushed the t3/add-pull-to-refresh branch from 489e22e to fb4dbc8 Compare November 19, 2026 20:11
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 2 new findings on fb4dbc8. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks, this round answers the size question: the hold is gone and the pull now dispatches through the existing gesture-plan pan, which brings production code to about 665 net lines. The earlier findings at 489e22e are mostly fixed: the hold is gone from the runner, refresh now refuses empty captures, short containers and non-positive amounts, and --pixels is clamped into 320-520. One finding remains, and CI is green (22 checks, 0 not passing) at fb4dbc8.

At fb4dbc8 the pull no longer uses the runner scroll path that was measured. scroll-runtime.ts:436 sends a linear-sample pan from buildGesturePlan through performGesturePlan. Every posted run, including the holdMs-0 run, used the old route (the Android output shows helperKind: swipe and the scroll report shape). So it is unproven that the pull commits a refresh on the shipped route. A constant-velocity pan may classify differently from the cubic ease-out release that was measured. The touchScrollSurface admission that newly allows iPadOS, and the split-view coordinate mapping, also have no live confirmation. Please build fb4dbc8 and run scroll refresh --json at the Refresh lab top: (1) iPad simulator in split view with the app not at x=0, once; (2) Android emulator, three times; (3) iPhone simulator, three times, because the dispatch route changed. Paste the raw output for each. It must show refresh: true, x1/y1 inside the app window container, movement not at-edge, the gesture-plan pan report (not helperKind: swipe), and the refresh-count increment from snapshot -i. It must not show scroll_refresh_unsupported_platform. Until those runs exist, this is the next step before merge.

Not blocking, take or leave: metadata.ts:82 still ties the 0.8 cap to refresh, but refresh clamps into 320-520px, so the clause could read "(for refresh, the container-height fraction, clamped into 320-520px)"; gesture-facts.ts:101 re-derives the iOS/iPadOS check that isHandheldAppleDevice already owns; and the new CaptureCapableScrollRuntime type at scroll-runtime.ts:568 sits between directionalMovementClaim and its JSDoc.

Of the other open threads, two minor notes still apply (#4770 (comment) and #4770 (comment)). These are fixed at head and can be resolved: #4770 (comment), #4770 (comment), #4770 (comment), #4770 (comment), #4770 (comment), #4770 (comment), #4770 (comment), #4770 (comment), #4770 (comment).

thymikee and others added 2 commits November 19, 2026 22:12
…tainer

The Apple touch-scroll fact re-derived the iOS/iPadOS rule
isHandheldAppleDevice already owns, so it reads that owner now.

The refresh pull resolved the outermost scroller, then re-read the tree at
that container's centre to narrow to the inner one. A screen can also carry a
scroller that only overlaps the centre without containing it — an iOS dev client
leaves its launcher list in the accessibility tree over the app's own — and the
narrowing accepted it, so the pull was planned onto that list and the app's
refresh control never saw the gesture. The narrowing may now only narrow the
container it started from.

The MCP scroll description tied the 0.8 fraction cap to refresh while refresh
clamps its pull into 320-520px, and the CaptureCapableScrollRuntime type sat
between directionalMovementClaim and its own JSDoc.

Co-Authored-By: Apex <noreply@callstack.com>
The capture branch of refreshAdmissionRefusal answered "requires snapshot
support" with no typed reason, while the two neighbouring branches of the same
refusal both carried one, so an agent branching on details.reason had to
text-match that one case. It reports scroll_refresh_unsupported_platform now.

The bound touchScrollSurface operation resolved undefined, so a call reported
success for device work it never did; the fact is admission-only, so the
binding refuses the call by name through the runtime-contract error the
contract layer already owns.

Co-Authored-By: Apex <noreply@callstack.com>
@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. The earlier gaps are fixed at efea6ce: Android refresh now dispatches the planner pan through performGesturePlan, empty captures and short containers refuse with typed reasons, explicit --pixels is clamped, and the hold is removed. One blocker remains, and it is live evidence.

No live run covers the route this PR now ships. performRefreshPull sends a linear-sample pan from buildPullRefreshGesturePlan through performGesturePlan. Every posted run predates that: the Android output shows helperKind: swipe, and the iOS runs used the runner scroll path. The delta also changes which container the pull anchors on, and iPadOS admission and split-view mapping have never run live. So nobody has shown that this pan commits a refresh, that iPadOS is admitted, or that the coordinates land inside a split-view window. An agent could get refresh: true for a pull that only rubber-bands. Please build efea6ce and run scroll refresh --json at the Refresh lab top: once on an iPad simulator in split view with the app window not at x=0, three times on an Android emulator, and three times on an iPhone simulator. Paste the raw output for each. Every run must show refresh: true, x1/y1 inside the app window's list container, movement not at-edge, the gesture-plan pan report (not helperKind: swipe), and the refresh-count increment read with snapshot -i. No run may return scroll_refresh_unsupported_platform. Then update the PR body to drop the hold.

Not blocking, and you can take or leave it: the narrowing guard at scroll-runtime.ts:536 uses rectContains, so a nested list that runs past the outer scroller or differs by sub-pixel noise (iOS rects like 163.3333282470703) silently falls back to the outer scroller and brings back the header-anchored pull. The rule would be that the pull container is the innermost scroller that descends from the resolved container, found by walking the ancestry chain instead of comparing rects.

CI is still pending: all 18 checks were queued or in progress, and no failure has been reported. No conflicts are known. Before merge, the live runs above must be posted.

Of the open inline threads, the Minor items that do not apply at this head can be resolved: r4632606377 (Android refresh now dispatches the planner pan), r4632606399 (metadata names refresh and the never-at-edge rule), r4632606408 (empty capture refuses with scroll_refresh_capture_unreadable), r4632606423 (--pixels is clamped), r4632606450 (metadata states the container-height fraction), r4633028789 (the hold was removed from the diff), r4633028806 (Android hold branch is gone), r4633028816 (reported pixels come from the pan plan), r4633028859 (short container refuses with scroll_refresh_container_too_short), r4634593309 (touchScrollSurface throws runtime-contract-invalid), and r4634593323 (capture branch carries scroll_refresh_unsupported_platform).

The refresh pull resolved the outermost scroller, then narrowed to the
innermost one at that container's centre. The guard compared rects, so a nested
list reporting a content frame taller than its parent's clip, or the sub-pixel
noise an iOS rect carries (163.3333282470703), failed it and put the pull back
on the header, where a refresh control never sees the gesture.

Membership is the tree: the edge read now reports the position of the container
it selected, and the narrowing accepts a candidate only when its own parentIndex
chain passes through that container. An unrelated scroller that merely overlaps
the centre without descending from it is still refused.

Co-Authored-By: Apex <noreply@callstack.com>
@apex-sentinel-staging

This comment has been minimized.

The pull goes through performGesturePlan, but the report only carried what the
owner echoed back. An Apple runner answers with its own execution profile; the
Android helper names the lowered single-contact form it synthesized, so the
refresh report said helperKind: swipe and a reader could not tell the planner
pan from the retired directional swipe without counting injected events.

The refresh report now names the profile of the plan the daemon dispatched, so
the route is readable from one field on every platform and the owner's own
fields still ride along underneath it.

Co-Authored-By: Apex <noreply@callstack.com>
@thymikee

Copy link
Copy Markdown
Member Author

Live evidence at head 545d39f (raw output)

Built at this head: pnpm build (CLI 0.21.42-dev) then pnpm clean:daemon, so no stale build answers. The iOS runner and Android helper (0.21.42-dev) are unchanged since their build — no Swift or Kotlin in 43cfb9a5b1..545d39ff85. Every run uses the branch-built CLI (node bin/agent-device.mjs) at the Refresh lab top.

Every run shows refresh: true, executionProfile: timed-pan (the profile of the plan performGesturePlan dispatched), x1/y1 inside the printed container frame, and movement that is never at-edge.

iPad Air 11-inch (M4) 26CA145D-29F1-40A8-873D-8EE69BCFCA71 — Split View, app window NOT at x=0

App window {x:415,y:0,w:405,h:1180}, list container {x:439,y:164,w:357,h:984}. The pull starts at x1=618, y1=172 (inside both) and drags to y2=569. Counter 0 → 1 → 2 → 3.

### ptr-ip4  device=26CA145D-29F1-40A8-873D-8EE69BCFCA71 (iPad Air 11-inch M4, Split View, app window NOT at x=0)  CLI=0.21.42-dev  head=545d39ff85
--- app window + list container frame (snapshot -i) ---
application {"width":405,"y":0,"x":415,"height":1180}
scroller    {"width":357,"y":164,"x":439,"height":984}
--- run 1 : counter BEFORE = Refreshed 0 times
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 397,
    "executionProfile": "timed-pan",
    "gestureStartUptimeMs": 792598011.67025,
    "currentUptimeMs": 792599557.1376251,
    "message": "Pulled to refresh at the top edge",
    "gestureEndUptimeMs": 792599556.6547917,
    "runnerMainThreadBusy": false,
    "x1": 618,
    "y1": 172,
    "x2": 618,
    "y2": 569,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- run 1 : counter AFTER = Refreshed 1 times
--- run 2 : counter BEFORE = Refreshed 1 times
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 397,
    "executionProfile": "timed-pan",
    "currentUptimeMs": 792609328.2774167,
    "message": "Pulled to refresh at the top edge",
    "gestureEndUptimeMs": 792609327.7882084,
    "runnerMainThreadBusy": false,
    "gestureStartUptimeMs": 792607815.2227918,
    "x1": 618,
    "y1": 172,
    "x2": 618,
    "y2": 569,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- run 2 : counter AFTER = Refreshed 2 times
--- run 3 : counter BEFORE = Refreshed 2 times
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 397,
    "executionProfile": "timed-pan",
    "gestureStartUptimeMs": 792617443.8632501,
    "runnerMainThreadBusy": false,
    "gestureEndUptimeMs": 792618961.1315001,
    "currentUptimeMs": 792618961.4634167,
    "message": "Pulled to refresh at the top edge",
    "x1": 618,
    "y1": 172,
    "x2": 618,
    "y2": 569,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- run 3 : counter AFTER = Refreshed 3 times

Android emulator-5562 — dedicated AVD agent-device-fieldreport-api37 (Android 17)

Booted with emulator -avd agent-device-fieldreport-api37 -port 5562 -no-snapshot-save, shut down after the runs. List container {x:63,y:451,w:954,h:1910}; pull x1=540, y1=459 → y2=979. Counter 0 → 1 → 2 → 3, movement: moved on all three.

The counter is read with snapshot because snapshot -i is the interactive-only cut and the Android tree drops static Text from it; the container frame is read with snapshot -i from the same capture.

### ptr-a5562  device=emulator-5562 (AVD agent-device-fieldreport-api37)  CLI=0.21.42-dev  head=545d39ff85
--- list container frames (snapshot -i) ---
scroller {"x":0,"y":142,"width":1080,"height":2282}
scroller {"x":63,"y":451,"width":954,"height":1910}
--- run 1 : counter BEFORE = 0
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "executionProfile": "timed-pan",
    "backend": "android-helper",
    "helperVersion": "0.21.42-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1536,
    "helperTransport": "persistent-session",
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "durationMs": 1200,
    "movement": "moved",
    "message": "Pulled to refresh at the top edge; the surface changed"
  }
}
--- run 1 : counter AFTER = 1
--- run 2 : counter BEFORE = 1
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "executionProfile": "timed-pan",
    "backend": "android-helper",
    "helperVersion": "0.21.42-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1390,
    "helperTransport": "persistent-session",
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "durationMs": 1200,
    "movement": "moved",
    "message": "Pulled to refresh at the top edge; the surface changed"
  }
}
--- run 2 : counter AFTER = 2
--- run 3 : counter BEFORE = 2
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "executionProfile": "timed-pan",
    "backend": "android-helper",
    "helperVersion": "0.21.42-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1309,
    "helperTransport": "persistent-session",
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "durationMs": 1200,
    "movement": "moved",
    "message": "Pulled to refresh at the top edge; the surface changed"
  }
}
--- run 3 : counter AFTER = 3

iPhone 17 Pro BC54AC11-CD86-4C10-8C4E-5101C773FFEB

App window {x:0,y:0,w:402,h:874}, list container {x:24,y:163.33,w:354,h:648.67}; pull x1=201, y1=172 → y2=492. Counter 0 → 1 → 2 → 3.

### ptr-if  device=BC54AC11-CD86-4C10-8C4E-5101C773FFEB  CLI=0.21.42-dev  head=545d39ff85
--- app window + list container frame (snapshot -i) ---
application {"height":874,"y":0,"width":402,"x":0}
scroller    {"x":24,"y":163.3333282470703,"height":648.6666717529297,"width":354}
--- run 1 : counter BEFORE = 0
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "executionProfile": "timed-pan",
    "gestureStartUptimeMs": 792513588.2539167,
    "runnerMainThreadBusy": false,
    "message": "Pulled to refresh at the top edge",
    "currentUptimeMs": 792515107.5104584,
    "gestureEndUptimeMs": 792515106.8822083,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- run 1 : counter AFTER = 1
--- run 2 : counter BEFORE = 1
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "executionProfile": "timed-pan",
    "message": "Pulled to refresh at the top edge",
    "gestureStartUptimeMs": 792522862.5548334,
    "currentUptimeMs": 792524373.9206251,
    "gestureEndUptimeMs": 792524373.4215001,
    "runnerMainThreadBusy": false,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- run 2 : counter AFTER = 2
--- run 3 : counter BEFORE = 2
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "executionProfile": "timed-pan",
    "gestureStartUptimeMs": 792531796.1278334,
    "message": "Pulled to refresh at the top edge",
    "currentUptimeMs": 792533305.8857085,
    "runnerMainThreadBusy": false,
    "gestureEndUptimeMs": 792533305.6010833,
    "x1": 201,
    "y1": 172,
    "x2": 201,
    "y2": 492,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- run 3 : counter AFTER = 3

The route: the planner pan, not the retired directional swipe

The Android helper names the lowered single-contact form it synthesized, so helperKind: swipe is what that helper reports for any one-finger path: the refresh plan, a direct gesture pan, and a directional scroll up. Same device, same container, three commands. A refresh and a hand-issued gesture pan 540 459 0 520 1200 are identical (77 injected events = the plan's 76 densified samples plus the down event, ~1.3 s). scroll up is the other route: 21 events, 382 ms, and it alone reports referenceWidth/referenceHeight, which the plan route never does. The refresh run also carries executionProfile: timed-pan, the profile of the plan the daemon dispatched.

### ROUTE COMPARATOR at head 545d39ff85 - same device (emulator-5562), same list container, three commands

--- (1) scroll refresh
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 520,
    "executionProfile": "timed-pan",
    "backend": "android-helper",
    "helperVersion": "0.21.42-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 2172,
    "helperTransport": "persistent-session",
    "x1": 540,
    "y1": 459,
    "x2": 540,
    "y2": 979,
    "durationMs": 1200,
    "movement": "moved",
    "message": "Pulled to refresh at the top edge; the surface changed"
  }
}

--- (2) gesture pan 540 459 0 520 1200  (the gesture-plan route, issued directly)
{
  "success": true,
  "data": {
    "kind": "pan",
    "durationMs": 1200,
    "pointerCount": 1,
    "from": {
      "x": 540,
      "y": 459
    },
    "to": {
      "x": 540,
      "y": 979
    },
    "backend": "android-helper",
    "helperVersion": "0.21.42-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 77,
    "elapsedMs": 1501,
    "helperTransport": "persistent-session",
    "executionProfile": "timed-pan",
    "timing": {
      "executionProfile": "timed-pan",
      "gestureDurationMs": 1200
    },
    "message": "Panned (540, 459) by (0, 520)"
  }
}

--- (3) scroll up  (the directional route, for contrast)
{
  "success": true,
  "data": {
    "direction": "up",
    "x1": 540,
    "y1": 485,
    "x2": 540,
    "y2": 1939,
    "referenceWidth": 1080,
    "referenceHeight": 2424,
    "pixels": 1454,
    "backend": "android-helper",
    "helperVersion": "0.21.42-dev",
    "installReason": "current",
    "helperKind": "swipe",
    "helperApiVersion": "2",
    "injectedEvents": 21,
    "elapsedMs": 382,
    "helperTransport": "persistent-session",
    "movement": "unobserved",
    "message": "Scrolled up"
  }
}

@thymikee

thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Answering the live-evidence round item by item, at head 545d39ff8553061feb36fc367be87e16ddde8504.

1. Build at the head, daemon restarted. pnpm build (CLI 0.21.42-dev), then pnpm clean:daemon so no stale build answers. No Swift or Kotlin changed in 43cfb9a5b1..545d39ff85, so the branch-built iOS runner and Android helper (0.21.42-dev) are still the current artifacts.

2 + 3. The nine runs, raw output. In this comment, with the container frame printed before each set and the lab counter read around every pull:

Device Runs Fired Route reported Counter
iPad Air 11-inch M4, Split View, window {x:415} 1 (×3) 3/3 executionProfile: timed-pan 0→1→2→3
Android emulator-5562 3 3/3 executionProfile: timed-pan, movement: moved 0→1→2→3
iPhone 17 Pro 3 3/3 executionProfile: timed-pan 0→1→2→3

Device change. emulator-5556 is released and was not used for any evidence in this PR body or the linked comment. Android ran on agent-device-fieldreport-api37 at -port 5562 -no-snapshot-save, installed the test app, and is shut down. Every Android run in the body is now that AVD.

The route, proved from the report. helperKind: swipe is what the Android helper reports for any single-contact path — it names the lowered form it synthesized (touch-helper.ts:174) — so I made the refresh report name the plan it dispatched instead: scroll-runtime.ts:449. Every refresh now carries executionProfile: timed-pan. The comparator run (same device, same container) shows a refresh and a hand-issued gesture pan 540 459 0 520 1200 are identical at 77 injected events (the plan's 76 densified samples + the down event), while scroll up is the other route at 21 events and 382 ms, and is the only one of the three that reports referenceWidth/referenceHeight.

4. Hold. The body no longer mentions it; scrollHoldMs and scrollPullContainer are gone from the diff and no hold rides in the resolved options.

Optional item, applied (43cfb9a5b1): the narrowing guard no longer compares rects. The edge read now reports the tree position of the container it selected (containerIndex, scroll-edge-state.ts:29) and the candidate is accepted only when its parentIndex chain passes through it (scroll-runtime.ts:560). A nested list whose content frame runs past its parent's clip, or an iOS rect at 163.3333282470703, now narrows correctly; an unrelated overlapping scroller is still refused. Two tests cover both directions.

11 inline threads the round listed as not applying: all resolved.

Gates. Full unit suite 2089 files / 20173 tests pass; lint, typecheck, format, check:native-dupes, check:mcp-metadata, check:layering, check:production-exports, check:xctest-selection pass. CI's Android Smoke Tests failed twice on infrastructure: once on assertHomeAndRecentsRestoration (a Home/Recents foreground assertion this PR does not touch, passing at both my earlier heads) and once before any code ran, on sdkmanager failing to fetch the emulator package (Error on ZipFile unknown archive). Both re-runs requested.

@apex-sentinel-staging

This comment has been minimized.

Co-Authored-By: Apex <noreply@callstack.com>
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Fixed in c19cfce, and the 11 flagged threads are resolved.

The fix went into capture-kit, per your design question. Yes — the analyzer already resolves the selected container and walks its ancestry, so it now answers both tree questions and the daemon plans only the gesture. readScrollPullContainer (scroll-edge-state.ts:122) returns pullRect on the edge state: the chosen container's frame intersected with visibility.resolveEffectiveViewport — the nearest clipping ancestor createSnapshotVisibility already resolves (selection.ts:94). The descendant rule stays the parentIndex chain, now via visibility.findAncestor (selection.ts:81). The daemon deleted its own descendsFromNode walk plus the two-pass geometry and now just plans against pullRect ?? containerRect (scroll-runtime.ts:217). Net for this fix: +86/−71 production lines; whole PR is now 694 (was 683).

Tests — your replay, exact numbers: outer y=650 h=530, nested y=605 h=395.

  1. starts a nested pull inside the band its ancestor shows (scroll-runtime-refresh.test.ts:498) — the visible band is 650..1000, the pull starts 410,658 (was 410,613), inside what the ancestor shows.
  2. refuses when the visible band a clipping ancestor leaves is too short (same file, :548) — the ancestor shows 200px, so the command refuses with the existing scroll_refresh_container_too_short and names the visible rect {0,650,820,200}, not the raw {0,605,820,400}; nothing dispatches.

Both fail without the fix (they do not merely reorder), and three capture-kit tests pin pullRect at its new owner (scroll-edge-state-pull-container.test.ts), including the closest negative: a plain group's frame never shortens the band.

Live re-check (iPhone 17 Pro, Refresh lab, head af70aa9c80 = this head minus a test comment): one scroll refresh --json, counter 1→2, refresh: true, pull 201,172 → 201,492, executionProfile: timed-pan, movement: unobserved as before. Caveats unchanged: the Expo launcher window must settle first, and the Android counter reads with snapshot, not snapshot -i.

Full unit suite at this head: 2090 files / 20178 tests pass; check:affected --run --head c19cfcef → [passed] exactCommit=true.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready. At c19cfce the clipped-band problem from the earlier review (#4770 (comment)) is fixed, and the new regression tests would fail on 545d39f. The earlier review threads were already resolved and none have changed since, and there are no conflicts. All 21 checks pass at c19cfce, and the next step is maintainer review. Not blocking, and fine to take or leave: pullRect clips only against the nearest scrollable ancestor, and ?? rect falls back to the raw frame when nothing overlaps, so a container wholly outside its clipping ancestor can still get a pull planned on pixels no touch reaches. Treating no overlap as an empty band would let the too-short refusal fire, and intersecting with every clipping ancestor and the window would make the rule complete. The live runs were taken at 545d39f and the dispatch route is unchanged since. One iOS scroll refresh --json rerun at c19cfce showing y1 at or below the clipping ancestor top would confirm the coordinates at head.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
… empty band

`pullRect` clipped only against the nearest scrollable ancestor and fell back to the
raw frame when nothing overlapped it. Every ancestor that clips by definition bounds
the pull, since nested clips compound, and a container one of them hides entirely has
no visible band: planning the pull there dispatches a gesture the list never receives.

The band now intersects the container's frame with each clipping ancestor's, keeping a
zero-height band at the hiding ancestor's edge. `buildPullRefreshGesturePlan` stops
capping travel at the padded viewport's lane, which for a degenerate container offered
travel the container does not have, so an empty band reaches the existing
`scroll_refresh_container_too_short` refusal with 0px of travel.

Co-Authored-By: Apex <noreply@callstack.com>
@thymikee

Copy link
Copy Markdown
Member Author

Live re-check of the pull band at head 2e871bb7 (iPhone 17 Pro, Refresh lab top, CLI 0.21.42-dev):

### head=2e871bb72b63d39e10754dceea4fd01bf35abf1e  CLI=0.21.42-dev
--- before ---
  application rect {"x":0,"y":0,"width":402,"height":874}
  scroller    rect {"x":24,"y":163.3333282470703,"width":354,"height":648.6666717529297}
  COUNTER=0
--- scroll refresh --json ---
{
  "success": true,
  "data": {
    "direction": "up",
    "refresh": true,
    "pixels": 320,
    "executionProfile": "timed-pan",
    "message": "Pulled to refresh at the top edge",
    "x1": 201, "y1": 172, "x2": 201, "y2": 492,
    "durationMs": 1200,
    "movement": "unobserved"
  }
}
--- after ---
  COUNTER=1

Both bounds printed, y1 at or below each: clipping ancestor (window root) top 0, and the container's own tighter top 163.33 → y1 = 172. Counter 0→1, refresh: true, executionProfile: timed-pan, movement: unobserved as before on iOS.

Both optional items are in: pullRect now intersects every clipping ancestor instead of only the nearest, and an ancestor that hides the container entirely leaves a zero-height band at its edge rather than the raw frame — travel is also floored at the container's own height, so that band reaches the existing scroll_refresh_container_too_short refusal with travelPixels: 0 and dispatches nothing. New tests: the no-overlap refusal in scroll-runtime-refresh.test.ts:606, plus the every-ancestor and empty-band rules at scroll-edge-state-pull-container.test.ts:58 and :72. Full unit suite at this head: 2090 files, 20181 tests pass.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 2e871bb. The earlier review of c19cfce (#4770 (comment)) found no problems, and the changes since then keep it that way. CI is green: 21 checks, none failing. There are no conflicts, and the only step left before merge is maintainer review.

Not blocking, and fine to take or leave: delete the stray /** at https://github.com/callstack/agent-device/blob/2e871bb/packages/daemon/src/execution/scroll-runtime.ts#L450, and make visiblePullRect in https://github.com/callstack/agent-device/blob/2e871bb/packages/capture-kit/src/snapshot/scroll-edge-state/selection.ts#L114 skip ancestors whose rect fails isPositiveFiniteRect, as the root collection already does, so a degenerate ancestor rect cannot empty the band and refuse a pull the screen can carry.

The live re-check was iOS only and covered the happy path, where the window root is the only clipping ancestor. The nested-ancestor and empty-band paths are covered by unit tests through the daemon route, not live. Android has no root node, so its window clipping still comes from the planner's padded-viewport intersection, which this change does not touch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Still ready at fd32b1e. The change since 2e871bb applies both optional notes: visiblePullRect now skips ancestors whose frame fails isPositiveFiniteRect, so a zero-height capture artifact no longer empties the pull band, and the new test covers it. The stray /** in scroll-runtime.ts is gone. The label stays.

thymikee and others added 4 commits November 20, 2026 08:18
A slow scroll up that starts on the list already commits a refresh control:
5/5 on an iOS simulator and 5/5 on an Android emulator through the existing
scroll operation. scroll refresh is now that scroll with a 1200ms duration
and a 0.4 amount, after one fresh top-edge read that refuses with
scroll_refresh_not_at_top while content is hidden above.

This removes the touch-scroll admission fact, the pull planner, the pull
container narrowing and clipping, and the gesture-plan dispatch.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* origin/main:
  chore(gates): ratchet wire-published reason literals by value (R89) (#4779)
  feat(audit): evaluate role-less clickable views on Android (#4780)
  fix(mutation): keep umask-setting tests out of Stryker's thread pool (#4785)
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At f7d5032 scroll refresh is a preset of the directional scroll, which removes most of the pull planner. CI is green (21 checks, 0 not passing), and all 11 earlier review threads are resolved. One docs problem remains before merge.

The CLI help (index.ts:608), the gestures help (src/commands/schema/cli-help-gestures.ts:24) and commands.md:608 say the pull runs "inside the scrollable area". After the pull planner was dropped, the preset passes top.containerRect to scrollDirection (scroll-runtime.ts:306-307). Only Android, Revyl and tv-cdp read containerRect. Apple's scroll path ignores it and centres a 0.4 lane on the viewport, as the PR body's known limit says. On iOS, a refreshable list in the top or bottom band of the screen (under a large header, or a half-height sheet) gets a pull that starts outside the list. An agent then reads "Pulled to refresh and the visible content did not change" as "the refresh ran and found nothing new", when no refresh happened. Every help and doc sentence about where the pull lands should match the lane each platform builds. One option is a shared, platform-neutral sentence in all three places, such as "one slow pull down (Android aims it inside the scroll container; on iOS it runs down the middle of the screen)". Another is to drop "inside the scrollable area" and add one line under the Scroll section in commands.md with the iOS limit.

Not blocking: the PR body says the net production change is about 100 lines, but it measures 179, so about 180 would be accurate. You can take or leave this.

The live evidence is from b3dd165; the later commits are docs, same-value refusal construction and unrelated upstream merges. The iOS 400 ms and 1200 ms defaults rest on your reported runs. Once the help wording matches the iOS lane, this is ready.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 finding moved to a new line on 9f6ff3c. The verdict and the full list are in the summary comment.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 5947d9e

Since the review of 9f6ff3c: 0 new · 0 still open · 1 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (854bba6c5a18).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

Ready at 5947d9e. The CLI help, the gestures help and commands.md now state where each platform aims the pull: inside the scroll container on Android, down the middle of the screen on iOS, so a list that does not reach the middle is not pulled. The unsupported-capture test now asserts the typed UNSUPPORTED_OPERATION code instead of the message. Nothing else changed since f7d5032.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee merged commit 35c3373 into main Nov 20, 2026
21 checks passed
@thymikee
thymikee deleted the t3/add-pull-to-refresh branch November 20, 2026 11:36
thymikee added a commit to pcbeingused333/agent-device that referenced this pull request Nov 20, 2026
* origin/main: (70 commits)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (callstack#4774)
  fix(android): require acknowledgements for test IME typing (callstack#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (callstack#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (callstack#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (callstack#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (callstack#4797)
  fix(host-kit): accept a group-writable script directory the user owns (callstack#4799)
  fix(cli): escape control characters at the CLI's stdout and stderr writes (callstack#4778)
  fix(audit): do not report rows under a persistent bar that scrolling reveals (callstack#4775)
  fix(daemon): refuse an unsafe state directory before first use (callstack#4783)
  refactor: settle remaining single-deadline races through settleWithin (callstack#4788)
  refactor(host-kit): settle deadline races via settleWithin with R87 race ratchet (callstack#4766)
  fix(android): authenticate and bound persistent snapshot helper sessions (callstack#4729)
  fix(daemon): bound upload ingress and finalization (callstack#4721)
  chore(gates): ratchet wire-published reason literals by value (R89) (callstack#4779)
  feat(audit): evaluate role-less clickable views on Android (callstack#4780)
  fix(mutation): keep umask-setting tests out of Stryker's thread pool (callstack#4785)
  feat(audit): report controls that share one accessible name (callstack#4771)
  fix(contracts): pair open runtime hints with their apply operation (callstack#4754)
  refactor(daemon): report startup progress over the launch channel instead of marker files (callstack#4777)
  ...
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  feat(gesture): hold before the move with gesture pan --hold-ms (#4767)
  docs: clarify device verification and security proposals (#4805)
  fix(daemon-client): say that a hung daemon is stopped before ensureDaemon starts a new one (#4803)
  test: remove five timing races from CI (#4800)
  refactor(remote): save a remote script from memory with the local publisher (#4802)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (#4774)
  fix(android): require acknowledgements for test IME typing (#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (#4797)
  fix(host-kit): accept a group-writable script directory the user owns (#4799)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant