Skip to content

feat: support git worktrees in code review#241

Merged
backnotprop merged 3 commits intomainfrom
fix-code-review-worktrees
Mar 7, 2026
Merged

feat: support git worktrees in code review#241
backnotprop merged 3 commits intomainfrom
fix-code-review-worktrees

Conversation

@backnotprop
Copy link
Owner

Summary

  • Detects git worktrees via git worktree list --porcelain and surfaces them as selectable diff options in the existing dropdown
  • When a worktree is selected, runs git diff HEAD with cwd set to that worktree's directory, picking up uncommitted + untracked changes there
  • No UI changes needed — worktrees appear as additional entries below a separator in the existing diff-type selector

Closes #196

Test plan

  • Create a test worktree: git worktree add ../test-wt -b test-branch
  • Make changes in ../test-wt/
  • Run /plannotator-review from the main repo
  • Verify dropdown shows "test-branch (worktree)" below a separator
  • Select it — should show the changes made in the worktree
  • Verify normal diff options (uncommitted, last-commit, branch) still work
  • Remove worktree and verify dropdown returns to normal

🤖 Generated with Claude Code

backnotprop and others added 2 commits March 7, 2026 08:31
Detect worktrees via `git worktree list --porcelain` and surface them
as selectable diff options in the existing dropdown. When a worktree is
selected, run git commands with cwd set to that worktree's directory.

Closes #196

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Selecting a worktree now enters "worktree mode" — the dropdown
replaces its contents with standard diff options (uncommitted,
last-commit, vs main) scoped to that worktree. A "Back to main
repo" entry returns to the original view.

- Add parseWorktreeDiffType() for compound types like worktree:/path:last-commit
- Add getWorktreeDiffOptions() to build worktree-mode dropdown entries
- Update runGitDiff() to handle worktree sub-types
- Update /api/diff/switch to return diffOptions on mode transitions
- Update App.tsx to consume updated diffOptions and refresh dropdown
- Add test sandbox with 4 worktrees for manual testing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@backnotprop
Copy link
Owner Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

`git diff HEAD~1..HEAD` crashes when a branch has only one commit.
Now checks for HEAD~1 existence first and falls back to
`git diff --root HEAD` to show the initial commit's full content.

Also fixes test sandbox: wrong filename in git add, and commits
changes in fix-parser/detached worktrees so "Last commit" and
"vs main" have actual content to display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@backnotprop backnotprop merged commit 411e1b9 into main Mar 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

code review doesn't work when using worktrees

1 participant