Repository navigation
Fix Claude hooks-disabled env passthrough - #4418
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR fixes a regression where ChangesPreserve CMUX_ env vars for disabled hooks*
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 17✅ Passed checks (17 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Resources/bin/claude`:
- Around line 195-199: The early-exit path that checks
CMUX_CLAUDE_HOOKS_DISABLED currently execs the real claude (via
REAL_CLAUDE="$(find_real_claude)" and exec "$REAL_CLAUDE" "$@") but does not
call clear_inherited_claude_auth_selection_env; modify this branch to invoke
clear_inherited_claude_auth_selection_env before exec so inherited auth vars
(ANTHROPIC_API_KEY, ANTHROPIC_MODEL, CLAUDE_CODE_USE_VERTEX, etc.) are cleared
consistently with the other passthrough paths while preserving Vertex/Bedrock
creds per the function's logic.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0afc4b7c-6594-4ac1-886c-b300d8d29fd0
📒 Files selected for processing (2)
Resources/bin/claudetests/test_claude_wrapper_hooks.py
Greptile SummaryThis PR fixes
Confidence Score: 5/5Safe to merge — the change is a clean behavioural split with explicit regression coverage for the new path. The hooks-disabled branch is narrow and self-contained: it unsets CLAUDECODE, runs auth cleanup, and execs real claude without touching CMUX_* or TERMINFO — exactly the stated intent. The remaining passthrough and hook-injection paths are untouched. New tests exercise both interactive and command-like invocations under hooks-disabled and verify auth-selection cleanup, covering the core regression surface. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[claude wrapper invoked] --> B{CMUX_CLAUDE_HOOKS_DISABLED == 1?}
B -- Yes --> C[unset CLAUDECODE if IN_CMUX=1]
C --> D[clear_inherited_claude_auth_selection_env]
D --> E[exec real claude\nCMUX_* and TERMINFO preserved]
B -- No --> F{IN_CMUX == 0 OR socket unavailable?}
F -- Yes --> G[unset CLAUDECODE if IN_CMUX=1]
G --> H[clear_inherited_claude_auth_selection_env]
H --> I[exec_real_claude_passthrough\nCMUX_* and TERMINFO stripped]
F -- No --> J[find real claude]
J --> K{should_inject_claude_hooks?}
K -- No command-like --> L[clear auth env]
L --> I
K -- Yes interactive --> M[unset CLAUDECODE]
M --> N[clear auth env]
N --> O[inject --session-id and --settings hooks JSON]
O --> P[exec real claude with hooks]
Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
Summary
Closes #4151.
Testing
Demo Video
Not applicable; this is deterministic shell-wrapper environment behavior.
Review Trigger Checklist
Note
Low Risk
Shell-wrapper passthrough behavior only, with targeted regression tests and no changes to hook injection or app auth flows when hooks remain enabled.
Overview
When
CMUX_CLAUDE_HOOKS_DISABLED=1, the Claude wrapper now takes a dedicated early passthrough that execs the real binary without strippingCMUX_*terminal metadata (socket, workspace/tab/panel IDs, etc.), so user-managed hooks can read cmux context. That path still unsetsCLAUDECODE, runs stale auth-selection cleanup / config-dir normalization, and does not inject session or hook settings—for both interactive and command-like invocations.Command-like passthrough when cmux still manages hooks (e.g.
agents) continues to clear the full cmux terminal fingerprint viaexec_real_claude_passthrough.Regression tests cover hooks-disabled env preservation and stale
ANTHROPIC_*scrubbing before passthrough.Reviewed by Cursor Bugbot for commit 86ac4d6. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Improvements
Tests