Skip to content

fix(agents): refresh remote detection on new launch surfaces - #21659

Merged
nwparker merged 1 commit into
mainfrom
fix/remote-agent-detection-refresh
Sep 19, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/remote-agent-detection-refresh

Conversation

@nwparker

@nwparker nwparker commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​68
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

Orca remembered the agents it saw on a remote host and treated that list as permanent. If you installed a new CLI afterward, opening another launch surface still showed the old list until restarting Orca.

When a new remote launch surface first sees a host, Orca now asks that host for one fresh agent list. Empty lists keep their existing retry behavior, and a mounted surface does not poll repeatedly.

Fixes #20383.

What changed

  • Refresh cached non-empty SSH agent lists once per newly observed launch surface.
  • Refresh cached non-empty orca serve runtime agent lists through the owning runtime.
  • Preserve the existing empty-result retry and in-flight deduplication behavior.

Verification

  • pnpm test src/renderer/src/hooks/useDetectedAgents.test.tsx src/renderer/src/store/slices/detected-agents.test.ts — 34 tests passed.
  • pnpm tc:web — passed.
  • pnpm run check:code-quality:changed — 0 findings across 2 changed files.
  • Pre-commit oxlint, React Doctor, and formatting hooks passed.

Visual proof is not included because this is a cache and host-probe behavior fix; the regression tests exercise the SSH and runtime launch-surface paths directly.

Merge risk

Low. The change is limited to remote agent discovery refresh policy, uses existing host-owned refresh RPCs, and leaves local detection unchanged. No persisted state, wire format, or agent launch behavior changes.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: 867e51e6-f7a7-4748-9c27-232d7b7cd6bd

📥 Commits

Reviewing files that changed from the base of the PR and between c22c442 and d2a8d2b.

📒 Files selected for processing (2)
  • src/renderer/src/hooks/useDetectedAgents.test.tsx
  • src/renderer/src/hooks/useDetectedAgents.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

useDetectedAgents now refreshes a newly observed SSH or runtime target when its cached agent list is non-empty. Targets with empty results still use the existing probe path. Tests verify one refresh per launch surface and confirm that re-rendering does not repeat detection. The empty-result test now re-renders one mounted root.

Priority: ➖ Normal

Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: refreshing remote agent detection on new launch surfaces.
Description check ✅ Passed The description explains the problem, solution, scope, linked issue, verification, and visual-proof rationale. It is mostly complete, although it does not use the template's exact section headings or …
Linked Issues check ✅ Passed For #20383, useDetectedAgents now refreshes a non-empty SSH or runtime cache when a new launch surface first observes the target. Empty caches still use ensure*DetectedAgents. The added SSH and ru…
Out of Scope Changes check ✅ Passed The reviewed changes modify remote agent detection in useDetectedAgents and add focused tests for SSH and runtime launch surfaces. The changes support #20383 directly. No unrelated product behavior,…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

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.

@pullfrog pullfrog 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.

ℹ️ No critical issues — the fix is well-scoped and the new tests genuinely exercise it. One stale test title and an FYI on probe cadence below.

Reviewed changes

  • Non-empty remote cache now refreshes — when a newly observed SSH or runtime target already has a non-empty cached list, useDetectedAgents now calls refreshRemoteDetectedAgents / refreshRuntimeDetectedAgents instead of doing nothing. This is the actual bug from #20383: the previous gate only retried on an empty result, so an agent installed after the first probe stayed invisible.
  • Empty-result retry preserved — empty caches still route through ensureRemoteDetectedAgents / ensureRuntimeDetectedAgents, keeping the once-per-mounted-surface retry and the no-spin guarantee.
  • Refresh reuses existing host-owned RPCs — SSH refresh wraps ensureRemoteDetectedAgents(force:true); runtime refresh uses preflight.refreshAgents with the method_not_found fallback to preflight.detectAgents. A failed refresh preserves the cached list, which is the right behavior for the automatic path.
  • Tests — added SSH and runtime cases that assert exactly one refresh per mount; reworked the runtime "explicit refresh finds no agents" case.

I verified the new tests can fail: restoring the pre-PR detectedIds.length === 0 gate makes all three new/changed cases red, while the head state is green (34 tests across the hook and store slice).

ℹ️ Nitpicks

  • Stale test name — does not re-probe after an explicit refresh finds no agents (src/renderer/src/hooks/useDetectedAgents.test.tsx:352) no longer calls refresh(); it now asserts the automatic refresh path. Rename it to match. While you're there, consider keeping one explicit-refresh() assertion so the "cache becomes empty on the same mounted surface, do not fall through to detect" case stays covered at the hook level — the reopened-surface test only covers the new-mount path.
  • Probe cadence FYI — QuickLaunchAgentMenuItems is rendered inside the dropdown content, so every open of a remote worktree's + menu remounts the hook and now fires one host probe (concurrent in-flight calls still dedupe, and a failure keeps the cached list). This is the intended once-per-surface trade-off and matches the pre-existing empty-host behavior, but a short per-target cooldown would bound SSH/runtime round-trips if rapid open/close becomes hot.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 6abd1ce into main Sep 19, 2026
57 of 59 checks passed
@nwparker
nwparker deleted the fix/remote-agent-detection-refresh branch September 19, 2026 12:12
husseincak added a commit to husseincak/orca that referenced this pull request Sep 19, 2026
Upstream stablyai#21274 split auto-ack into per-surface adapters (terminal and
structured chat). The grid target now carries surfaceKind: 'terminal',
the parked-card BEL check (group-level unread) moves into
acknowledgeViewedAutoAckTarget, and the sessions view branch no longer
sits behind the terminal-view early return.

stablyai#21659 chains .finally on ensureRemoteDetectedAgents; the launch picker
test stubs it with a resolved promise like upstream's own tests.
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.

[Bug]: Agent installed after the first probe never appears on a remote host until the Orca client restarts

1 participant