Repository navigation
fix(emulator): list only the worktree's attached emulators, iOS and Android - #37127
Conversation
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
516a7792-bde0-4d64-a6fe-bb4daeafbb58
Files selected for processing: 13-
docs/site/content/docs/cli/overview.mdxmobile/scripts/start-emulator.mjsskill-guides/orca-emulator.mdsrc/cli/bundled-skill-guides.tssrc/cli/root-help-text-primary.tssrc/cli/specs/emulator.tssrc/main/emulator/backends/ios-emulator-backend.tssrc/main/emulator/emulator-bridge.test.tssrc/main/emulator/emulator-bridge.tssrc/main/emulator/emulator-session-registry.tssrc/main/emulator/emulator-types.tssrc/main/emulator/serve-sim-execution.tssrc/main/runtime/orca-runtime-emulator.ts
Files with no reviewable changes: 1-
- src/main/emulator/backends/ios-emulator-backend.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
-
| worktreeId: string | undefined, | ||
| backendForKind: CensusBackendForKind | ||
| ): Promise<EmulatorActiveSession[]> { | ||
| await this.pruneGoneManagedSessions(backendForKind) |
There was a problem hiding this comment.
Prune stopped iOS sessions before listing them.
If an attached iOS simulator shuts down outside Orca, listLiveActive still returns its session. pruneGoneManagedSessions keeps records when the backend has no device census, and IosEmulatorBackend does not implement listRunningDeviceIds. Add an iOS census that identifies booted simulator IDs and preserves records when simctl cannot answer. (raw.githubusercontent.com)
emulator list ignored --worktree and returned serve-sim's global iOS helper list. It now lists the session registry's attached sessions (iOS and Android) for the selected worktree, or every worktree's for --worktree all.
7a0e8ea to
e7310f9
Compare
ELI5
orca emulator list --worktree Xwas meant to show the devices attached to worktree X. Instead it showed every iOS simulator helper running on the machine, including other worktrees' and other tools' helpers, and never showed Android. Now it shows only what that worktree has attached, iOS and Android, and--worktree allshows every worktree's.What Changed
RuntimeEmulatorCommands.emulatorListignored itsworktreeparam and returned serve-sim's global--listoutput:{"running":true,"streams":[…every helper on the host…]}, with the same answer for every worktree and no Android sessions at all. An Android attach still listed as{"running":false}.emulator.listresolves the selector with the sameresolveEmulatorWorkspaceIdthatattachuses when it registers a session. It returns{ sessions: [{ worktreeId, backend, deviceUdid, streamUrl, wsUrl, axUrl, helperPid, streamCodec }] }fromEmulatorSessionRegistry, the per-worktree record the action verbs already target. No selector (--worktree all) lists every worktree's sessions, one row per worktree, so a device shared by two worktrees appears once for each.pruneGoneManagedSessions, so a device stopped outside Orca isn't reported as attached. Only Android has a running-device census today; iOS records are kept as they were.listRunningHelperswas removed from the bridge and the iOS backend.orca-emulatorskill guide row (regeneratedbundled-skill-guides.ts), the CLI overview doc, a script comment, and the "no active emulator" hint, which now points toorca emulator devicesfor picking a device.Why
The registry already owns "which device is active for which worktree":
attachwrites to it andtap/ax/killread from it. Listing from serve-sim was a second, global source of truth that had no idea about worktrees or Android. Filtering serve-sim's output by worktree wasn't possible, because serve-sim doesn't know about worktrees, and it would still have missed Android. Raw serve-sim helpers started outside Orca are deliberately left out of the list: they aren't owned by any worktree, andorca emulator devicesalready shows device state across both backends.Linked Issue
Fixes #34749
Visual Proof
N/A: CLI JSON output only, no UI change. The real before/after output is under Testing.
Testing
Real repro on macOS against a headless
orca servebuilt from this branch. One iOS simulator was attached in worktree A only; worktree B (the repo's main worktree) had nothing attached.New regression test at the runtime boundary (
emulator-bridge.test.ts): an iOS session in one worktree and an Android session in another. It covers a scoped list, a worktree with nothing attached, andall. It fails on main, which returned serve-sim's output, and passes here.Focused emulator, CLI spec and skill-guide tests pass, along with every test that loads a changed module;
check:code-quality:changed,check:react-doctor:changedandverify:bundled-skill-guidespass. Typecheck and the full lint run in CI.Not run locally: a live Android attach. Android uses the same registry path, and the unit test covers it.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Two review rounds, Codex plus Claude. Accepted: drop stopped devices before listing (reuses
pruneGoneManagedSessions), and fix the error hint that still pointed users atlistto pick a device. Not changed: unscoped remote calls (no--worktree) list every worktree, which matches how every other emulator verb treats a missing selector; scoping the prune to the listed worktree's backends would add branching to save one fastadb devicescall.Agent skill upstream boundary
Notes
Waiting for blessing. Two decisions here were my call: the new
{ sessions: [...] }result shape, and--worktree alllisting only Orca's sessions without raw serve-sim helpers. To try it, from worktree/Users/kelvinamoaba/orca/workspaces/orca/emulator-list-scope-34749:orca emulator attach "<simulator>" --worktree <A> --json, thenorca emulator list --worktree <A> --jsonshows one row withworktreeId,backend,deviceUdid.orca emulator list --worktree <B> --jsonreturns{"sessions":[]};--worktree allshows A's row.Mixed versions:
emulator.listhas no result schema and the CLI prints the result raw. An old CLI on a new server already sendsworktree, so it gets scoped results; a new CLI on an old server prints serve-sim's output as before. Params are unchanged.Remote/SSH: the list runs on the host that owns the registry, and the selector resolves there.
Folder workspaces: they resolve to the same
folder:key thatattachregisters under.Mobile: no mobile caller of
emulator.list.Cross-platform: no platform-specific code; on non-macOS hosts the iOS census is absent and Android works as before.
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)