Skip to content

fix(startup): shell PATH probe falls back and retries when the shell cannot launch - #30204

Merged
nwparker merged 2 commits into
mainfrom
nwparker/hydrate-shell-path-process-host
Oct 18, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/hydrate-shell-path-process-host

Conversation

@nwparker

@nwparker nwparker commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​64 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​64
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15

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

  • 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:

  1. 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.
  2. 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.
  3. hydrateShellPath drops its cached promise when that promise rejects, but only if it is still the current one.
  4. 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)

@coderabbitai

coderabbitai Bot commented Oct 18, 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: e23e045c-264f-42ad-8d66-09941d3ed227
📥 Commits

Reviewing files that changed from the base of the PR and between dcfe8c9 and 70017ca.

📒 Files selected for processing: 4
  • config/process-host-direct-import-baseline.txt
  • src/main/startup/hydrate-shell-path.test.ts
  • src/main/startup/hydrate-shell-path.ts
  • src/main/startup/hydrate-shell-path.windows.test.ts
💤 Files with no reviewable changes: 1
  • config/process-host-direct-import-baseline.txt

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: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning 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 Warning 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 Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: shell PATH probe fallback and retry behavior when shell launch fails.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 4baacca into main Oct 18, 2026
34 checks passed
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.

1 participant