Skip to content

feat: Allow more than one mobile emulator at a time (one per worktree) #12893

Done

Description

@stevediesbach

Problem or use case

I work on two iOS projects side by side, each in its own Orca worktree, each with its own dedicated simulator. Only one of them can be visible at any moment: whichever worktree attaches last takes over, and both emulator panes end up mirroring the same device.

The stream helper is the bottleneck. Every orca emulator attach spawns a fresh serve-sim on port 3100 and kills the previous one, so lsof -nP -iTCP:3100-3110 -sTCP:LISTEN never shows more than a single serve-sim process. --worktree <selector> does not isolate it: attaching worktree B's device while sitting in worktree A switches both worktrees onto that device. And since Window only offers Minimize and Zoom, a second Orca window isn't an option either.

This is not a serve-sim limitation. Its own README states "Multiple booted simulators are supported", and -p, --port is documented as a starting port. Starting a second stream by hand with the bundled CLI does work — node /Applications/Orca.app/Contents/Resources/serve-sim/dist/serve-sim.js --no-preview --detach <UDID> lands on 3101 and orca emulator list --worktree all lists both — but the pane pulls everything back to 3100 shortly after.

Concretely, this means an agent can't drive app A while I test app B, and a two-project mobile session degrades into constantly re-attaching.

Proposed solution

Let each worktree own its emulator stream, the way browser tabs are already scoped:

  • allocate a distinct port per attached device instead of reusing 3100, and keep existing helpers alive when a different worktree attaches;
  • have each emulator pane bind to its worktree's stream rather than to whatever currently holds 3100;
  • allow several emulator panes to be open at once, one per worktree.

A --port passthrough on orca emulator attach would already unblock scripted setups, even before the UI supports multiple panes.

Alternatives or additional context

Current workaround: keep one project in Orca's emulator pane and open the others in Apple's Simulator.app, which shows one window per booted device natively. It works, but those devices are then outside Orca — no orca emulator ax, tap or type on them, so agents can't drive them.

Environment: Orca 1.4.167, macOS 15 (Darwin 25.5), Xcode 26.5, two iOS 26.5 simulators (iPhone 17 devices).

Side note that may share a root cause: when a simulator is booted outside Orca (xcrun simctl boot <UDID>, no Simulator.app), the video stream works but the accessibility tree stays permanently empty — orca emulator ax returns a single Application node with no label and a 0×0 frame, and neither kill + attach nor relaunching the app restores it. Booting through orca emulator attach avoids it. Happy to open that separately if it's unrelated.

Activity

  1. AmethystLiang commented on Sep 13, 2026

    @AmethystLiang
    Contributor

    Additional report: with two worktrees configured to use different iOS simulators, agent-driven automation in one worktree can affect the simulator selected by the other. An extra simulator screen may also appear concurrently. The selector in each worktree still displays a different device, so the visible configuration and the automation target have diverged.

    High-level proposed solution:

    • Treat a stream session as a first-class (execution host, worktree, device UDID) resource, with the device-to-session mapping owned by the execution host.
    • On iOS attach, allocate and pass an isolated serve-sim port/session identity per device (or reuse only the existing session for that exact device); never allow a new worktree attach to replace another worktree session.
    • Route pane video, gesture WebSocket input, and every CLI/action verb through the worktree session record, rather than through process-global or default serve-sim state.
    • Keep the binding stable while an agent operates, and return a clear conflict/error if a requested device is already intentionally claimed under incompatible ownership.
    • Add integration coverage with two booted simulators and two worktrees: each pane shows its selected device and automation in A cannot change or control B.

    This would preserve parallel iOS workflows and make the worktree device selector authoritative for both UI and agent automation.

  2. Masiriope commented on Sep 13, 2026

    @Masiriope

    Additional observation from 2026-09-13: this affects action routing as well as video. During two concurrent iOS worktree sessions with distinct simulators, attaching the second simulator replaced the shared serve-sim target on port 3100. Subsequent taps and text from the first session could land on the second simulator. This matches the existing report and the previous comment. The currently installed Orca version is 1.4.194.

    Reproduction sequence:

    1. Use two worktrees, each assigned a different booted iOS simulator. Open harmless, visibly different test screens on A and B.
    2. Attach A from its worktree and verify its pane and action target.
    3. Attach B from the other worktree.
    4. Request accessibility state and perform a harmless tap from A's worktree. Check both devices: the target can now be B, despite the separate worktree assignments.

    We stopped using the shared emulator action path and directed axe / simctl explicitly by device UDID. Unsaved input was discarded, and application data was checked afterwards; no persistent changes resulted from the crossed actions in this session.

    Acceptance coverage should exercise both devices concurrently, checking that accessibility reads, text entry, gestures, and screenshots stay bound to the requested worktree/device. Attaching, detaching, or restarting B must not retarget or terminate A's session. If isolation is unavailable or ownership is ambiguous, return an explicit error before acting on a different simulator.

    No application data or private project logs are included in this report.

  3. johseffer commented on Oct 22, 2026

    @johseffer

    +1, with a cross-platform use case. I'm porting a Flutter app from Android to iOS and need to compare the same flow on both platforms at the same time: an iOS Simulator (iPhone 17 Pro) and an Android emulator (AVD, scrcpy backend), each attached to its own worktree of the same repo.

    Same result as described here: only one device is visible at a time, and switching worktrees swaps the emulator pane. The CLI side already works (orca emulator attach <udid> --worktree id:<A> and orca emulator attach emulator-5554 --worktree id:<B> both return ok), so per-worktree streams — or letting the emulator pane be split/duplicated with a different device on each side (related: #26214, #4623) — would cover it.

    Environment: Orca 1.4.237, macOS 26.5 (Apple silicon), iOS Simulator runtime 26.5, Android emulator 37.2 / API 36.

  4. added
    emulator
    on Nov 1, 2026
  5. nwparker commented on Dec 1, 2026

    @nwparker
    Contributor

    Implemented on main: EmulatorSessionRegistry (src/main/emulator/emulator-session-registry.ts) and EmulatorBridge (src/main/emulator/emulator-bridge.ts) track per-worktree active attachments (activeByWorktree) and independent per-device iOS (serve-sim) and Android (scrcpyVideoRegistry) sessions simultaneously. useEmulatorPaneSessionEvents (src/renderer/src/components/emulator-pane/session/use-emulator-pane-session-events.ts) scopes attach/shutdown events by worktreeId, PR #28176 (cbeb53714640) updated serveSimKillArgs (src/main/emulator/serve-sim-execution.ts) to --kill=${udid} so stopping one simulator does not kill others, and PR #37127 (ac99f1cb3925) scoped emulator.list per worktree.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    emulator

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions