Skip to content

fix(device-selection): list only tied devices in an ambiguous device error - #4506

Merged
thymikee merged 1 commit into
mainfrom
fix/open-ambiguous-device-app-tiebreak
Nov 13, 2026
Merged

thymikee merged 1 commit into
mainfrom
fix/open-ambiguous-device-app-tiebreak

Conversation

@thymikee

@thymikee thymikee commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

When open without a platform finds a booted iOS simulator and a booted Android emulator, it fails with AMBIGUOUS_MATCH. This PR does not change that. It makes the failure cheaper to recover from, so an agent needs only one short retry:

  • Only the tied devices are listed. The error used to list every device that matched, including every shut-down simulator. Now details.devices and details.retrySelectors hold only the devices that are equally preferred, which are the ones the kernel refused to choose between.
  • Typed as never dispatched. The kernel's device tie now carries dispatched: 'no'. The --platform ios simulator ambiguity and the provider ambiguity carry it too. Selection runs before any device operation, so the "May have reached the device… Run snapshot" text no longer appears.
  • One recovery step. The hint is now Retry with the id of the intended device: --serial emulator-5554 or --udid <sim-udid>., built from the tied devices' ids.

Scope reduced by maintainer decision. An earlier version of this PR let the installed app break the tie (it probed each tied device and picked the only one with the app). That is dropped: when a device request is ambiguous, agent-device fails explicitly instead of picking a device by a heuristic that different users would expect differently. The existing --platform ios behaviour, where the booted simulator that has the app wins, is unchanged from main. No help or docs change: the error code and its fields keep the same shape.

Validation

  • Head b66bea3: focused vitest passes (device-selection, kernel, command-output: 44 files, 580 tests). pnpm typecheck and pnpm lint are clean.
  • New test: a cross-platform tie with shut-down simulators lists only the two booted devices, carries dispatched: 'no', and names both ids in the hint.
  • No live device run. Only the error contents change, not dispatch or native execution. CI owns full validation.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.26 MB 6.26 MB +19 B
Package (unpacked) 6.26 MB 6.26 MB +19 B
Package (download) 1.90 MB 1.90 MB -20 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.3 ms 22.0 ms -1.3 ms
CLI --help 43.0 ms 43.4 ms +0.4 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 21 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/commands/schema/cli-help.ts Resolved
Comment thread website/docs/docs/commands.md Resolved
@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 2 no longer raised (2 marked fixed)

No open findings. 1 withdrawn by a re-check since this review.

3 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (80075b6412df).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

Earlier reviews

Review of 1491e27f · 13.11.2026 14:21 UTC

Apex Sentinel · ✅ Approve

2 finding(s): 2 minor.

🟡 Minor (2)

Where Finding
packages/device-selection/src/device-selection-resolver.ts:202 An unreadable Android device aborts open instead of leaving the tie ambiguous
src/commands/schema/cli-help.ts:88 Help text drops 'explicit' and 'only filter' wording users relied on

3 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (80075b6412df).

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on 1491e27. The verdict and the full list are in the summary comment.

Comment thread src/commands/schema/cli-help.ts Resolved
… tied devices

An ambiguous device selection now lists only the equally preferred devices,
is typed dispatched: 'no', and its hint names the --udid/--serial of each tied
device as the one retry step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee
thymikee force-pushed the fix/open-ambiguous-device-app-tiebreak branch from 1491e27 to b66bea3 Compare November 13, 2026 14:22
@thymikee thymikee changed the title fix(device-selection): let the installed app break a cross-platform open tie fix(device-selection): list only tied devices in an ambiguous device error Nov 13, 2026

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on b66bea3. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at b66bea3. CI is green: 20 checks, none failing or pending. There are no conflicts. Nothing else needs to happen before merge. I did not run the tests locally, and I did not do a live device run, because the change only affects error content before dispatch.

Not blocking, and you can take or leave these. (1) The resolver recomputes the tied set in packages/device-selection/src/device-selection-resolver.ts:253, but the kernel error already carries it in details.devices, so for an Apple-only tie or more than 10 tied devices devices, retrySelectors and the hint can use a different order or subset. Would keeping the kernel's list and building retrySelectors from those ids give one owner and remove the new exported preferredDeviceCandidates? The new test only uses a mixed Android and iOS set, so it cannot see this. (2) buildAmbiguousDeviceHint in packages/kernel/src/device.ts:792 falls back to --udid <id> for platforms with no identity flag, such as linux and web, where --udid cannot work. Listing --device <name> for those devices would fix it. I did not check whether such devices can appear in a real unscoped tie. (3) The provider ambiguity test at packages/device-selection/src/tests/dispatch-resolve.test.ts:475 could also assert dispatched is 'no'.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 13, 2026
@thymikee
thymikee merged commit 9e4b5a4 into main Nov 13, 2026
20 checks passed
@thymikee
thymikee deleted the fix/open-ambiguous-device-app-tiebreak branch November 13, 2026 15:01
thymikee added a commit that referenced this pull request Nov 14, 2026
* origin/main:
  fix(android): carry an empty text on a node labelled by its content description (#4531)
  fix(ios): restore the back swipe's pre-swipe still span (#4515)
  fix(daemon-client): type the remote daemon refusal with its dispatch fact (#4532)
  fix: prepare reinstall artifacts before removing apps (#4533)
  fix(ios): classify the keyboard dismiss refusal by what it dispatched (#4536)
  fix(ios): press the navigation bar back button and speed up the back swipe (#4508)
  refactor(gestures): one owner for the densified gesture path; drop the unproven sendevent transport (#4239)
  fix(host-kit): keep Linux process identity stable across clock steps (#4438)
  fix(ios): bound the idle wait of keyboard dismiss and keyboard enter (#4454)
  fix(device-selection): fail an ambiguous device request with only the tied devices (#4506)
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.

1 participant