pingdotgg / pingdotgg/t3code

[Bug]: Reused long-lived branch remains associated with a historical merged PR

Open
#4,970 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

Before submitting
  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
Area

apps/web

Steps to reproduce
  1. Use a long-lived integration branch in a local checkout, for example dev.
  2. Open a PR from dev to main and merge it.
  3. Continue using the same dev branch after the merge for new work.
  4. Create a new T3 Code thread on the local checkout while dev is checked out.
  5. Complete a turn and inspect the branch/PR indicator and Sidebar V2 thread state.

Concrete observed case: GitHub PR rebel-tickets/NewWeb#182 was merged from dev into main. New unrelated threads created later on the still-active dev branch display #182 as their PR.

Expected behavior

A new thread on a reused long-lived branch should not inherit a historical merged PR merely because its head branch name matches.

T3 Code should associate a terminal PR only while it still describes the current branch state. If the branch HEAD has advanced beyond the PR head after merge, the historical PR badge/state should be ignored. Consequently, unrelated new threads should remain active.

Actual behavior

T3 Code displays the historical merged PR on every new thread using the reused dev branch. The merged PR state is then fed into automatic settlement, so each new unrelated thread settles when its turn finishes even when Auto-settle inactive threads is disabled.

The settle behavior is secondary damage. The root problem is stale PR association for a reused branch.

This appears adjacent to #4460, which prevents PR state from a different branch affecting settlement, but exact branch-name equality is insufficient for a long-lived branch reused after a merge. It is also related to #4752/#4755, which retain terminal PR state for local checkouts.

Suggested minimal fix: for merged/closed PRs, verify that the current branch HEAD still corresponds to the PR head commit before displaying or applying its terminal state. If the branch has advanced, discard the historical association. Open PR selection can continue using the existing branch match.

Impact

Major degradation or frequent failure

Version or commit

Current T3 Code desktop build as of 2026-07-30

Environment

macOS desktop app, local checkout, Sidebar V2, GitHub repository, Codex provider

Logs or stack traces
No runtime error. GitHub reports the historical PR as:
baseRefName=main
headRefName=dev
state=MERGED
Workaround

Disable Sidebar V2 or create threads on a new uniquely named branch/worktree. Disabling Auto-settle inactive threads does not help because merged/closed PR settlement is unconditional.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/web by tracing the Sidebar V2 branch/PR indicator and the automatic-settlement path. Reproduce the merged PR on a reused dev branch, advance the branch, and create a new thread. Done means the historical PR is ignored after the branch HEAD advances and the unrelated thread remains active.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github, typescript
Domain
desktop, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.