Skip to content

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

Open
justsomelegs wants to merge 17 commits into
pingdotgg:mainfrom
justsomelegs:t3code/git-audit-stability
Open

improve and prevent silent thread branch drift and PR fetching#2284
justsomelegs wants to merge 17 commits into
pingdotgg: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

Fix thread branch drift and improve PR matching for dedicated worktrees

  • matchesBranchHeadContext in GitManager.ts now correctly rejects cross-repo PR mismatches and tolerates missing GitHub head identity metadata instead of silently drifting.
  • GitActionsControl no longer overwrites an existing server thread's branch from current checkout state when using a shared checkout.
  • resolveThreadPr in ThreadStatusIndicators.tsx returns a PR for dedicated worktrees even when the stored branch name is stale or missing; shared checkouts still scope to the thread branch.
  • BranchToolbarBranchSelector detects when the local checkout differs from the thread branch and offers actions to either switch the checkout or update the thread.
  • PR status tooltips now render structured content via a new PrStatusTooltipContent component with a bold lead and truncated title.

Macroscope summarized 7ecd31d.


Open in Devin Review

Note

Medium Risk
Adjusts git/PR matching and thread-branch persistence logic plus adds new branch-switch actions in the UI; mistakes could cause incorrect PR reuse or unintended branch/thread association changes.

Overview
Prevents silent thread branch drift in local checkout mode by detecting when the stored thread branch differs from the current checkout and surfacing a warning state in the branch picker (highlight + icon + popover), with one-click actions to either switch the checkout back or update the thread to the current branch.

Tightens PR/status correctness across repos and worktrees. Server-side PR reuse now matches head identity more defensively (handling missing GitHub head metadata and rejecting cross-repo vs same-repo mismatches), and web PR indicators are now scoped to the stored thread branch for shared checkouts while allowing dedicated worktree threads to show PR status even if stored branch metadata is stale/missing; tooltips were also restructured via PrStatusTooltipContent.

Adds/updates targeted tests to cover the new PR head-identity matching rules, branch mismatch detection, and avoiding overwriting an existing server thread branch when the shared checkout changes.

Reviewed by Cursor Bugbot for commit d9e44e3. Bugbot is set up for automated code reviews on this repo. Configure here.

@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: a1e38445-6d05-422e-8fd2-a12dbb5f683f

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 new user-facing behavior: a warning UI when the local checkout branch diverges from the thread branch, with actions to resolve the mismatch. It also modifies PR matching logic for cross-repository scenarios and changes how PR status is resolved for worktree threads. These are non-trivial runtime behavior changes that warrant human review.

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

Comment thread apps/server/src/git/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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. and removed vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 30, 2026
@justsomelegs justsomelegs force-pushed the t3code/git-audit-stability branch from f1ffd01 to 02bb838 Compare May 1, 2026 22:56
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 23355c1. Configure here.

Comment thread apps/server/src/git/GitManager.ts
@juliusmarminge
Copy link
Copy Markdown
Member

either i messed soemthing up when mergin main or i don't understand this PR:

CleanShot.2026-05-02.at.23.02.21.mp4

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels May 3, 2026
@justsomelegs justsomelegs force-pushed the t3code/git-audit-stability branch from e0314cf to beb7b1a Compare May 4, 2026 09:20
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

@justsomelegs is attempting to deploy a commit to the Ping Labs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels May 4, 2026
@justsomelegs
Copy link
Copy Markdown
Contributor Author

either i messed soemthing up when mergin main or i don't understand this PR:

CleanShot.2026-05-02.at.23.02.21.mp4

It meant to warn the user when switching branches that the thread was last working on another branch so that they dont accidently try and continue the work on the wrong branch.

just pushed my local version up that is rebased onto main if you wanna try that one out.

Screen.Recording.2026-05-04.101354.mp4

Comment thread apps/web/src/components/BranchToolbarBranchSelector.tsx
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:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants