Repository navigation
Detect agents in the serve user's package-manager bins; don't pin empty remote-detect results - #6029
Conversation
…ty remote-detect results Two defects prevent the desktop client from detecting agents installed on a remote `orca serve`: D1 (src/relay/relay-command-env.ts): the relay probes agents with a login shell (`/bin/sh -lc`), which sources ~/.profile but not the interactive ~/.bashrc that real PTY sessions source. Per-user package-manager bins added to PATH only in ~/.bashrc are therefore invisible to detection. Resolve the serve user's package-manager bins from $HOME (.local/bin, .npm-global/bin, .cargo/bin, .bun/bin, go/bin, .deno/bin, .local/share/pnpm), honor npm_config_prefix, append to the POSIX fallback set, dedupe against inherited PATH; win32 unchanged. D2 (src/renderer/src/store/slices/detected-agents.ts): an empty detection result ([], truthy in JS) was pinned by the `if (existing)` short-circuit, so detection never retried after the server env was fixed. Changed to `if (existing?.length)`; in-flight dedup still prevents re-detect storms; failures stay uncached. No new transport, no PowerShell/bash bridge. D1 and D2 are independent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit e63fd39 on Jun 22, 2026 2:24am UTC. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughTwo independent changes improve agent detection and relay command environment setup. First, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
…pin bug The D2 fix guarded only ensureRemoteDetectedAgents (the SSH path). The desktop client's headline scenario — pairing to a remote `orca serve` — routes through ensureRuntimeDetectedAgents (kind: 'runtime'), which had the identical bug: an empty detection result ([], truthy in JS) was pinned by the `if (existing)` short-circuit, so a later install / PATH fix was never picked up without a reconnect. Change the runtime guard to `if (existing?.length)`, mirroring the remote path. In-flight dedup still collapses concurrent re-detects; failed requests stay uncached. Add a runtime regression test proving detection re-runs after an empty result (fails on the pre-fix guard). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extend the existing npm_config_prefix precedence to cargo, bun, deno, go, and pnpm so relocated installs (CARGO_HOME, BUN_INSTALL, DENO_INSTALL, GOBIN/GOPATH, PNPM_HOME/XDG_DATA_HOME) are detected, falling back to the $HOME defaults. Mirrors the remote-node probe's NVM_DIR handling (stablyai#6037). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This PR has both a direct precedent and a companion already in
If useful, I can align the bin resolution here to #6037's structure and add a clean-room Debian + Fedora container matrix to match the bar those PRs set. (@brennanb2025 — you're the assigned reviewer; flagging the #6037 / #5842 links purely for context.) |
|
Pushed an alignment commit (
This mirrors how the remote-node probe honors |
Co-authored-by: Orca <help@stably.ai>
…all-bins' into fix/relay-detect-user-install-bins # Conflicts: # src/relay/relay-command-env.test.ts # src/relay/relay-command-env.ts
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks, this fixes the right remote detection path.\n\nI added a maintainer follow-up before landing:\n- covered relocation env vars plus common macOS/Linux/Windows user package-manager bins in the relay PATH fallback\n- made hook-owned remote/runtime launch surfaces retry a cached empty result once when reopened, without creating a same-surface detection loop\n- added regression tests for SSH/runtime empty-result retries and the additional platform PATH fallbacks\n\nValidated with targeted tests, full typecheck/lint, and Electron dev runtime checks.
…ty remote-detect results (stablyai#6029) * Detect agents in the serve user's package-manager bins; don't pin empty remote-detect results Two defects prevent the desktop client from detecting agents installed on a remote `orca serve`: D1 (src/relay/relay-command-env.ts): the relay probes agents with a login shell (`/bin/sh -lc`), which sources ~/.profile but not the interactive ~/.bashrc that real PTY sessions source. Per-user package-manager bins added to PATH only in ~/.bashrc are therefore invisible to detection. Resolve the serve user's package-manager bins from $HOME (.local/bin, .npm-global/bin, .cargo/bin, .bun/bin, go/bin, .deno/bin, .local/share/pnpm), honor npm_config_prefix, append to the POSIX fallback set, dedupe against inherited PATH; win32 unchanged. D2 (src/renderer/src/store/slices/detected-agents.ts): an empty detection result ([], truthy in JS) was pinned by the `if (existing)` short-circuit, so detection never retried after the server env was fixed. Changed to `if (existing?.length)`; in-flight dedup still prevents re-detect storms; failures stay uncached. No new transport, no PowerShell/bash bridge. D1 and D2 are independent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Also patch the runtime (orca serve) detection path against the empty-pin bug The D2 fix guarded only ensureRemoteDetectedAgents (the SSH path). The desktop client's headline scenario — pairing to a remote `orca serve` — routes through ensureRuntimeDetectedAgents (kind: 'runtime'), which had the identical bug: an empty detection result ([], truthy in JS) was pinned by the `if (existing)` short-circuit, so a later install / PATH fix was never picked up without a reconnect. Change the runtime guard to `if (existing?.length)`, mirroring the remote path. In-flight dedup still collapses concurrent re-detects; failed requests stay uncached. Add a runtime regression test proving detection re-runs after an empty result (fails on the pre-fix guard). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Honor package-manager relocation env vars in relay PATH detection Extend the existing npm_config_prefix precedence to cargo, bun, deno, go, and pnpm so relocated installs (CARGO_HOME, BUN_INSTALL, DENO_INSTALL, GOBIN/GOPATH, PNPM_HOME/XDG_DATA_HOME) are detected, falling back to the $HOME defaults. Mirrors the remote-node probe's NVM_DIR handling (stablyai#6037). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Tighten remote agent detection retries Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: LesleyMurfin <260182349+LesleyMurfin@users.noreply.github.com> Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com> Co-authored-by: Orca <help@stably.ai>
Summary
Fixes two independent defects that prevent the desktop client from detecting agents installed on a remote
orca serve(Fixes #6028):D1 —
src/relay/relay-command-env.ts: the relay probes agents with a login shell (/bin/sh -lc), which sources~/.profilebut not the interactive~/.bashrc, while the user's real PTY sessions are interactive and DO source~/.bashrc. Agents whose bin is on PATH only via~/.bashrc(common for per-user package managers) are therefore invisible to detection even though the user can run them, and the POSIX fallback list didn't cover those bins. Fix: resolve the serve user's package-manager bins from$HOME(.local/bin,.npm-global/bin,.cargo/bin,.bun/bin,go/bin,.deno/bin,.local/share/pnpm) and honor a relocated npm prefix vianpm_config_prefix, appended to the fallback set and deduped against the inherited PATH via the existingSetsemantics. win32 path unchanged.D2 —
src/renderer/src/store/slices/detected-agents.ts: an empty detection result ([], which is truthy in JS) was pinned by theif (existing)short-circuit, so detection never retried after the server env was fixed. Changed toif (existing?.length)in both detection paths:ensureRemoteDetectedAgents(SSH,kind: 'ssh') andensureRuntimeDetectedAgents(orca serve,kind: 'runtime'). The runtime path is the one that serves the headline remote-orca servescenario, so patching only the SSH path would have left the primary case broken. Non-empty results still short-circuit; the in-flight dedup still prevents concurrent re-detect storms; failed requests remain uncached.No new transport, no PowerShell/bash bridge. This is the minimal change covering the common package-manager prefixes; a fuller fix (sourcing the interactive shell config so the probe sees the exact PTY PATH) would cover the whole login-vs-interactive class but is a larger surface — noted as follow-up, not bundled here.
Screenshots
No visual change. (D1 is relay-side PATH resolution; D2 is a store cache-guard. No UI was touched.)
Testing
pnpm lint— pass (oxlint + switch-exhaustiveness + styled-scrollbars + localization catalog/coverage)pnpm typecheck— pass (all 3 tsgo configs)pnpm test— the 3 touched test files pass, 25/25 (full-suite not run locally due to unrelated pre-existing env noise on the dev box — node-pty/fakeredis; clean-env CI is authoritative)pnpm build— not run locally (Electron multi-platform build); relying on CIrelay-command-env.test.ts(POSIX$HOME-resolved bins;npm_config_prefixhonored; dedup against inherited PATH;homedir()fallback on emptyHOME; win32 env unchanged with no POSIX bins leaking in),detected-agents.test.ts(empty result re-detects on both the remote/SSH and runtime/serve paths; non-empty short-circuits; in-flight dedup; failure stays uncached — each empty-redetect test was confirmed to fail on the pre-fixif (existing)guard),useDetectedAgents.test.tsx(ssh call site fires once on mount, no re-detect loop on a zero-agent host)D1 was also validated with a live end-to-end probe on a WSL
orca serve: an executable placed in~/.npm-global/bin(bashrc-only PATH) is invisible to the login-shell probe and to the old POSIX fallback, but detected with the patchedbuildRelayCommandEnv.AI Review Report
An independent review pass covered the axes CONTRIBUTING requires:
win32early-return ingetFallbackSegments; win32 returnsWINDOWS_RELAY_PATH_FALLBACKSunchanged. Paths useposix.join(notpath.join), so segments are always/-joined — correct, since these are POSIX remote targets. A test explicitly asserts POSIX user bins do not leak into a win32 relay env.buildRelayCommandEnvis the shared env builder for every relay handler; the change is purely additive (extra PATH segments appended after the inherited PATH).$HOMEresolves on the relay host where the probe runs, with ahomedir()fallback. Other consumers (git/fs handlers) only get a richer PATH — no behavioral regression. This is exactly the remote-serve path the fix targets.detectedIds === null(and[]≠null, so no effect loop), and in-flight dedup collapses concurrent calls. The only added cost is a boundedcommand -vprobe per user-initiated menu re-open on zero-agent hosts — the deliberate trade-off that lets a newly installed agent appear without a reconnect.isDetectingRemoteAgentsspinner state is still set/cleared correctly around the re-detect.Security Audit
posix.joinfromHOME/npm_config_prefixand passed as discreteenvPATH entries, never interpolated into a shell string. The probe passes the agent name as a positional$1arg tocommand -v(unchanged), so the broadened PATH introduces no injection surface.PATHitself; no privilege boundary is crossed and detection only runscommand -v(it never executes the found binary). Non-blocking nit:npm_config_prefixis not asserted absolute, buthasAbsoluteCommandPathonly accepts absolutecommand -voutput, so a relative prefix cannot cause a false-positive — harmless. An absolute-path guard is a possible follow-up for PATH hygiene.os.homedir/path.posixfrom the standard library).Notes
orca serve. Local detection is unaffected.npm_config_prefix.Credit: reported and diagnosed by @hufeide (#5899). This PR corrects the original diagnosis: the
-lc/command -vmechanism is already inmain; the actual fixes are the login-vs-interactive PATH gap in the relay fallback (D1) and the truthy-[]cache pin (D2).Contributor: @lesleymurfin on X.