Skip to content

feat(gesture): hold before the move with gesture pan --hold-ms - #4767

Merged
thymikee merged 7 commits into
mainfrom
t3/hold-drag-coordinate-support
Nov 20, 2026
Merged

thymikee merged 7 commits into
mainfrom
t3/hold-drag-coordinate-support

Conversation

@thymikee

@thymikee thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

gesture pan now accepts the existing --hold-ms flag (MCP input holdMs) as a hold at the origin before the move starts:

agent-device gesture pan 200 420 0 160 500 --hold-ms 800

Step 0 evidence (below) showed a real gap: hold-activated drags — reorder handles with no accessibility element (no @ref), long-press-armed PanResponders, iOS Reminders edit-mode grips — cannot be started by coordinate input today, because gesture drag only accepts @refs/selectors and gesture pan moves immediately without a hold. The fix reuses the existing flag and the same contact-hold plan shape gesture drag already produces, so no iOS/Android runner or backend changes were needed. 22 files changed: contracts (input/plan/normalization), command-surface, command-runtime, daemon replay, CLI/MCP metadata, docs, tests, plus a reorderable-list lab in the test app whose drag handle is a plain View with a hold-armed PanResponder.

holdMs is single-pointer only (rejected with --pointer-count 2), capped so holdMs + durationMs <= 10000, and rejected for all other gesture kinds.

Review fixes (at head c74f7b7b63)

  1. Held pan is admitted through the target-authored-drag tier. gestureRuntimeTier now routes intent === 'pan' && holdMs > 0 to target-authored-drag, so endpoint-only plan lowering (Linux, HarmonyOS, macOS, tvOS) refuses the held pan with UNSUPPORTED_OPERATION and the drag hint before dispatch instead of silently dropping the hold and reporting success. The drag-tier binding forwards the pan keyboard-inclusive viewport read. The gestures help topic and commands.md now scope the --hold-ms pan line to the same platforms as gesture drag (Android touch devices and iOS/iPadOS). Evidence — admission unit tests (all passing):

    ✓ packages/daemon/src/core/gesture-runtime-admission.test.ts > Linux desktop refuses a held pan with UNSUPPORTED_OPERATION and the drag hint before binding
    ✓ packages/daemon/src/core/gesture-runtime-admission.test.ts > macOS desktop refuses a held pan with UNSUPPORTED_OPERATION and the drag hint before binding
    

    plus a tier unit test (platform-runtime-operations.test.ts: held pan -> target-authored-drag, holdMs 0/absent -> plan) and a handler test proving a held pan is admitted while the plain plan cell is unavailable (interaction-gesture-viewport.test.ts).

  2. Pan reads holdMs only from explicit input. The CLI parser strips a config/env/remote-config holdMs for gesture pan unless --hold-ms was typed (providedFlags), and the MCP config merge skips it for kind: 'pan' unless the tool call carries the field — so a press-oriented "holdMs": 300 config no longer makes every pan hold and no longer fails two-finger pans. gesture tap keeps the config default. Parser tests: config holdMs + pan -> no hold (and payload has no holdMs); explicit --hold-ms 800 + config -> 800; two-finger pan + config holdMs -> parses and dispatches with no holdMs and no error; tap + config holdMs -> 300. MCP test covers the same three cases through resolveMcpConfigDefaults.

Live re-verification at c74f7b7b63 (branch-built CLI, repacked test app; verbatim transcripts)

iOS (iPhone Air simulator, gesture pan on the reorder handle of the lab's reorder list):

$ iosb open "Agent Device Tester" --relaunch
Session state: /tmp/ad-holddrag-state/sessions/holddrag-ios
$ iosb scroll down 600
Scrolled down by 600 of the viewport (730px)
reorder-list rect: "rect":{"x":34.33,"y":375.67,"width":351.33,"height":144}
$ iosb gesture pan 364 400 0 100 600   # no hold, on the reorder handle
Panned (364, 400) by (0, 100)
canary: reorder hold activated no
$ iosb gesture pan 364 488 0 100 600 --hold-ms 800
Panned (364, 488) by (0, 100)
canary: reorder hold activated yes
reorder last dy 3

Android (emulator agent-device-fieldreport-api37):

$ andb open com.callstack.agentdevicelab --relaunch
Session state: /tmp/ad-holddrag-state/sessions/holddrag-android
reorder-list rect: "rect":{"x":90,"y":843,"width":900,"height":378}
$ andb gesture pan 932 906 0 200 600   # no hold, on the reorder handle
Panned (932, 906) by (0, 200)
canary: reorder hold activated no
$ andb gesture pan 932 936 0 200 600 --hold-ms 800
Panned (932, 936) by (0, 200)
canary: reorder hold activated yes
reorder last dy 9

iOS smoke CI log at the fixed head

Run 44585385953, job Smoke Tests (ios): 0 ##[error] lines; ✓ 01-settings.ad 13.5s, ✓ gesture-pan-duration.ad 6.21s. The new reorder rows did not shift any coordinate used by the committed replays (the lab sits below the gesture target; the pan-duration replay passes). Smoke Tests and Smoke Tests (macos) also SUCCESS.

Fix index (file:line at c74f7b7b63)

  • Tier routing pan && holdMs > 0 -> target-authored-drag: packages/contracts/src/platform-runtime-operations.ts:384; tests: packages/contracts/src/platform-runtime-operations.test.ts (held/unheld tier), packages/daemon/src/core/gesture-runtime-admission.test.ts (Linux/macOS refusal + two-way Linux admission test), packages/daemon/src/execution/interaction/internal/interaction-gesture-viewport.test.ts (held pan admitted while plan cell unavailable, records holdMs).
  • Explicit-only pan hold: src/cli/parser/args.ts:220,417 (CLI strip) and src/mcp/tool-input-config.ts:42 (MCP guard: config holdMs applies only to gesture tap); tests: src/cli/parser/__tests__/args-parse-interaction.test.ts (config+pan no hold, explicit --hold-ms wins, two-finger+config no error, tap keeps config), src/mcp/tool-input-config.test.ts (now including the fling case: config holdMs + fling merges no holdMs and the payload parses).
  • Platform-scoped text: src/commands/schema/cli-help-gestures.ts:25, website/docs/docs/commands.md:570, packages/command-surface/src/interaction/metadata.ts:245 (MCP holdMs description); test: src/mcp/__tests__/command-tools-gesture-tap.test.ts.

Step 0 evidence (installed CLI 0.21.36 = "today")

App / surface Handle has a ref in snapshot -i? gesture drag (refs) gesture pan (coords) swipe
test-app RNGH hold-drag fixture (iOS + Android) yes works (600–1000 ms hold → "drag completed yes") no — hold recognizer never activated no
test-app new reorder list, handle = plain View (iOS + Android) no (only row labels have refs) coords refused (INVALID_ARGS); dragging the label ref does not capture the handle no no
iOS Reminders edit-mode ≡ grip no (cell has ref) works via cell refs (800 ms hold) no reorder on grip coords no
iOS Home screen icon refs exist but zero bounds → drag fails "no usable bounds" fails works only after manually entering jiggle mode n/a
iOS Settings Text Size slider slider element has ref (thumb doesn't) n/a works (50% → 100%) works (→ 0%)
Android Settings > Languages ⋮ reorder yes ("Edit system language list" button) drag refs 900 ms: no reorder pan scrolls list, no reorder no; long press → menu "Move down" works
Android launcher icon yes (label cell ref) works (drag @e6 → @e8, 900 ms, moved Gmail) no-hold pan: no move contaminated
Android Settings volume SeekBar seekbar has ref n/a works (thumb moved) n/a

Decision: the gap is real (ref-less handles + hold activation), so the feature was built as gesture pan --hold-ms.

Validation

  • Tested SHA: c74f7b7b63 (branch t3/hold-drag-coordinate-support; device runs were executed at this head c74f7b7b63).
  • Unit: 209 tests across the 9 touched test files pass (vitest run packages/contracts/src/gesture-{input,normalization,plan}.test.ts packages/command-surface/src/interaction/gesture.test.ts packages/command-runtime/src/commands/interaction/runtime/gestures.test.ts packages/ad-script/src/internal/__tests__/script.test.ts packages/daemon/src/core/__tests__/session-store.test.ts src/cli/parser/__tests__/args-parse-interaction.test.ts src/mcp/__tests__/command-tools-gesture-tap.test.ts); cli-help tests 52 pass. pnpm build green; pnpm format clean. Full unit-core sweep showed only load-sensitive daemon/host-kit timing flakes unrelated to this change (they pass in isolation).
  • Device verification with the branch-built CLI (iOS iPhone Air simulator, Android emulator api37, test app repacked with the new lab):
Scenario Without --hold-ms With --hold-ms
iOS lab reorder handle pan 364 408 0 100 600 hold activated: no --hold-ms 800: yes
iOS lab RNGH fixture pan (117,304) +186,0 500 drag completed: no --hold-ms 800: yes
iOS Reminders edit mode, grip pan 388 283 0 -124 700 order unchanged --hold-ms 900: order changed (Scheduled | All | Today | Completed)
Android lab reorder handle pan 932 205 0 200 600 hold activated: no --hold-ms 800: yes
Android lab RNGH fixture pan 302 832 476 0 500 drag completed: no --hold-ms 800: yes
Android launcher icon pan 413 1650 509 0 700 no change --hold-ms 1000: icons rearranged
  • Replay invariants re-checked on device with the relocated lab: iOS pan 110 443 48 0 500 -> "pan duration >=400ms"; Android fresh launch pan 300 1237 180 0 500 + --pointer-count 2 -> "two-pointer pan activations 1".
  • CI: required checks run on this PR; see gh pr checks.
  • Risks: under synthesized touches the RN PanResponder in the new lab sees a small dy, so the row swap does not commit in automation; the hold-activation canary is the reliable signal there, and full hold-drag completion was proven on the RNGH activateAfterLongPress(500) fixture on both platforms.

🤖 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.46 MB 6.46 MB +1.7 kB
Package (unpacked) 6.45 MB 6.46 MB +1.7 kB
Package (download) 1.97 MB 1.97 MB +564 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 20.7 ms 19.2 ms -1.5 ms
CLI --help 49.9 ms 39.9 ms -10.0 ms

@apex-sentinel-staging

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Two problems in bfcc9b8 need fixes before merge.

First, gestureRuntimeTier sends a one-pointer pan to the plan tier whatever its holdMs. The hold exists only in intermediate samples. Linux, HarmonyOS, macOS and tvOS lower a plan from the first and last sample only, so gesture pan x y dx dy 500 --hold-ms 800 reports success with no hold, and the move slows to 1300 ms. An agent following the new help cannot tell the hold was dropped. The hold-preserving fact already exists as performTargetAuthoredDrag ("needs an adapter preserving source hold"). The rule: a gesture whose plan carries a contact hold must be admitted by the tier whose fact promises hold-preserving execution. Please route intent === 'pan' && (holdMs ?? 0) > 0 to target-authored-drag, so unsupported backends refuse with UNSUPPORTED_OPERATION and the drag hint before dispatch. Please add an admission test that a Linux or macOS desktop device refuses pan with holdMs, and scope the help and docs line to the same platforms as the gesture drag line.

Second, holdMs is projectConfig: true (flag-definitions-action.ts:142), so config and env defaults merge into flags for every action. On base, pan ignored flags.holdMs. Now gesture-normalization.ts:294 passes it through. Reading the config merge, a repo with "holdMs": 300 for press makes every one-finger pan hold 300 ms first, and every gesture pan ... --pointer-count 2 fail with INVALID_ARGS for a flag the user never passed. The rule: a config default must never change a gesture kind it was not requested for. Please read pan's hold only from explicit input (provided flags in the CLI; MCP already sends an explicit field), or give pan its own non-config key. Please add a parser test where a config holdMs plus a two-finger pan still parses, and a one-finger pan gets no hold.

Could the change stay smaller? Keep the reused flag and withContactHolds. With the tier route above, admission, the refusal hint and the backend set are exactly gesture drag's, and the doc line can copy drag's platform sentence. Letting gesture drag accept coordinate endpoints would remove the pan hold field entirely, but it needs a coordinate recording path, so it looks larger than this PR.

For validation after the fix, please show that an endpoint-only backend refuses gesture pan ... --hold-ms with UNSUPPORTED_OPERATION and the target-authored-drag hint before dispatch. A Linux or macOS app session or the admission unit test on that device fact is enough. Please also rerun the iOS and Android lab canary ('reorder hold activated yes' or 'drag completed yes') on the fixed head.

CI is unclear. I captured no failure log. 'Smoke Tests' follows 'Smoke Tests (ios)', which may be affected by the new reorder rows shifting the coordinates that the iOS replays use in GestureLab, but that is not proven. 'Runner Build (tvOS + visionOS)' looks unrelated because the diff touches no Swift. Please check the iOS smoke log before merge.

Not blocking, take or leave: the new case in session-store.test.ts:583 passes on base, because gestureReplayFlags is never called by a test, so driving a pan with holdMs through the handler and asserting --hold-ms in the written line would guard it; the reorder lab in GestureLab.tsx:444 cannot prove a reorder from its swap state, so keeping only the hold canary or adding a replay that asserts it would help; and the MCP schema in metadata.ts:244 keeps min 16 for holdMs while the CLI and payload reader accept 0..10000 for pan, so one bound would be cleaner.

The Android TV, Vega and web plan lowering were not traced; WebDriver iterates all samples, so it likely keeps the hold.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Neither earlier finding is fixed at 27091ea. The only change since bfcc9b8 moves the GestureLab below the pan, multi-touch and multi-tap targets, which addresses the iOS smoke concern about shifting replay coordinates. The earlier review is here: #4767 (comment)

gestureRuntimeTier still sends a one-pointer pan with holdMs > 0 to the plan tier. Linux, HarmonyOS, macOS and tvOS lower a plan from its first and last samples only. So gesture pan x y dx dy 500 --hold-ms 800 would drop the hold, slow the move to 1300 ms and report success. An agent following the new help gets a silent no-hold pan. A gesture whose plan carries a contact hold must be admitted by the tier whose fact promises hold-preserving execution. Please route intent === 'pan' && (holdMs ?? 0) > 0 to target-authored-drag in that function, since it is the one place that enumerates tier admission.

Pan now reads flags.holdMs, but holdMs is projectConfig: true (flag-definitions-action.ts#L142). A repo that sets holdMs: 300 for press makes every one-finger pan hold 300 ms first. It also makes every gesture pan ... --pointer-count 2 fail with INVALID_ARGS for a flag the user never passed. A config default must never change a gesture kind it was not requested for. Please read pan's hold only from explicit input (MCP already sends an explicit field), or give pan its own non-config key.

The help sentence, the commands.md line and the MCP holdMs description promise a hold on every platform. After the routing fix, please scope those lines to the same platforms as the gesture drag line.

Validation is still missing. After the routing fix, please show gesture pan ... --hold-ms refused with UNSUPPORTED_OPERATION and the target-authored-drag hint before dispatch, on a Linux or macOS app session or from an admission unit test on that device fact. Please also add a parser test: with a config holdMs, a two-finger pan still parses and a one-finger pan gets no hold. Then rerun the iOS and Android lab canary on the fixed head and report 'reorder hold activated yes' or 'drag completed yes'. The device results in the PR body are author-reported, without logs.

CI passes. Before merge, the routing, config and docs fixes above need to land with the admission and parser tests.

thymikee added a commit that referenced this pull request Nov 19, 2026
… only from explicit input

Review fixes for #4767:

- gestureRuntimeTier routes pan with holdMs > 0 to target-authored-drag, so
  endpoint-only plan lowering (Linux, HarmonyOS, macOS, tvOS) refuses the held
  pan with UNSUPPORTED_OPERATION and the drag hint before dispatch instead of
  silently dropping the hold. The drag-tier binding now forwards the pan
  keyboard-inclusive viewport read. Admission tests cover Linux and macOS
  desktop refusals; a handler test proves a held pan is admitted while the
  plan cell is unavailable, and the tier unit test pins plan vs drag routing.
- A config/env holdMs no longer reaches gesture pan: the CLI parser strips it
  unless --hold-ms was typed, and the MCP config merge skips it for kind pan
  unless the tool call carries the field, so a press-oriented config default
  never makes a pan hold and a two-finger pan never fails for it. Parser and
  MCP tests cover config-only, explicit, and two-finger cases.
- The gestures help topic and commands.md scope the pan --hold-ms line to the
  same platforms as gesture drag (Android touch devices and iOS/iPadOS).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This is ready at 2c85bd7, and everything from the earlier review (#4767 (comment)) is now fixed. Not blocking, and you can take or leave it: with a config "holdMs": 300, an MCP gesture call of kind fling, swipe, pinch, rotate, transform or drag still merges holdMs into the input, so the call fails with the tap-and-pan-only error for a field the caller never sent (https://github.com/callstack/agent-device/blob/2c85bd7/src/mcp/tool-input-config.ts#L42). Base threw the same error for this input, and the CLI is not affected.

Not blocking question: would applying the config holdMs only for the kinds that read it as a default, plus one non-tap case such as fling in the existing MCP test, be enough?

All checks pass at 2c85bd7. Production code at this head is identical to the device-run commit 22774b3, so the iOS and Android canary in the PR body still applies, and the Step 0 evidence shows the gap this flag closes (hold-activated drag handles with no ref). Whether the WebDriver and Limrun providers keep the intermediate hold samples was not checked.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Still ready at c74f7b7. The only change since 2c85bd7 is the optional MCP item: a config holdMs now reaches only gesture tap, so it no longer leaks into pan, fling, swipe, pinch, rotate, transform or drag calls, with a test for a non-tap kind. CI is green, and the label stays.

@thymikee

Copy link
Copy Markdown
Member Author

Still ready at e99d55e. The rebase onto main is clean: the changed lines match c74f7b7 exactly. The earlier code verdict stands.

thymikee and others added 7 commits November 20, 2026 12:56
Step 0 evidence showed hold-activated drags (reorder handles without an
accessibility element, long-press-armed PanResponders) cannot be started
by coordinate input: gesture drag only accepts @refs/selectors, and
gesture pan moves immediately without a hold. gesture pan now accepts the
existing --hold-ms flag (MCP holdMs) as a hold at the origin before the
move, reusing the same contact-hold plan shape drag already produces, so
no runner or backend changes are needed.

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

Keeps the gesture reader under the fallow complexity threshold now that
pan reads pointerCount, durationMs, and holdMs.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The reorder list sat between the drag fixture and the pan/pinch/rotate/
fling target, shifting it down so the fixed-coordinate gesture replays
(110 443 / 300 1237) landed on the reorder rows instead of the target.
Moving the list and its canaries to the bottom of the card keeps every
existing replay coordinate unchanged; verified on iOS and Android with
the branch-built CLI.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
… only from explicit input

Review fixes for #4767:

- gestureRuntimeTier routes pan with holdMs > 0 to target-authored-drag, so
  endpoint-only plan lowering (Linux, HarmonyOS, macOS, tvOS) refuses the held
  pan with UNSUPPORTED_OPERATION and the drag hint before dispatch instead of
  silently dropping the hold. The drag-tier binding now forwards the pan
  keyboard-inclusive viewport read. Admission tests cover Linux and macOS
  desktop refusals; a handler test proves a held pan is admitted while the
  plan cell is unavailable, and the tier unit test pins plan vs drag routing.
- A config/env holdMs no longer reaches gesture pan: the CLI parser strips it
  unless --hold-ms was typed, and the MCP config merge skips it for kind pan
  unless the tool call carries the field, so a press-oriented config default
  never makes a pan hold and a two-finger pan never fails for it. Parser and
  MCP tests cover config-only, explicit, and two-finger cases.
- The gestures help topic and commands.md scope the pan --hold-ms line to the
  same platforms as gesture drag (Android touch devices and iOS/iPadOS).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…way admission test

The MCP gesture holdMs description now names the platforms where the pan
hold works (Android touch devices and iOS/iPadOS), matching gesture drag.
A new admission test proves both routing directions on a Linux desktop:
an unheld pan is admitted through the plan tier and binds, a held pan is
refused with UNSUPPORTED_OPERATION and the drag hint before binding.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
A press-oriented config holdMs merged into every gesture kind's MCP input,
so fling, swipe, pinch, rotate, transform and drag calls failed with the
tap-and-pan-only error for a field the caller never sent. The config default
now applies only to the kind that reads it (tap); pan still reads holdMs
only from the tool call's own field. The MCP test gains a fling case:
config holdMs + gesture fling merges no holdMs and the payload parses.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@thymikee
thymikee force-pushed the t3/hold-drag-coordinate-support branch from e99d55e to 12d861a Compare November 20, 2026 11:56
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 12d861a

Since the review of c74f7b7: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (7de4587536f8).

💬 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
thymikee merged commit 0a1c2cc into main Nov 20, 2026
22 checks passed
@thymikee
thymikee deleted the t3/hold-drag-coordinate-support branch November 20, 2026 12:30
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