fix(mobile): cancel presses when the response wait expires

Merged
SH
4d ago
+254-60

Summary

  • Cancel pending SDK interactions.press calls when the run is interrupted or their response wait expires. Keep the existing 250 ms acknowledgement allowance and nonretryable timeout result.
  • Route every press through InputBudget.press and pass the whole operation to the budget factory, so callers cannot omit the signal forward. No new test API.
  • Limit cancellation to taps, double taps, focus, check and uncheck actions, and the press calls used to focus a field or dismiss a keyboard tip. Other input requests retain their existing lifetimes. Canceling a promise does not prove an accepted native hold, gesture or text sequence finished; extending cancellation to those requests needs a separate drain policy. Recording finalization is unchanged.
flowchart LR
  A[Operation signal] --> B[Input budget]
  B --> C[SDK press]
  D[Response wait expires] --> E[Abort SDK request]
  C -- answers --> F[Return original result]

Issue

Fixes #1684. Related: #1682 and callstack/agent-device#4388.

Verified

Ran it locally: yes

  • Built CLI, e2e run --video on --trace on, on a constructed UIKit fixture. The same test and SDK build reproduce late input on main and prevent it here.
main d8b694fthis branch c282cf9
Tap fails at 502 ms, then lands after the three-second overlay finishes. The unchanged zero-input assertion fails.Zero input after the overlay finishes; the immediately following attempt receives exactly its own one tap. All three cases pass.

· ·

Exact commands, tests, native events and all five videos.

The package still pins agent-device 0.21.36, used by the SDK boundary tests. The native overlay comparison deliberately uses the separately identified readiness candidate 965e77b and matching native assets on both builds. It is not a claim that the published SDK already has readiness polling.

Accepted native iOS input was verified separately on the same SDK/native build: main with recording off, this branch with recording off, and this branch with recording on. After the native runner accepted a double tap, caller cancellation was followed immediately by the next attempt's app relaunch and one tap. All three cases preserved the device ordering; each fresh app received exactly its own tap. With recording off, this branch admitted the next attempt locally before native completion, while the SDK fenced subsequent device work. Three videos, native event logs and exact hashes.

The iOS SDK runner owns that bounded drain (#3383, #3385, already in 0.21.36). An original command deadline, unavailable status or notAccepted can leave native work unconfirmed; rejecting the client promise is not a universal termination guarantee. Arbitrary custom transports that bypass the daemon are outside this native proof.

At d45a6e15, the branch added test coverage to the unchanged production source from e15c0585. All 524 mobile tests and the full repository check pass in a separately installed checkout with pinned agent-device 0.21.36. The coverage proof records all eight isolated press-route bypass mutations failing the new assertions, plus the fresh device-fixture budget signal delivering one late input and failing the zero-input oracle; restoring the source passes.

The native cancellation videos above retain their original tested commits and SDK identifiers. Those dedicated probes were not repeated for the structural revision or this test-only follow-up.

Android ordering is supported by the pinned 0.21.36 source, separately from those iOS recordings: existing requests hold both session and device keys; abort rejects queued work but does not release an admitted task. Android tap and the outer request wrapper await the backend promise. The next relaunch therefore remains queued while that promise is pending. This is backend-promise ordering, not a universal native-completion guarantee. Version-pinned code trace.

Head 66957b62 adds documentation/test nits only. The exact reviewed patch was validated in a separately installed checkout: 247 focused tests, all 524 mobile tests, full pnpm check and mobile/workspace type checks pass. Committed bytes are identical to the tested patch; no Android native run or new native video is claimed. Source, checks and attribution.

Current-head CI is terminal: 25 successful checks and 3 skipped, including successful iOS/Android deterministic suites and all runnable gates. Automated review reports zero issues across five files. Maintainer re-review remains pending. Earlier native recordings and coverage controls retain their original source attribution.