Skip to content

fix(emulator): list only the worktree's attached emulators, iOS and Android - #37127

Merged
AmoabaKelvin merged 5 commits into
mainfrom
emulator-list-scope-34749
Nov 1, 2026
Merged

AmoabaKelvin merged 5 commits into
mainfrom
emulator-list-scope-34749

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​51 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28

ELI5

orca emulator list --worktree X was 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 all shows every worktree's.

What Changed

  • Before: RuntimeEmulatorCommands.emulatorList ignored its worktree param and returned serve-sim's global --list output: {"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}.
  • After: emulator.list resolves the selector with the same resolveEmulatorWorkspaceId that attach uses when it registers a session. It returns { sessions: [{ worktreeId, backend, deviceUdid, streamUrl, wsUrl, axUrl, helperPid, streamCodec }] } from EmulatorSessionRegistry, 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.
  • Before listing, the registry runs the existing 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.
  • The unused listRunningHelpers was removed from the bridge and the iOS backend.
  • Updated to match what the command now does: help text, CLI spec summary, the orca-emulator skill guide row (regenerated bundled-skill-guides.ts), the CLI overview doc, a script comment, and the "no active emulator" hint, which now points to orca emulator devices for picking a device.

Why

The registry already owns "which device is active for which worktree": attach writes to it and tap/ax/kill read 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, and orca emulator devices already 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 serve built from this branch. One iOS simulator was attached in worktree A only; worktree B (the repo's main worktree) had nothing attached.

list --worktree path:<wtA>   → [(wtA, ios, 17468F65)]
list --worktree path:<repo>  → []
list --worktree all          → [(wtA, ios, 17468F65)]
serve-sim --list (main's path, same for every worktree):
  {"running":true,"streams":[{device 17468F65…}, {device 43A07F15…  ← another agent's simulator}]}
  • 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, and all. 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:changed and verify:bundled-skill-guides pass. 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 at list to 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 fast adb devices call.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Waiting for blessing. Two decisions here were my call: the new { sessions: [...] } result shape, and --worktree all listing 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, then orca emulator list --worktree <A> --json shows one row with worktreeId, backend, deviceUdid.

  • orca emulator list --worktree <B> --json returns {"sessions":[]}; --worktree all shows A's row.

  • Mixed versions: emulator.list has no result schema and the CLI prints the result raw. An old CLI on a new server already sends worktree, 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 that attach registers 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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: 52d9a666-8f19-4518-9bb6-ddcbb43fd1a9
Commits

Reviewing files that changed from the base of the PR and between 7a0e8ea and e7310f9.

Files selected for processing: 1
  • src/cli/bundled-skill-guides.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The emulator list command now returns active sessions from the session registry and supports an optional worktree selector. The registry removes managed sessions whose devices are confirmed stopped before listing. Tests cover selected, unmatched, and omitted selectors. CLI descriptions and guides now describe worktree-attached iOS and Android sessions.

Severity of issue fixed: Medium

Merge Risk: Moderate · up to e7310

Most local listings are correctly scoped, but certain invocations can expose unrelated worktree sessions and stopped iOS sessions can remain visible. These behaviors should be resolved before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: limiting emulator listings to the selected worktree and including iOS and Android.
Description check Passed The description is detailed and mostly follows the required template. It explains the user impact, implementation, rationale, linked issue, testing, visual-proof status, compatibility considerations, …
Linked Issues check Passed Issue [#34749] requires worktree-scoped listing and an explicit global mode. emulatorList resolves the selector through resolveEmulatorWorkspaceId and lists registry sessions. listLiveActive fil…
Out of Scope Changes check Passed The changes stay within [#34749]. Runtime, bridge, registry, type, and backend changes replace the global helper source with ownership-aware session listing. The test covers the changed behavior. Help…
Full details: Description check

Explanation

The description is detailed and mostly follows the required template. It explains the user impact, implementation, rationale, linked issue, testing, visual-proof status, compatibility considerations, and checklist. The Risk section and risk level are missing, and the full validation command checklist remains unchecked, but these omissions do not make the description largely incomplete.

Full details: Linked Issues check

Explanation

Issue [#34749] requires worktree-scoped listing and an explicit global mode. emulatorList resolves the selector through resolveEmulatorWorkspaceId and lists registry sessions. listLiveActive filters by worktree ID and lists all worktree sessions when the selector resolves to the global mode. The registry prunes stopped managed sessions before listing. The regression test covers scoped iOS and Android sessions, an empty worktree, and the global result.

Full details: Out of Scope Changes check

Explanation

The changes stay within [#34749]. Runtime, bridge, registry, type, and backend changes replace the global helper source with ownership-aware session listing. The test covers the changed behavior. Help text, specifications, skill guides, documentation, the script comment, and the no-active-emulator hint update related user guidance. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 10 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai 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.

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
Commits

Reviewing files that changed from the base of the PR and between 9f416bb and 7a0e8ea.

Files selected for processing: 13
  • docs/site/content/docs/cli/overview.mdx
  • mobile/scripts/start-emulator.mjs
  • skill-guides/orca-emulator.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/root-help-text-primary.ts
  • src/cli/specs/emulator.ts
  • src/main/emulator/backends/ios-emulator-backend.ts
  • src/main/emulator/emulator-bridge.test.ts
  • src/main/emulator/emulator-bridge.ts
  • src/main/emulator/emulator-session-registry.ts
  • src/main/emulator/emulator-types.ts
  • src/main/emulator/serve-sim-execution.ts
  • src/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)

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.

Minor · Functional Correctness · Quick win

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: emulator list ignores the supplied worktree scope and lists global iOS helpers

1 participant