fix(mobile): boot one simulator when nothing is booted and no device is named
An iOS target with no device, on a machine 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. Android hits it too once two AVDs exist and none is running.
Issue
Fixes ENG-1037
Cause
With nothing booted, the pool bound one empty slot ({}), so warm and the worker's init called devices.boot({ platform: 'ios' }). agent-device 0.21.33 ranks every shut-down iPhone simulator the same and throws AMBIGUOUS_MATCH.
Fix
BootedDevicesinpackages/mobile/src/pool.tsnow reads the whole inventory. When nothing is booted,coldPickchooses one shut-down simulator or emulator no other agent-device session holds, ranked by:- phone before tablet (
formFactor: 'phone' | 'tablet') - newest OS
- name in numeric order
- id
- phone before tablet (
- Only agent-device's own fields (
kind,target,appleOs,osVersion) decide: TV and visionOS simulators, AVDs it reports astv, and physical devices are never picked. It lists a shut-down AVD with no form factor or OS version, so on Android the pick is the first AVD by name. - On a stock Xcode 26 set the pick is iPhone 16e: numeric name order puts it before iPhone 17.
- A simulator binds by UDID and an AVD by name, since an AVD has no serial until it runs. If nothing bootable is listed, the old daemon-picks path remains.
deviceLabelreadsname (id)when a binding has both, and booted devices now carry their name. Progress lines, error text, and the report's device showiPhone 17 (948FF738-…)instead of a bare UDID.
const coldPreference: readonly DeviceOrder[] = [
(a, b) => formFactorRank[a.formFactor] - formFactorRank[b.formFactor],
// Newest OS first; an empty string sorts lowest, so an unknown OS comes last.
(a, b) => numeric.compare(b.osVersion ?? '', a.osVersion ?? ''),
(a, b) => numeric.compare(a.name, b.name),
(a, b) => a.id.localeCompare(b.id),
];
A device name alone is still not unique across iOS runtimes: agent-device takes the first match. A UDID remains the way to pin one.
Verified
Ran it locally: yes
- MacBook, Xcode 26.6. agent-device was scoped to a private simulator set (
AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET) holding iPhone 17 Pro, iPhone 17, and iPad Pro 13-inch (M5) on iOS 26.5, all shut down. Nothing else on the machine was touched. apps/mobile-benchmark,E2E_MOBILE_BENCHMARK_IOS_DEVICEunset (nodevice), Release build from.github/actions/expo-app,e2e run tests/smoke.e2e.ts --target ios-simulator.- main is this branch with main's
pool.tsrebuilt in.
| main | this branch |
|---|---|
no booted ios device; agent-device boots one | no booted ios device; picked iPhone 17 (26.5). Name another in the target's device option, or boot one first |
ENGINE_FAILURE (launch) boot failed: 2 devices match this request equally; select one explicitly. | booting iPhone 17 (1F5AAED4-5302-4A25-AFEF-C49DA590E829) (1 of 1) |
| no test ran, exit 3, nothing booted | engine prepared 29.4s, home lists the scenarios and opens one passed, exit 0; only iPhone 17 booted |
On main the error says 2, not 3: agent-device already ranks the iPad below the two tied iPhones.
Not run on a real Android emulator; the Android pick (bind by AVD name, skip an AVD reported as a TV) is covered by tests/unit/engine.test.ts. Skipping a shut-down simulator another session holds is covered there too, not on a device.
Made with Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running inside T3 Code.