fix(cli): name --udid when a device identity is passed to --device - #2065
fix(cli): name --udid when a device identity is passed to --device#2065NicolasBataille wants to merge 1 commit into
--udid when a device identity is passed to --device#2065Conversation
`--device <udid>` failed with "No device named <udid>" and the generic booted/connected hint, and `help commands` listed no device selector at all, so `--udid` — the only flag that pins one simulator among several sharing a name — was reachable only from `help device`'s usage line. Two changes, both discoverability: - `resolveDeviceByName` now answers the flag mistake instead of the literal lookup. When the `--device` value is the id of a listed device it names that device and the flag the value belongs to (`--udid` for Apple, `--serial` for serial-addressable platforms); when it merely has UDID shape it names `--udid`. An ordinary unknown name keeps the generic hint. This mirrors the answer `assertSelectorFlagMatchesPlatform` already gives for a mismatched identity flag. - `help commands` renders a `Device Selection` section for the selectors every command accepts (`--platform`, `--device`, `--udid`, `--serial`, `--session`). They stay in `COMMON_COMMAND_SUPPORTED_FLAG_KEYS`, not `GLOBAL_FLAG_KEYS`, so the option schema and `explain` output are unchanged. Closes callstack#2064
|
[P1] Remove the partial UDID-shape heuristic and keep the hint grounded in observed device identity. The exact |
Closes #2064
Summary
--udidis the only selector that pins one simulator when several share a name, and it waseffectively undiscoverable:
help commandslisted no device selector at all, and passing a UDID to--deviceanswered with a literal lookup failure that neither named--udidnor hinted that aUDID-taking flag exists.
Before:
After:
Two changes:
resolveDeviceByNameanswers the flag mistake. When the--devicevalue is the id of alisted candidate it names that device and the flag the value belongs to —
--udidfor Apple,--serialfor serial-addressable platforms. When it merely has UDID shape (8-4-4-4-12 hex) butmatches no listed device, it names
--udidanyway, because a shut-down simulator is still awrong-flag answer. An ordinary unknown name keeps the generic hint untouched.
This mirrors, rather than invents, the answer
assertSelectorFlagMatchesPlatformalready givesa few lines above for a mismatched identity flag (
--udidon--platform android).help commandsrenders aDevice Selectionsection for the selectors every commandaccepts:
--platform,--device,--udid,--serial,--session.Deliberately a new help section rather than a
GLOBAL_FLAG_KEYSaddition: those keys mark aflag as supported by
*inbuildOptionSpecsand move it fromsupportedFlagstoglobalFlagsin
explain. These selectors reach device resolution, not the CLI envelope; they stay inCOMMON_COMMAND_SUPPORTED_FLAG_KEYS, so the option schema,explainoutput and MCP surface arebyte-identical.
--udidand--devicealso get sharper one-line descriptions, which is where an agent reading thenew section actually learns the distinction.
Tests
packages/kernel/src/device-selector-flags.test.ts— the existing home for selector-flagmistakes — gains four cases: a UDID and a serial passed to
--device(each naming the rightflag and the device it identifies), a UDID-shaped value no listed device carries, and an ordinary
unknown name keeping the generic hint. All four were observed red against the pre-fix code.
src/cli-schema/cli-help-topics.test.tsgains aDevice Selectionsection assertion. Theexisting "only global flags in its global flags section" test slices from
Global Flags:toConfiguration:; the new section sits aboveGlobal Flags:, so that slice is unaffected.pnpm check:quick,pnpm test:unit(8092 passed),pnpm check:command-docsandpnpm check:agent-guidanceare green.Live check
Run from the built clone against a local simulator set with two simulators named "iPhone 17":
--device <udid>→ the new identity hint naming--udidand"iPhone 17".--device 11111111-2222-3333-4444-555555555555(no such device) → the shape hint naming--udid.--device "iPhone 99"→ unchanged generic hint.help commandsrenders the new section.What a maintainer might push back on
against the candidate set, which needs no shape knowledge and gets
--serialright for Android.The regex only covers a device the current inventory does not list. Dropping it would still fix
the reported case; keeping it covers the shut-down-simulator variant the issue's workaround
section implies.
--deviceaccepting a UDID outright was the issue's other suggested fix. Not taken: it wouldmake
--devicea two-meaning flag and quietly duplicate--udid/--serial's platform routing,including the
assertSelectorFlagMatchesPlatformcross-check. Naming the right flag is smallerand keeps one meaning per selector.
Device Selection (accepted by every device command)is long;a shorter title works if it does not read as "global", which is exactly the distinction that
keeps the option schema unchanged.
--targetis also a common selector and was left out to match the issue's list.Adding it is a one-line change to
DEVICE_SELECTION_FLAG_KEYS.