Skip to content

fix(agent-hooks): exit Windows hooks when Orca env is missing - #11568

Merged
brennanb2025 merged 13 commits into
stablyai:mainfrom
innocarpe:fix/codex-hook-no-more-com-drain
Aug 9, 2026
Merged

brennanb2025 merged 13 commits into
stablyai:mainfrom
innocarpe:fix/codex-hook-no-more-com-drain

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

Stop Windows managed agent hooks (Codex/Claude/etc.) from hanging in more.com when invoked outside an Orca pane without ORCA_* env.

User-wide Codex hooks still run for non-Orca sessions. Missing PORT/TOKEN/PANE_KEY now exit /b 0 immediately instead of routing to the stdin-drain epilogue that can leave visible cmd.exe + more.com processes forever.

Focused fix

  • In scope: buildWindowsHookEnvironmentGuardLines() missing-env path
  • Out of scope: removing drain for other failure modes, changing happy-path curl post

Preserves

  • Full Orca env still posts hook payloads via curl as today
  • Drain epilogue remains for non-env failure paths that still need stdin ownership

Evidence

  • Test: pnpm exec vitest run --config config/vitest.config.ts src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts src/main/codex/hook-service.test.ts src/main/claude/hook-service.test.ts src/main/agent-hooks/installer-utils.test.ts (92 passed, 10 skipped)
  • Guard lines assert exit /b 0 and no goto drain for missing env

User-regression-tradeoffs

  • Outside-Orca hooks still flash briefly via cmd.exe /C (Codex launcher); they no longer stick open

Fixes #11549

@coderabbitai

coderabbitai Bot commented Jul 30, 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 Plus

Run ID: 163aca1e-9acc-47db-8c17-d2da29d4088e

📥 Commits

Reviewing files that changed from the base of the PR and between 58a4728 and 074279f.

📒 Files selected for processing (2)
  • src/main/agent-hooks/hook-stdin-contract.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/agent-hooks/hook-stdin-contract.ts

📝 Walkthrough

Walkthrough

Windows managed hook environment guards now exit successfully when required Orca port, token, or pane variables are missing. Windows hook execution refreshes endpoint credentials and applies environment guards before the Devin-specific skip. Lifecycle tests verify immediate exits, stdin draining for other failures, and permitted EPIPE or ECONNRESET errors for .cmd hooks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and tests but omits most required template sections, including the security audit and AI review report. Use the required headings and add screenshots status, test checklist, AI review details, cross-platform review confirmation, security audit, and notes.
Out of Scope Changes check ⚠️ Warning The Claude/Devin guard reorder extends behavior beyond the linked Codex issue, which states that other agents should remain unchanged [#11549]. Remove the Claude-specific changes or link a separate issue that requires the broader managed-hook guard behavior.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary Windows hook behavior change.
Linked Issues check ✅ Passed The changes address the core issue by exiting on missing Orca variables, preventing more.com hangs while preserving the configured payload path [#11549].
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.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a Windows-specific process hang where managed agent hooks (Codex, Claude, etc.) registered as user-wide hooks would leave cmd.exe + more.com processes running indefinitely when invoked outside an Orca pane. The root cause was that more.com waits for EOF, but the hook caller (the agent) never closes stdin in the no-Orca-context case.

  • buildWindowsHookEnvironmentGuardLines() now emits exit /b 0 for each missing env var check instead of goto :orca_agent_hook_drain_stdin, so the batch script exits immediately without touching more.com when ORCA_AGENT_HOOK_PORT, ORCA_AGENT_HOOK_TOKEN, or ORCA_PANE_KEY are absent.
  • The buildWindowsHookStdinDrainEpilogue() function and its label remain in every generated script, still reachable from other failure-path goto statements (e.g., missing script files), preserving stdin ownership for those cases.
  • Tests are updated with explicit positive (exit /b 0) and negative (not.toContain goto :orca_agent_hook_drain_stdin) assertions, plus a comment linking to issue [Bug]: Codex managed hook leaves persistent cmd.exe windows outside Orca on Windows #11549.

Confidence Score: 5/5

Safe to merge — the change is a one-function edit to a well-tested, centrally-consumed helper, and it directly eliminates the hanging process class without touching the happy path.

The fix is minimal and mechanically correct: swapping goto :orca_agent_hook_drain_stdin for exit /b 0 in the three env-guard lines prevents more.com from blocking when the agent never closes stdin. The drain epilogue label and its more.com invocation remain in every generated script for other goto failure paths, so those cases are unaffected. The centralized function means the change propagates to all 10+ hook services automatically, and tests include explicit negative assertions to prevent regression to the old form.

Files Needing Attention: No files require special attention. Both changed files are straightforward — the implementation change is a 3-line swap in a pure string-builder function, and the test changes mirror it exactly.

Important Files Changed

Filename Overview
src/main/agent-hooks/hook-stdin-contract.ts Core change: replaces goto :orca_agent_hook_drain_stdin with exit /b 0 in the env-guard lines; drain epilogue function is untouched and all 10+ hook services consume this function centrally, so the fix propagates consistently.
src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts Test updated with both positive assertions for exit /b 0 and negative assertions confirming the old goto form is gone; the drain-epilogue assertion is preserved, confirming non-env failure paths still route to more.com.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent invokes Windows .cmd hook] --> B{ORCA_AGENT_HOOK_ENDPOINT defined?}
    B -- Yes --> C[call endpoint file to refresh env]
    B -- No --> D{ORCA_AGENT_HOOK_PORT set?}
    C --> D
    D -- No --> E["exit /b 0 (was: goto drain → more.com hangs)"]
    D -- Yes --> F{ORCA_AGENT_HOOK_TOKEN set?}
    F -- No --> E
    F -- Yes --> G{ORCA_PANE_KEY set?}
    G -- No --> E
    G -- Yes --> H[curl POST hook payload to Orca server]
    H --> I[exit /b 0]
    H -- curl fails / other error --> J[goto :orca_agent_hook_drain_stdin]
    J --> K["more.com reads stdin to EOF"]
    K --> L[exit /b 0]
Loading

Reviews (1): Last reviewed commit: "fix(agent-hooks): exit Windows hooks whe..." | Re-trigger Greptile

…tdin handoff

The Windows-only executable matrix still asserted every managed .cmd drains
its writer, which the missing-env fast exit intentionally stops doing. That
assertion never runs in CI (vitest is ubuntu-only), so it would only fail on
a Windows dev machine.

- Accept a broken writer for .cmd hooks on the missing-env path; keep the
  no-error contract for the PowerShell and Git Bash hooks that still read
  stdin first.
- Correct the drain-epilogue comment: claude-hook.cmd is the remaining
  in-script jump to it.
runHookProcess always closes stdin, so the executable case cannot reproduce
the abandoned-pipe hang; say so and name the guard strings as the real gate.
Also record that the Devin skip guard still routes to the drain above these
guards, so stablyai#11549 stays reachable for Devin outside an Orca pane.
…tdin policy

The two templates now answer the same question opposite ways and nothing states
the rule, so name the constraint (batch has no bounded stdin reader) and the
evidence (POSIX callers have not shown the abandon; Windows callers have).
…aiming

The renamed case covers two missing-script launchers that still read to EOF, so
'without stranding a reader' was false for them. Payload size was also the wrong
reason for the .cmd exit — the statusline script buffers the same size through
more.com; the real constraint is that any read-to-EOF hangs on an abandoned pipe.

Also record that the broken-writer relaxation is only sound because
hookEnvironment() strips every ORCA_* var, since the branch keys on .cmd.
The revert pin was three exact string denials, so a fourth ORCA_* guard — copied
from the nearest in-repo pattern, which still routes to the drain — would have
reintroduced stablyai#11549 with the suite green. Assert instead that no ORCA_* guard in
a generated .cmd routes to the more.com drain.

Verified both directions: reverting the source fails it, and adding a simulated
ORCA_TAB_ID guard that gotos the drain fails it too. Does not match the Devin
skip, which is not an ORCA_* guard and whose caller is a live Orca pane.
…-contradicting

The previous wording set a rule that claude/statusline-script.ts breaks 25 lines
away in the same export surface, and said nothing about the Windows .ps1 and Git
Bash hooks. State the rule for generated .cmd, then name every hook that still
reads first and why — the read is the payload capture, not a drain. Batch is the
exception because it streams to curl, so owning stdin buys nothing there.
The guard-spelling regex only covered `if "%VAR%"==""`, but `if not defined VAR`
is equally house idiom here — every Windows hook opens with `if defined
ORCA_AGENT_HOOK_ENDPOINT`. A fourth guard written that way routed to the drain
with the suite green. Match the whole line instead of one spelling, which also
covers `goto` without its colon.

Probed all eight cases: the five bypass spellings are caught, and the Devin skip,
the endpoint refresh, and the fixed guard are correctly exempt.
… .cmd rule

The list conflated them. POSIX, copilot .ps1 and kimi .sh read first because the
read is the payload capture. claude/statusline-script.ts does route its guard to
the drain — it is exempt because its caller closes stdin, which the in-pane
capture already proves. Grouping them under 'the read is the capture' would let a
future author reach the right conclusion from the wrong premise.
…vin skip

claude-hook.cmd checked DEVIN_PROJECT_DIR before the Orca env guards, and that
check jumps to the more.com drain. Outside an Orca pane the caller is not Orca's
PTY, so it can abandon stdin and leave more.com waiting forever — the stablyai#11549 hang
this guard reordering is meant to close.

Both branches end the hook, so the only behavior that changes is Devin outside an
Orca pane: it now exits 0 instead of parking in more.com. In-pane Devin still
reaches the skip and still owns stdin.

Depends on stablyai#11568.
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for this — good catch on the root cause, and the fix is the right shape.

Heads up that I pushed a few commits directly to this branch. Here's what changed and why:

Folded in one more instance of the same bug

  • claude-hook.cmd checked DEVIN_PROJECT_DIR before the Orca env guards, and that check jumps to the more.com drain. Devin imports .claude hooks by default, so a Devin session outside an Orca pane still parked in more.com forever — a known-reachable instance of exactly the bug this PR fixes. I moved the env guards above the Devin skip. Both branches end the hook, so nothing changes inside a pane; only the out-of-pane Devin case now exits 0 instead of hanging.

Made the regression test actually hold the line

  • The guard test pinned three exact string literals. A fourth ORCA_* guard copied from an existing pattern would have reintroduced [Bug]: Codex managed hook leaves persistent cmd.exe windows outside Orca on Windows #11549 with the suite still green — it now asserts the rule (no ORCA_* guard in a generated .cmd may route to the drain label) rather than the three guards that happen to exist today.
  • That rule also now catches the if not defined ORCA_X goto :drain spelling, which is the common idiom at several other sites and was slipping straight through.
  • The Windows launch matrix asserted that every .cmd drains its writer, which your fix deliberately makes false. Fixed that, plus its name and a comment that both claimed more than the test checked.

Docs

Verified on a real Windows host: before the change, the missing-env path left a live more.com child and never exited; after, it exits 0 promptly with no child. The happy path (ORCA env present) is unchanged — the POST still lands.

Two things I saw but left out of this PR so they don't get lost:

  • managed-agent-hook-controls.ts skips install on cli_not_found without removing an already-installed script, and hook scripts are never deleted — so a user whose CLI moved keeps the leaking script indefinitely. Worth a follow-up.
  • copilot-hook.ps1 and kimi-hook.sh have the same hang class, but they need a bounded read rather than this fix.

One thing for the release notes whenever this lands: it stops new stuck processes but can't reap ones that leaked before the upgrade, so anyone with leftover cmd.exe/more.com will need to kill them or reboot once.

@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/claude/hook-service.ts (1)

64-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce these comments to concise rationale.

Keep only the non-obvious reason at each site.

  • src/main/claude/hook-service.ts#L64-L68: use short comments for endpoint refresh and guard ordering.
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts#L273-L284: shorten the regex rationale and drain-label note.
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts#L294-L296: shorten the guard-order rationale.
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts#L369-L374: shorten the broken-writer rationale.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bd7b223a-e907-4c4e-a30a-e9acc69884f2

📥 Commits

Reviewing files that changed from the base of the PR and between a69d862 and b83d724.

📒 Files selected for processing (3)
  • src/main/agent-hooks/hook-stdin-contract.ts
  • src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts
  • src/main/claude/hook-service.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/agent-hooks/hook-stdin-contract.ts

# Conflicts:
#	src/main/claude/hook-service.ts
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@brennanb2025

Copy link
Copy Markdown
Contributor

Correction on my earlier push: it left this branch conflicting with main in src/main/claude/hook-service.ts. The branch was well behind main, and main had since reworded the same block I moved, so the change landed here textually collided once it was published.

Fixed by merging latest main in and resolving that block: main's current wording and structure are kept, and the guard reorder is re-applied on top — env guards above the Devin skip. Diffing the Windows branch against main shows the same set of emitted lines in a different order, so the behavior delta is still just the reorder.

agent-hooks + claude hook suites, typecheck, and lint are green, and the PR is mergeable again. Sorry for the churn.

The three-line guard fix needed a three-line comment, not a thirteen-line
taxonomy adjudicating three other files. Swap the hand-rolled drain gate and
broken-writer set for the combinators already used repo-wide: not.toMatch
(94 uses) and toContain on a literal.
@brennanb2025

Copy link
Copy Markdown
Contributor

Follow-up from a standard-fix audit pass over this PR — no change to your fix, which was right.

Swapping the three ORCA_* guards from goto :orca_agent_hook_drain_stdin to exit /b 0 is exactly the standard shape here: batch streams the payload straight to curl instead of capturing it, so the guard has nothing to lose by giving up stdin, and more.com draining to EOF is precisely what strands the process when the caller abandons the pipe. Three lines, no new machinery. Your diagnosis of #11549 and the mechanism you chose are what ships.

The audit was aimed at my own review commits on top of yours, and it found two things worth cutting:

  • The gate I added asserting "no ORCA_* guard routes to the drain" was hand-rolled as script.match(/^.*…*$/gm) + .toBeNull(). That is just expect(script).not.toMatch(/…/), which this repo already uses in 94 places. Verified equivalent: with a synthetic fourth guard added in the other house spelling (if not defined ORCA_AGENT_HOOK_ENV goto :…) and all three real guards left intact, the rewritten gate still fails.
  • A module-level BROKEN_WRITER_CODES = new Set([...]) asserted via .has(x)).toBe(true) — used once, 280 lines from its definition. Inlined to expect(['EPIPE', 'ECONNRESET']).toContain(error.code), which also gives a real diff on failure instead of "expected false to be true."

I also cut the comment I had grown on buildWindowsHookEnvironmentGuardLines from 13 lines back to 4. It had turned into a taxonomy adjudicating three other files' exemptions, and one of those claims (that the statusline caller provably closes stdin) was stated more firmly than the evidence supports — for a file this PR does not touch. Net −20 lines, all mine.

Behavior is unchanged and pinned: reverting the guards to goto, reverting the guard/Devin-skip ordering, and adding a fourth drain-routed guard each turn the suite red. The Windows-only live matrix still skips off-win32, so that one is pinned by the generated-script assertions rather than by execution here.

@innocarpe

Copy link
Copy Markdown
Contributor Author

@brennanb2025 Thank you for taking this so carefully — and for co-authoring on the branch.

Your diagnosis of the Devin / DEVIN_PROJECT_DIR path was a real find: that would have left the same more.com hang outside an Orca pane even after the env-guard fix. The stronger regression rule (no ORCA_* guard routes to the drain, including the if not defined spelling), the merge conflict cleanup, and the standard-fix audit that trimmed the review-side nits all look right to me.

I’m good with landing your tip as-is. The two follow-ups you left out (stale hook scripts on cli_not_found, and the bounded-read hang class in copilot-hook.ps1 / kimi-hook.sh) make sense as separate focused PRs rather than packing them into this one.

Also noted for release notes: this stops new stuck processes but can’t reap ones that already leaked before upgrade.

@brennanb2025
brennanb2025 merged commit 9a6c5cd into stablyai:main Aug 9, 2026
43 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor

Thank you for the PR!!

brennanb2025 added a commit that referenced this pull request Aug 10, 2026
… unavailable (#13378)

* fix(agent-hooks): refresh existing shared hook scripts when the CLI is no longer detected

A CLI that falls off PATH (moved npm prefix, relocated shim) keeps its user-wide
config invoking Orca's launcher script under ~/.orca/agent-hooks, but the
presence gate skips install() with no removal — freezing the script at whatever
Orca generated last. Anyone in that state kept the pre-#11568 more.com-leaking
.cmd forever, because no launcher script is ever deleted and Windows startup
deliberately skips shell PATH hydration.

Reconcile before gating: every existing shared launcher/statusline script is
rewritten to the current template on each install pass. Creating scripts stays
behind the presence gate — an existing file is proof of a prior install; a
missing one means the gate did its job. Amp and Hermes are deliberately absent:
they write provider-native plugin code with its own install lifecycle, not
shared launchers.

- refreshManagedScriptIfPresent() in installer-utils (no-op unless the file exists)
- refreshManagedScripts() on the 11 launcher-writing services (openclaude via
  the shared Claude class)
- reconcile pass in installManagedAgentHooks before presence detection,
  filtered by the agents option, best-effort per agent
- coverage gate: a launcher written to ~/.orca/agent-hooks without a matching
  refresher entry fails the suite, in both directions

* perf(agent-hooks): refresh launchers off the main thread

* test(agent-hooks): keep refresh mode assertion POSIX-only
brennanb2025 added a commit that referenced this pull request Aug 12, 2026
…n stdin (#13379)

Same hang class #11568 closed for .cmd: copilot-hook.ps1 ran
[Console]::In.ReadToEnd() and kimi-hook.sh captured stdin before checking the
Orca env, so a user-wide hook fired outside an Orca pane blocked forever when
the caller abandoned the pipe — one stranded powershell.exe or bash.exe per
hook event.

Move the env guard (after the endpoint refresh, which can supply PORT/TOKEN)
above the read on the Windows-local variants. The payload is discarded on the
missing-env path anyway; the broken writer is the trade #11568 established.
POSIX variants keep capture-first — those callers close stdin, and exiting
mid-write there surfaces as EPIPE the agent can see (#8110). Kimi's remote
install now asks for the posix variant explicitly.

Verified on a real Windows host: pre-fix copilot with an abandoning caller
never exits; post-fix both exit 0 immediately, and the env-present copilot
path still consumes stdin and delivers the POST (paneKey + payload received
by a local listener).
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ai#11568)

* fix(agent-hooks): exit Windows hooks when Orca env is missing

* test(agent-hooks): pin the Windows missing-env exit as a deliberate stdin handoff

The Windows-only executable matrix still asserted every managed .cmd drains
its writer, which the missing-env fast exit intentionally stops doing. That
assertion never runs in CI (vitest is ubuntu-only), so it would only fail on
a Windows dev machine.

- Accept a broken writer for .cmd hooks on the missing-env path; keep the
  no-error contract for the PowerShell and Git Bash hooks that still read
  stdin first.
- Correct the drain-epilogue comment: claude-hook.cmd is the remaining
  in-script jump to it.

* docs(agent-hooks): cite stablyai#11549 and the stdin-ownership trade in the guard comment

* test(agent-hooks): stop overstating what the live matrix pins

runHookProcess always closes stdin, so the executable case cannot reproduce
the abandoned-pipe hang; say so and name the guard strings as the real gate.
Also record that the Devin skip guard still routes to the drain above these
guards, so stablyai#11549 stays reachable for Devin outside an Orca pane.

* docs(agent-hooks): record why Windows batch diverges from the POSIX stdin policy

The two templates now answer the same question opposite ways and nothing states
the rule, so name the constraint (batch has no bounded stdin reader) and the
evidence (POSIX callers have not shown the abandon; Windows callers have).

* test(agent-hooks): stop the live matrix name and comment from over-claiming

The renamed case covers two missing-script launchers that still read to EOF, so
'without stranding a reader' was false for them. Payload size was also the wrong
reason for the .cmd exit — the statusline script buffers the same size through
more.com; the real constraint is that any read-to-EOF hangs on an abandoned pipe.

Also record that the broken-writer relaxation is only sound because
hookEnvironment() strips every ORCA_* var, since the branch keys on .cmd.

* test(agent-hooks): gate the rule, not the three guards that exist today

The revert pin was three exact string denials, so a fourth ORCA_* guard — copied
from the nearest in-repo pattern, which still routes to the drain — would have
reintroduced stablyai#11549 with the suite green. Assert instead that no ORCA_* guard in
a generated .cmd routes to the more.com drain.

Verified both directions: reverting the source fails it, and adding a simulated
ORCA_TAB_ID guard that gotos the drain fails it too. Does not match the Devin
skip, which is not an ORCA_* guard and whose caller is a live Orca pane.

* docs(agent-hooks): name the exceptions so the stated rule is not self-contradicting

The previous wording set a rule that claude/statusline-script.ts breaks 25 lines
away in the same export surface, and said nothing about the Windows .ps1 and Git
Bash hooks. State the rule for generated .cmd, then name every hook that still
reads first and why — the read is the payload capture, not a drain. Batch is the
exception because it streams to curl, so owning stdin buys nothing there.

* test(agent-hooks): close the if-not-defined bypass in the drain gate

The guard-spelling regex only covered `if "%VAR%"==""`, but `if not defined VAR`
is equally house idiom here — every Windows hook opens with `if defined
ORCA_AGENT_HOOK_ENDPOINT`. A fourth guard written that way routed to the drain
with the suite green. Match the whole line instead of one spelling, which also
covers `goto` without its colon.

Probed all eight cases: the five bypass spellings are caught, and the Devin skip,
the endpoint refresh, and the fixed guard are correctly exempt.

* docs(agent-hooks): separate the two reasons a hook is exempt from the .cmd rule

The list conflated them. POSIX, copilot .ps1 and kimi .sh read first because the
read is the payload capture. claude/statusline-script.ts does route its guard to
the drain — it is exempt because its caller closes stdin, which the in-pane
capture already proves. Grouping them under 'the read is the capture' would let a
future author reach the right conclusion from the wrong premise.

* fix(agent-hooks): let the missing-Orca-env exit outrank the Claude/Devin skip

claude-hook.cmd checked DEVIN_PROJECT_DIR before the Orca env guards, and that
check jumps to the more.com drain. Outside an Orca pane the caller is not Orca's
PTY, so it can abandon stdin and leave more.com waiting forever — the stablyai#11549 hang
this guard reordering is meant to close.

Both branches end the hook, so the only behavior that changes is Devin outside an
Orca pane: it now exits 0 instead of parking in more.com. In-pane Devin still
reaches the skip and still owns stdin.

Depends on stablyai#11568.

* refactor(agent-hooks): cut the review additions back to house idiom

The three-line guard fix needed a three-line comment, not a thirteen-line
taxonomy adjudicating three other files. Swap the hand-rolled drain gate and
broken-writer set for the combinators already used repo-wide: not.toMatch
(94 uses) and toContain on a literal.

---------

Co-authored-by: Brennan Benson <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… unavailable (stablyai#13378)

* fix(agent-hooks): refresh existing shared hook scripts when the CLI is no longer detected

A CLI that falls off PATH (moved npm prefix, relocated shim) keeps its user-wide
config invoking Orca's launcher script under ~/.orca/agent-hooks, but the
presence gate skips install() with no removal — freezing the script at whatever
Orca generated last. Anyone in that state kept the pre-stablyai#11568 more.com-leaking
.cmd forever, because no launcher script is ever deleted and Windows startup
deliberately skips shell PATH hydration.

Reconcile before gating: every existing shared launcher/statusline script is
rewritten to the current template on each install pass. Creating scripts stays
behind the presence gate — an existing file is proof of a prior install; a
missing one means the gate did its job. Amp and Hermes are deliberately absent:
they write provider-native plugin code with its own install lifecycle, not
shared launchers.

- refreshManagedScriptIfPresent() in installer-utils (no-op unless the file exists)
- refreshManagedScripts() on the 11 launcher-writing services (openclaude via
  the shared Claude class)
- reconcile pass in installManagedAgentHooks before presence detection,
  filtered by the agents option, best-effort per agent
- coverage gate: a launcher written to ~/.orca/agent-hooks without a matching
  refresher entry fails the suite, in both directions

* perf(agent-hooks): refresh launchers off the main thread

* test(agent-hooks): keep refresh mode assertion POSIX-only
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…n stdin (stablyai#13379)

Same hang class stablyai#11568 closed for .cmd: copilot-hook.ps1 ran
[Console]::In.ReadToEnd() and kimi-hook.sh captured stdin before checking the
Orca env, so a user-wide hook fired outside an Orca pane blocked forever when
the caller abandoned the pipe — one stranded powershell.exe or bash.exe per
hook event.

Move the env guard (after the endpoint refresh, which can supply PORT/TOKEN)
above the read on the Windows-local variants. The payload is discarded on the
missing-env path anyway; the broken writer is the trade stablyai#11568 established.
POSIX variants keep capture-first — those callers close stdin, and exiting
mid-write there surfaces as EPIPE the agent can see (stablyai#8110). Kimi's remote
install now asks for the posix variant explicitly.

Verified on a real Windows host: pre-fix copilot with an abandoning caller
never exits; post-fix both exit 0 immediately, and the env-present copilot
path still consumes stdin and delivers the POST (paneKey + payload received
by a local listener).
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]: Codex managed hook leaves persistent cmd.exe windows outside Orca on Windows

3 participants