fix(daemon): resolve an explicit selector for the bound device from the session

Merged
TH
11d ago
+181-9

Summary

An explicit --udid/--serial/--device that names the device the session is already bound to now resolves from the session, like an unselected request, with no inventory read. snapshot was already cheap because its handler reads session.device directly (selector conflicts are refused earlier by assertSessionSelectorMatches); resolveCommandDevice alone forced an inventory read for every explicit selector.

Refusals are kept:

  • A selector naming another device still takes the inventory path unchanged.
  • An explicit UDID whose simulator is gone is refused with DEVICE_NOT_FOUND. It is never replaced by a same-name simulator, so the session-only rename fallback is off for explicit selectors.
  • The request device pin is still asserted on the fast path.
  • Claims: a bound session already holds its claim, and the require-owner guard only runs for a fresh session.

2 files touched (+121/āˆ’6, of which 98 are tests). Closes #4643.

Validation

Source head 85dace3bda. Base 26a8a1b301 (main).

Unit: session-device-resolution.test.ts passes (20). Without the fix, the matching-selector test and the pin test fail. The mismatch and stale-UDID tests pass on both, as intended. tsc, oxlint and oxfmt --check are clean. CI validates the rest.

Live: iPhone 17e simulator (iOS 27.0), warm daemon, private state dir per CLI, Wallet app, n=8 wall-clock medians in ms. press taps coordinates on the screen title. keyboard status is refused on iOS on both builds, so it measures resolution only.

Commandmain, sessionmain, --udidbranch, sessionbranch, --udid
appstate247261185193
snapshot -i355328254309
press660637613601
keyboard status242474204187

keyboard status with --udid drops by about 290 ms. The other three were already within noise on main: appstate takes the Apple-session path and snapshot/press do not go through resolveCommandDevice. The main and branch blocks ran sequentially, so compare within a block.

No independent reviewer was available; I read the full diff cold.

šŸ¤– Generated with Claude Code


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