Skip to content

fix(mobile): agents for workspaces another runtime owns show why - #27196

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/d4-d4-ag2
Oct 10, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/d4-d4-ag2

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​134
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​151 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​109

ELI5

If your phone is paired to computer A, and you open a workspace that actually lives on another Orca server B, the phone used to show A's agents in the new-tab menu, as if they were B's. Now it says "Agents on Another Server — Pair that server directly" instead of showing a wrong list.

What Changed

  • Before: in the new-tab drawer (and "send diff notes to a new agent"), a workspace owned by another Orca server listed the agents installed on the paired computer. Starting one of them was misleading, and if the paired computer had no agents the section was simply empty. When that server's project used SSH, the phone even probed the paired computer's SSH target of the same name.
  • After: the drawer shows one disabled row, "Agents on Another Server", with the hint "Pair that server directly". The AI triage launch shows the full sentence ("This workspace runs on another Orca server. Pair that server directly to see its agents.").

Mechanism:

  • Host side (src/main/preflight/workspace-agent-detection.ts): when preflight.detectAgents / preflight.refreshAgents is asked about a worktree or folder workspace whose owner is a runtime: host, it now refuses with workspace_on_other_runtime instead of falling back to probing itself. Unknown workspaces keep the old host-default answer.
  • The host advertises this with a new capability, preflight.other-runtime-refusal.v1.
  • Phone side (mobile/src/session/mobile-new-tab-agent-loader.ts): it maps that refusal to a typed error. It also recognises the case by itself: when every repo row with that id is owned by another runtime it asks nothing. When rows on several hosts share the repo id and one of them belongs to another runtime, the first row's SSH connection could name the paired computer's own target, so the phone asks a host with the new capability to decide by worktree, and shows the "another server" row on an older host (which cannot be trusted to tell).
  • The drawer gets a new load state, other-runtime, rendered as the row above.

Why

The design for owner routing keeps "no hub": the paired computer does not forward to the other server. Until the phone pairs that server directly, the honest answer is "can't verify from here", never the paired computer's list. Putting the refusal on the host fixes every client (including older phones, which now show "Agent Presets Unavailable" instead of a wrong list); the phone-side check covers older hosts. Delegating detection through the paired computer was rejected: it needs loop prevention and a trust model for which servers a phone may reach through another, which the design defers.

Linked Issue

Part of #13752 (the interim from the design: show why, rather than list the wrong host's agents). Listing the other server's agents needs the phone to pair that server directly, so the issue stays open.

Visual Proof

N/A — one new disabled text row in an existing menu, using the same row component and icon as "Agent Presets Unavailable". No local Electron/device run on this load-capped machine; behavior is covered by tests.

Testing

  • src/main/preflight/workspace-agent-detection.test.ts: runtime-owned worktree (including one with a nested SSH connection id) and runtime-owned folder are refused; preflight.detectAgents answers the refusal and never probes this machine. Both tests fail on origin/main (the resolver returned the host default and the local probe ran).

  • mobile/src/session/mobile-new-tab-agent-loader.test.ts: an unambiguous runtime-owned repo raises the typed error without any detection request (on main it called preflight.detectRemoteAgents on the paired host with the other server's SSH id); a shared repo id (SSH row first, runtime row second) is decided by a refusing host via preflight.detectAgents({ worktreeId }) and never probes the first row's SSH target; an older host is not asked at all.

  • pnpm tc, mobile pnpm typecheck, mobile src/session tests, oxlint, check:code-quality:changed.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

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

Mixed versions: no new RPC method or field, one additive capability string. A new host's refusal reaches older phones as the generic "Agent Presets Unavailable" row. A new phone on an older host shows the "another server" row only when a repo row for that id belongs to another runtime; local and SSH-only repos route exactly as before. SSH and local workspaces, WSL project runtimes and folder workspaces resolve exactly as before.

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)

The paired host no longer lists its own agents for a workspace another Orca
server owns: preflight.detectAgents refuses with workspace_on_other_runtime,
and the phone shows 'Agents on Another Server - Pair that server directly'.
The phone also recognises an unambiguous runtime-owned repo row itself, so an
older host is never asked.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f271f66-44c8-4031-a017-ae5adeb60f39


📥 Commits

Reviewing files that changed from the base of the PR and between 35da79a and 3ed8aa8.



📒 Files selected for processing (7)
  • mobile/src/session/mobile-new-tab-agent-loader.test.ts
  • mobile/src/session/mobile-new-tab-agent-loader.ts
  • mobile/src/session/pr-ai-triage-launch.ts
  • mobile/src/session/use-mobile-session-attachments.ts
  • src/main/preflight/workspace-agent-detection.test.ts
  • src/main/preflight/workspace-agent-detection.ts
  • src/shared/protocol-version.ts


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds a protocol capability and refusal result for workspaces owned by another runtime. Preflight detection returns that refusal for runtime-owned worktrees and folders. Mobile agent loading checks repository ownership and translates the refusal into a typed error. The mobile attachment hook records a distinct other-runtime state, and agent actions show a disabled row for that state.



Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 3ed8a

Runtime-owned workspaces receive a direct-pairing notice instead of showing agents from another host, and supported shared-repository cases resolve detection by worktree. No concrete merge blocker remains; run the project’s normal checks before merging.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the mobile fix for workspaces owned by another runtime and explains the user-facing behavior. Its wording is slightly awkward but remains specific and relevant.
Description check Passed The description is complete and on-topic. It covers the user impact, implementation, rationale, linked issue, visual proof, testing, compatibility considerations, and checklist status. It also clearly…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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

Comment @coderabbitai help to get the list of available commands.

@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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66830e60-3e67-4a26-b182-7a83271d8b7c
📥 Commits

Reviewing files that changed from the base of the PR and between 180e8c1 and 66c6dcb.

📒 Files selected for processing (9)
  • mobile/src/session/mobile-new-tab-agent-loader.test.ts
  • mobile/src/session/mobile-new-tab-agent-loader.ts
  • mobile/src/session/mobile-session-read-operations.ts
  • mobile/src/session/mobile-session-route-types.ts
  • mobile/src/session/use-mobile-session-attachments.ts
  • mobile/src/session/use-mobile-session-panel-route-actions.tsx
  • src/main/preflight/workspace-agent-detection.test.ts
  • src/main/preflight/workspace-agent-detection.ts
  • src/shared/agent-detection-refusal.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.

Comment on lines +99 to +103
repos.every(
(candidate) =>
candidate.id !== repoId ||
parseExecutionHostId(candidate.executionHostId)?.kind === 'runtime'
)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,175p' mobile/src/session/mobile-new-tab-agent-loader.ts
sed -n '50,145p' mobile/src/session/mobile-new-tab-agent-loader.test.ts
rg -n 'detectRemoteAgents|detectAgents|executionHostId|connectionId' src/main/runtime/rpc/methods/preflight.ts mobile/src/session/mobile-session-read-operations.ts

Repository: stablyai/orca

Length of output: 9343


🏁 Script executed:

set -e
printf '%s\n' '--- preflight RPC ---'
nl -ba src/main/runtime/rpc/methods/preflight.ts | sed -n '1,90p'
printf '%s\n' '--- resolveAgentDetectionHost definitions/usages ---'
rg -n -F --glob '*.ts' -- 'resolveAgentDetectionHost' src mobile || true
printf '%s\n' '--- MobileRuntimeRepoSummary and repo.list definitions/usages ---'
rg -n -F --glob '*.ts' -- 'MobileRuntimeRepoSummary' mobile src || true
rg -n -F --glob '*.ts' -- 'name: '\''repo.list'\''' src mobile || true
printf '%s\n' '--- executionHostId references ---'
rg -n -F --glob '*.ts' -- 'executionHostId' src/main mobile/src/session | head -120

Repository: stablyai/orca

Length of output: 20354


🏁 Script executed:

set -e
printf '%s\n' '--- runtime resolver ---'
nl -ba src/main/runtime/orca-runtime-get-orchestration-dispatch-authority.ts | sed -n '235,295p'
printf '%s\n' '--- repo RPC ---'
nl -ba src/main/runtime/rpc/methods/repo.ts | sed -n '1,110p'
printf '%s\n' '--- mobile repo summary contract ---'
nl -ba mobile/src/session/mobile-session-read-operations.ts | sed -n '25,110p'
printf '%s\n' '--- preflight parameter contract ---'
nl -ba src/shared/rpc-contract/preflight-params.ts | sed -n '1,110p'
printf '%s\n' '--- repo list / execution-host row construction ---'
nl -ba src/main/workspace-space-repo-scan.ts | sed -n '125,205p'
nl -ba src/main/workspace-space-repo-scan.ts | sed -n '235,290p'

Repository: stablyai/orca

Length of output: 17085


🏁 Script executed:

set -e
printf '%s\n' '--- listRepos declarations and callers ---'
rg -n -F --glob '*.ts' -- 'listRepos(' src/main mobile/src || true
printf '%s\n' '--- Repo type and connection/execution host helpers ---'
rg -n -F --glob '*.ts' -- 'type Repo' src/main src/shared | head -40
rg -n -F --glob '*.ts' -- 'interface Repo' src/main src/shared | head -40
rg -n -F --glob '*.ts' -- 'getRepoExecutionHostId' src/main src/shared || true
printf '%s\n' '--- client projection ---'
rg -n -F --glob '*.ts' -- 'projectRepoVisibilityForClient' src/main || true
printf '%s\n' '--- execution-host parsing ---'
rg -n -F --glob '*.ts' -- 'parseExecutionHostId' src/shared src/main || true

Repository: stablyai/orca

Length of output: 41320


🏁 Script executed:

set -e
printf '%s\n' '--- Repo type ---'
nl -ba src/shared/repo-types.ts | sed -n '45,105p'
printf '%s\n' '--- listRepos implementation ---'
nl -ba src/main/runtime/orca-runtime-get-worktree-ps.ts | sed -n '125,170p'
printf '%s\n' '--- repo visibility projection ---'
nl -ba src/main/runtime/rpc/repo-visibility-projection.ts | sed -n '1,130p'
printf '%s\n' '--- execution host helpers ---'
nl -ba src/shared/execution-host.ts | sed -n '175,245p'
printf '%s\n' '--- runtime repository registration ---'
nl -ba src/main/runtime/runtime-repository-registration-controller.ts | sed -n '1,100p'
printf '%s\n' '--- duplicate/shared repo tests ---'
rg -n -F --glob '*.test.ts' -- 'runtime:env-b' src/main mobile/src/session || true
rg -n -F --glob '*.test.ts' -- 'connectionId:' src/main mobile/src/session | grep -E 'runtime|env|repo-1' || true

Repository: stablyai/orca

Length of output: 42266


Use workspace-aware detection for shared repository IDs.

When a runtime row with a non-empty connectionId precedes a local row with the same repository ID, the every predicate is false, but find still selects the runtime row. The loader then calls preflight.detectRemoteAgents, which always probes the selected SSH target instead of resolving the worktree host. This can show agents from the wrong machine or fail to detect the workspace agents.

Use worktreeId whenever multiple rows share the repository ID. Keep the connectionId path for an unambiguous row.

Suggested fix
--- "a/mobile/src/session/mobile-new-tab-agent-loader.ts"
+++ "b/mobile/src/session/mobile-new-tab-agent-loader.ts"
@@ -90,21 +90,22 @@
   // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: Preserve the established response shape at this boundary.
   const repos = (newTabRepoListRead.interpret(repoResponse) as MobileRuntimeRepoSummary[]) ?? []
   const repoId = getRepoIdFromMobileWorktreeId(worktreeId)
-  const repo = repos.find((candidate) => candidate.id === repoId)
+  const matchingRepos = repos.filter((candidate) => candidate.id === repoId)
+  const repo = matchingRepos[0]
   if (!repo) {
     throw new Error('worktree_repo_not_found')
   }
   // Why every row: rows on several hosts can share a repo id, and then only the host can tell.
   if (
-    repos.every(
+    matchingRepos.every(
       (candidate) =>
-        candidate.id !== repoId ||
         parseExecutionHostId(candidate.executionHostId)?.kind === 'runtime'
     )
   ) {
     throw new MobileWorkspaceOnOtherRuntimeError()
   }
-  const connectionId = repo.connectionId?.trim() || null
+  const connectionId =
+    matchingRepos.length === 1 ? repo.connectionId?.trim() || null : null
   return connectionId
     ? {
         reply: await preflightDetectRemoteAgentsRead.request(client, { connectionId }),

…fusing host

Rows on several hosts can share a repo id, and the first row's SSH connection
could name the paired host's own target. When any row is runtime-owned the phone
now asks a host that advertises preflight.other-runtime-refusal.v1 to decide by
worktree, and shows the other-server row on an older host.

@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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 39b471bf-088e-46f2-825b-06ac1a8f6d18
📥 Commits

Reviewing files that changed from the base of the PR and between 66c6dcb and 35da79a.

📒 Files selected for processing (6)
  • mobile/src/session/mobile-new-tab-agent-loader.test.ts
  • mobile/src/session/mobile-new-tab-agent-loader.ts
  • mobile/src/session/pr-ai-triage-launch.ts
  • mobile/src/session/use-mobile-session-attachments.ts
  • src/main/preflight/workspace-agent-detection.test.ts
  • src/shared/protocol-version.ts

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

return {
reply: await preflightDetectAgentsRead.request(client, { worktreeId }),
interpret: preflightDetectAgentsRead.interpret,
repo

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -u
printf '%s\n' '--- diff ---'
git diff --unified=80 180e8c186f779bc8bfbddc93391855e03eeee006 35da79a8871073fbeb20d2ef40124bf9cef77d0d -- mobile/src/session/mobile-new-tab-agent-loader.ts mobile/src/session/pr-ai-triage-launch.ts
printf '%s\n' '--- loader references ---'
rg -n -F --glob '*.ts' -- 'loadMobileAgentLaunchContext' mobile/src || test "$?" -eq 1
rg -n -F --glob '*.ts' -- 'resolveMobileSourceControlLaunchAgent' mobile/src || test "$?" -eq 1
printf '%s\n' '--- consumer definitions and callers ---'
rg -n -F --glob '*.ts' -- 'function resolveMobileSourceControlLaunchAgent' mobile/src || test "$?" -eq 1
rg -n -F --glob '*.ts' -- 'const resolveMobileSourceControlLaunchAgent' mobile/src || test "$?" -eq 1
rg -n -F --glob '*.ts' -- 'context.repo' mobile/src/session mobile/src || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 14047


🏁 Script executed:

set -u
printf '%s\n' '--- launch consumer ---'
nl -ba mobile/src/session/mobile-source-control-launch-agent.ts | sed -n '1,120p'
printf '%s\n' '--- readSavedRecipe definition and uses ---'
rg -n -F --glob '*.ts' -- 'function readSavedRecipe' mobile src || test "$?" -eq 1
rg -n -F --glob '*.ts' -- 'readSavedRecipe(' mobile src || test "$?" -eq 1
printf '%s\n' '--- repository summary type and resolver-related tests ---'
rg -n -F --glob '*.ts' -- 'type MobileRuntimeRepoSummary' mobile src || test "$?" -eq 1
rg -n -F --glob '*.{test,spec}.ts' -- 'hostRefusesOtherRuntime' mobile src || test "$?" -eq 1
rg -n -F --glob '*.{test,spec}.ts' -- 'MobileWorkspaceOnOtherRuntimeError' mobile src || test "$?" -eq 1
rg -n -F --glob '*.{test,spec}.ts' -- 'resolveMobileSourceControlLaunchAgent' mobile src || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 6269


🏁 Script executed:

set -u
printf '%s\n' '--- mobile read operation declarations ---'
nl -ba mobile/src/session/mobile-session-read-operations.ts | sed -n '1,100p'
printf '%s\n' '--- focused loader tests ---'
nl -ba mobile/src/session/mobile-new-tab-agent-loader.test.ts | sed -n '1,190p'
printf '%s\n' '--- preflight worktreeId bindings ---'
rg -n -F --glob '*.ts' -- 'preflightDetectAgents' src mobile | head -80
rg -n -F --glob '*.ts' -- 'worktreeId' src | grep -E 'preflight|detectAgents|other-runtime' | head -120

Repository: stablyai/orca

Length of output: 23144


🏁 Script executed:

set -u
printf '%s\n' '--- runtime repo list schema ---'
rg -n -F --glob '*.ts' -- 'runtimeRepoListSchema' src mobile
printf '%s\n' '--- schema and repo-list response excerpts ---'
rg -n -F --glob '*.ts' -- 'executionHostId' src mobile | head -100
rg -n -F --glob '*.ts' -- 'runtime-repo-list' src mobile | head -40

Repository: stablyai/orca

Length of output: 13136


🏁 Script executed:

nl -ba mobile/src/session/session-read-reply-schema.ts | sed -n '25,48p'

Repository: stablyai/orca

Length of output: 1499


🏁 Script executed:

set -u
printf '%s\n' '--- repo.list handlers ---'
rg -n -F --glob '*.ts' -- 'repo.list' src mobile | head -120
rg -n -F --glob '*.ts' -- "method === 'repo.list'" src mobile | head -40
rg -n -F --glob '*.ts' -- "name: 'repo.list'" src mobile | head -40
printf '%s\n' '--- source-control override projections near repo responses ---'
rg -n -F --glob '*.ts' -- 'sourceControlAi' src/main src/shared | head -120

Repository: stablyai/orca

Length of output: 33038


🏁 Script executed:

set -u
printf '%s\n' '--- repo RPC handler ---'
nl -ba src/main/runtime/rpc/methods/repo.ts | sed -n '1,130p'
printf '%s\n' '--- repo projection references ---'
nl -ba src/shared/project-host-setup-projection.ts | sed -n '270,315p'
rg -n -F --glob '*.ts' -- 'listRepos' src/main src/shared | head -60
rg -n -F --glob '*.ts' -- 'getRepos' src/main/runtime src/main | head -60

Repository: stablyai/orca

Length of output: 18020


🏁 Script executed:

set -u
printf '%s\n' '--- visibility projection ---'
rg -n -F --glob '*.ts' -- 'function projectRepoVisibilityForClient' src/main
rg -n -F --glob '*.ts' -- 'export function projectRepoVisibilityForClient' src/main
rg -n -F --glob '*.ts' -- 'projectRepoVisibilityForClient' src/main/runtime src/main | head -40

Repository: stablyai/orca

Length of output: 2579


🏁 Script executed:

nl -ba src/main/runtime/rpc/repo-visibility-projection.ts | sed -n '1,50p'

Repository: stablyai/orca

Length of output: 1635


Use the host-resolved repository for launch configuration.

When matching rows share an ID and the runtime row is first, the loader returns the first row even after host resolution receives the worktree ID. resolveMobileSourceControlLaunchAgent reads context.repo.sourceControlAi for the saved recipe. This can apply the wrong repository-specific launch configuration.

Return the host-resolved repository, or prevent the first row from being used as its substitute.

Move the refusal code beside its capability in protocol-version, read the
capability in the loader, and test the runtime: prefix directly: importing
execution-host into the loader split a web bundle chunk (129 > 128 assets).
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.

1 participant