Skip to content

fix(agents): route WSL OMP hooks to the Windows listener (#7565) - #7641

Merged
brennanb2025 merged 3 commits into
stablyai:mainfrom
rodboev:pr/orca-7565-wsl-omp-hook-bridge
Jul 9, 2026
Merged

brennanb2025 merged 3 commits into
stablyai:mainfrom
rodboev:pr/orca-7565-wsl-omp-hook-bridge

Conversation

@rodboev

@rodboev rodboev commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Route the bundled WSL OMP status extension through Windows curl.exe after native fetch fails, so loaded WSL OMP agents can reach the Windows loopback hook listener. The primary fetch path stays in place, /hook/omp routing stays unchanged, and src/main/pty/wsl-orca-env.ts is untouched.

Closes #7565.
Related issue: #7377.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/main/pi/agent-status-extension-source.test.ts
  • pnpm exec vitest run --config config/vitest.config.ts src/main/pty/wsl-orca-env.test.ts
  • pnpm run typecheck:node

AI Review Report

  • Cross-platform behavior stays narrow: macOS, Linux, native Windows, and SSH relay paths keep using the existing fetch transport.
  • WSL only gets the Windows curl.exe fallback after the current POST fails, so the bridge does not duplicate successful deliveries.
  • The change stays inside the generated Pi/OMP status extension, so OMP extension loading and other PTY wiring remain owned by their existing targets.
  • No visual change.
  • Provider behavior stays neutral because the hook payload and listener contract are unchanged.

Security Audit

  • The fallback only runs when WSL evidence is present and /mnt/c/Windows/System32/curl.exe exists.
  • WSLENV alone does not enable the bridge.
  • The hook token still goes out in X-Orca-Agent-Hook-Token, and the listener stays on Windows loopback.
  • Fail-open behavior remains intact when native fetch fails, when curl is missing, or when the bridge exits nonzero.

Notes

  • The change stays scoped to loaded Pi/OMP status-extension transport. OMP extension loading remains separate from this transport fix.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6a2c74f8-e438-45fd-b614-0f6e70017d67

📥 Commits

Reviewing files that changed from the base of the PR and between a021319 and 204fed6.

📒 Files selected for processing (2)
  • src/main/pi/agent-status-extension-source.test.ts
  • src/main/pi/agent-status-extension-source.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/pi/agent-status-extension-source.ts
  • src/main/pi/agent-status-extension-source.test.ts

📝 Walkthrough

Walkthrough

This change adds a WSL-aware fallback to the generated Pi agent status hook sender. If loopback fetch POSTs fail, the code now detects WSL, checks for /mnt/c/Windows/System32/curl.exe, and retries the same JSON payload through Windows curl.exe. A new Vitest suite exercises native fetch routing, curl fallback invocation, and fail-open behavior across WSL and non-WSL cases.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the WSL OMP hook transport fix and matches the main change.
Description check ✅ Passed The description covers summary, testing, review, security, and notes, but it omits a dedicated Screenshots section.
Linked Issues check ✅ Passed The change matches #7565 by adding a WSL-only fallback that routes OMP status posts to Windows curl.exe when fetch fails.
Out of Scope Changes check ✅ Passed The diff stays focused on the WSL OMP transport fix and its regression tests, with no clear unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/pi/agent-status-extension-source.ts (1)

164-188: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

Correctness looks solid; consider that spawnSync blocks the event loop.

The argument list, JSON content-type, and --data-binary @-`` faithfully reproduce the native fetch payload and reuse the same `X-Orca-Agent-Hook-Token` contract, and passing the token as a discrete argv element (no shell) avoids injection.

One consideration: spawnSync runs synchronously inside the async post(). In a sustained WSL failure state, the fallback fires on every hook event (status hooks fire multiple times per turn), each blocking the pi process for up to --connect-timeout/--max-time before returning. If the Windows loopback is reachable this is fast, but in a partial-failure scenario it can stall the TUI. An async spawn (promisified) would keep the event loop responsive. Optional given the bounded timeouts and fail-open intent.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e3a1d2bc-e500-4fe8-a1de-89e094f76df1

📥 Commits

Reviewing files that changed from the base of the PR and between 98d850a and 05cf779.

📒 Files selected for processing (2)
  • src/main/pi/agent-status-extension-source.test.ts
  • src/main/pi/agent-status-extension-source.ts

@euclodius

Copy link
Copy Markdown

This looks like the right narrow fix for the OMP/Pi status-extension transport. One cross-link so the broader WSL hook class does not get lost: #6907 appears to need a separate Codex-specific owner proof/fix.

In the same Windows desktop + WSL runtime setup, Codex had the same WSL -> Windows listener boundary problem, but through Orca's native Codex hook contract rather than the OMP/Pi generated status extension. The local workaround made Codex appear in the sidebar only after forwarding Codex hook events across that boundary.

So #7641 may close #7565 for OMP, but I do not think it covers Codex sidebar/status in #6907 unless there is another Codex hook transport path being fixed elsewhere.

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for digging into this and for the fix — routing the fallback through Windows-side curl is the right call here, since it keeps the hook listener loopback-only. We're going to pick this up and apply a few adjustments on our side before landing it (async delivery instead of a blocking spawn per event, plus a couple of small hardening tweaks). Appreciate the thorough tests!

brennanb2025 and others added 2 commits July 7, 2026 21:29
The fallback ran spawnSync inside the pi/omp process on every hook
event whenever the loopback fetch failed — which on WSL-NAT is every
event — blocking the TUI's event loop for the full curl round-trip.
Delivery is fire-and-forget, so use async spawn with the payload fed
via stdin and errors swallowed (the bridge stays best-effort).

Also:
- Add --noproxy 127.0.0.1 so a proxy env var in the WSL shell cannot
  route the token and payload off-box (matches the shell hook scripts).
- Memoize the WSL evidence and curl.exe probes — process-lifetime
  constants; the per-event failure path must not re-read /proc or
  stat /mnt/c each time.
- Restore the fail-open why-comment the bridge displaced and document
  why delivery must not block.

Tests updated to pin the async spawn shape (stdin payload, stdio
config, error listeners) plus a probe-once memoization test.

Co-authored-by: Orca <help@stably.ai>
Windows validation showed --connect-timeout 0.5 dropping 3/3 events to
a healthy listener while the machine was under load (dev app + WSL
hydration running); the same posts succeeded at 3s. The tight bounds
were sized for the old blocking spawnSync path where every millisecond
held the pi event loop — the spawn is now detached, so the timeouts
bound a background curl process, not the TUI. Raise to
--connect-timeout 3 / --max-time 10 so loaded Windows+WSL machines
stop dropping status events.

Co-authored-by: Orca <help@stably.ai>
@brennanb2025
brennanb2025 merged commit 01d21cd into stablyai:main Jul 9, 2026
1 check passed
Jinwoo-H added a commit that referenced this pull request Jul 9, 2026
Clean auto-merge, no conflicts. Brought in from main:
- daemon boot hardening: fail builds/CI when terminal daemon can't start;
  plain-node-entry-guard + verify-packaged-daemon-entry (electron require
  leaked into daemon-entry chunk, #7844/#7849)
- perf(windows): relax whole-process-table scans for terminals with no
  agent evidence (#7607) — foreground-scan-cadence
- fix(agents): route WSL OMP hooks to the Windows listener (#7565/#7641)
- fix: recover fresh local terminal spawns from a deleted saved cwd (#7847)
- native-chat: upload composer attachments over SSH (#7832)
- mobile: keyboard dismiss control; agent-tab launch fix
- new GitHub issue draft persistence (#7778)

Perf-branch structure preserved (clean auto-merge; no restructured terminal
files conflicted). Gates: typecheck 0 errors; terminal-pane + ipc/pty +
daemon + pane-manager suites 4497 passed / 14 skipped / 0 failed.

Co-authored-by: Orca <help@stably.ai>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…) (stablyai#7641)

Co-authored-by: Orca <help@stably.ai>
Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
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.

[Bug]: WSL OMP agents no longer appear in the worktree sidebar after v1.4.124

3 participants