Repository navigation
Conversation
|
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. Walkthrough
Severity of issue fixed: Low Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/codex/hook-service-neutral-json.test.ts (1)
5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBuild the mocked app-data path portably.
Use
path.joinor another Node path utility instead of'/tmp/orca-user-data'.As per coding guidelines: “File paths: Use
path.joinor Electron/Node path utilities — never assume/or\.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 654281d9-169d-48a3-a22c-a1cf971b876d
📥 Commits
Reviewing files that changed from the base of the PR and between 822087c and 31828cf9862b10e140db40701c3121e80601a0c3.
📒 Files selected for processing (2)
src/main/codex/hook-service-neutral-json.test.tssrc/main/codex/hook-service.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Thanks — both taken. 1. Windows assertion. You're right that expect(lines.indexOf('echo {}')).toBe(lines.indexOf('setlocal') + 1)That matches the real generated script ( 2.
|
481f330 to
54f6a13
Compare
|
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. |
|
|
Rebased onto One thing needs a maintainer's call. Every sibling hook already prints neutral JSON unconditionally, in the same position, on current If the intent of #16685 was that Codex specifically must stay byte-silent outside Orca, say so and I'll gate the neutral JSON on the Orca environment instead — but that leaves #16356 unfixed for out-of-terminal sessions, which is the majority of them. Verified on the new base: The PR description is updated to match the new file layout and carries the same note. |
|
Bumping the one open question here, since it's a maintainer decision rather than anything I can settle on the branch. This PR changes four But it is someone else's test, so I don't want to land the change on my own reading. Two ways forward:
Current head |
54f6a13 to
8b24213
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Update the Windows stdout assertions. · codex-hook-script.ts:15-16
src/main/codex/codex-hook-script.ts:15-16
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUpdate the Windows stdout assertions.
On Windows,
echo {}writes'{}\r\n'.runProcesspreserves that output. The Windows-only test currently expectsstdout: ''for successful and server-close runs, so it fails. Keep the neutral JSON output and update both expectations.Suggested fix
- .map((payload) => invoke(getManagedCommand(scriptPath), payload)) + .map((payload) => invoke(getManagedCommand(scriptPath), payload)) ) for (const result of results) { - expect(result).toMatchObject({ code: 0, stdout: '', stderr: '', timedOut: false }) + expect(result).toMatchObject({ + code: 0, + stdout: '{}\r\n', + stderr: '', + timedOut: false + }) } @@ expect(await invoke(getManagedCommand(scriptPath), payloads[0])).toMatchObject({ code: 0, - stdout: '', + stdout: '{}\r\n', stderr: '', timedOut: false })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 40597da9-5a2e-4eb1-9fd9-635431b989ab
📥 Commits
Reviewing files that changed from the base of the PR and between 54f6a137389f06705dd25df91f299bfce384ccba and 8b24213.
📒 Files selected for processing (1)
src/main/agent-hooks/hook-script-outside-orca.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Rebased onto main I also fixed the two Windows delivery/fallback assertions flagged by CodeRabbit: the generated batch script intentionally prints neutral JSON first, so both now expect The latest three targeted suites pass through Node/Vitest: 13 passed, 1 Windows-native test skipped. The earlier four related suites passed 30 tests with 4 skips before the two assertion corrections. Fresh-context Codex reviews found no correctness blocker in either the rebase or the Windows test correction. Native Windows execution was not rerun. This refresh does not resolve the outstanding outside-Orca stdout contract question from my September 7 comment. |
3db015b to
c47ed4a
Compare
c47ed4a to
e28ccec
Compare
|
Rebased onto #24641 added a fourth outside-Orca case (Claude background job) that also asserts empty stdout. I changed it to The question from 09-07 still stands. If the empty-stdout contract in |
e28ccec to
f47f004
Compare
Codex fails closed on a hook whose stdout is not valid JSON, so every session started from an Orca terminal reported "invalid session start/stop hook JSON output" even though the POST to Orca's listener succeeded (stablyai#16356). The managed Codex script never wrote anything to stdout. Its siblings all do: claude (stablyai#14818), gemini, copilot and antigravity each emit neutral JSON as the first line, before any early-exit guard. Codex was the only one without it. Rebased onto the module split from stablyai#17260: the builder moved from hook-service.ts to codex-hook-script.ts, so the two lines land there instead.
…de/hook-script.ts Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W3aMySdNJ9b2CDfWac3rSt
Move the neutral-JSON test next to codex-hook-definition after the Codex hook modules moved under hooks/.
f47f004 to
b1adf3b
Compare
|
Rebased onto
That also retires the question I raised on 09-07. The test asserting empty stdout is gone, and the POSIX command in Checked on the rebased head (macOS, Node 24):
Not run on Windows; The diff is now +4 lines in |
|
Thank you for the PR. Closing it because the root cause doesn't hold up. Codex's hook runner treats empty stdout as success for both SessionStart and Stop, and the "invalid ... JSON output" error only fires when stdout is non-empty and fails to parse. A leading |
ELI5
Codex refuses any hook whose output isn't JSON. Orca's Codex hook printed nothing, so Codex marked session start and stop as failed even though the hook's real work succeeded. This prints
{}first, which is what Orca's Claude, Gemini, Copilot and Antigravity hooks already do.What Changed
src/main/codex/hooks/definitions/codex-hook-script.ts, ingetManagedScript(+4 lines):printf "{}\n"immediately after#!/bin/sh, before the payload capture and the tmux pane capture..cmdbranch:echo {}immediately aftersetlocal.Placement matters: both branches exit 0 without posting when the payload or the
ORCA_*environment is missing, so neutral JSON emitted later would never run.Tests:
src/main/codex/hooks/installation/windows-hook-command.test.ts: its twostdoutexpectations change from''to'{}\r\n'.src/main/codex/hooks/definitions/codex-hook-script-neutral-json.test.ts(new, 49 lines) pins the ordering on both branches. Given the "tests are the exception" rule from test: cut the suite to the tests that guard real invariants #46786, I'm happy to drop it if you'd rather not carry it.Why
Codex fails closed on a hook whose stdout is not valid JSON, so a Codex session launched from an Orca terminal reported:
The hook's actual job was fine: the POST to the local hook endpoint went through. What broke was only the stdout contract, and the cost is that users learn to ignore red hook errors, including real ones.
On current
mainthe Claude, Gemini, Copilot and Antigravity managed hooks each print neutral JSON; Codex is the one that doesn't.{}is a neutral response because every field in Codex's hook output schema is optional.Scope
This covers what #16356 reports: a Codex session started from an Orca terminal.
An earlier version of this description said the fix also covered sessions launched from a plain terminal. On POSIX that does not hold. The installed command (
codex-hook-command-form.ts) runs the script only whenORCA_PANE_KEYis set and otherwise just drains stdin, so outside Orca nothing here changes. The test that asserted empty stdout outside Orca (hook-script-outside-orca.test.ts) was removed by #46786, and this PR no longer touches it.Linked Issue
Fixes #16356
Visual Proof
N/A. No UI surface; this changes a generated shell script.
Testing
On the rebased head
b1adf3b2af(basef2f0cce6e4), macOS, Node 24:getManagedScript('posix')) run undersh,bashanddash: withmain's script stdout is empty; with this branch it is{}. Exit 0 both ways.buildCodexHookCommand(), with a pane key and port set: empty stdout withmain's script,{}with this one. Without a pane key: empty in both.main's version.pnpm check:changed: 26 checks passed.windows-hook-command.test.tsis skipped on macOS.echo {}sits at the same position relative tosetlocalas the line in Claude's.cmdhook. Worth a reviewer's eye on a real Windows box.I did not run the Codex CLI against the fixed hook; that the empty stdout is what Codex rejects rests on the report in #16356 and the follow-up there.
AI Disclosure
Written with Claude Code. The checks above were run on the rebased head.
Review
printf, a shell builtin, so it adds no process and behaves the same undersh/dash/bash. Windows not tested on Windows (see Testing).{}carries no decision, so it cannot alter a permission or turn outcome.