Repository navigation
fix(agents): one agent inventory per host and execution context - #27225
Conversation
Launch surfaces that pick an agent for a workspace now read and load the agent list through one helper keyed by the workspace's own host, instead of each re-deriving "SSH connection id, else this computer". A paired server's workspace (including one on the server's own SSH target) reads the server's list; this client's own list and its SSH map are never consulted for it. - Source Control AI actions (Resolve with AI, recovery, Fix checks), the new-agent-tab shortcut, Explain commit, session continuation and the checks panel use readDetectedAgentsForWorktree / ensureDetectedAgentsForWorktree. - An old paired server without workspace-scoped detection probes its own SSH target with preflight.detectRemoteAgents instead of answering its default list. - A disconnected SSH host rejects detection instead of answering [], so it is no longer cached as "no agents installed"; Quick Launch says the host is unreachable. - On Windows, an active workspace on another host no longer drops this machine's agent context to the Windows host; it uses the global runtime default.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to A saved Fix Checks agent installed only on a paired runtime may be missed in this fallback path. The impact is limited to that workflow, so merging with owner awareness and follow-up is reasonable. 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:
7ae75129-57ae-4759-88cb-d8fd73e84e07
📒 Files selected for processing (24)
src/main/ipc/preflight-remote-ssh.test.tssrc/main/preflight/agent-detection.tssrc/renderer/src/components/right-sidebar/SourceControlAgentActionDialog.test.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-comment-resolution.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsxsrc/renderer/src/components/right-sidebar/source-control/ai/controller-types.tssrc/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.tssrc/renderer/src/components/right-sidebar/source-control/sync/use-git-history-commit-actions.tssrc/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.tssrc/renderer/src/components/tab-bar/QuickLaunchButton.test.tssrc/renderer/src/components/tab-bar/QuickLaunchButton.tsxsrc/renderer/src/components/terminal-agent-tab-shortcut.test.tssrc/renderer/src/components/terminal-agent-tab-shortcut.tssrc/renderer/src/hooks/useAgentDetectionTarget.tssrc/renderer/src/lib/agent-detection-target-inventory.test.tssrc/renderer/src/lib/agent-detection-target-inventory.tssrc/renderer/src/lib/fix-checks-agent-launch.test.tssrc/renderer/src/lib/fix-checks-agent-launch.tssrc/renderer/src/lib/launch-agent-session-continuation.test.tssrc/renderer/src/lib/launch-agent-session-continuation.tssrc/renderer/src/lib/local-preflight-context.test.tssrc/renderer/src/lib/local-preflight-context.tssrc/renderer/src/store/slices/runtime-detected-agents.test.tssrc/renderer/src/store/slices/runtime-detected-agents.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| ): Promise<TuiAgent | null> { | ||
| const connectionId = getConnectionId(worktreeId) ?? repoConnectionId ?? null | ||
| const detectedAgents = await detectAgentsForConnection(connectionId) | ||
| const detectedAgents = await ensureDetectedAgentsForWorktree(useAppStore.getState(), worktreeId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C4 'detectionTargetForRepo|detectionTargetForWorktree|executionHostId' src/renderer/src/lib/agent-detection-target-inventory.ts
rg -nP -C3 'resolveSavedAgentOverride|detectAgentsForConnection' src/renderer/src/lib/fix-checks-agent-launch.tsRepository: stablyai/orca
Length of output: 1933
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- fix-checks-agent-launch.ts ---'
nl -ba src/renderer/src/lib/fix-checks-agent-launch.ts | sed -n '1,280p'
printf '%s\n' '--- agent-detection-target-inventory.ts ---'
nl -ba src/renderer/src/lib/agent-detection-target-inventory.ts | sed -n '1,180p'
printf '%s\n' '--- changed hunks ---'
git diff --unified=30 fff0bb0d0650195e3ffa8bb638719f37111b3130 bed447c8ddc2b0f82bc0dd77a2aba3f8db8c8f28 -- src/renderer/src/lib/fix-checks-agent-launch.ts src/renderer/src/lib/agent-detection-target-inventory.tsRepository: stablyai/orca
Length of output: 25076
🏁 Script executed:
#!/bin/bash
set -e
nl -ba src/renderer/src/lib/fix-checks-agent-launch.ts | sed -n '1,280p'
nl -ba src/renderer/src/lib/agent-detection-target-inventory.ts | sed -n '1,180p'
git diff --unified=30 fff0bb0d0650195e3ffa8bb638719f37111b3130 bed447c8ddc2b0f82bc0dd77a2aba3f8db8c8f28 -- src/renderer/src/lib/fix-checks-agent-launch.ts src/renderer/src/lib/agent-detection-target-inventory.tsRepository: stablyai/orca
Length of output: 24975
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- detection target ownership ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'getAgentDetectionTargetKeyForWorktree' src/renderer/src
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'executionHostId' src/renderer/src | head -80
printf '%s\n' '--- target resolver ---'
target=$(rg -l -F --glob '*.ts' --glob '*.tsx' -- 'function getAgentDetectionTargetKeyForWorktree' src/renderer/src | head -1)
if [ -n "$target" ]; then
nl -ba "$target" | sed -n '1,260p'
fi
printf '%s\n' '--- direct work-item launch ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -- 'launchWorkItemDirect' src/renderer/srcRepository: stablyai/orca
Length of output: 23440
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- mixed repo ownership fixture ---'
nl -ba src/renderer/src/store/adopt-from-endpoint.test.ts | sed -n '88,106p'
printf '%s\n' '--- direct launch implementation ---'
nl -ba src/renderer/src/lib/launch-work-item-direct.ts | sed -n '1,180p'
printf '%s\n' '--- fix-checks tests for no-worktree behavior ---'
nl -ba src/renderer/src/lib/fix-checks-agent-launch.test.ts | sed -n '130,230p'Repository: stablyai/orca
Length of output: 14414
Resolve saved-agent detection from the repository’s owning host.
When no existing worktree is available, startFixChecksAgent passes repo?.connectionId to resolveSavedAgentOverride. detectAgentsForConnection treats every connection ID as an SSH target. A repository can instead use executionHostId: 'runtime:env-a' with connectionId: 'nested', so the check can reject an agent installed on the runtime host before launchWorkItemDirect creates the workspace. Resolve the detection target from the repository’s owning execution host, while preserving SSH and local behavior.
ELI5
Orca asks "which AI agents are installed?" before it starts one. For a workspace that lives on another machine, it has to ask that machine. Several buttons asked the wrong one: this computer, or an SSH connection this computer does not have. Now every one of them asks the machine the workspace actually runs on, and a machine that cannot be reached says so instead of claiming nothing is installed.
What Changed
Before → after, as a user sees it:
+menu worked ([Bug]: New-agent-tab shortcut says "No agent CLI detected" on a paired host's SSH workspace #25804). It now uses the same list as the+menu. If the paired server is too old to look inside its own workspaces, Orca now asks it to check that SSH host directly instead of showing the server's own list or an "update server" notice.Mechanism:
readDetectedAgentsForWorktree/ensureDetectedAgentsForWorktree(inlib/agent-detection-target-inventory.ts), resolves a workspace to its owning host with the existinggetAgentDetectionTargetKeyForWorktree(the one Quick Launch and the tab bar already use) and reads or loads that host's list. Source Control AI actions (Resolve with AI, recovery, Fix checks), the new-agent-tab shortcut, Explain commit, session continuation and the checks panel call it instead of each re-deriving "SSH connection id, else local". An owner that cannot be resolved lists nothing; it never falls back to this computer.preflight.detectRemoteAgents({ connectionId })on that host for its own SSH target. No new RPC and no wire change.detectRemoteAgentson the main process now rejects when the SSH connection is missing or disposed, instead of returning[].[]was cached as a real empty list. A rejection leaves the list unloaded, which the existingdetectionFailedflag already reports, and Quick Launch now shows a separate message for it.getLocalAgentPreflightContexttreats "the active workspace is on another host" like "no project is active". That way, this machine's agent detection uses the global Windows runtime default instead of falling through to the Windows host.Why
Each launch surface had its own copy of the "which host?" branch, and the copies disagreed. Some never checked for a paired server; others read the server's SSH connection id as if it belonged to this client. Fixing each copy where it was would leave the next new surface free to get it wrong again. The design (D4 rev 3, AG1) asks for one agent list per host and execution context, read through one resolver. That resolver already existed for Quick Launch, so this reuses it rather than adding a parallel one.
For an unreachable host, the design rule is that a host we could not reach is "unverifiable", never "empty". Returning an error from the probe is the smallest change that keeps it out of the cache. Old desktop clients, mobile ("or-skip" reads) and web (catches to
[]) already handle a failed probe.Not in this PR: the new-workspace composer still picks its list by repo connection. A paired server's SSH project there belongs to the "create on a server's SSH project" slice (D4-V4b), which is waiting on an open decision. #21037 and #22009 (listed as "verify") are not addressed here.
Linked Issue
Fixes #21429
Fixes #25804
Fixes #25523
Fixes #18837
Visual Proof
N/A. The only visible change is one line of menu copy ("Can’t reach this workspace’s host to list its agents"), covered by a render test. Everything else changes which host is asked, not how anything looks. The machine is load-capped, so no Electron run.
Testing
Each acceptance test below was run against
origin/mainsource first and failed there (11 failures, plus the dialog test), then passed with this change:SourceControlAgentActionDialog.test.tsx: a paired server's workspace auto-starts with the server's agent; this client's own list is not consulted (Resolve with AI (and other Source Control AI actions) never detect agents on paired Remote Orca Server workspaces #21429).terminal-agent-tab-shortcut.test.ts: the shortcut picks the default agent from a paired server's SSH workspace list ([Bug]: New-agent-tab shortcut says "No agent CLI detected" on a paired host's SSH workspace #25804).runtime-detected-agents.test.ts: on an old Windows paired server, both detect and refresh go throughpreflight.detectRemoteAgentsfor the server's SSH target ([Bug]: New-agent-tab shortcut says "No agent CLI detected" on a paired host's SSH workspace #25804).preflight-remote-ssh.test.ts: a missing or disposed SSH connection rejects instead of resolving[]([Bug]: Quick-launch says "No agents detected" when the SSH or runtime host is simply unreachable #25523).QuickLaunchButton.test.ts: a failed probe shows the unreachable copy, not "No agents detected".local-preflight-context.test.ts: with an SSH project active on Windows and a WSL default, this machine's context is the same one used with no project open ([Bug]: Usage refresh in an SSH workspace overwrites AI Agent visibility with Windows-side detection results #18837).agent-detection-target-inventory.test.ts: paired-server SSH, local (keeps its own project runtime), direct SSH, and an unresolved owner that probes nothing.pnpm tc, oxlint,check:code-quality:changedand the owner-routing ratchet pass. 112 related test files (1211 tests) pass.AI Disclosure
Review
Agent skill upstream boundary
Notes
preflight.detectRemoteAgentsfor its own SSH workspaces. An old client with a new desktop host is unaffected, becausepreflight:detectRemoteAgentsIPC ships with the renderer. Runtime RPC callers that hit a disconnected SSH workspace on a new host now get an error instead of[]; desktop and mobile already treat that as "not loaded" or skip it, and web's preload catches it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)