fix(git): stop new threads inheriting historical branch PRs#31958

open1
main
GitHub fork: fix/31896-historical-branch-pr
opened4d agobySsldone
View on GitHubTwo-way sync enabledPR last imported 18h ago

New threads on a reused non-default branch inherit its latest merged or closed PR. Clearing the automatic association alone also leaves the toolbar and command palette showing the same historical PR through raw Git status.

Filter automatic discovery and saved-reference restoration when the PR completed before the thread was created. Include creation time in the narrow discovery snapshot, and share the open-only Git-status fallback across the toolbar and thread status indicators. Older threads and explicit PR links retain their historical context. Hosts without completion timestamps retain their existing association behavior.

Fixes #31896. This is a focused fix for the unresolved badge bug acknowledged in the maintainer follow-up.

Verification:

  • Reproduced the failure with tests for two new threads sharing staging; both inherited the historical PR before the fix.
  • Regression coverage checks open/merged/closed PRs, older and same-time threads, stale saved automatic references, explicit links, and the raw-status display fallback.
  • vp run check:changed passed: formatting, lint, both knip checks, GraphQL validation, typechecking for four affected packages, 77 tests, and React compiler checks for both changed components.
  • Two independent agent reviews completed; the first found the raw-status UI bypass, which is fixed. The final review reported no further findings.
  • No live GitHub merge reproduction or manual desktop/mobile session was performed.

Written with GPT-6.1 Sol through the Codex harness in T3 Code.

Checks

23 successful · 8 skipped
All checks passed
1f472f0

Added 1 commit

  • fix(git): stop new threads inheriting historical branch PRs1f472f0
Synced from GitHub

Approvability

Verdict: Approved at 1f472f0

Macroscope's review found this PR approvable — Prevents new threads from inheriting PRs that closed before the thread existed and limits unlinked branch badges to open PRs. The change is confined to thread associations and presentation, with existing synchronization safeguards retained.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Explain Change →

Walkthrough

The server now uses thread creation time when associating merged or closed pull requests. The web branch selector displays a Git-status pull request only when it is open.

Changes: Pull request handling

Layer / File(s)Summary
Server association and snapshot
apps/server/src/orchestration-v2/ProjectionStore.ts, apps/server/src/orchestration-v2/ThreadPullRequestService.ts, apps/server/src/orchestration-v2/ThreadPullRequestService.test.ts
Pull request snapshots now include thread creation time. The service does not associate a merged or closed pull request with a thread when its terminal timestamp predates the thread. Tests cover open, merged, and closed pull requests, saved associations, and the projected timestamp.
Branch pull request display
apps/web/src/components/ThreadStatusIndicators.tsx, apps/web/src/components/BranchToolbarBranchSelector.tsx, apps/web/src/components/ThreadStatusIndicators.test.ts
The branch selector uses the shared pull request resolver. The resolver accepts a Git-status pull request only when its state is open, and tests cover open, merged, and closed states.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • pingdotgg/t3code#8209 reports a historical merged pull request appearing through Git status; this change limits that display fallback to open pull requests.

Possibly related PRs

  • pingdotgg/t3code#25728: Changes the service’s pull request sync snapshot, which this PR extends with thread creation time.
  • pingdotgg/t3code#30356: Adds the pull request snapshot that this PR extends with thread creation time.

Suggested labels: bugfix

Suggested reviewers: juliusmarminge

Merge Risk: External image Minimal · up to 1f472

The reviewed changes have no established merge-blocking issue. The optional timestamp explanation need not delay merging.

Pre-merge checks: Passed 4

Check nameStatusExplanation
Title checkPassedThe title clearly describes the main change: preventing new threads from inheriting historical branch PRs.
Description checkPassedThe description covers the problem, change, scope, and verification. It omits the template headings and before-and-after screenshots for the UI changes.
Linked Issues checkPassed[#31896] Automatic discovery and saved-reference restoration reject PRs completed before thread creation. Open PRs, older threads, explicit links, and hosts without completion timestamps retain their …
Out of Scope Changes checkPassed[#31896] The projection timestamp, association filter, shared display fallback, and tests support the linked issue. No unrelated changes are identified.
Full details: Linked Issues check

Explanation

[#31896] Automatic discovery and saved-reference restoration reject PRs completed before thread creation. Open PRs, older threads, explicit links, and hosts without completion timestamps retain their behavior. The toolbar and status indicators use an open-only Git-status fallback. Regression tests cover PR states, thread timing, saved references, explicit links, and the fallback.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
CcoderabbitaiBotreviewed4d ago
Synced from GitHub
External image Additional comments: 1

apps/server/src/orchestration-v2/ThreadPullRequestService.ts: 1

53-64: External image Trivial · Maintainability & Code Quality · Low value

External image Unverified finding Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Handle unparseable terminal timestamps explicitly.

closedAt and mergedAt are Schema.String in PullRequestSummary. They are not IsoDateTime. If a host returns a non-ISO string, Date.parse returns NaN. The comparison NaN < n is false. The function then returns false, so the PR is associated as before. This behavior is a safe fallback and matches the stated "no timestamp" behavior. Add a short comment to state that this fallback is intentional.

External image Review info

External image Run configuration

External image Commits

Reviewing files that changed from the base of the PR and between 9899b4724d14ad1911a228cfebeca35aa6cad8b1 and 1f472f0f17ce2e0ec0dddfdb3d1ff044d38e726f.

External image Files selected for processing: 6

  • apps/server/src/orchestration-v2/ProjectionStore.ts
  • apps/server/src/orchestration-v2/ThreadPullRequestService.test.ts
  • apps/server/src/orchestration-v2/ThreadPullRequestService.ts
  • apps/web/src/components/BranchToolbarBranchSelector.tsx
  • apps/web/src/components/ThreadStatusIndicators.test.ts
  • apps/web/src/components/ThreadStatusIndicators.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Synced from GitHub

Reviewed the optional timestamp note: missing or unparseable completion timestamps intentionally preserve existing associations, since they do not establish that a PR predates the thread. The PR description already documents this compatibility fallback. No behavior change is needed.