Repository navigation
fix(wsl): await Pi and OMP guest relay materialization - #21721
Conversation
|
Runtime gate update (win-lowspec, 2026-09-19): verified the paired Windows host has WSL/Ubuntu, but the WSL distro currently has neither |
|
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 (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change installs Pi and OMP overlays in WSL for explicit launches. The relay tracks launch kinds, startup, installation, and guest paths. PTY environment setup waits for guest readiness. WSL environment export handles guest paths. Tests cover successful materialization, delayed endpoint exposure, failures, timeout, and bare-shell launches. Priority: ➖ Normal Severity of issue fixed: Medium 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation The PR also adds OMP-only guest extension transport and materialization, Resolution Remove the OMP-only transport, materialization, state, environment, readiness, and test changes from this PR, or link the applicable OMP issue and move that work to a separate pull request. Retain shared relay changes that directly support the Pi fix. ✨ 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: c2df50d0-9889-4333-9c3c-3d1d0b439686
📒 Files selected for processing (5)
src/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-pi-omp-guest-readiness.tssrc/main/ipc/pty/provider/local-configure.tssrc/main/ipc/pty/runtime/spawn-preflight.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
Additional Windows evidence (win-lowspec): WSL/Ubuntu was exercised and Pi 0.85.1 was installed locally under |
There was a problem hiding this comment.
Important
Two things to settle before merge. The readiness wait can block an explicit Pi/OMP WSL launch for the full 10s timeout whenever the relay can never start, and I can't find the guest Pi/OMP materialization this wait is anchored to — as landed, the WSL relay install pass still only materializes the OpenCode plugin. Details inline and below.
Reviewed changes
- Await helper (new).
awaitExplicitPiOmpGuestReadiness()callsensureForDistroand pollsgetGuestEndpointFilePath(25ms, 10s default) for explicit WSLpi/omplaunches, returning early for everything else. - Manager readiness signal.
getGuestEndpointFilePathnow returns the path only onceconnectedAtis set, so callers see a guest endpoint only afterrunWslRelayGuestInstallcompletes. - Local and daemon spawn wiring. Both
provider/local-configure.tsandruntime/spawn-preflight.tsawait the helper beforebuildPtyHostEnv;prime-agent, non-WSL, and bare shells skip it. - Tests. New cases cover the warm path, an install-gated readiness run, startup failure, timeout, and a bare shell.
⚠️ The awaited guest materialization does not install Pi/OMP extensions
The gate resolves when connectedAt is set, i.e. after runWslRelayGuestInstall. That pass does not write a Pi/OMP extension into the guest: installWslGuestHooks only runs the remote installer list (claude, codex, gemini, … — no Pi/OMP), and the WSL relay's createInstallPluginsHandler materializes only the OpenCode overlay. defaultWslHookRelayDeps.pluginSources ships only opencodePluginSource, and the WSL relay never calls PluginOverlayManager.materializePi. Waiting therefore cannot make ~/.pi/agent/extensions/orca-agent-status.ts exist in WSL — the outcome #19739 requires. If the source shipping and guest materialization land in a companion change, linking it here would make the intent clear; otherwise this PR alone won't resolve the issue.
Technical details
# Waited-for guest materialization has no Pi/OMP producer
## Affected sites
- `src/main/agent-hooks/wsl-hook-relay-manager.ts:286-291` — `connectedAt` is set after `runWslRelayGuestInstall`, which is the signal the helper polls.
- `src/main/agent-hooks/wsl-hook-relay-guest-install.ts:39-56` — install pass = `installWslGuestHooks` + `requestGuestOpenCodeOverlayDir`; neither write a Pi/OMP extension.
- `src/main/agent-hooks/remote-managed-hook-installers.ts:44-76` — installer list has no `pi`/`omp`/`prime-agent`.
- `src/relay/wsl-install-plugins-handler.ts:56-91` — only `materializeOpenCode`; Pi/OMP sources are cached but never materialized.
- `src/main/agent-hooks/wsl-hook-relay-deps.ts:121-122` — `pluginSources` ships `opencodePluginSource` only.
- `src/main/pty/wsl-orca-env.ts:100-103` — WSLENV passthrough lists `ORCA_OMP_SOURCE_AGENT_DIR`/`ORCA_OMP_STATUS_EXTENSION` but not the Pi equivalents.
## Required outcome
- An explicit WSL `pi`/`omp` launch must result in the guest `~/.pi/agent/extensions/orca-agent-status.ts` existing before the agent starts, without creating `~/.pi` for bare shells (#10196).
## Open questions for the human
- Is the guest Pi/OMP materialization landing in a companion PR? If so, link it and note the dependency; if it is meant to be in this PR, the wait has nothing to synchronize with.ℹ️ Nitpicks
- The readiness result is discarded at both call sites (
local-configure.ts:67,spawn-preflight.ts:269), so a timeout/failure is indistinguishable from success to the caller. Either consume the boolean or returnvoidto make the "delay only" contract explicit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Windows/WSL runtime verification on
Therefore the actual #19739 symptom is not fixed by this PR as currently written. I am leaving #21721 unmerged. The relay readiness wait is exercised, but it cannot be called complete issue verification until the guest Pi extension is written and Pi starts with that file available before prompt dispatch. |
0608e2e to
a4c0c9d
Compare
Verification updateELI5: Pi was starting before its WSL extension existed. The relay now copies the extension into the WSL home first, then Pi starts with that guest path. Verified on the real Windows host
|
There was a problem hiding this comment.
Important
The new guest-path env wiring in buildPtyHostEnv is discarded before the env leaves the function, so the relay-materialized Pi/OMP paths never reach the guest; and requiring the guest agent path in the readiness gate adds a fresh full-timeout stall whenever the extension cannot be materialized. Details inline.
Reviewed changes
- Guest-side Pi/OMP materialization. The WSL relay's
createInstallPluginsHandlernow callsPluginOverlayManager.materializePifor an explicitly requestedpi/ompand returnsoverlayDirs.pi/overlayDirs.omp;defaultWslHookRelayDeps.pluginSourcesnow shipspiExtensionSource/ompExtensionSource. launchKindplumbing.ensureForDistro(distro, home, kind)→ensureInternal→runWslRelayGuestInstall→ the guest install request; the manager storespiAgentDir/ompStatusExtension/launchKindand resetslastInstallAtso a running relay re-runs install when the kind changes.- Readiness gate.
awaitExplicitPiOmpGuestReadinessnow requires both the guest endpoint andgetGuestAgentPath(distro, kind)before returning. - PTY env export.
buildPtyHostEnvsetsORCA_PI_SOURCE_AGENT_DIR/ORCA_OMP_STATUS_EXTENSIONfrom the guest paths. - State-machine extraction.
markWslRelayFailed,resumeWslStoppedRelays,resolveWslDefaultDistromoved tosrc/main/agent-hooks/wsl-hook-relay-state-machine.ts, with tests for the Pi materialization and readiness wait.
ℹ️ Nitpicks
- The header comments at
src/relay/wsl-install-plugins-handler.ts:5andsrc/main/agent-hooks/wsl-hook-relay-deps.ts:122still say WSL scope is OpenCode-only and Pi/OMP land "later" — now contradicted by this commit. markWslRelayFailed(src/main/agent-hooks/wsl-hook-relay-state-machine.ts:38) drops the distro from the warn prefix the extracted code carried ([agent-hooks] WSL hook relay (${state.distro}): …), which matters when several distros are live.- The readiness tests don't isolate the new gate: the fake
AGENT_HOOK_INSTALL_PLUGINS_METHODhandler returnspi/ompdirs regardless oflaunchKind, and the assertions check the OpenCode overlay, so they would still pass if onlygetGuestEndpointFilePathgated.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
6330441 to
1a1a038
Compare
Verification update (corrected head)ELI5: Pi was starting before its WSL extension existed. The relay now copies the extension into the WSL home first, then Pi starts with that guest path. The runtime proof was exercised on real Windows host
|
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: 1fe3f9ea-a987-4d62-a0c6-6a9fc4c2910b
📒 Files selected for processing (12)
src/main/agent-hooks/wsl-guest-plugin-install.tssrc/main/agent-hooks/wsl-hook-relay-deps.tssrc/main/agent-hooks/wsl-hook-relay-guest-install.tssrc/main/agent-hooks/wsl-hook-relay-manager.test.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state-machine.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/agent-hooks/wsl-pi-omp-guest-readiness.tssrc/main/ipc/pty-spawn-env-terminal-basics.test.tssrc/main/ipc/pty/host-env/assembly.tssrc/relay/wsl-install-plugins-handler.test.tssrc/relay/wsl-install-plugins-handler.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Review feedback addressed in
|
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: ea51b8d8-5a8f-4da3-ae60-d59c55723f9f
📒 Files selected for processing (8)
src/main/agent-hooks/wsl-hook-relay-guest-install.tssrc/main/agent-hooks/wsl-hook-relay-manager.tssrc/main/agent-hooks/wsl-hook-relay-state.tssrc/main/agent-hooks/wsl-pi-omp-guest-readiness.tssrc/main/ipc/pty-spawn-env-terminal-basics.test.tssrc/main/ipc/pty-write-ipc-validation.test.tssrc/main/ipc/pty/host-env/assembly.tssrc/main/pty/wsl-orca-env.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/agent-hooks/wsl-hook-relay-state.ts
- src/main/ipc/pty/host-env/assembly.ts
- src/main/agent-hooks/wsl-pi-omp-guest-readiness.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| if (state.installation) { | ||
| await state.installation | ||
| return |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '45,230p' src/main/agent-hooks/wsl-hook-relay-manager.ts
sed -n '1,140p' src/main/agent-hooks/wsl-hook-relay-guest-install.ts
rg -n "maybeRerunWslRelayGuestInstall|runWslRelayGuestInstall|lastInstallAt|launchKinds|ensureForDistro" src/main/agent-hooksRepository: stablyai/orca
Length of output: 17540
🏁 Script executed:
sed -n '220,295p' src/main/agent-hooks/wsl-hook-relay-manager.ts
sed -n '230,450p' src/main/agent-hooks/wsl-hook-relay-manager.test.ts
sed -n '535,685p' src/main/agent-hooks/wsl-hook-relay-manager.test.ts
rg -n -C 6 "runWslRelayGuestInstall|maybeRerunWslRelayGuestInstall|installation|launchKind|pi|omp|codexHomePath" src/main/agent-hooks/*.test.ts src/main/agent-hooks/*guest-install*Repository: stablyai/orca
Length of output: 45535
🏁 Script executed:
printf '%s\n' '--- manager connect/install path ---'
sed -n '245,285p' src/main/agent-hooks/wsl-hook-relay-manager.ts
printf '%s\n' '--- focused manager tests ---'
rg -n -C 12 "guest install|reinstall|launchKind|codexHomePath|installation|startup" src/main/agent-hooks/wsl-hook-relay-manager.test.ts
printf '%s\n' '--- guest install tests/files ---'
fd -i 'wsl-hook-relay.*(test|spec)?\\.(ts|tsx)$' src/main/agent-hooks
rg -n -C 12 "maybeRerunWslRelayGuestInstall|runWslRelayGuestInstall|installation|launchKinds|lastInstallAt" src/main/agent-hooks/wsl-hook-relay-guest-install* src/main/agent-hooks/*guest-install*.test.ts 2>/dev/null || trueRepository: stablyai/orca
Length of output: 20056
🏁 Script executed:
printf '%s\n' '--- reinstall constants and uses ---'
rg -n -C 8 "REINSTALL_(MIN_INTERVAL|ONE_SHOT_DELAY)_MS|scheduleOneShotReinstall" src/main/agent-hooks
printf '%s\n' '--- recovery implementation ---'
fd -i 'wsl.*recovery.*\\.ts$' src/main/agent-hooks
rg -n -C 15 "scheduleOneShotReinstall|oneShotReinstall|clearTimers" src/main/agent-hooks/wsl-*recovery*.ts src/main/agent-hooks/*recovery*.ts 2>/dev/null || trueRepository: stablyai/orca
Length of output: 30960
Replay requirements changed during an active installation.
When state.installation exists, maybeRerunWslRelayGuestInstall waits for it and returns. If an overlapping caller changes codexHomePath or adds a launch kind during that pass, the caller resolves without installing the new requirement. Continue through the normal reinstall checks after the awaited installation instead of returning.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the incremental delta 1a1a038 → b4f85d5 on top of the earlier a4c0c9d guest-materialization work. All three prior Pullfrog threads (relay-cannot-start stall, materialization-refused stall, discarded guest env) are addressed by this commit and were resolved.
- Readiness stopped polling.
awaitExplicitPiOmpGuestReadinessnow racesensureForDistro(...)against the timeout, so the gate resolves as soon as the install pass settles and only a relay whose startup never settles pays the full 10s. ensureForDistro/ensureInternalbecame async and share startup. A running relay awaits the rate-limited reinstall, a starting or cooling-down relay awaitsexisting.startup, and a fresh state storesstartupso concurrent callers join the same launch instead of no-oping.- Per-kind install state replaced the single
launchKind.launchKinds: Setdrives a per-kind install loop that recordspiAgentDir/ompStatusExtension;installationdedups concurrent passes and a newly requested kind resetslastInstallAtso the pass re-runs. - Guest Pi/OMP env now reaches the guest. The
ORCA_PI_SOURCE_AGENT_DIR/ORCA_OMP_STATUS_EXTENSIONassignment moved belowclearPiAgentShadowEnvand the host extension blocks, andwsl-orca-env.tscrosses them as/uwhen they hold guest POSIX paths. - Tests updated for the async 3-arg signature and cover readiness waiting on a gated install, startup failure, timeout, and the bare-shell skip.
Verification: pnpm tc:node passed; the six changed test files passed (104 tests).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
ebb8a35 to
baa88d2
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — one rebase-hygiene suggestion inline.
Reviewed changes — the delta since pullfrog review 5261791541 on b4f85d5: a rebase onto current main with no content change to any PR file, plus one duplicate-helper issue the new base surfaces.
- Rebased onto current
main. Every one of the 17 PR files is byte-identical to the previously reviewedb4f85d5(diff-treerestricted to the PR paths is empty); only the base advanced.main's newerclearPiAgentShadowEnv/ host-extension ordering inassembly.tsstill leaves the guest Pi/OMP env assignment (new lines 229-242) last, so the prior fix holds. main's extracted helpers became unreferenced.wsl-hook-relay-state-machine.tsre-declaresresolveWslDefaultDistro/resumeWslStoppedRelays, which now duplicatemain'swsl-hook-default-distro.ts/wsl-hook-relay-resume.tsand leave those modules with no callers. Details inline.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| } | ||
| } | ||
|
|
||
| export async function resolveWslDefaultDistro( |
There was a problem hiding this comment.
resolveWslDefaultDistro here, and resumeWslStoppedRelays above it, duplicate main's resolveWslHookDefaultDistro (wsl-hook-default-distro.ts:1) and resumeStoppedWslHookRelays (wsl-hook-relay-resume.ts:1) exactly, and main's manager was those modules' only caller. After this rebase the branch leaves both files unreferenced, so the tree ships two implementations of each. Prefer importing the existing helpers, or delete the now-dead files in this PR.
Technical details
# Rebase leaves `main`'s extracted WSL helpers dead
## Affected sites
- `src/main/agent-hooks/wsl-hook-relay-state-machine.ts:42` — `resumeWslStoppedRelays` duplicates `wsl-hook-relay-resume.ts:1`.
- `src/main/agent-hooks/wsl-hook-relay-state-machine.ts:60` — `resolveWslDefaultDistro` duplicates `wsl-hook-default-distro.ts:1`.
- `src/main/agent-hooks/wsl-hook-relay-manager.ts:31-35` — imports the state-machine copies; `main`'s manager imported the two files instead.
- `wsl-hook-default-distro.ts` / `wsl-hook-relay-resume.ts` — `git grep` on HEAD matches only their own declarations; no callers remain.
## Required outcome
- One implementation of each helper. Either the manager imports `resolveWslHookDefaultDistro`/`resumeStoppedWslHookRelays` from their existing modules (keeping only `markWslRelayFailed` in `wsl-hook-relay-state-machine.ts`), or those two files are deleted so the state-machine copies are the sole definitions.
## Open questions for the human
- Were `wsl-hook-default-distro.ts` and `wsl-hook-relay-resume.ts` added to `main` after this branch forked, and is the intent for the branch to adopt them? If a follow-up is planned, a note would avoid the dead-code window.…ike host spawns (#29780) A Pi or OMP agent started from the window inside WSL, with the terminal daemon on, could start before the distro's hook relay was up. It then reported no working/idle status for that session. Host starts and local-provider starts already waited (#21721); the window's daemon path was the one left out. The shared host-env step now always runs the wait on the daemon spawns it builds, so the lane input that skipped it for window starts is gone. The wait is a no-op for anything but an explicit Pi/OMP launch in WSL.

ELI5
Pi can run inside WSL, but WSL has a different home directory from Windows. Orca was starting Pi before the managed status extension had been copied into that WSL home, so the first prompt could stall and the session was invisible in the sidebar.
This change waits for the WSL relay's guest installation to finish for explicit Pi/OMP launches. Plain shells remain lazy and do not create Pi configuration.
What changed
Proof
ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/main/agent-hooks/wsl-hook-relay-manager.test.ts— 25 passed.pnpm tc— passed.Readiness checklist
Completed runtime proof
On
win-lowspecusing the rebuilt app (ORCA_BACKGROUND_LAUNCH=1, CDP9345) at commit1a1a0382b6e:launchAgent: pi,wslDistro: Ubuntu, and a new PTY.~/.pi/agent/extensions/orca-agent-status.tswas non-empty (29,883bytes) and began with// @orca-managed-pi-extension.0.85.1reached its interactive TUI prompt; the captured buffer showed/home/orcatest/.npm/_npx/...and the Pi prompt (π - neil).launchAgent: pi,wslDistro: Ubuntu, and reached the same prompt without reinstalling dependencies.Fixes #19739