Fix Claude restore cwd after subagent metadata#4979
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesClaude Transcript
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly Related Issues
Poem
🚥 Pre-merge checks | ✅ 17 | ❌ 1❌ Failed checks (1 warning)
✅ 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 |
Greptile SummaryThis PR fixes a bug in
Confidence Score: 5/5Safe to merge — the change is a small, well-contained guard in one parsing loop backed by a direct regression test. The production change is three lines in a private static parsing helper: a local boolean flag prevents subsequent No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[extractClaudeMetadata called\nwith head, tail, projectDir] --> B[out.cwd = decodeClaudeProjectDir\ndidReadTranscriptCwd = false]
B --> C{Iterate head lines}
C --> D[Parse JSON line]
D --> E{didReadTranscriptCwd?\nor cwd empty?}
E -- "No / has cwd" --> F[out.cwd = cwdField\ndidReadTranscriptCwd = true]
E -- "Yes (already read)" --> G[Skip cwd update]
F --> H[Continue parsing\ngitBranch, model, title…]
G --> H
H --> C
C -- done --> I{Iterate tail lines}
I --> J[Parse pr-link, gitBranch,\npermissionMode, model]
J --> I
I -- done --> K[Return ClaudeParsed\nwith parent cwd preserved]
style F fill:#d4edda,stroke:#28a745
style G fill:#fff3cd,stroke:#ffc107
Reviews (1): Last reviewed commit: "fix: preserve Claude restore cwd after s..." | Re-trigger Greptile |
Summary
cwdparsed from a Claude transcript so later subagent metadata cannot move the parent session into another directory.cwd, then a subagentcwd, and verifies the directory snapshot plusclaude --resumecommand still use the parent folder.Red failure
At commit
2ed6ac65f, the focused AWScmux-unitrun failed for the intended reason:The session disappeared from the parent directory snapshot because the later subagent
cwdoverwrote the parentcwd.Green pass
At commit
4b235c269, the same focused AWScmux-unitrun passed with exit code 0:Tagged build
./scripts/reload.sh --tag claude-cwdsucceeded and builtcmux DEV claude-cwd.app.Proof notes
Cloud bootstrap artifacts are under
/Users/lawrence/fun/cmuxterm-hq/cmux-assets/issue-claude-restore-wrong-folder-after-subagent/auto-issue/20260528-232909. The accepted proof for this fix is the red/green behavior test because it exercises the restore command source directly. The initial cloud recording was only a CUA bootstrap smoke check and did not reproduce the Claude restore path.Note
Low Risk
Small, targeted change to Claude metadata parsing plus a unit test; no auth, persistence, or broad indexing refactors.
Overview
Claude session indexing now keeps only the first
cwdfound while scanning a transcript’s head, so later lines (including subagentisMetabookkeeping with a different folder) no longer replace the parent session’s working directory.That fixes wrong directory snapshots and
claude --resumecommands that previouslycd’d into a subagent scratch path and could hide the session from the parent repo’s index. A regression test builds a transcript with parent then subagentcwdand asserts snapshotcwdand resume command stay on the parent folder.Reviewed by Cursor Bugbot for commit 4b235c2. Bugbot is set up for automated code reviews on this repo. Configure here.
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Summary by cubic
Fixes Claude restore picking the wrong folder when subagent metadata includes a different cwd. We now lock to the first cwd in the transcript so directory snapshots and
claude --resumestay in the project root.Written for commit 4b235c2. Summary will update on new commits.
Review in cubic
Summary by CodeRabbit