fix(worktree): reuse an existing group branch on resume instead of recreating it#82
Conversation
…creating it WorktreePool.acquire now checks out an existing group branch (git worktree add <path> <branch>) instead of always branching from base (-b <branch> <base>). On a resumed run whose prior worktree was removed, the branch ref — and its committed-but-unpushed work — persists; the old '-b from base' would fail outright on the existing branch (crashing resume) or, if recreated, drop the prior commits. A brand-new group still branches from base. This eliminates the resume crash and the loss of committed-but-unpushed work. Auto-opening a PR for that recovered work when a resumed task then blocks remains a smaller follow-up. Refs #77
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesWorktreePool Branch Reuse on Resume
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 `@packages/aitm/src/workspace/worktree-pool.ts`:
- Around line 35-38: The branchExists() helper is swallowing all git rev-parse
failures and treating them as a missing branch, which can send acquire() down
the wrong git worktree add path. Update branchExists in worktree-pool.ts to
catch only the specific missing-ref case from runGit(['rev-parse', '--verify',
'--quiet', ...]) and rethrow any other repo, permission, or runtime errors so
callers can distinguish real failures from an absent branch.
🪄 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.yml
Review profile: CHILL
Plan: Pro
Run ID: 0b149be9-d472-47a8-b073-292d9519816d
📒 Files selected for processing (2)
packages/aitm/src/workspace/worktree-pool.test.tspackages/aitm/src/workspace/worktree-pool.ts
…xists Per review: branchExists swallowed every git rev-parse failure as a missing branch, so a real error (not a repo, permissions, git missing) would silently send acquire down the new-branch path. It now returns false only for the rev-parse --verify --quiet exit-1 'ref absent' case and rethrows anything else.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
WorktreePool.acquirealways rangit worktree add -b <branch> <base>, which fails outright when the group branch already exists (a resumed run) — or, if recreated from base, drops the prior commits. It now checks out an existing branch instead, preserving committed-but-unpushed work and fixing the resume crash. A brand-new group still branches from base.Changes
src/workspace/worktree-pool.ts—branchExists()helper;acquirereusesgit worktree add <path> <branch>when the branch exists, else-b <branch> <base>.Testing
src/workspace/worktree-pool.test.ts: integration test creating a branch with a commit, removing its worktree, then acquiring — asserts the prior commit/file is checked out. Existing fresh-branch path unchanged. Full suite green (672);biome+tscclean.Note
Auto-opening a PR for the recovered work when a resumed task then blocks is a smaller follow-up.
Refs #77
Summary by CodeRabbit