Skip to content

fix(server): preserve merged PR badges after branch deletion - #6216

Merged
t3dotgg merged 2 commits into
pingdotgg:mainfrom
tris203:t3code/preserve-merged-pr-badge
Aug 24, 2026
Merged

fix(server): preserve merged PR badges after branch deletion#6216
t3dotgg merged 2 commits into
pingdotgg:mainfrom
tris203:t3code/preserve-merged-pr-badge

Conversation

@tris203

@tris203 tris203 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

A merged or closed PR badge disappeared when its remote head branch was deleted. Git could no longer resolve the upstream ref, and the unpublished-branch optimization treated the missing remote-tracking ref as proof that the branch had never been published, suppressing the provider lookup.

Treat a branch as definitely unpublished only when it has neither a matching remote-tracking ref nor complete branch remote/merge configuration. The latter survives deletion of a tracked remote branch, so the provider can still discover the merged or closed change request while genuinely local branches keep the API-call optimization.

Verification:

  • pnpm exec vp test run apps/server/src/git/GitManager.test.ts (82 passed)
  • targeted formatting and lint checks passed
  • server typecheck passed

Implemented with GPT-5.6-sol via the Codex harness in T3 Code.


Note

Low Risk
Narrow change to the unpublished-branch skip used for PR lookup; local-only branches still skip the API, and a targeted test covers the deleted-remote-branch case.

Overview
Fixes git status so a merged/closed PR badge still appears after GitHub deletes the remote head branch.

isUnpublishedBranch no longer treats a missing remote-tracking ref as “never published.” If branch.<local>.remote and branch.<local>.merge are still set (Git keeps those after a delete), the branch is treated as published and the provider lookup still runs. Genuinely local branches keep the skip.

Adds a regression test that deletes the remote branch, asserts hasUpstream is false, and still returns the merged PR.

Reviewed by Cursor Bugbot for commit 73f6c59. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix GitManager.make.isUnpublishedBranch to read git config for upstream metadata

When GitHub auto-deletes a merged PR's head branch, the remote-tracking ref disappears but local git config (branch.<name>.remote and branch.<name>.merge) persists. The old logic relied only on remote-tracking ref presence, so these branches were misclassified as unpublished and PR lookups were skipped.

  • isUnpublishedBranch now accepts both headBranch and localBranch, and first checks the git config keys for localBranch; if both are present, the branch is treated as published
  • Falls back to checking remotes and remote-tracking refs for headBranch only when config keys are absent
  • Adds a test in GitManager.test.ts verifying that manager.status returns hasUpstream: false but still populates PR metadata with a merged state after branch deletion
  • Risk: branches pushed without -u that have neither config keys nor remote-tracking refs remain unpublished — no change to those; but any branch with stale branch.<name>.merge config pointing at a deleted upstream will now trigger a provider PR lookup it would not have before

Macroscope summarized 73f6c59.

@coderabbitai

coderabbitai Bot commented Aug 11, 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: 88397bf6-3328-4cf5-a3cd-b408cbebb8c7

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 11, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Skipped

Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

@tris203

tris203 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

GPT-5.6-sol via Codex, responding on behalf of @tris203:

Thanks for flagging this. The direct gitCore.readConfigValue calls are intentional here. A missing config key is returned as null, so the remote-ref checks still run and genuinely unpublished branches retain the API-call optimization. A Git/config command failure instead propagates to the outer orElseSucceed(() => false), which means “we cannot prove this branch is unpublished” and preserves the provider lookup.

Using readConfigValueNullable would collapse a command failure into null, allowing the subsequent ref checks to classify the branch as unpublished and potentially suppress a real PR lookup during a transient Git failure. The conservative fallback is therefore deliberate and matches the existing function comment that any failed probe keeps the lookup.

@tris203
tris203 force-pushed the t3code/preserve-merged-pr-badge branch from 53a2238 to 85edeb7 Compare August 13, 2026 10:50
@tris203
tris203 force-pushed the t3code/preserve-merged-pr-badge branch from 85edeb7 to 7f9c975 Compare August 23, 2026 08:28
@t3dotgg
t3dotgg merged commit ba30177 into pingdotgg:main Aug 24, 2026
23 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 24, 2026
## What's Changed
* fix(server): bound OpenCode skill discovery output by @Lucenx9 in pingdotgg/t3code#7675
* fix(mobile): persist thread shelf collapse state by @PixPMusic in pingdotgg/t3code#5152
* fix(mobile): restore Android tablet thread controls, clean up header by @PixPMusic in pingdotgg/t3code#5385
* fix(mobile): land the first thread open above the composer on Android by @PollyGlot in pingdotgg/t3code#5585
* fix(server): check out submodules in a new worktree by @Brechard in pingdotgg/t3code#7674
* fix(server): preserve merged PR badges after branch deletion by @tris203 in pingdotgg/t3code#6216
* fix(server): return fresh live pull request reads by @Adamulek123 in pingdotgg/t3code#6472
* fix(web): compare client and server versions as semver, not strings by @spiky02plateau in pingdotgg/t3code#7579
* fix(web): stop follow-ups from leaving giant blank space by @t3dotgg in pingdotgg/t3code#8068
* fix(marketing): stop automatic Vercel deployments on pull requests by @t3dotgg in pingdotgg/t3code#8070
* chore: vouch repeat contributors by @t3dotgg in pingdotgg/t3code#8071
* fix(server): keep the authoritative subagent model when snapshots race task_started by @spiky02plateau in pingdotgg/t3code#7583
* fix(server): honor auto-accept edits for the OpenCode provider by @Rishet11 in pingdotgg/t3code#7100
* fix(server): run the CLI on Node versions without import.meta.main by @CDVolvik in pingdotgg/t3code#7141
* fix(server): recover from provider interrupt failures by @mrmg in pingdotgg/t3code#7412
* fix(server): recreate a thread's worktree before starting a turn by @mackinleysmith in pingdotgg/t3code#7839
* fix(server): thread delete no longer fails on already-removed worktrees by @t3dotgg in pingdotgg/t3code#8076
* fix(web): stop update notices showing through the composer by @t3dotgg in pingdotgg/t3code#8083

## New Contributors
* @spiky02plateau made their first contribution in pingdotgg/t3code#7579

**Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260824.1175...v0.0.34-nightly.20260824.1176

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260824.1176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants