fix(git): make worktree PR detection reliable#4108
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
ApprovabilityVerdict: Needs human review This PR introduces substantial new runtime behavior (PR lookup state tracking, refresh coalescing, UI indicators) rather than a simple fix. Additionally, there are unresolved HIGH and MEDIUM severity review comments identifying potential race conditions in the branch refresh logic. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Issue: pingdotgg#4106 Co-authored-by: codex <codex@users.noreply.github.com>
106234c to
4517d76
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4517d76. Configure here.
| { concurrency: "unbounded" }, | ||
| ); | ||
| return yield* updateCachedStatus(cwd, local, remote, { publish: true }); | ||
| return mergeGitStatusParts(local, remote); |
There was a problem hiding this comment.
Stale pending after branch refresh race
High Severity
The new branch-correlation guard in applyGitStatusStreamEvent incorrectly filters remoteUpdated events. It prevents updates for new branches from being applied if they arrive before local updates, leaving PR status stuck as pending. It also misinterprets remote: null as a branch mismatch, causing clients to retain stale remote state instead of clearing it.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4517d76. Configure here.
| return VcsStatusBroadcaster.of({ | ||
| getStatus, | ||
| refreshLocalStatus, | ||
| refreshChangeRequestStatus, |
There was a problem hiding this comment.
Stale remote delays PR refresh
Medium Severity
streamStatus only starts the remote poller immediately when no remote cache entry exists. After this PR, local refresh can advance refName while the cached remote still belongs to the previous branch, so a new poller sleeps for the full lightweight interval before looking up the current branch’s PR. Turn-completion reconcile also skips when either concurrent refresh fails, so a branch-changing turn with a failed change-request refresh can stay pending until the next poll.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4517d76. Configure here.


Summary
Closes #4106
Testing
vp checkvp run typecheckBefore / After
Risks
Note
Medium Risk
Wire schema and all status producers/consumers must include the new fields; added provider polling and concurrent turn-completion refreshes increase integration surface without exposing raw auth errors to the client.
Overview
VCS status now carries
statusRefNameandchangeRequestLookup(pending/succeeded/failedwith stable reasons) so clients can tell “lookup not done” or “lookup failed” apart from “no PR.”GitManagermaps provider errors into those categories instead of silently returningpr: null.VcsStatusBroadcasteraddsrefreshChangeRequestStatus(no upstream fetch), per-worktree refresh locking, coalescing, and keeps a cached open PR when a same-branch lookup fails. Background polling still runs lightweight change-request refreshes when automatic Git fetch is disabled; upstream fetch timing is split from that polling.CheckpointReactorrefreshes local git status and change-request status in parallel after turn completion (with cwd fallback and optional reconcile when the branch moved).Shared reducers tie remote PR data to
statusRefNameand reset remote state when the local branch changes; git action quick actions and menus usecanCreateChangeRequestso PR creation is blocked while lookup is pending or failed (cached open PRs stay actionable).UI shows amber lookup-failure tooltips on sidebar / thread status rows; settings copy notes lightweight MR/PR checks continue without remote fetch.
Reviewed by Cursor Bugbot for commit 4517d76. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix worktree PR detection by tracking change request lookup state in git status
VcsStatusChangeRequestLookupfield to remote git status that tracks whether a PR lookup is pending, succeeded, or failed (with structured reasons likeauthentication_requiredorprovider_unavailable).VcsStatusBroadcasternow coordinates remote refreshes per worktree with locking and deduplication, and retains cached PR data on transient lookup failures for the same branch.CheckpointReactornow concurrently refreshes both local git status and change request status, with a follow-up refresh when the branch has changed.statusRefNamedoes not match the current local branch, preventing stale cross-branch data from leaking into status merges.VcsStatusRemoteResultnow requireschangeRequestLookupandstatusRefName; existing decoders will fail if these fields are absent.Macroscope summarized 4517d76.