Skip to content

[Bug]: Mobile Emulator pane never connects in a folder workspace — raw selector_not_found; CLI attach/list/pane disagree on scope #13831

Closed

Description

@kimnamwook1

Summary

In a folder workspace (folder:<id> context), the Mobile Emulator pane can never connect to a booted Android AVD: it shows the raw internal error string selector_not_found under the device combo and stays "Not connected", while the same device is booted, adb-visible, and even orca emulator attach reports success. CLI scoping is inconsistent in the same shell: attach succeeds, but unqualified list says nothing is running and --worktree active fails with selector_not_found.

Environment

  • Orca 1.4.179 (production, macOS), com.stablyai.orca
  • macOS Darwin 25.5.0 (arm64)
  • Android Emulator 36.4.10.0, AVD Medium_Phone (android-35, google_apis_playstore, arm64-v8a), serial emulator-5554
  • Workspace: a folder context (ORCA_WORKTREE_ID=folder:46363936-...), i.e. a plain folder workspace, not a git-repo worktree. Shell cwd is a subfolder that is not under any Orca-managed git worktree.

Steps to reproduce

  1. Open a folder workspace (add a plain folder as a project; ORCA_WORKTREE_ID is a folder: id).
  2. Boot an Android AVD so it is adb-visible (adb devices shows emulator-5554 device). Either GUI or headless — the result is identical.
  3. Open the Mobile Emulator pane (⌘⌥⇧E / "새로운 모바일 에뮬레이터").
  4. The pane pre-selects the AVD (Medium_Phone) but shows "Not connected" with the literal text selector_not_found and "연결된 에뮬레이터가 없습니다".
  5. Click 연결 (Connect) — the click is accepted but nothing changes; the same selector_not_found remains.

CLI evidence (same shell, same cwd)

$ orca emulator devices --json   # device is visible and booted
emulator-5554  Medium_Phone  booted  true

$ orca emulator attach Medium_Phone --focus --json
{"ok":true,"result":{"attached":true,"info":{"deviceUdid":"emulator-5554","streamUrl":"scrcpy://emulator-5554","wsUrl":"","streamCodec":"h264","backend":"android"}}}

$ orca emulator list --json      # immediately after the successful attach
{"ok":true,"result":{"running":false}}

$ orca emulator list --worktree active --json
{"ok":false,"error":{"code":"selector_not_found","message":"No Orca-managed worktree contains the current directory: /Users/.../beautyrella/beautyrella_flutter"}}

$ orca emulator attach Medium_Phone --worktree "name:<folder workspace name>" --focus --json
{"ok":false,"error":{"code":"selector_not_found","message":"selector_not_found"}}

So attach (unqualified) resolves some scope — presumably via the ORCA_WORKTREE_ID env — and reports success, but list in the same shell and the pane itself resolve a different scope and fail. The three surfaces (attach, list, pane) disagree about what the active emulator scope is.

Expected

  • The pane connects to the booted AVD in a folder workspace, or
  • if folder workspaces are intentionally unsupported for the emulator surface, the pane says so in a human-readable way instead of leaking the internal error code selector_not_found, and ideally doesn't offer the device picker at all;
  • attach, list, and the pane agree on scope: an attach that reports "attached": true should be visible to list and the pane.

Notes

Activity

  1. manuaudio commented on Aug 11, 2026

    @manuaudio
    Contributor

    Your CLI evidence is the whole diagnosis — thank you for capturing all four commands from the same shell. The chain is fully traceable in source, and it ends somewhere better than "scope disagreement": attach reports success while skipping the half that makes it visible. Checked against upstream/main at a0a654c3a9.

    First, a correction: the three surfaces do not resolve different scopes

    You inferred that attach resolves one scope and list another. They can't — emulator list, emulator devices and emulator attach all call the same getEmulatorCommandTarget(flags, cwd, client) (src/cli/handlers/emulator.ts:118, :123, :128), which calls the same getEmulatorWorktreeSelector. Same inputs, same result.

    And two of those RPCs ignore the worktree entirely. orca-runtime-emulator.ts:172-175:

      async emulatorList(_params: { worktree?: string } = {}): Promise<unknown> {
        const bridge = this.requireEmulatorBridge()
        return bridge.listRunningHelpers()
      }

    Note the _params — the selector is accepted and discarded. emulatorListDevices (:201-203) does the same, and emulatorListSimulators (:186-193) says so explicitly: "Worktree param ignored (simulators are host-local, not per-worktree)."

    So {"running": false} is not a scoping answer. It means the bridge has no running helper registered. That's the thread to pull.

    The actual chain

    1. A folder workspace has no enclosing managed worktree. resolveCurrentWorktreeSelector (src/cli/selectors.ts:46-75) walks worktree.list looking for a record whose path contains your cwd, and throws when none matches:

      if (!enclosingWorktree) {
        throw new RuntimeClientError(
          'selector_not_found',
          `No Orca-managed worktree contains the current directory: ${currentPath}`
        )
      }

    That is verbatim the message your --worktree active run printed.

    2. Unqualified commands swallow that failure. getEmulatorWorktreeSelector (:221-245):

      try {
        return await resolveCurrentWorktreeSelector(cwd, client)
      } catch {
        return undefined
      }

    --worktree active takes the branch at :231-234 with no try/catch, which is the only reason it errors loudly. Everything else silently degrades to "no worktree" — so all three of your unqualified commands sent worktree: undefined, identically.

    3. And that is what breaks attach. emulatorAttach (orca-runtime-emulator.ts:124-170) resolves worktreeId at :144 — resolveWorktreeId (:205-207) returns undefined for a falsy selector rather than throwing — and then:

        const info = await bridge.startHelperForDevice(device)
        if (worktreeId) {
          bridge.registerActiveEmulator(worktreeId, info, { managed: true })
          this.notifyRendererEmulatorAutoAttach(worktreeId, info)
          if (params.focus) {
            this.notifyRendererEmulatorPaneFocus(worktreeId)
          }
        }
        // …
        return { attached: true, info }

    With worktreeId undefined, the helper does start — so attached: true is truthful about the device — but registerActiveEmulator never runs, and neither renderer notification is sent. Nothing is registered, so list reports running: false, and the pane is never told anything, so it stays "Not connected". Your --focus flag was silently inert for the same reason.

    So the three surfaces agree about scope perfectly. What they disagree about is whether the attach was recorded, and the if (worktreeId) guard is why.

    Two different failures wearing one error code

    Worth separating, because they need different fixes:

    • The CLI's selector_not_found — "your cwd is not inside a managed worktree." Real, well-described, and swallowed everywhere except --worktree active.
    • The pane's bare selector_not_found — no message, which is a different call site: the pane passes a folder: id and main fails to resolve it. I have not traced that one, so I'm not asserting its mechanism. Your suspected link to [Bug]: Mobile Source Control retries selector_not_found for folder-workspace git RPCs that were never routed #11153 (folder-workspace RPCs failing with selector_not_found) is about the right shape for it, and if that's the same defect this issue is partly a duplicate of the routing problem rather than an emulator problem.

    On your "unsupported feature vs bug" question

    I'd say bug, and specifically the if (worktreeId) guard. Even if the Android visual pane is still in development, attach returning {"attached": true} after skipping registration and notification is a success receipt for work that was only half done — a caller cannot distinguish it from a real attach. The narrow fix is for attach to refuse (or report a distinct partial state) when it cannot resolve a worktree to register against, rather than reporting plain success.

    Also worth noting your attach receipt already hints at the incompleteness: "wsUrl": "" alongside "streamUrl": "scrcpy://emulator-5554".

    What would confirm it

    The prediction that follows from the above: run the same attach with an explicit, resolvable worktree selector — one of the ids from orca worktree list --json rather than active/name:.

    Either way that single run splits the two error codes apart.

    What I did not verify

    No Android SDK or emulator here, so I have not reproduced the pane state or watched the notifications fire. The CLI resolver, the swallow, the ignored _params, and the if (worktreeId) guard are read from source and are solid; the pane's own selector_not_found is the part I deliberately left untraced.

  2. AmethystLiang commented on Aug 11, 2026

    @AmethystLiang
    Contributor

    thanks for reporting. looking into it

  3. kimnamwook1 commented on Aug 11, 2026

    @kimnamwook1
    Author

    Ran the confirmation test from @manuaudio's analysis (same host as the original report, Orca 1.4.179, same booted AVD Medium_Phone / emulator-5554). Outcome A confirmed — and one new finding about list below.

    1. Attach with an explicit, resolvable worktree selector

    $ orca emulator attach Medium_Phone --worktree "id:d83d4d2a-...::/Users/.../techtainment/orca" --focus --json
    {"ok":true,"result":{"attached":true,"info":{"deviceUdid":"emulator-5554","streamUrl":"scrcpy://emulator-5554","wsUrl":"","streamCodec":"h264","backend":"android"}}}

    2. Registration actually happened this time

    Probed the registry via a target-resolving command with --worktree but no --device — resolveTarget only succeeds here if getActiveForWorktree(worktreeId) returns a session, otherwise it throws emulator_no_active:

    $ orca emulator ax --worktree "id:d83d4d2a-..." --json   # no --device
    {"ok":true,"result":{ ...full uiautomator tree from emulator-5554... }}

    So with a resolvable worktreeId, registerActiveEmulator runs and the session is queryable. The registration chain itself is fine.

    3. The pane connects in a git-worktree workspace

    Opened the Mobile Emulator pane (⌘⌥⇧E) in a regular git-worktree workspace on the same host: the pane went "에뮬레이터 연결 중…" → Connected, with a live scrcpy stream of the same booted AVD. So the pane surface works end-to-end when its workspace resolves to a managed worktree — the failure is specific to folder workspaces, exactly as predicted: folder: id → selector unresolvable → worktreeId undefined → registration + renderer notifications skipped.

    4. New finding: emulator list is iOS-only, so it was a red herring

    Even with the attach registered and queryable (step 2), list still reports nothing:

    $ orca emulator list --worktree "id:d83d4d2a-..." --json
    {"ok":true,"result":{"running":false}}

    Reason, at a0a654c3a9 — src/main/emulator/emulator-bridge.ts:64-66:

      async listRunningHelpers(): Promise<unknown> {
        return this.iosBackend.listRunningHelpers()
      }

    emulatorList delegates straight to the iOS backend, so a fully successful, registered Android attach never appears in orca emulator list. The "running": false in my original evidence was therefore not additional proof of the registration failure — it's a separate defect (Android-blind list), stacked on top of the if (worktreeId) guard issue.

    Summary

  4. manuaudio commented on Aug 11, 2026

    @manuaudio
    Contributor

    That's a decisive test, and your step 2 is better evidence than what I proposed — probing with --worktree but no --device so resolveTarget can only succeed via getActiveForWorktree is a much sharper registration probe than anything I suggested. Outcome A confirmed, so the if (worktreeId) guard is the whole of the pane failure.

    Your list finding is right, and it's stronger than you put it

    I verified emulator-bridge.ts:64-66 at 6acd69c516 — exactly as you quote:

      async listRunningHelpers(): Promise<unknown> {
        return this.iosBackend.listRunningHelpers()
      }

    And it isn't only that the bridge delegates to iOS. listRunningHelpers is implemented in exactly one place in the whole emulator tree — backends/ios-emulator-backend.ts:98. The Android backend doesn't define it at all, so there is nothing to delegate to even if the bridge wanted to. orca emulator list cannot report an Android helper under any circumstances.

    That correction lands on me too. My comment said {"running": false} "means the bridge has no running helper registered" — I was right that it wasn't a scoping answer, but wrong about what it was. It isn't a registration report at all; it's a report from a backend that never sees Android. You've replaced my inference with the actual reason.

    Where that leaves the issue

    Three independent defects, now cleanly separated by your run:

    1. folder: selector unresolvable → worktreeId undefined → silent half-attach (attached: true, no registration, no notification). Confirmed by Outcome A. This is the pane bug.
    2. emulator list is Android-blind — independent of folder workspaces entirely, and reproducible on any workspace type with any Android device. Nothing about it involves worktree scoping.
    3. The pane's bare selector_not_found — still the folder: resolution path, still [Bug]: Mobile Source Control retries selector_not_found for folder-workspace git RPCs that were never routed #11153 family, still untraced by me.

    (2) genuinely doesn't belong in this issue: it has a different trigger, a different file, and a different audience — anyone using orca emulator list with Android hits it whether or not they've ever opened a folder workspace. It'd get lost as a sub-finding here. Worth its own report, and your two console blocks plus the :64-66 citation are already a complete one.

    One thing that would sharpen (1) for whoever fixes it

    Your successful attach used --worktree "id:<uuid>::<path>". The failing case is a folder:<id> workspace, where resolveCurrentWorktreeSelector (cli/selectors.ts:46-75) finds no enclosing managed worktree and throws. So the fix has two candidate shapes, and they're not equivalent:

    The second is narrow and stops the silent failure everywhere it occurs, including cases nobody has reported yet. The first is the real fix but is a much bigger surface. Ideally both — but if only one lands, the guard is the one that prevents a future attached: true from lying.

    What I did not verify

    I still have no Android SDK here, so steps 1–3 of your run are your measurements. The emulator-bridge.ts and ios-emulator-backend.ts facts above I checked directly at 6acd69c516.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions