Skip to content

fix(agents): one agent inventory per host and execution context - #27225

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/d4-d4-ag1
Oct 10, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/d4-d4-ag1

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​210 $\color{#cf222e}{\Huge{\mathbf{−}}}$​45 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​165
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​155 $\color{#cf222e}{\Huge{\mathbf{−}}}$​93 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62

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:

Mechanism:

  • One helper, readDetectedAgentsForWorktree / ensureDetectedAgentsForWorktree (in lib/agent-detection-target-inventory.ts), resolves a workspace to its owning host with the existing getAgentDetectionTargetKeyForWorktree (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.
  • The paired-server detection slice now takes an optional nested SSH target. If the host does not support workspace-scoped detection, it calls the long-standing preflight.detectRemoteAgents({ connectionId }) on that host for its own SSH target. No new RPC and no wire change.
  • detectRemoteAgents on 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 existing detectionFailed flag already reports, and Quick Launch now shows a separate message for it.
  • getLocalAgentPreflightContext treats "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/main source first and failed there (11 failures, plus the dialog test), then passed with this change:

pnpm tc, oxlint, check:code-quality:changed and the owner-routing ratchet pass. 112 related test files (1211 tests) pass.

  • 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

  • SSH: a disconnected host is reported as unreachable, never as empty, and is never replaced by a local probe. A paired server's SSH workspace is always asked through that server.
  • Mixed versions: new client with an old server uses the server's existing preflight.detectRemoteAgents for its own SSH workspaces. An old client with a new desktop host is unaffected, because preflight:detectRemoteAgents IPC 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.
  • Windows/WSL: covered by the local-context test. Folder workspaces keep the same behavior: they resolve through the same owner helper, and the local-context change applies only to repo-backed active workspaces.

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)

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.
@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: f40dff05-adae-4894-b65e-3ae2c4926eb0

📥 Commits

Reviewing files that changed from the base of the PR and between bed447c and 4aafa97.


📒 Files selected for processing (1)
  • src/renderer/src/i18n/locales/en.json

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



📝 Walkthrough

Walkthrough

The change adds worktree-based agent inventory helpers and uses them in source control actions, launch flows, and terminal shortcuts. Runtime detection can route to an SSH target for a runtime-hosted worktree. Remote SSH detection now rejects when its host is unavailable, and quick launch distinguishes detection failure from an empty agent list. Windows local preflight context also accounts for an active workspace on another host.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 4aafa

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 24 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: centralizing agent inventory by host and execution context.
Description check Passed The description is complete and follows the required template. It explains the user impact, implementation, rationale, linked issues, testing, visual proof, scope, and compatibility considerations.
Linked Issues check Passed The PR meets the coding requirements for all four active linked issues. For #21429, Source Control and related launch flows use ensureDetectedAgentsForWorktree, which resolves the workspace owner an…
Out of Scope Changes check Passed The changes remain within the linked issue scope. The shared inventory resolver, updated Source Control, recovery, continuation, Explain commit, and checks flows enforce one owner-specific agent list.…

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 24 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
  • 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: 7ae75129-57ae-4759-88cb-d8fd73e84e07
📥 Commits

Reviewing files that changed from the base of the PR and between fff0bb0 and bed447c.

📒 Files selected for processing (24)
  • src/main/ipc/preflight-remote-ssh.test.ts
  • src/main/preflight/agent-detection.ts
  • src/renderer/src/components/right-sidebar/SourceControlAgentActionDialog.test.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-comment-resolution.tsx
  • src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-controller-state.tsx
  • src/renderer/src/components/right-sidebar/source-control/ai/controller-types.ts
  • src/renderer/src/components/right-sidebar/source-control/ai/recovery-launch.ts
  • src/renderer/src/components/right-sidebar/source-control/sync/use-git-history-commit-actions.ts
  • src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.test.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/components/terminal-agent-tab-shortcut.test.ts
  • src/renderer/src/components/terminal-agent-tab-shortcut.ts
  • src/renderer/src/hooks/useAgentDetectionTarget.ts
  • src/renderer/src/lib/agent-detection-target-inventory.test.ts
  • src/renderer/src/lib/agent-detection-target-inventory.ts
  • src/renderer/src/lib/fix-checks-agent-launch.test.ts
  • src/renderer/src/lib/fix-checks-agent-launch.ts
  • src/renderer/src/lib/launch-agent-session-continuation.test.ts
  • src/renderer/src/lib/launch-agent-session-continuation.ts
  • src/renderer/src/lib/local-preflight-context.test.ts
  • src/renderer/src/lib/local-preflight-context.ts
  • src/renderer/src/store/slices/runtime-detected-agents.test.ts
  • src/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)

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 | 🟡 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.ts

Repository: 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.ts

Repository: 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.ts

Repository: 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/src

Repository: 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.

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

Labels

None yet

Projects

None yet

1 participant