Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthroughthis pr fixes issue Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Notes
Suggested labels
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/codex.js`:
- Around line 256-265: The auto-tty fallback in
shouldCaptureForwardedCodexOutput only reads process.stdout/stderr globals
making that branch hard to exercise in tests — add a unit/integration test in
test/codex-bin-wrapper.test.ts that sets
env.CODEX_MULTI_AUTH_CAPTURE_FORWARD_OUTPUT="1" to exercise the explicit capture
path (ensure the wrapper still captures and triggers the retry path), and update
tests to cover both "1" and "0" overrides; also add a one-line comment above
shouldCaptureForwardedCodexOutput explaining that process.stdout.isTTY may be
undefined on Windows for child processes and that treating undefined as non-tty
(i.e., capture) is intentional to preserve the unsupported-model retry behavior.
In `@test/codex-bin-wrapper.test.ts`:
- Around line 1234-1261: Add a symmetric regression test that asserts the
explicit "1" branch preserves capture and triggers the gpt-5.5→gpt-5.4 retry:
duplicate the existing gpt-5.5→gpt-5.4 retry spec but set
CODEX_MULTI_AUTH_CAPTURE_FORWARD_OUTPUT: "1" in the runWrapper env, keep using
createCustomFakeCodexBin/runWrapper/combinedOutput, and assert
readFileSync(join(stateDir, "attempt.txt"), "utf8") === "2" and output contains
"Retrying with gpt-5.4"; this protects the behavior of
shouldCaptureForwardedCodexOutput in scripts/codex.js from regressions that
invert the explicit "1" branch.
- Around line 1234-1261: The test "can forward without capturing child stdio for
terminal-sensitive Codex runs" leaves CODEX_HOME unpinned causing it to pick up
the host ~/.codex and produce non-deterministic shadow-home behavior; update the
test (where runWrapper and createWrapperFixture are used and the env vars
CODEX_MULTI_AUTH_TEST_STATE_DIR, CODEX_MULTI_AUTH_REAL_CODEX_BIN,
CODEX_MULTI_AUTH_CAPTURE_FORWARD_OUTPUT are set) to set a deterministic
CODEX_HOME in extraEnv (similar to the sibling test that sets CODEX_HOME:
originalHome) so the wrapper will not fall back to join(HOME, ".codex") and
avoid createCompatibilityCodexHome shadowing and potential Windows EBUSY/EPERM
races; ensure the new env key is added to the runWrapper invocation rather than
relying on host HOME forwarding through buildWrapperEnv/WRAPPER_ENV_ALLOWLIST.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 64fd62f9-d806-4f78-a753-7cd6fcb1f471
📒 Files selected for processing (2)
scripts/codex.jstest/codex-bin-wrapper.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (1)
test/**
⚙️ CodeRabbit configuration file
tests must stay deterministic and use vitest. demand regression cases that reproduce concurrency bugs, token refresh races, and windows filesystem behavior. reject changes that mock real secrets or skip assertions.
Files:
test/codex-bin-wrapper.test.ts
🔇 Additional comments (1)
scripts/codex.js (1)
267-340: stdio switch looks correct; spawn failure path is sound.the three things i look for here all check out:
- synchronous spawn throw →
failLaunch→returnatscripts/codex.js:311prevents the laterchild.stdout?.on/child.oncefrom dereferencing an undefinedchild.- async
error+closeboth funneled throughfinalize, guarded bysettled. no double-resolve, no hanging promise.- when
captureOutput === false,stdio: "inherit"inherits stdin too, which is exactly what the real codex needs to keep its raw-mode tty setup. matches issue#436.one minor smell: in the no-capture branch the local
stderraccumulator atscripts/codex.js:277is only ever written byfailLaunch, and that same message is already emitted viaconsole.error. theoutputfield returned toforwardToRealCodexwill therefore be either empty or just the launch-failure line, which correctly causesresolveUnsupportedModelRetryTargetto short-circuit — intended behavior, but worth a one-line comment so future readers don't "helpfully" wire the buffer back up and silently re-enable retries on tty runs.
Summary
Verification
Notes
Fixes #436
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this pr fixes tty passthrough for forwarded codex runs by introducing
shouldCaptureForwardedCodexOutput, which skips piping when both stdout and stderr are tty-attached, and falls back to capture mode for non-tty (ci/pipe) runs so unsupported-model retries can still inspect stderr. it also hardensspawn()with a try/catch to handle synchronous launch failures (e.g. windows EPERM) and adds two explicit-override integration tests.Confidence Score: 5/5
safe to merge — all remaining findings are P2 style/coverage gaps with no runtime correctness risk
the logic is sound: tty detection uses
!== trueto safely handle windowsundefinedisTTY, the two explicit-override tests cover the primary regression scenarios, and the spawn try/catch is a net improvement. the only gaps are the untested tty auto-detect fallback branch and the minorfailLaunch/no-capture stderr inconsistency, neither of which causes incorrect retries or data loss in practiceno files require blocking attention;
test/codex-bin-wrapper.test.tscould add a test omitting the override to exercise the tty auto-detect pathImportant Files Changed
shouldCaptureForwardedCodexOutputto skip piping when stdin/stdout are TTY, and wrapsspawn()in try/catch for synchronous-failure resilience; minor inconsistency wherefailLaunchstill mutatesstderrin no-capture modeshouldCaptureForwardedCodexOutputremains untestedFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[forwardToRealCodex] --> B[shouldCaptureForwardedCodexOutput] B --> C{CODEX_MULTI_AUTH_CAPTURE_FORWARD_OUTPUT} C -- "1" --> D[captureOutput = true] C -- "0" --> E[captureOutput = false] C -- unset --> F{stdout.isTTY === true AND stderr.isTTY === true} F -- yes --> E F -- no/undefined Windows safe --> D D --> G[spawn with stdio: inherit,pipe,pipe] E --> H[spawn with stdio: inherit] G --> I[buffer stdout+stderr, write to process streams] H --> J[child inherits parent TTY, no buffering] I --> K[result.output = buffered text] J --> L[result.output = empty string] K --> M{resolveUnsupportedModelRetryTarget} L --> N[retry skipped by design] M -- match --> O[retry with fallback model] M -- no match --> P[return exitCode]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "docs: clarify no-capture retry behavior" | Re-trigger Greptile