Ignore merged pull requests found by implicit branch matches (#5524)

Merged pull requests are historical branch matches and should not be
treated as implicit review context unless the worktree has an explicit
PR link. Showing them as implicit review context leaves nothing
meaningful to unlink after the branch has been rebased or merged.
This commit is contained in:
Jinjing
2026-06-16 15:39:57 -07:00
committed by GitHub
parent 2e93b6002e
commit f6fec257eb
2 changed files with 215 additions and 0 deletions
+15
View File
@@ -1928,6 +1928,13 @@ function mapRestPullRequest(pr: RestPullRequest): PullRequestLookupData {
}
}
function isMergedImplicitPR(data: PullRequestLookupData, linkedPRNumber?: number | null): boolean {
// Why: merged PRs are historical branch matches unless the worktree has an
// explicit PR link. Showing them as implicit review context leaves nothing
// meaningful to unlink after the branch has been rebased or merged.
return typeof linkedPRNumber !== 'number' && mapPRState(data.state, data.isDraft) === 'merged'
}
function normalizePullRequestLookupData(data: PullRequestLookupData): PullRequestLookupData {
return {
...data,
@@ -2423,6 +2430,11 @@ export async function getPRForBranchOutcome(
}
}
}
if (data && isMergedImplicitPR(data, linkedPRNumber)) {
data = null
dataRepo = null
dataHeadRepo = headRepo
}
if (!data && typeof linkedPRNumber !== 'number' && typeof fallbackPRNumber === 'number') {
const fallbackLookup = await lookupPRByNumber({
candidates,
@@ -2435,6 +2447,9 @@ export async function getPRForBranchOutcome(
if (!data) {
return { kind: 'no-pr', fetchedAt: Date.now() }
}
if (isMergedImplicitPR(data, linkedPRNumber)) {
return { kind: 'no-pr', fetchedAt: Date.now() }
}
const mergeable = derivePullRequestMergeable(data)
const conflictSummary =