Repository navigation
fix(mobile): agents for workspaces another runtime owns show why - #27196
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
66830e60-3e67-4a26-b182-7a83271d8b7c
📒 Files selected for processing (9)
mobile/src/session/mobile-new-tab-agent-loader.test.tsmobile/src/session/mobile-new-tab-agent-loader.tsmobile/src/session/mobile-session-read-operations.tsmobile/src/session/mobile-session-route-types.tsmobile/src/session/use-mobile-session-attachments.tsmobile/src/session/use-mobile-session-panel-route-actions.tsxsrc/main/preflight/workspace-agent-detection.test.tssrc/main/preflight/workspace-agent-detection.tssrc/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.
| repos.every( | ||
| (candidate) => | ||
| candidate.id !== repoId || | ||
| parseExecutionHostId(candidate.executionHostId)?.kind === 'runtime' | ||
| ) |
There was a problem hiding this comment.
🎯 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.tsRepository: 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 -120Repository: 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 || trueRepository: 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' || trueRepository: 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.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
39b471bf-088e-46f2-825b-06ac1a8f6d18
📒 Files selected for processing (6)
mobile/src/session/mobile-new-tab-agent-loader.test.tsmobile/src/session/mobile-new-tab-agent-loader.tsmobile/src/session/pr-ai-triage-launch.tsmobile/src/session/use-mobile-session-attachments.tssrc/main/preflight/workspace-agent-detection.test.tssrc/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 |
There was a problem hiding this comment.
🗄️ 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 1Repository: 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 1Repository: 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 -120Repository: 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 -40Repository: 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 -120Repository: 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 -60Repository: 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 -40Repository: 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).
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
Mechanism:
src/main/preflight/workspace-agent-detection.ts): whenpreflight.detectAgents/preflight.refreshAgentsis asked about a worktree or folder workspace whose owner is aruntime:host, it now refuses withworkspace_on_other_runtimeinstead of falling back to probing itself. Unknown workspaces keep the old host-default answer.preflight.other-runtime-refusal.v1.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).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.detectAgentsanswers the refusal and never probes this machine. Both tests fail onorigin/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 (onmainit calledpreflight.detectRemoteAgentson 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 viapreflight.detectAgents({ worktreeId })and never probes the first row's SSH target; an older host is not asked at all.pnpm tc, mobilepnpm typecheck, mobilesrc/sessiontests,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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)