Skip to content

fix(web): scope PR state to the thread branch#4460

Draft
juliusmarminge wants to merge 1 commit into
mainfrom
agent/fix-divergent-thread-pr-state
Draft

fix(web): scope PR state to the thread branch#4460
juliusmarminge wants to merge 1 commit into
mainfrom
agent/fix-divergent-thread-pr-state

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jul 24, 2026

Copy link
Copy Markdown
Member

What changed

  • Require the live Git checkout branch to match the thread's stored branch before associating PR state.
  • Apply the same branch-consistent resolution across the sidebar, sidebar v2, chat settlement banner, and branch toolbar.
  • Replace the stale-worktree expectation with regression coverage for mismatched, missing, and matching branch metadata.

Why

A dedicated worktree could temporarily switch to a stacked PR's head branch while the thread retained its original base branch. The UI bypassed its branch consistency check for dedicated worktrees, combining the persisted base-branch label with the live checkout's PR badge.

This could also feed the unrelated PR's merged or closed state into automatic thread settlement.

Impact

Threads no longer display or settle from a PR belonging to a different live checkout. PR indicators remain visible when the live checkout matches the thread branch.

Validation

  • vp test run apps/web/src/components/ThreadStatusIndicators.test.ts
  • targeted vp lint --report-unused-disable-directives for the six changed files
  • vp run --filter @t3tools/web typecheck
  • git diff --check
  • React Doctor completed without changed-source diagnostics

An isolated T3 web environment launched and authenticated successfully. Browser-level inspection could not complete because collaborative preview snapshots timed out and the documented fallback reported no available browser backend.

Note

Fix resolveThreadPr to scope PR state to the thread branch

Previously, resolveThreadPr could return a PR when a dedicated worktree existed, regardless of which branch was checked out. It now returns a PR only when gitStatus.refName matches the stored threadBranch, and returns null if threadBranch is null or mismatched.

  • The hasDedicatedWorktree parameter is removed from resolveThreadPr in ThreadStatusIndicators.tsx and all call sites.
  • Behavioral Change: PR indicators are now hidden when the live checkout branch differs from the stored thread branch.
📊 Macroscope summarized 463d7de. 4 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

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 Plus

Run ID: 9ef55687-1658-4fdc-80c9-d51f23891dbc

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
  • Commit unit tests in branch agent/fix-divergent-thread-pr-state

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 24, 2026
@@ -593,7 +593,6 @@ export function BranchToolbarBranchSelector({
const branchPr = resolveThreadPr({
threadBranch: resolvedActiveBranch,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Medium components/BranchToolbarBranchSelector.tsx:594

resolveThreadPr is called with resolvedActiveBranch, which falls back to currentGitBranch via resolveBranchToolbarValue. When the thread has no stored branch, resolvedActiveBranch equals gitStatus.refName, so the PR pill displays even though no thread-branch association exists — exactly the behavior the hasDedicatedWorktree removal was meant to eliminate. Pass activeThreadBranch instead so the PR only shows when the thread has an explicit stored branch.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/components/BranchToolbarBranchSelector.tsx around line 594:

`resolveThreadPr` is called with `resolvedActiveBranch`, which falls back to `currentGitBranch` via `resolveBranchToolbarValue`. When the thread has no stored branch, `resolvedActiveBranch` equals `gitStatus.refName`, so the PR pill displays even though no thread-branch association exists — exactly the behavior the `hasDedicatedWorktree` removal was meant to eliminate. Pass `activeThreadBranch` instead so the PR only shows when the thread has an explicit stored branch.

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

Labels

size:S 10-29 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.

1 participant