Skip to content

Commit 540fe67

Browse files
PR Batch Testerclaude
andcommitted
fix(shared): a duplicate pull request link can't loop the stack walk
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7b82650 commit 540fe67

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎packages/shared/src/threadPullRequests.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,16 @@ describe("chain selection and badge state", () => {
477477
});
478478
});
479479

480+
it("lists a pull request once when two links share its identity", () => {
481+
const links = [
482+
link(1, { snapshot: snapshot({ headBranch: "a" }) }),
483+
link(1, { snapshot: snapshot({ headBranch: "b", baseBranch: "a" }) }),
484+
];
485+
expect(resolveThreadPullRequestChains(links).map((chain) => chain.layers)).toEqual([
486+
[links[0]],
487+
]);
488+
});
489+
480490
it("does not guess a parent when a head branch was reused", () => {
481491
const links = [
482492
link(1, { snapshot: snapshot({ state: "merged", headBranch: "reused" }) }),

‎packages/shared/src/threadPullRequests.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ export function resolveThreadPullRequestChains(
284284
];
285285
for (let next = pending.pop(); next !== undefined; next = pending.pop()) {
286286
const key = threadPullRequestKeyOf(next.link);
287+
// Two links with one identity would otherwise share a child list and expand forever.
288+
if (placed.has(key)) continue;
287289
placed.add(key);
288290
layers.push(next.link);
289291
depths.push(next.depth);

0 commit comments

Comments
 (0)