Skip to content

improve and prevent silent thread branch drift and PR fetching#2284

Open
justsomelegs wants to merge 8 commits intopingdotgg:mainfrom
justsomelegs:t3code/git-audit-stability
Open

improve and prevent silent thread branch drift and PR fetching#2284
justsomelegs wants to merge 8 commits intopingdotgg:mainfrom
justsomelegs:t3code/git-audit-stability

Conversation

@justsomelegs
Copy link
Copy Markdown
Contributor

@justsomelegs justsomelegs commented Apr 22, 2026

What Changed

Improves the local branch mismatch warning in the branch picker.

  • Highlights the branch picker with a warning color when the thread branch and current checkout differ.
  • Adds an inline warning icon to the picker.
  • Shows a popover above the picker explaining the mismatch.
  • Adds actions to either switch the checkout back to the thread branch or update the thread to use the current checkout.
  • Keeps server thread branch metadata from being overwritten when the shared local checkout changes.
  • Tightens PR/status indicator behavior so local checkout PR state is scoped to the relevant thread branch.
  • Improves PR fetching so that forked repos with PR on upstream not origin allow showing PR status in application

Why

When using local checkout mode, the active Git branch can drift away from the branch a thread was last associated with. Previously this was easy to miss and could lead to continuing work on the wrong branch.

This makes the mismatch visible in-place and gives users clear recovery actions without changing branches automatically.

The thread’s associated branch should only change when the user intentionally chooses a branch for the thread, creates/checks out a branch through the picker, or clicks Use current in the warning popover. It should not change just because the shared local checkout moved while viewing an existing server thread.

UI Changes

image image

Screenshots/video to attach:

  • Before screenshot of the old picker state.
  • After screenshot of the warning picker and popover.
  • Short video showing hover/click on the warning icon and the Use current / Switch actions.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

[!NOTE]

Fix thread branch drift and improve PR matching for cross-repo and dedicated worktree cases

  • Refactors matchesBranchHeadContext in GitManager.ts to reject ambiguous or mismatched PR head identities, including cross-repo PRs missing head metadata and same-repo PRs where identities conflict.
  • Prevents GitActionsControl from overwriting an existing server thread's branch based on shared checkout state; automatic branch sync is now limited to draft threads.
  • Adds a branch mismatch warning to BranchToolbarBranchSelector: when the active thread's branch differs from the current local checkout (and no dedicated worktree is in use), a warning icon and popover appear with options to switch the checkout or update the thread.
  • Updates resolveThreadPr to return PR status for dedicated worktree threads regardless of stored branch metadata, so PR indicators appear even when branch data is stale.
  • Risk: matchesBranchHeadContext behavior changes may cause previously reused PRs to be rejected and new PRs created in cross-repo fork scenarios.

Macroscope summarized fdc70b6.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0ab4375f-38cc-495c-a5e7-b3aceb52ef14

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 22, 2026
Comment thread apps/server/src/git/Layers/GitManager.ts
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 22, 2026

Approvability

Verdict: Needs human review

This PR introduces a new user-facing feature (branch mismatch warning popover with switch/update actions) and modifies PR matching logic in GitManager that affects which PRs are associated with threads. While well-tested, the new capability and behavioral changes to PR resolution warrant human review.

You can customize Macroscope's approvability policy. Learn more.

Comment thread apps/server/src/git/Layers/GitManager.ts
@justsomelegs justsomelegs changed the title improve and prevent silent thread branch drift improve and prevent silent thread branch drift and PR fetching Apr 22, 2026
@juliusmarminge
Copy link
Copy Markdown
Member

Heya I will properly review your PRs when we get back from Miami. Seems like some good stuff just don't have capacity to review big PRs while we're here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants