Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergedjuliusmarmingemerged 5 commits intomain fromrefs/pull/4460/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

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

Scope PR state display to the active thread branch in the branch toolbar and sidebar

  • resolveThreadPr in ThreadStatusIndicators.tsx removes the hasDedicatedWorktree parameter and now returns null unless gitStatus.refName exactly matches the stored threadBranch.
  • A new resolveBranchToolbarPrBranch util in BranchToolbar.logic.ts gates the PR pill in the branch selector on the explicit thread branch matching the currently displayed branch, hiding it during optimistic branch switches.
  • Call sites in BranchToolbarBranchSelector.tsx, ChatView.tsx, Sidebar.tsx, and SidebarV2.tsx drop the hasDedicatedWorktree argument.
  • Behavioral Change: PR indicators that previously appeared whenever a dedicated worktree was present will now be hidden if the checked-out branch does not match the stored thread branch.
Macroscope summarized 9eb2b6e.

Note

Medium Risk Changes thread settlement and PR UI across several surfaces, but narrows behavior to branch-consistent checks and is covered by updated unit tests.

Overview PR badges and auto-settlement now only apply when the live Git checkout matches the thread’s stored branch. resolveThreadPr drops the dedicated-worktree bypass and the hasDedicatedWorktree argument everywhere (sidebar, chat banner, branch toolbar).

The branch toolbar adds resolveBranchToolbarPrBranch so the PR pill uses the thread branch only when it matches the displayed branch, and stays hidden during optimistic branch switches or when thread branch metadata is missing.

Tests replace the old “stale worktree still shows PR” cases with coverage for mismatched checkout, missing branch, and matching branch.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9eb2b6eb4761f27826b27c484f2e38e9d6842d8b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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: 379d7b85-f7aa-4fdc-8ff2-eb2db936e89b

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot), but a cloud agent failed to start. Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cb3744ebaa2795d73711d754a58f6fda775d344f. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved

      This is a straightforward bug fix scoping PR state display to only when the thread branch matches the current checkout. Changes are limited to UI indicator logic with comprehensive test coverage.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge merged this7248877

    6. juliusmarminge closed this

Sign in to join this conversation.