fix(mobile): recognize stale-ref refusals by agent-device's typed reason
What and why
-
staleOrdecidedNODE_STALEwith a regex over agent-device's message. agent-device 0.21.16 gave stale refs a typeddetails.reason(callstack/agent-device#2960, added at this repo's request), and its ref frames refuse with four more reasons. The engine now reads the reason:const STALE_REF_REASONS: ReadonlySet<string> = new Set([ 'ref_not_found', 'ref_frame_expired', 'ref_generation_mismatch', 'plain_ref_requires_complete_frame', 'ref_not_issued', ]); -
Three of the five messages never matched the regex ("minted from a superseded snapshot generation", "needs a complete snapshot", "was not issued by the current ref frame"), so those refusals would fail the action as
ENGINE_FAILUREinstead of re-resolving the node. The engine sends plain refs, so it rarely meets them today; the point is that a reworded message in a later agent-device release can no longer change the classification. -
It keys on the reason alone, not on
details.dispatched === 'no': agent-device refuses all five before the action reaches the device, but a drag's refusal comes back asdispatched: 'unknown'(callstack/agent-device#3183). Requiringnowould stop retrying a staledragTothat main retries today. -
The unsupported and no-session message checks stay as they are: a platform refusing a setting or permission e2e itself names (
sirion Android,faceidon Android) still arrives asINVALID_ARGStext.
Verified
Ran it locally: yes
- iOS 26.2 simulator, agent-device 0.21.20 through the engine's client. Each refusal was captured live and passed through
staleOrfrom main and from this branch (the pinned ref in row two is sent by hand, to get that reason):
| Refusal | agent-device sends | main | this branch |
|---|---|---|---|
press @e9999 | ref_not_found, dispatched no | NODE_STALE (retryable) | NODE_STALE (retryable) |
press @e15~s708703 after a newer snapshot | ref_generation_mismatch, dispatched no | ENGINE_FAILURE | NODE_STALE (retryable) |
drag @e15 @e31 after a tap | ref_frame_expired, dispatched unknown | NODE_STALE (retryable) | NODE_STALE (retryable) |
E2E_AGENT_DEVICE_SIMULATOR=1 pnpm --filter @e2e-dev/mobile exec vitest run: unit and simulator integration tests pass on Settings.- Not run locally: the mobile benchmark. This Mac has Xcode 26.2, which cannot build the Expo SDK 57 app; the PR's mobile jobs run it on iOS and Android.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.