Skip to content

fix(mobile): boot a shut-down device when none is booted and no device is named - #1674

Merged
kdy1 merged 2 commits into
mainfrom
krzysztof/eng-1037-boot-pick-newest
Nov 11, 2026
Merged

kdy1 merged 2 commits into
mainfrom
krzysztof/eng-1037-boot-pick-newest

Conversation

@KrzysztofMoch

@KrzysztofMoch KrzysztofMoch commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

An iOS target with no device, on a Mac where no simulator is booted, fails e2e run in prepare:

ENGINE_FAILURE (launch) boot failed: 43 devices match this request equally; select one explicitly

The e2e init iOS preset writes mobile({ platform: 'ios' }), so the first run of a fresh project hits this on most Macs.

Issue

Refs ENG-1037

Cause

With nothing booted, the pool binds one empty slot, and both warm and the worker's init call devices.boot({ platform: 'ios' }). agent-device ranks every shut-down iPhone simulator equally and throws AMBIGUOUS_MATCH.

Fix

export function bootRequest(selection: DeviceSelection): DeviceSelection & Pick<DeviceBootOptions, 'pick'> {
  const named = selection.device ?? selection.udid ?? selection.serial;
  return named === undefined ? { ...selection, pick: 'newest' } : selection;
}

Known gaps, all in agent-device

A Vision Pro simulator can win the pick. agent-device reports visionOS simulators as target: 'mobile' and ranks them level with iPhones under --platform ios, and no selector field excludes them. On equal OS versions the name decides, so Apple Vision Pro beats iPhone 17. Checked with agent-device's own resolveInventoryDeviceSelection on 0.21.36 and on 0.21.37-nightly.20261110.154: shut-down Apple Vision Pro, iPhone 17 Pro, iPhone 17, and iPad Pro, all on 26.1, give Apple Vision Pro; without the Vision Pro, iPhone 17. So on a Mac with the visionOS runtime installed, the run goes from a clear AMBIGUOUS_MATCH to booting the Vision Pro and failing later. Macs without that runtime get the fix. Naming a device avoids both. The real fix is ranking visionOS below iOS in agent-device's pick, not a second picker in e2e (the approach #1433 dropped).

The pick ignores session claims. agent-device's tie-break never reads claimedBy, so two runs starting at once on a cold Mac can both pick the device the first is still booting. Before this PR both failed with AMBIGUOUS_MATCH. Left open for the maintainer in the review thread.

A paired iPhone that isn't connected counts as booted.

Verifying this on a Mac with a paired iPhone turned up callstack/agent-device#4209 (reported from #1528): agent-device lists a paired iPhone that CoreDevice cannot reach as booted: true. With nothing booted, e2e then drives that phone instead of reaching the no-booted path, and the run fails at app launch. The fix, callstack/agent-device#4210, merged on 2026-11-04, after 0.21.36, so it is only in nightlies. No e2e change is needed for it: the pool already reads booted. Once agent-device 0.21.37 ships, a bump picks it up, and ENG-1037 can be closed after a live run on a Mac with a paired phone.

Verified

Ran it locally: no - the live simulator run was blocked by callstack/agent-device#4209 (above); unit tests only.


Made with Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running inside T3 Code.

…e is named

With no `device` and nothing booted, the engine called agent-device's boot with only the platform, which fails with AMBIGUOUS_MATCH on any Mac with several simulators. Pass agent-device's opt-in `pick: 'newest'` (0.21.35+) when the selection names no device.

Fixes ENG-1037
@github-actions github-actions Bot added the size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 10, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 10 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/mobile/src/pool.ts">

<violation number="1" location="packages/mobile/src/pool.ts:66">
P2: A shut-down inventory entry can still be claimed by another session, but `bind()` checks claims only on booted entries and returns `[{}]` when none are booted; this request can therefore take the held device. Filter cold candidates with the same own-session predicate before requesting `pick: 'newest'`.

(Based on your team's feedback about cold-pick session ownership.)</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread docs/reference/mobile.mdx Resolved
*/
export function bootRequest(selection: DeviceSelection): DeviceSelection & Pick<DeviceBootOptions, 'pick'> {
const named = selection.device ?? selection.udid ?? selection.serial;
return named === undefined ? { ...selection, pick: 'newest' } : selection;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: A shut-down inventory entry can still be claimed by another session, but bind() checks claims only on booted entries and returns [{}] when none are booted; this request can therefore take the held device. Filter cold candidates with the same own-session predicate before requesting pick: 'newest'.

(Based on your team's feedback about cold-pick session ownership.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/mobile/src/pool.ts, line 66:

<comment>A shut-down inventory entry can still be claimed by another session, but `bind()` checks claims only on booted entries and returns `[{}]` when none are booted; this request can therefore take the held device. Filter cold candidates with the same own-session predicate before requesting `pick: 'newest'`.

(Based on your team's feedback about cold-pick session ownership.) </comment>

<file context>
@@ -54,6 +55,17 @@ export function deviceSelection(
+ */
+export function bootRequest(selection: DeviceSelection): DeviceSelection & Pick<DeviceBootOptions, 'pick'> {
+  const named = selection.device ?? selection.udid ?? selection.serial;
+  return named === undefined ? { ...selection, pick: 'newest' } : selection;
+}
+
</file context>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[claude-opus-5-5] responding on behalf of krzysztof

Valid, and it is agent-device's pick, not e2e's: the tie-break (J in agent-device 0.21.36's sdk-device.js) sorts the shut-down candidates by target, OS, and name and never reads claimedBy. No boot option or selector field lets e2e exclude a device from it. The only e2e-side fix is picking the device in e2e and binding its UDID, the approach #1433 dropped in favor of the upstream pick.

The realistic trigger is narrow: two runs starting on a cold Mac at once, where the second lists the device the first is still booting as shut down but claimed. Before this PR both failed with AMBIGUOUS_MATCH; now both can pick the same device. Leaving this open for the maintainer: accept it until agent-device's pick skips claimed devices, or pick in e2e.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e ios agent: 21 passed, 1 skipped

25 agent steps · 12 replayed from cache · 75 model calls · 582.1k tokens (78% cached) · $0.0455

All 22 tests in 1 file
Test Agent Time
⏭️ tests-agent/scenarios.e2e.ts · 21 passed, 1 skipped 25 steps · 75 calls 10m 9s
🟢 act completes Login Form 1 step 34.9s
🟢 act completes Infinite Scroll List 1 step 37.9s
🟢 act completes Modal Flow 1 step 10.4s
🟢 act completes Bottom Tabs 1 step 7.2s
🟢 act completes Text Input Variations 1 step 13.2s
🟢 act completes Broken Accessibility 2 steps · 14 calls 1m 17s
🟢 act completes Vision Only 2 steps · 6 calls 28.6s
🟢 act completes Gestures 1 step · 10 calls 46.6s
🟢 act completes Async States 1 step · 9 calls 33.0s
🟢 act completes Debounced Search 1 step · 1 call 27.1s
🟢 act completes Flattened Registration Form 2 steps · 1 call 28.4s
🟢 act completes Flattened Login 2 steps · 19 calls 1m 44s
🟢 act completes Sticky Chrome Target 1 step 13.7s
🟢 act completes WebView Accessibility 1 step 12.1s
🟢 act completes Permission Prompt 1 step 11.2s
🟢 act completes Photo Picker 1 step · 2 calls 29.1s
🟢 act completes Product Catalog 1 step 10.1s
🟢 act completes Error Recovery 1 step 9.4s
🟢 act completes Choice Controls 1 step · 5 calls 33.9s
🟢 act completes Stripe PaymentSheet 1 step · 8 calls 30.4s
🟢 act completes Apple Pay 1 step 10.5s
⏭️ act completes Apple Pay Billing Address (skipped: the CI simulator's Apple Pay sheet skips the billing-address step, so the scenario cannot be completed there)

Tested by e2e 0.23.0 · 10m 9s · ios-simulator · run artifacts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

View guided diff | Turn on auto-fix | Re-trigger cubic

@github-actions

Copy link
Copy Markdown
Contributor

🟢 e2e android agent: 20 passed

24 agent steps · 15 replayed from cache · 42 model calls · 242.4k tokens (83% cached) · $0.0160

All 20 tests in 1 file
Test Agent Time
🟢 tests-agent/scenarios.e2e.ts · 20 passed 24 steps · 42 calls 7m 23s
🟢 act completes Login Form 1 step 39.9s
🟢 act completes Infinite Scroll List 1 step 35.3s
🟢 act completes Modal Flow 1 step 16.5s
🟢 act completes Bottom Tabs 1 step 12.2s
🟢 act completes Text Input Variations 1 step 13.7s
🟢 act completes Broken Accessibility 2 steps · 5 calls 24.6s
🟢 act completes Vision Only 2 steps · 1 call 11.5s
🟢 act completes Gestures 1 step · 7 calls 21.4s
🟢 act completes Async States 1 step · 17 calls 38.6s
🟢 act completes Debounced Search 1 step 6.7s
🟢 act completes Huge Virtualized List 1 step 1m 56s
🟢 act completes Flattened Registration Form 2 steps · 1 call 8.1s
🟢 act completes Flattened Login 2 steps · 6 calls 15.3s
🟢 act completes Sticky Chrome Target 1 step 9.5s
🟢 act completes WebView Accessibility 1 step · 5 calls 16.0s
🟢 act completes Permission Prompt 1 step 7.8s
🟢 act completes Product Catalog 1 step 9.6s
🟢 act completes Error Recovery 1 step 11.2s
🟢 act completes Choice Controls 1 step 14.3s
🟢 act completes Sequential Onboarding 1 step 14.4s

Tested by e2e 0.23.0 · 7m 25s · android-emulator · run artifacts

@github-actions

Copy link
Copy Markdown
Contributor

🟢 e2e ios: 55 passed, 1 skipped

All 56 tests in 7 files
Test Time
⏭️ tests/controls.e2e.ts · 23 passed, 1 skipped 2m 53s
🟢 control inventory › a label query resolves a labeled text field 11.7s
🟢 control inventory › a labeled field answers name, display value, value reads, fill, and clear 14.7s
🟢 control inventory › a placeholder query and attribute reads find the field 4.6s
🟢 control inventory › a secure field takes a fill and denies value reads 9.3s
🟢 control inventory › press sends a character and Enter through the soft keyboard 8.8s
🟢 control inventory › a field autofocuses on mount and focus() moves the focus 9.8s
🟢 control inventory › toBeFocused follows the focus 8.6s
🟢 control inventory › a switch checks, unchecks, and reports its state 9.7s
🟢 control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap 8.5s
🟢 control inventory › checkbox and radio roles check, uncheck, and report their state 12.6s
🟢 control inventory › a radio group reports the checked option 8.9s
🟢 control inventory › buttons report disabled, enabled, and a state that arrives later 7.6s
🟢 control inventory › a display: none element is absent rather than hidden, its visible twin attached 6.8s
🟢 control inventory › a header answers its accessible name 4.0s
🟢 control inventory › a tab row answers count, all, texts, filters, positions, and switching 6.0s
🟢 control inventory › a list answers counts, list-form text, reads, and boxes in order 6.3s
⏭️ control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…)
🟢 control inventory › a long press lands as one 8.0s
🟢 control inventory › pointer verbs land at the point asked for 9.8s
🟢 control inventory › an ambiguous locator fails at once 5.6s
🟢 control inventory › screenshot, restart, and clearState reopen the app on its home list 10.1s
🟢 refusals › verbs a device never declares are refused before the engine 2ms
🟢 refusals › keys the soft keyboard cannot send are refused by the engine 560ms
🟢 refusals › a missing locator fails as not found once its timeout passes 1.1s
🟢 tests/device-fixture.e2e.ts · 11 passed 1m 26s
🟢 device fixture › setAppearance flips the color scheme the app reads 11.9s
🟢 device fixture › setOrientation rotates the window the app measures 7.9s
🟢 device fixture › the clipboard reads back what was written 6.1s
🟢 device fixture › home leaves the app, openApp brings it back where it was 6.4s
🟢 device fixture › closeApp then openApp relaunches on the home list 7.8s
🟢 device fixture › closeApp leaves the next commands on the same device 10.7s
🟢 device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN 5.4s
🟢 device fixture › device.back pops the scenario 5.5s
🟢 device fixture › unstable_raw reaches the test session through agent-device 4.3s
🟢 device fixture › setLocation and clearLocation change what the app reads 10.4s
🟢 device fixture › enrollBiometrics and setBiometrics answer a biometric prompt 10.1s
🟢 tests/device.e2e.ts · 3 passed 1m 6s
🟢 sequential onboarding echoes the exact values 41.4s
🟢 onboarding rejects a malformed email before advancing 13.5s
🟢 dismissing the keyboard over choice controls leaves them as they were 11.5s
🟢 tests/flows-lists.e2e.ts · 7 passed 4m 19s
🟢 infinite scroll reaches the target item 33.0s
🟢 product catalog adds exactly two of the right variant 10.7s
🟢 gestures: long-press, then swipe left 9.2s
🟢 sticky chrome: accept below the fold, then continue 12.8s
🟢 async states: load, pull to refresh, claim through the toast 15.6s
🟢 huge virtualized list reaches row 512 2m 46s
🟢 web view coupon form applies the code shown on the page 12.1s
🟢 tests/flows.e2e.ts · 7 passed 1m 10s
🟢 text inputs unlock the submit button 12.8s
🟢 filled text inputs report their values 10.9s
🟢 modal flow confirms through the native alert 10.0s
🟢 bottom tabs act inside the last tab 7.4s
🟢 error recovery retries, then confirms the delete 9.8s
🟢 choice controls place the exact order 7.8s
🟢 debounced search selects the target once results arrive 11.7s
🟢 tests/login-form.e2e.ts · 3 passed 47.6s
🟢 login form › rejects a malformed email 13.6s
🟢 login form › rejects an unknown account 13.7s
🟢 login form › signs in and logs out 20.3s
🟢 tests/smoke.e2e.ts · 1 passed 7.6s
🟢 home lists the scenarios and opens one 7.6s

Tested by e2e 0.23.0 · 6m 53s · ios-simulator · run artifacts

@github-actions

Copy link
Copy Markdown
Contributor

🟢 e2e android: 57 passed, 1 skipped

All 58 tests in 7 files
Test Time
⏭️ tests/controls.e2e.ts · 24 passed, 1 skipped 3m 31s
🟢 control inventory › a label query resolves a labeled text field 36.8s
🟢 control inventory › a labeled field answers name, display value, value reads, fill, and clear 16.1s
🟢 control inventory › a placeholder query and attribute reads find the field 7.7s
🟢 control inventory › a secure field takes a fill and denies value reads 10.7s
🟢 control inventory › press sends a character and Enter through the soft keyboard 11.3s
🟢 control inventory › a field autofocuses on mount and focus() moves the focus 10.3s
🟢 control inventory › toBeFocused follows the focus 10.1s
🟢 control inventory › a switch checks, unchecks, and reports its state 9.7s
🟢 control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap 8.6s
🟢 control inventory › checkbox and radio roles check, uncheck, and report their state 12.7s
🟢 control inventory › a tab role answers getByRole 5.4s
🟢 control inventory › a radio group reports the checked option 8.4s
🟢 control inventory › buttons report disabled, enabled, and a state that arrives later 8.4s
🟢 control inventory › a display: none element is absent rather than hidden, its visible twin attached 7.3s
🟢 control inventory › a header answers its accessible name 4.6s
🟢 control inventory › a tab row answers count, all, texts, filters, positions, and switching 6.2s
🟢 control inventory › a list answers counts, list-form text, reads, and boxes in order 5.9s
⏭️ control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…)
🟢 control inventory › a long press lands as one 7.7s
🟢 control inventory › a double tap lands inside the 300 ms window 6.8s
🟢 control inventory › an ambiguous locator fails at once 5.3s
🟢 control inventory › screenshot, restart, and clearState reopen the app on its home list 7.9s
🟢 refusals › verbs a device never declares are refused before the engine 4ms
🟢 refusals › keys the soft keyboard cannot send are refused by the engine 1.6s
🟢 refusals › a missing locator fails as not found once its timeout passes 1.1s
🟢 tests/device-fixture.e2e.ts · 10 passed 1m 19s
🟢 device fixture › setOrientation rotates the window the app measures 4.9s
🟢 device fixture › home leaves the app, openApp brings it back where it was 4.5s
🟢 device fixture › foregroundApp sees the home screen after home() 4.1s
🟢 device fixture › closeApp then openApp relaunches on the home list 7.7s
🟢 device fixture › closeApp leaves the next commands on the same device 7.6s
🟢 device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN 4.3s
🟢 device fixture › device.back pops the scenario 5.0s
🟢 device fixture › unstable_raw reaches the test session through agent-device 3.9s
🟢 device fixture › setNetwork and setAirplaneMode change what the app sees 15.8s
🟢 device fixture › setLocation and clearLocation change what the app reads 21.2s
🟢 tests/device.e2e.ts · 5 passed 41.1s
🟢 permission prompt › allowing the system dialog enables the microphone 6.1s
🟢 permission prompt › a denied prompt recovers once the permission is granted outside 12.3s
🟢 sequential onboarding echoes the exact values 9.9s
🟢 onboarding rejects a malformed email before advancing 5.8s
🟢 dismissing the keyboard over choice controls leaves them as they were 7.1s
🟢 tests/flows-lists.e2e.ts · 7 passed 3m 25s
🟢 infinite scroll reaches the target item 30.1s
🟢 product catalog adds exactly two of the right variant 9.1s
🟢 gestures: long-press, then swipe left 7.9s
🟢 gestures: double-tap completes the flow 9.7s
🟢 sticky chrome: accept below the fold, then continue 11.3s
🟢 async states: load, pull to refresh, claim through the toast 14.5s
🟢 huge virtualized list reaches row 512 2m 3s
🟢 tests/flows.e2e.ts · 7 passed 58.7s
🟢 text inputs unlock the submit button 8.3s
🟢 filled text inputs report their values 6.9s
🟢 modal flow confirms through the native alert 9.8s
🟢 bottom tabs act inside the last tab 7.5s
🟢 error recovery retries, then confirms the delete 9.2s
🟢 choice controls place the exact order 7.3s
🟢 debounced search selects the target once results arrive 9.7s
🟢 tests/login-form.e2e.ts · 3 passed 29.9s
🟢 login form › rejects a malformed email 8.5s
🟢 login form › rejects an unknown account 8.3s
🟢 login form › signs in and logs out 13.1s
🟢 tests/smoke.e2e.ts · 1 passed 6.5s
🟢 home lists the scenarios and opens one 6.5s

Tested by e2e 0.23.0 · 10m 33s · android-emulator · run artifacts

@KrzysztofMoch

KrzysztofMoch commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

[claude-opus-5-5] responding on behalf of krzysztof

Ready for review. Left for a human:

@kdy1

kdy1 commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

I changed Closes ENG-1037 to Refs ENG-1037 because agent-device@0.21.37 is not released yet

@kdy1

kdy1 commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

A Vision Pro simulator can win the pick

I filed callstack/agent-device#4402

@kdy1
kdy1 added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit e534014 Nov 11, 2026
35 checks passed
@kdy1
kdy1 deleted the krzysztof/eng-1037-boot-pick-newest branch November 11, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants