Skip to content

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

Merged
thymikee merged 2 commits into
mainfrom
t3/skip-bound-device-inventory
Nov 17, 2026
Merged

thymikee merged 2 commits into
mainfrom
t3/skip-bound-device-inventory

Conversation

@thymikee

@thymikee thymikee commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

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.

Command main, session main, --udid branch, session branch, --udid
appstate 247 261 185 193
snapshot -i 355 328 254 309
press 660 637 613 601
keyboard status 242 474 204 187

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.

View guided diff Turn on auto-fix

…he session

An explicit --udid/--serial/--device that names the device the session is bound to no longer
re-reads the simulator inventory (~256 ms per command). A selector naming another device, a
stale UDID, and the device pin still refuse as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.37 MB 6.30 MB -69.5 kB
Package (unpacked) 6.37 MB 6.30 MB -69.5 kB
Package (download) 1.93 MB 1.91 MB -21.4 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 19.6 ms 22.8 ms +3.2 ms
CLI --help 44.4 ms 43.6 ms -0.8 ms

… as well

The explicit-selector fast path has no inventory read, so the retirement test now covers both
resolution points: an inventory read for another device, and runner observation for the bound one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

I found no code problems in 67366c8, and the PR is ready from review. CI was still queued or running on all eight jobs when I looked, so wait for Smoke Tests, Integration Tests and Coverage, which overlap resolveCommandDevice, before merging. Not blocking, take or leave: the test "keeps an app device session on its app when a selector names the Mac" now takes the new fast path with --device Mac, so it no longer reaches the host override it names (select the host by udid: host-mac and assert the inventory read happens once); the pin test could assert details.reason is device_pin_conflict, and one --device fast-path case plus a gone-simulator refusal would cover the other explicit flags, with the comment at session-device-resolution.ts:147 saying "explicit selector"; an explicit --serial on an Android session now also skips the inventory read, which fits the issue but deserves a sentence in the PR body and a test; the pin assertion block now appears three times and could become one shared helper; and the PR body names head 85dace3 with 2 files (+121/-6) while the head is 67366c8 with 3 files (+181/-9), and it has no check:affected --run --head receipt. The stale-UDID, pin and lifetime-guard behavior is covered by mocks only; could you confirm the snapshot and press handlers also go through resolveCommandDevice?

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
@thymikee
thymikee merged commit bf0ba73 into main Nov 17, 2026
18 of 19 checks passed
@thymikee
thymikee deleted the t3/skip-bound-device-inventory branch November 17, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An explicit --udid re-reads the simulator inventory on every command (~256 ms)

1 participant