fix(mobile): skip booted devices another agent-device session holds

Merged
OK
21d ago
+95-18

What and why

  • A mobile target without device used every booted device of the platform (packages/mobile/src/pool.ts, BootedDevices). A simulator another tool was driving through its own agent-device session (a host app, another agent) was picked like any other, and the run died at prepare with agent-device's DEVICE_IN_USE, even with a free simulator booted next to it.
  • agent-device 0.21.29 already has the signal: device claims are host-global (~/.agent-device/device-claims, shared by every daemon), and devices.list projects a live claim as claimedBy: { session, workspace }. Dead owners are not projected.
  • BootedDevices.bind now skips a device whose claimedBy.session is not one of this target's slot sessions (<session>-0..slots-1), and logs what it skipped. A device held by its own slot session stays in the pool.
  • Every booted device held: prepare fails with ENGINE_FAILURE (not retryable) naming each device and holding session, instead of failing on the first one.
  • No booted device and zero-config CI with one booted simulator or emulator behave as before.
  • A booted device nothing holds (one you use by hand) is still in the pool. agent-device has no signal for that, so the docs say to name the device.
ℹ 2 booted ios device(s), skipping 1 held by another agent-device session (bds-a by session "t3-holder"); driving 1: bds-b

Verified

Ran it locally: yes

  • Two fresh iOS 26.5 simulators in an isolated simulator set (AGENT_DEVICE_IOS_SIMULATOR_DEVICE_SET), each daemon under its own AGENT_DEVICE_STATE_DIR. bds-a held by agent-device open com.apple.MobileSMS --session t3-holder from a separate daemon, standing in for another tool. Scratch project: mobile({ platform: 'ios' }), no device, one Settings test, e2e run --workers 2 --retries 0.
mainthis branch
2 booted ios device(s); driving 1: bds-a then ENGINE_FAILURE boot failed: ios device DA9C... is owned by session "t3-holder", no tests runskipping 1 held by another agent-device session (bds-a by session "t3-holder"); driving 1: bds-b, test passes, t3-holder still on Messages
  • Both held (t3-holder, t3-holder-2): every booted ios device is held by another agent-device session (bds-a by session "t3-holder", bds-b by session "t3-holder-2"); boot another one, close a holding session, or name the device in the target's \device` option`, nothing booted or opened.
  • Holders closed, two free: drives as before. One booted, no holder (CI shape): 1 booted ios device(s); driving 1: bds-a, passes.