fix(device): select the only booted iPhone or iPad before ranking iPhones above iPads

Merged
SJ
5d ago
+59-5

Summary

With one booted iPad simulator and three shut-down iPhones, iOS commands without a selector fail with AMBIGUOUS_MATCH. Apple ranking drops the iPad before boot state is considered.

This change puts iPhones and iPads of the same kind (simulator or hardware) in one tier. The only booted handheld in the best tier wins; otherwise, the existing iPhone-over-iPad ranking applies.

Simulators still rank above hardware, and handhelds above TV, desktop, and watch. A booted iPhone plus a booted iPad still selects the iPhone. Equal matches still require an explicit selector. The ranking documentation is updated.

Before / after

For resolveDevice(devices, { platform: 'ios' }), with one booted iPad simulator and three shut-down iPhone simulators:

  • Base 8a29aea9a: throws AMBIGUOUS_MATCH: “3 devices match this request equally; select one explicitly.”
  • Head f8ccebdb2: returns the booted iPad.

A live Mac check with one booted iPad (A16, iOS 26.5) and 10 shut-down iPhones confirmed the same behavior. Running node bin/agent-device.mjs capabilities --platform ios --json without a selector selects the booted iPad at head (exit 0). Base throws AMBIGUOUS_MATCH: “10 devices match this request equally; select one explicitly.” (exit 1).

Validation

Tested head f8ccebdb2 against base 8a29aea9a.

  • All 43 kernel device tests passed.
  • check:affected --run passed format, lint, typecheck, layering, fallow, build, and vitest-related checks (441 tests). It stopped at the unit lane on the Revyl failure described below, so daemon-wire-compat did not run within the gate.
  • Run separately at head, check:daemon-wire-compat passed with the protocol unchanged, test:smoke passed all 76 tests, and check:tmpdir-leaks was clean.
  • The full unit suite finished with 21,937 passed, 1 failed, and 10 skipped.

The only unit failure was packages/provider-revyl/src/runtime.test.ts: “Revyl answers health with 503 until the worker attaches, and the start keeps polling,” which timed out after 5,000 ms. It fails the same way on base and is unrelated to this change. The gate and full unit suite therefore remain failing; how to handle that pre-existing failure for merge readiness is up to maintainers.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.