Repository navigation
Provide the Orca CLI automatically in managed WSL terminals - #22761
Conversation
There was a problem hiding this comment.
Important
Managed WSL terminals now refuse to open when the distro's login shell is not bash or zsh. The reference doc calls this intentional, but it converts a previously working pane into an immediate failure for fish/ksh/dash users — see the inline comment for a fallback option before merging.
Reviewed changes
- App-owned launcher provisioning — on a
win32host,prependOrcaCliDirToChildPathnow callsapplyManagedWslCliEnvironment, which writes an app-owned launcher/bridge tree under<userData>/wsl-managed-cli/<content hash>and exportsORCA_WSL_CLI_DIRplus aWSLENV/ptranslation (orORCA_WSL_CLI_ERRORon failure). - Guest-side PATH restore — the shared
WSL_MANAGED_CLI_PATHblock is injected into the bash shell-ready rcfile, the local zsh.zshenvdeferred init (fixture snapshots updated), and everybuildWslLoginShellCommandpayload, so the CLI survives profile resets without editing guest profiles or~/.local/bin. - Managed launcher/bridge variants —
buildWslLauncher/buildWslBridgeScriptgain optional managed behavior: host-resolved Windows PowerShell viawslpath,ORCA_USER_DATA_PATHpinning, hidden child, explicit stdout/stderr forwarding, and dev-modeELECTRON_RUN_AS_NODEdirect CLI invocation. - Capability advertisement —
terminal.managed-wsl-cli.v1is added toRUNTIME_CAPABILITIESfor a later UI integration; no consumer yet. - Concurrency/repair semantics — content-addressed directories, temp+rename publishing, missing-file repair, and refusal of modified files/symlinks, with focused unit, snapshot, and opt-in live WSL tests.
ℹ️ Two different "managed WSL CLI" concepts now share a name
main already has reconcileManagedWslCliRegistrations / repairManagedRegistration (src/main/cli/wsl-cli-registration-reconciliation.ts), which means guest-side global registration of orca-ide into each distro. This PR introduces ensureManagedWslCli / applyManagedWslCliEnvironment (src/main/cli/wsl-managed-cli.ts), which means host-side app-owned launcher provisioning. Same phrase, opposite mechanisms — a future reader could reasonably wire the wrong one. Consider naming the new surface around the app-owned/terminal reach (e.g. ensureWslTerminalCli) so the two do not collide.
Technical details
# Distinct "managed WSL CLI" subsystems share a name
## Affected sites
- `src/main/cli/wsl-cli-registration-reconciliation.ts:61` — `reconcileManagedWslCliRegistrations`, startup repair of per-distro global registration.
- `src/main/cli/wsl-managed-cli.ts:18` — `ensureManagedWslCli`, host-side app-owned launcher tree.
- `src/shared/protocol-version.ts:139` — `TERMINAL_MANAGED_WSL_CLI_RUNTIME_CAPABILITY` names the new behavior "managed WSL CLI" too.
## Required outcome
- A name for the new surface that does not read as the existing global-registration reconciliation, or an explicit doc note distinguishing them.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change resolves and provisions the managed WSL CLI from host runtime details, generates launcher and bridge scripts, and passes the managed CLI directory into WSL. Local Bash and zsh wrappers now restore the directory to PATH when the configured executable is available. The change also updates bridge and WSL integration tests, shell snapshots, and reference documentation. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The reviewed quoting and shell-test concerns are addressed, and CLI output remains available in managed WSL terminals. No material unresolved issue remains before merge. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Processes and agents in Orca-managed WSL terminals will be able to invoke the host application’s CLI without the previous manual registration step. The change is scoped to managed terminals and handles unavailable launchers, but the expanded access to application commands warrants a security design review. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d63d412b-5b91-44cb-b44b-f881b2dc13ce
📒 Files selected for processing (18)
docs/reference/wsl-managed-cli.mdsrc/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txtsrc/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txtsrc/main/cli/orca-cli-child-path.test.tssrc/main/cli/orca-cli-child-path.tssrc/main/cli/wsl-cli-powershell-boundary.test.tssrc/main/cli/wsl-cli-scripts.tssrc/main/cli/wsl-managed-cli.test.tssrc/main/cli/wsl-managed-cli.tssrc/main/cli/wsl-managed-cli.wsl.test.tssrc/main/providers/local-pty-shell-ready-bash-rcfile.tssrc/main/providers/local-pty-shell-ready-wrapper-fileset.tssrc/main/zsh-startup-wrapper-builder.tssrc/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsxsrc/shared/protocol-version.tssrc/shared/wsl-login-shell-command.test.tssrc/shared/wsl-login-shell-command.tssrc/shared/wsl-managed-cli-path.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| userDataPath: string | ||
| cliEntryPath?: string | ||
| }): string { | ||
| const psQuote = (value: string): string => `'${value.replace(/'/g, "''")}'` |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Escape typographic single quotes in psQuote.
PowerShell treats U+2018, U+2019, U+201A, and U+201B as single-quote delimiters inside single-quoted strings. psQuote escapes only the ASCII '. Assume userDataPath or cliEntryPath contains ’, for example a Windows profile named O’Brien. The generated literal then ends early, and the bridge fails to parse. Every managed CLI call in that case fails with a script error.
🐛 Proposed fix
- const psQuote = (value: string): string => `'${value.replace(/'/g, "''")}'`
+ const psQuote = (value: string): string =>
+ `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, (quote) => quote + quote)}'`📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const psQuote = (value: string): string => `'${value.replace(/'/g, "''")}'` | |
| const psQuote = (value: string): string => | |
| `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, (quote) => quote + quote)}'` |
Never block a shell on CLI availability, keep the shared WSL login-shell builder unchanged, provision from PTY env assembly only, drop the error variable and command probing, and reuse the existing WSLENV helper.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 7bd9b572-a492-4cd9-8106-556ed087d0ce
📒 Files selected for processing (17)
docs/reference/wsl-managed-cli.mdsrc/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txtsrc/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txtsrc/main/cli/orca-cli-child-path.tssrc/main/cli/wsl-cli-scripts.tssrc/main/cli/wsl-managed-cli.test.tssrc/main/cli/wsl-managed-cli.tssrc/main/cli/wsl-managed-cli.wsl.test.tssrc/main/daemon/daemon-zsh-shell-ready-wrapper-spec.tssrc/main/ipc/pty/host-env/assembly.tssrc/main/pty/wsl-orca-env.tssrc/main/zsh-startup-wrapper-builder.tssrc/relay/pty-shell-overlay-wrappers.tssrc/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsxsrc/renderer/src/components/settings/CliSkillRuntimeSetup.tsxsrc/shared/protocol-version.tssrc/shared/wsl-managed-cli-path.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/shared/protocol-version.ts
- docs/reference/wsl-managed-cli.md
Files not reviewed due to moderation or processing errors (15)
- src/main/cli/wsl-cli-scripts.ts
- src/main/cli/wsl-managed-cli.ts
- src/main/cli/wsl-managed-cli.test.ts
- src/main/cli/wsl-managed-cli.wsl.test.ts
- src/main/ipc/pty/host-env/assembly.ts
- src/main/pty/wsl-orca-env.ts
- src/main/cli/orca-cli-child-path.ts
- src/shared/wsl-managed-cli-path.ts
- src/main/zsh-startup-wrapper-builder.ts
- src/main/fixtures/shell-wrapper-snapshots/local-bash-rcfile.txt
- src/main/fixtures/shell-wrapper-snapshots/local-zsh-zshenv.txt
- src/main/daemon/daemon-zsh-shell-ready-wrapper-spec.ts
- src/relay/pty-shell-overlay-wrappers.ts
- src/renderer/src/components/settings/CliSkillRuntimeSetup.tsx
- src/renderer/src/components/settings/CliSkillRuntimeSetup.test.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| return null | ||
| } | ||
| const powerShellPath = win32.join( | ||
| process.env.SystemRoot || 'C:\\Windows', | ||
| 'System32\\WindowsPowerShell\\v1.0\\powershell.exe' | ||
| ) | ||
| const launcherScript = buildColocatedWslLauncher(launcher, powerShellPath) | ||
| const bridge = buildWslBridgeScript({ userDataPath: options.userDataPath, cliEntryPath }) | ||
| const digest = createHash('sha256').update(launcherScript).update(bridge).digest('hex') | ||
| const directory = join(options.userDataPath, 'wsl-managed-cli', digest.slice(0, 20)) | ||
| const files = [ | ||
| [join(directory, options.isPackaged ? 'orca-ide' : 'orca-dev'), launcherScript], | ||
| [join(directory, 'orca-wsl-bridge.ps1'), bridge] | ||
| ] as const | ||
| const ready = | ||
| files.every(([path]) => existsSync(path)) || writeShellWrapperFiles(files, '[WSL CLI]') | ||
| return ready ? directory : null | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,110p' src/main/cli/wsl-managed-cli.ts
sed -n '1,100p' src/main/shell-wrapper-file-writer.ts
sed -n '1,100p' src/main/cli/wsl-managed-cli.test.tsRepository: stablyai/orca
Length of output: 8607
🏁 Script executed:
printf '%s\n' '--- diff ---'
git diff --unified=40 bf40d35b0b77b02fe1ad0f4103f83b73b1637522 -- src/main/cli/wsl-managed-cli.ts src/main/cli/wsl-cli-scripts.ts src/main/shell-wrapper-file-writer.ts
printf '%s\n' '--- script definitions and calls ---'
rg -n -C 5 "buildColocatedWslLauncher|buildWslBridgeScript|ORCA_WSL_CLI_DIR|orca-wsl-bridge|orca-dev|orca-ide|ensureManagedWslCli" src/main src/shared
printf '%s\n' '--- remaining managed CLI test ---'
sed -n '90,260p' src/main/cli/wsl-managed-cli.test.tsRepository: stablyai/orca
Length of output: 45659
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 36696
🏁 Script executed:
git diff --unified=25 bf40d35b0b77b02fe1ad0f4103f83b73b1637522 -- src/main/cli/wsl-managed-cli.ts src/main/cli/wsl-cli-scripts.ts src/main/shell-wrapper-file-writer.ts
printf '%s\n' '--- bindings ---'
rg -n -C 4 "buildColocatedWslLauncher|buildWslBridgeScript|ORCA_WSL_CLI_DIR|orca-wsl-bridge|orca-dev|orca-ide|ensureManagedWslCli" src/main src/shared
printf '%s\n' '--- tests ---'
sed -n '90,260p' src/main/cli/wsl-managed-cli.test.tsRepository: stablyai/orca
Length of output: 45659
🏁 Script executed:
set -eu
printf '%s\n' '--- managed cli and writer ---'
nl -ba src/main/cli/wsl-managed-cli.ts
nl -ba src/main/shell-wrapper-file-writer.ts | sed -n '1,90p'
printf '%s\n' '--- WSL path and assembly ---'
nl -ba src/shared/wsl-managed-cli-path.ts
rg -n -C 12 "applyManagedWslCliEnvironment|WSL_MANAGED_CLI_PATH|ensureManagedWslCli" src/main src/shared -g '*.ts'
printf '%s\n' '--- base-tree candidates ---'
git ls-tree -r --name-only bf40d35b0b77b02fe1ad0f4103f83b73b1637522 | rg 'wsl-managed-cli|wsl-cli|shell-wrapper-file-writer|wsl-managed-cli-path'Repository: stablyai/orca
Length of output: 38275
🏁 Script executed:
rg -n -C 8 "modified|user.?owned|managed|marker|safe.*replace|conflict|repair|overwrite|existsSync|readFileSync" \
src/main/cli/wsl-cli-installer.ts \
src/main/cli/wsl-cli-registration-command.ts \
src/main/cli/wsl-cli-registration-operation.ts \
src/main/cli/wsl-cli-registration-reconciliation.ts \
src/main/cli/wsl-cli-scripts.ts \
src/main/cli/wsl-cli-*.test.tsRepository: stablyai/orca
Length of output: 42571
Repair modified managed WSL files before reuse.
ensureManagedWslCli accepts any existing launcher and bridge. WSL then prepends ORCA_WSL_CLI_DIR to PATH, so later orca-ide or orca-dev calls execute the modified files. Compare file contents before reusing the content-addressed directory and rewrite mismatches.
Suggested fix
-import { existsSync } from 'node:fs'
+import { existsSync, readFileSync } from 'node:fs'
...
- const ready =
- files.every(([path]) => existsSync(path)) || writeShellWrapperFiles(files, '[WSL CLI]')
+ const ready =
+ files.every(([path, content]) => {
+ try {
+ return readFileSync(path, 'utf8') === content
+ } catch {
+ return false
+ }
+ }) || writeShellWrapperFiles(files, '[WSL CLI]')There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (184b33c6d6 → c356ac0e01, "Simplify managed WSL CLI provisioning"):
- Removed the shell-refusal guard — non-bash/zsh login shells and a missing zsh wrapper now degrade to the plain login shell instead of failing the pane, and the in-guest
ORCA_WSL_CLI_ERRORhard-stop is gone (host now logs and leaves the var unset). - Simplified guest PATH restore —
WSL_MANAGED_CLI_PATHnow just prependsORCA_WSL_CLI_DIRtoPATHwhen readable (noORCA_CLI_COMMANDexport, noexit 1), andbuildWslLoginShellCommandno longer injects it; the renderer skill-setup path prepends it explicitly (CliSkillRuntimeSetup.tsx:67). - Scoped provisioning to PTYs —
applyManagedWslCliEnvironmentmoved fromprependOrcaCliDirToChildPathintobuildPtyHostEnv, so it covers every Windows PTY (native PowerShell panes included) without leaking into the structured-worker env. - Softer
ensureManagedWslCli— returnsstring | nullinstead of throwing and trusts a present content-addressed tree rather than re-verifying file contents; therefuses to overwrite unrelated contenttest was dropped. - Builder refactor —
wsl-cli-scripts.tsgainedbuildColocatedWslLauncher/buildLauncher/bridgeLines/quotePowerShell; the guest-registration launcher/bridge output is unchanged.ZshWrapperRestoreSpec.managedWslCliis now a required boolean.
Both prior pullfrog inline threads were addressed and resolved: the managed-block assertion was restored in CliSkillRuntimeSetup.test.tsx, and the non-bash/zsh refusal was removed.
ℹ️ Nitpicks
- The PR description still says "Missing or modified files produce actionable errors." That no longer matches the code after this commit — missing files are silently repaired, a present tree is trusted as-is, and provisioning failures only
console.warnon the host. Worth updating the description for reviewers.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Provision only for WSL panes and publish the directory through addOrcaWslInteropEnv, so daemon terminals keep inherited WSLENV entries and non-WSL builds never see the variable. Write the bridge with a UTF-8 BOM so Windows PowerShell 5.1 keeps non-ASCII user-data paths, give the dev bridge the dev launcher's app-launch env, and drop the unused skill-setup wiring and runtime capability.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (c356ac0e01 → 2a69500731, "Scope the managed WSL CLI to WSL terminals"):
- Scoped provisioning to WSL panes —
buildPtyHostEnvnow callsgetManagedWslCliDironly insideif (opts.isWsl)and deletes any inheritedORCA_WSL_CLI_DIR, so native Windows PTYs no longer receive it. - Dropped the runtime capability and skill-setup injection —
TERMINAL_MANAGED_WSL_CLI_RUNTIME_CAPABILITYand itsRUNTIME_CAPABILITIESentry are removed, the renderer's WSL skill-setup command no longer prepends the managed block, and the doc's integration section is gone. - Moved and strengthened the guest PATH restore —
WSL_MANAGED_CLI_PATHbecamesrc/main/wsl-managed-cli-path-restore.ts; it now checks the launcher is executable, de-dupes a nested PATH entry, and warns with clearer text. - Split host resolution —
getManagedWslCliDir/getWslCliCommandName/resolveManagedWslCliRuntime, usingwindowsPowerShellPath()and ahasAppEnvironment()gate for dev. - Bridge hardening — app bridges are written with a UTF-8 BOM and set the dev app-launch env (
ELECTRON_RUN_AS_NODE,ORCA_APP_EXECUTABLE,ORCA_APP_EXECUTABLE_NEEDS_APP_ROOT). - Tests — added a non-ASCII PowerShell 5.1 boundary test; reworked the unit and opt-in WSL e2e tests; dropped the concurrent-provisioning and interop-failure coverage.
ℹ️ PR description still describes the pre-scoping behavior
The body says the runtime advertises terminal.managed-wsl-cli.v1 and links to docs/reference/wsl-managed-cli.md#integration-with-pr-22720, but this commit deletes both the capability constant and that doc section. It also still claims managed terminals "cover skill installers that start in PowerShell and then enter WSL", which the WSL-only scoping (plus the removed skill-setup injection) no longer does. Worth updating so the description matches the shipped surface.
Technical details
# Stale PR description claims after scoping
## Affected sites
- `docs/reference/wsl-managed-cli.md` — no longer contains an `#integration-with-pr-22720` section.
- `src/shared/protocol-version.ts` — `TERMINAL_MANAGED_WSL_CLI_RUNTIME_CAPABILITY` and its `RUNTIME_CAPABILITIES` entry were deleted in `2a69500731`.
- `src/main/ipc/pty/host-env/assembly.ts:277` — provisioning is now `opts.isWsl` only, so a native PowerShell pane that shells into WSL no longer has `ORCA_WSL_CLI_DIR` to `/p`-translate.
## Required outcome
- The PR body's capability claim, doc anchor, and "skill installers that start in PowerShell and then enter WSL" sentence should reflect the shipped surface.
## Open questions for the human
- Is `terminal.managed-wsl-cli.v1` intentionally deferred to the #22720 UI work, or should it stay advertised here?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Launch the bridge child exactly like the registered bridge (no hidden window or output relay; verified through WSL with Node and Electron), give the dev bridge the dev launcher's NODE_OPTIONS stash, clear the guest-only directory before starting Windows processes, collapse setup into one function, warn once, and guard WSL env routing with tests.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (2a69500731 → a29b49763d, "Tighten the managed WSL CLI bridge and setup"):
- Extracted shared script builders —
wsl-cli-scripts.tsnow factors the launcher into a genericbuildLauncher, keepsbuildWslLauncher(guest registration) and addsbuildColocatedWslLauncher(managed, bridge found beside itself, PowerShell resolved viawslpath).buildWslBridgeScripttakes an optionalappobject; the registered bridge's output is unchanged. - Hardened the managed bridge — it pins
ORCA_USER_DATA_PATH, clears the WSLENV-mappedORCA_WSL_CLI_DIRso a CLI-started app never inherits a guest path, and mirrorsbuildWindowsDevLauncher's dev env (ELECTRON_RUN_AS_NODE,ORCA_APP_EXECUTABLE/_NEEDS_APP_ROOT, stashingNODE_OPTIONS/NODE_REPL_EXTERNAL_MODULEintoORCA_*). The bespoke hidden-child stdout/stderr redirection is gone — the managed bridge now launches its child exactly like the registered one, which the live WSL test still covers for piped stdout/stderr/exit codes. - Simplified host resolution —
getManagedWslCliDirinlines the formerresolveManagedWslCliRuntime/ensureManagedWslClisplit and latches the "runtime missing" warning to fire once per process. - Cleared stale provisioning for non-WSL panes —
buildPtyHostEnvdeletes any inheritedORCA_WSL_CLI_DIRbefore re-provisioning for WSL, and derivesORCA_CLI_COMMANDfromgetWslCliCommandName. - Coverage — new PowerShell 5.1 boundary test pinning the non-ASCII app identity, stashed
NODE_OPTIONS, and cleared guest-onlyORCA_WSL_CLI_DIR; unit tests for reuse/repair/isolation and missing runtime; a pty-serializer assertion that a staleORCA_WSL_CLI_DIRis stripped from non-WSL panes.
Both prior pullfrog inline threads remain resolved (the managed-block assertion and the non-bash/zsh refusal), and no open pullfrog threads remain.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
PowerShell also ends single-quoted strings at typographic quotes, so a user-data path such as O'Brien with a curly apostrophe broke the managed bridge. Fix the shared quotePowerShellLiteral and reuse it. Drop an inherited ORCA_WSL_CLI_DIR on the daemon path, remove the unreachable PATH dedupe, and cover failed setup with a stale caller value.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (a29b49763d → 81d5752ae6, "Harden managed WSL CLI quoting and inheritance"):
- Typographic-quote escaping hardened —
quotePowerShellLiteralnow doubles U+2018/U+2019/U+201A/U+201B in addition to ASCII', andwsl-cli-scripts.tsuses it instead of its local copy. Verified against PowerShell'sCharTraits.IsSingleQuote, which matches all four code points (QuoteSingleLeft/Right,QuoteSingleBase,QuoteReversed), so the doubling round-trips rather than corrupting the path. - Inherited CLI dir stripped in the daemon —
ORCA_WSL_CLI_DIRjoinedPANE_IDENTITY_ENV_KEYS, socreateDaemonPtyEnvironmentdrops an inherited copy unless the caller sends one explicitly; the host path likewise clears it inbuildPtyHostEnvbefore re-provisioning. - PATH de-dupe removed — both guest restore hooks already run once per Orca shell (the bash rcfile is sourced once; the zsh
__orca_deferred_initself-guards on_orca_deferred_init_doneand removes its precmd entry), so the leading-entrycasewas dead weight. Doc and both fixture snapshots updated to match. - Coverage extended — the PowerShell 5.1 boundary test now exercises a typographic/non-ASCII userData path and adds
windowsHide; the pty-serializer suite asserts a stale callerORCA_WSL_CLI_DIRis dropped even when provisioning fails.
Focused changed suites pass locally (64 tests across 6 files).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Add a live zsh case that reaches a real prompt, a POSIX test that runs the PATH restore snippet in bash and zsh under set -u, and a null result for unwritable user data. Say what a failed write actually costs, and document per-spawn write logging and older-daemon behaviour.
There was a problem hiding this comment.
Important
The new POSIX test src/main/wsl-managed-cli-path-restore.test.ts fails on Ubuntu CI. Both bash cases assert an empty stderr, but bash reads /etc/bash.bashrc under set -u and writes PS1: unbound variable. CI shard test / tests node 24 8/8 is red on exactly these two assertions (:47 and :57); the other seven shards are green.
Reviewed changes — the delta since the prior pullfrog review (81d5752ae6 → 6cad86cb84, "Cover the managed WSL CLI in zsh and on POSIX CI"):
- Added a POSIX restore test — runs
WSL_MANAGED_CLI_PATH_RESTOREin bash (-uc) and zsh (-fuc, wrapped in a__orca_hookfunction) and asserts PATH-leading, warning, and no-op behavior. - Added a live zsh case — drives an interactive zsh through
scriptto reach the first-prompt hook, and extracts awithManagedClihelper so the bash and zsh cases share provisioning, wrapper files, and the profile-unchanged snapshot. - Added an unwritable-userData unit case —
getManagedWslCliDirreturns null when the userData path is a file. - Gave
writeShellWrapperFilesaconsequenceparameter — managed WSL provisioning now logsWSL terminals will start without the Orca CLIinstead of the generic unwrapped-shell line; other callers keep the default. - Updated the reference doc — per-spawn write logging, older-daemon behavior, and the zsh test's skip conditions.
ℹ️ Nitpicks
- The PR body's Testing list still says the live WSL test checks "that shells outside Orca do not get the command"; that assertion was removed in this commit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
CI runners make bash -c read /etc/bash.bashrc, which fails under set -u.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (6cad86cb84 → e4bb947235, "Keep system bashrc out of the PATH restore test"):
- Fixed the red POSIX bash case — the bash variant of
wsl-managed-cli-path-restore.test.tsnow spawns with--norc --noprofile, so it no longer sources/etc/bash.bashrc(whosePS1reference aborts underset -u) and the empty-stderrassertions pass. Verified locally on Linux: 3 bash cases pass, 3 zsh cases skip where zsh is absent.
The prior thread at wsl-managed-cli-path-restore.test.ts:25 is resolved and no open pullfrog threads remain.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…li-auto-setup # Conflicts: # src/main/cli/wsl-cli-powershell-boundary.test.ts
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (e4bb947235 → 96d329e5cc, a merge of origin/main):
- Merged
origin/main— main independently added-WslDistroforwarding to the WSL launcher and bridge. It merged cleanly with the refactor froma29b49763d: the distro block now lives inside the sharedbuildLauncher(src/main/cli/wsl-cli-scripts.ts:59), so both the guest launcher and the managedbuildColocatedWslLauncherforward$WSL_DISTRO_NAME. The bridge's-WslDistroparse andORCA_CLI_WSL_DISTROclear/set are intact, so managed-CLI calls now also pin the distro. - Resolved the single merge conflict in
src/main/cli/wsl-cli-powershell-boundary.test.ts— kept both sides: main's-WslDistroinvocation and staleORCA_CLI_WSL_DISTRO/WSL_DISTRO_NAMEassertions, plus the PR'swindowsHide: true(invocations and exit case) and the non-ASCII app-identity test.
All prior pullfrog threads are resolved and no new issues surfaced; the review of e4bb947235 still holds.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Terminals Orca opens inside WSL (Linux on Windows) now have this Orca's command-line tool (
orca-ide, ororca-devin development) ready to use. Nothing is installed inside Linux, and no shell profile or PATH setting is edited. Before, the command only existed if the user had registered it by hand in Settings → General, which is still how shells opened outside Orca get it.What Changed
Before: in an Orca WSL terminal,
orca-idewas "command not found" unless the user had registered the CLI, and agents running there could not call back into Orca.After: it resolves to the Orca instance that opened the terminal.
How:
buildPtyHostEnv),getManagedWslCliDirwrites a small launcher script and PowerShell bridge into<userData>/wsl-managed-cli/<content hash>and setsORCA_WSL_CLI_DIR. Terminals that are not WSL clear the variable.addOrcaWslInteropEnv, which every WSL launch already goes through (daemon and in-process), passes the folder withWSLENV/p, so each distro translates the path with its own mount settings.The launcher and bridge reuse the builders from WSL registration (
wsl-cli-scripts.ts). The registered scripts' output is byte-for-byte unchanged. The managed bridge also:quotePowerShellLiteral(now also escaping typographic quotes such as’, which PowerShell treats as string delimiters);out/cli/index.jswith the same environment as the existing dev launcher.Why
WSLENVavoid all three.shell-wrapper-content-address.ts): builds that share user data never overwrite each other, and a file that exists is complete because each one lands by rename.addOrcaWslInteropEnv? It runs on the final, merged environment for both spawn paths, so a user's ownWSLENVentries survive.Linked Issue
Launch-side prerequisite for the WSL skill-setup work in #22720; that branch is not modified. This PR removes no UI prerequisite. Skill setup can stop requiring WSL registration only in a follow-up that also handles older paired hosts.
Visual Proof
Before: in an isolated home with
PATH=/usr/bin:/bin, neitherorca-idenororca-devresolved.After (captured on the first revision of this PR through Playwright CDP from a hidden Electron build): a managed WSL terminal resolves its own launcher,
--helppasses, andstatus --jsonreturns the isolated app's runtime ID.The current revision was verified by the live WSL test below rather than a new app screenshot.
Testing
Windows 11, WSL 2, Ubuntu-24.04,
ORCA_BACKGROUND_LAUNCH=1.Live tests (Windows only):
wsl-managed-cli.wsl.test.ts(opt-in) runs the real rcfile in the real distro, with a profile that resets PATH and a user-data path containing张三. It checks:$, piped stdout, stderr and exit codes;wsl-cli-powershell-boundary.test.tsruns the managed bridge under Windows PowerShell 5.1 with a张三 O’Brienuser-data path, checking the devNODE_OPTIONSstash and thatORCA_WSL_CLI_DIRis cleared. It fails without the byte-order mark (the path arrives aså¼ ä¸‰) and without the typographic-quote escaping (Unexpected token 'Brien').Unit tests:
WSLENVrouting for WSL terminals, and clearing a leftover value for other terminals.Checks: typecheck (node and web), oxlint, oxfmt and the changed-code quality gate pass.
Full-suite comparison: the whole suite (89,197 tests) was run on this branch and on its base commit on the same Windows machine, and the failing-test lists compared. Every branch-only failure either also fails on the base when re-run alone (timing flakes under full-suite load) or passes in a fresh checkout of this exact commit (one SQLite
EBUSYcleanup failure local to the original worktree). No failure is attributable to this change.Not covered:
To repeat the live test:
Review
powershell.exe -ExecutionPolicy Bypass -File <bridge>. Before, this happened only after the user registered the CLI.docs/reference/windows-edr-posture.mdrecords this.buildPtyHostEnvis local-only, and the relay wrapper spec opts out).Agent skill upstream boundary
Notes
Mechanism details:
docs/reference/wsl-managed-cli.md.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (focused checks above pass locally; the package runner cannot reinstall here, so CI covers the rest)