You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(startup): shell PATH probe falls back and retries when the shell cannot launch - #30204
When Orca starts, it asks your shell for its PATH so it can find agent CLIs. On Windows, if the preferred PowerShell 7 can't even be started, Orca was supposed to try the built-in Windows PowerShell instead. It didn't, and it then kept remembering the failure, so agent detection broke until restart.
What Changed
Before (Windows): when the Microsoft Store build of PowerShell 7 (pwsh.exe) refused to launch with a synchronous EPERM, the PATH probe rejected outright. The inbox powershell.exe fallback never ran. The rejected promise stayed cached, so every later caller got the same failure without probing again. Agent detection failed, and the "+" menu said "Can't reach this workspace's host to list its agents".
After: a synchronous launch failure is reported as an ordinary spawn_error, so the existing fallback to powershell.exe runs. If a probe still rejects for some other reason, the cache is cleared and the next call probes again.
Mechanism, in src/main/startup/hydrate-shell-path.ts:
The probe now starts the shell through spawnProcess from @orca/process-host, not child_process.spawn, as AGENTS.md requires. The spawn options are the same: windowsHide, no shell, piped stdout only, same env and argv.
A synchronous throw from the spawn call resolves { ok: false, failureReason: 'spawn_error' }, the same result an async error event already produced. The existing fallback branch handles it.
hydrateShellPath drops its cached promise when that promise rejects, but only if it is still the current one.
The file comes off config/process-host-direct-import-baseline.txt (the ratchet shrinks by one).
Why
The fallback chain already keys off spawn_error. Making a synchronous throw produce that same result fixes the bug in one place and needs no second fallback path. We could have caught the rejection in hydrateShellPath and retried the fallback there, but that would also swallow real bugs from custom spawners. Clearing the cache on rejection only (and not on ok: false) keeps the existing contract: a resolved failure such as timeout stays cached until a forced refresh, so a slow profile isn't re-probed on every caller.
Platform impact: on macOS and Linux, spawnProcess passes the same file, argv and options to Node, so behaviour there is unchanged. The existing POSIX argv, env and Nushell tests pass unchanged through the real wrapper. SSH: this probe only runs on the local Electron host, and remote hosts are unaffected.
Linked Issue
No issue exists for this. Found during the SSH reliability audit.
Visual Proof
N/A. Startup PATH probing has no UI of its own. The visible symptom (the agent list error in the "+" menu) needs a Windows host whose Store pwsh can't launch.
Testing
New tests, which fail on main and pass here:
Windows: pwsh.exe throws EPERM synchronously and the probe falls back to powershell.exe, then parses its PATH.
Windows: when both shells throw synchronously, the result is spawn_error, not a rejection.
POSIX: a synchronous EACCES gives spawn_error.
A rejected hydration is re-probed by the next non-forced call instead of serving the cached rejection.
src/main/startup, src/main/preflight and the IPC callers' tests pass (single worker). pnpm tc passes. The local steps of the static-analysis job pass.
Verified live on macOS: a real /bin/zsh and /bin/bash probe through spawnProcess returns the PATH (49 / 44 segments), and a missing shell returns spawn_error.
Not verified live on Windows: reproducing a Store pwsh EPERM on a real host wasn't feasible, so the Windows path is covered by the unit tests only.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Codex review (gpt-6.1-sol, high) run before handoff.
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
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
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)
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
Shell PATH hydration now uses spawnProcess instead of child_process.spawn. Synchronous launch errors produce an unsuccessful result with failureReason: 'spawn_error', and stdout handling tolerates a missing stream. A rejected hydration promise is removed from the cache when it is still current, allowing a later call to retry. Tests cover retry behavior, synchronous launch failures, and Windows shell fallback.
Priority: ➖ Normal
Merge Risk:⚪ Minimal · up to 70017
The shell PATH fallback and retry changes are ready to merge after normal checks.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
The description covers the change, rationale, testing, platform impact, and checklist. However, the required Linked Issue is missing, and the description does not clearly verify every command claimed …
Add an actual linked issue under Linked Issue, or document the maintainer exemption if applicable. Align the Testing section and checklist with the commands that actually passed, including lint, typecheck, test, and build results or CI cove…
Docstring Coverage
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: shell PATH probe fallback and retry behavior when shell launch fails.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description covers the change, rationale, testing, platform impact, and checklist. However, the required Linked Issue is missing, and the description does not clearly verify every command claimed by the completed checklist.
Resolution
Add an actual linked issue under Linked Issue, or document the maintainer exemption if applicable. Align the Testing section and checklist with the commands that actually passed, including lint, typecheck, test, and build results or CI coverage.
Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When Orca starts, it asks your shell for its PATH so it can find agent CLIs. On Windows, if the preferred PowerShell 7 can't even be started, Orca was supposed to try the built-in Windows PowerShell instead. It didn't, and it then kept remembering the failure, so agent detection broke until restart.
What Changed
pwsh.exe) refused to launch with a synchronousEPERM, the PATH probe rejected outright. The inboxpowershell.exefallback never ran. The rejected promise stayed cached, so every later caller got the same failure without probing again. Agent detection failed, and the "+" menu said "Can't reach this workspace's host to list its agents".spawn_error, so the existing fallback topowershell.exeruns. If a probe still rejects for some other reason, the cache is cleared and the next call probes again.Mechanism, in
src/main/startup/hydrate-shell-path.ts:spawnProcessfrom@orca/process-host, notchild_process.spawn, as AGENTS.md requires. The spawn options are the same:windowsHide, no shell, piped stdout only, same env and argv.{ ok: false, failureReason: 'spawn_error' }, the same result an asyncerrorevent already produced. The existing fallback branch handles it.hydrateShellPathdrops its cached promise when that promise rejects, but only if it is still the current one.config/process-host-direct-import-baseline.txt(the ratchet shrinks by one).Why
The fallback chain already keys off
spawn_error. Making a synchronous throw produce that same result fixes the bug in one place and needs no second fallback path. We could have caught the rejection inhydrateShellPathand retried the fallback there, but that would also swallow real bugs from custom spawners. Clearing the cache on rejection only (and not onok: false) keeps the existing contract: a resolved failure such astimeoutstays cached until a forced refresh, so a slow profile isn't re-probed on every caller.Platform impact: on macOS and Linux,
spawnProcesspasses the same file, argv and options to Node, so behaviour there is unchanged. The existing POSIX argv, env and Nushell tests pass unchanged through the real wrapper. SSH: this probe only runs on the local Electron host, and remote hosts are unaffected.Linked Issue
No issue exists for this. Found during the SSH reliability audit.
Visual Proof
N/A. Startup PATH probing has no UI of its own. The visible symptom (the agent list error in the "+" menu) needs a Windows host whose Store pwsh can't launch.
Testing
New tests, which fail on main and pass here:
pwsh.exethrowsEPERMsynchronously and the probe falls back topowershell.exe, then parses its PATH.spawn_error, not a rejection.EACCESgivesspawn_error.src/main/startup,src/main/preflightand the IPC callers' tests pass (single worker).pnpm tcpasses. The local steps of the static-analysis job pass.Verified live on macOS: a real
/bin/zshand/bin/bashprobe throughspawnProcessreturns the PATH (49 / 44 segments), and a missing shell returnsspawn_error.Not verified live on Windows: reproducing a Store pwsh
EPERMon a real host wasn't feasible, so the Windows path is covered by the unit tests only.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Codex review (gpt-6.1-sol, high) run before handoff.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)