Repository navigation
Conversation
…t switches back Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — The change refreshes stale branch/worktree metadata after agent checkouts. An unresolved finding identifies overlapping selections that can leave the thread on the wrong worktree; selection ordering needs resolution before release. Needs human approval because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… cases listRefs no longer matches a null worktree root against branches without a worktree, which made every call reread refs when worktree metadata is missing. The picker keeps its worktree claim when its confirming read was truncated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ne page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
When an agent runs
git switchitself, picking the previously current branch in the branch picker (composer or thread details) did nothing. The thread recorded the old branch, but git stayed on the agent's branch. maria-rcks found this while verifying #28575 (comment), and it reproduces onmain.Change
The picker skips
vcs.switchRefwhen a ref claims aworktreePath("reuse that worktree"). That claim came from data that a provider's own checkout never invalidates:listRefsserves a snapshot cached for 2 minutes, plus the current branch from a path cache kept for 10 minutes. Both still mapped the old branch to this checkout.Now:
listRefsreads this checkout's HEAD (git symbolic-ref, run in parallel with the snapshot read). If HEAD disagrees with the cache, it invalidates the snapshot and re-reads it. This adds one subprocess perlistRefscall and nothing to status reads.readRefs. If that read fails or misses the ref, it runs a real checkout, and Git refuses that if the branch is checked out in another worktree.Mobile always calls
switchRef, so it was not affected. No contract changes.Scope and approval
This qualifies for the small, focused bug-fix exception in CONTRIBUTING.md. It makes the branch picker switch branches as asked, without adding a feature, changing defaults, or altering contracts.
Verification
GitVcsDriverCore.test.tscase, "follows a checkout made outside the driver after refs were cached". It warmslistRefs, switches with plaingit, and checks the refs,switchRefback, and detached HEAD. It fails onmain(the stale ref still has thisworktreePath) and passes here.vp run check:changed: format, lint, knip, and typecheck pass. All 234GitVcsDriverCore.test.tscases pass except "keeps generated worktree folders short…", which fails identically onmainon macOS (/varvs/private/var).Replay (dev), scratch repo withmainandfeature/agent. I opened the picker to warm it, rangit switch feature/agentin the workspace, then pickedmain.On
main, git stays onfeature/agent. On this branch,git branch --show-currentprintsmainafter the selection.Made with Claude Opus 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code