Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): avoid PRs inherited from default upstreams #7317

Mergedgsimone(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/7317/headmerged by maria-rcks View on GitHub

Problem

A local feature branch can legitimately track the repository's default branch when it is created from a remote start point:

git worktree add -b feature/local-worktree /tmp/local-worktree origin/main

Git records origin/main as the new branch's upstream. T3 currently derives the PR head selector from that upstream, so it searches for PRs whose head is main instead of feature/local-worktree.

If the repository has ever merged a reverse PR with main as its head and another branch as its base, T3 associates that historical merged PR with the unrelated feature thread. The merged PR state then feeds the normal thread lifecycle and auto-settles the thread once its session is idle.

This is intermittent across repositories and worktrees because it requires both:

  1. a differently named local feature branch tracking the remote default branch; and
  2. historical PR metadata with the default branch as the PR head.

Anonymized reproduction

A public repository containing only synthetic fixture data is available at:

https://github.com/gsimone/t3-default-upstream-pr-repro

Its merged PR #1 deliberately uses main as the head and maintenance-target as the base:

https://github.com/gsimone/t3-default-upstream-pr-repro/pull/1

Reproduce the Git state with:

git clone git@github.com:gsimone/t3-default-upstream-pr-repro.git
cd t3-default-upstream-pr-repro
git worktree add -b feature/local-worktree /tmp/t3-pr-repro-worktree origin/main
git -C /tmp/t3-pr-repro-worktree status --short --branch
git -C /tmp/t3-pr-repro-worktree rev-parse --abbrev-ref --symbolic-full-name '@{upstream}'

Before this fix, opening a T3 thread for /tmp/t3-pr-repro-worktree can show the merged synthetic PR even though feature/local-worktree has no PR. When the thread becomes idle, the unrelated merged state can move it to the settled shelf.

Expected behavior: the remote default branch is treated as the feature branch's starting/base relationship, not as its published PR head.

Fix

  • Expose the resolved default branch in the internal remote Git status details.
  • Include it in PR lookup cache identity.
  • Skip PR lookup when a differently named local branch resolves through its upstream to the default branch.
  • Preserve existing same-repository remote aliases and cross-repository/fork PR detection.
  • Add an integration-style GitManager regression that constructs the tracking relationship with real Git commands and verifies that no provider PR lookup occurs.

Verification

  • vp test run apps/server/src/git/GitManager.test.ts — 83 passed
  • pnpm --filter t3 typecheck — passed (existing unrelated Effect suggestions only)

Implemented with GPT-5.6 Sol through the Codex harness in T3 Code.

Note

Fix PR status resolution to ignore PRs inherited from default branch upstreams

  • When a local branch tracks origin/main (or the repo's default branch) in the same repository, GitManager.status now returns null for the PR lookup instead of inheriting a merged PR from that default branch.
  • Fork PRs whose head branch happens to share the name of the default branch (e.g., contributor:main) are still resolved correctly, since the early-exit only applies to same-repo branches.
  • The PR lookup cache key in prLookupCacheKey now includes defaultBranch so cache entries are correctly segmented when the default branch varies.
  • defaultBranch is added to GitRemoteStatusDetails and propagated from GitVcsDriverCore through to lookupStatusPr.
Macroscope summarized 81a3765.
    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: 5b7e8e46-9e77-4514-9288-e0981606630b

      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

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

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      1 blocking correctness issue found.

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

    5. maria-rcks closed this

Sign in to join this conversation.