diff --git a/packages/source-control-core/src/server/pullRequestChecks.test.ts b/packages/source-control-core/src/server/pullRequestChecks.test.ts index ba685083292449d6c8767db975c116c638fb0c5b..5033e719decb0a03ed67f5bc28507b4f9c8dfc91 100644 --- a/packages/source-control-core/src/server/pullRequestChecks.test.ts +++ b/packages/source-control-core/src/server/pullRequestChecks.test.ts @@ -50,6 +50,28 @@ describe("dedupeChecks", () => { ]); }); + it("keeps distinct workflow and check pairs even when their names join to the same text", () => { + const checks = dedupeChecks([ + entry("Linux tests", "success", { + workflowName: "Build", + at: "2026-08-11T16:00:00Z", + }), + entry("tests", "success", { + workflowName: "Build Linux", + at: "2026-08-11T17:00:00Z", + }), + entry("Linux tests", "failure", { + workflowName: "Build", + at: "2026-08-11T18:00:00Z", + }), + ]); + + expect(checks.map((check) => [check.name, check.status])).toEqual([ + ["Linux tests", "failure"], + ["tests", "success"], + ]); + }); + it("loses a run that never said when it happened to one that did, whichever came first", () => { const undated = dedupeChecks([ entry("build", "success", { at: "2026-08-11T16:00:00Z" }), diff --git a/packages/source-control-core/src/server/pullRequestChecks.ts b/packages/source-control-core/src/server/pullRequestChecks.ts index 819cf47b01af485b83769c0c96f37f58d5769ae9..491b018032317af0eed6adea3973969611c78aca 100644 --- a/packages/source-control-core/src/server/pullRequestChecks.ts +++ b/packages/source-control-core/src/server/pullRequestChecks.ts @@ -36,7 +36,7 @@ export function dedupeChecks( ): ReadonlyArray { const newestByCheck = new Map(); for (const entry of entries) { - const key = `${entry.workflowName ?? ""} ${entry.check.name}`; + const key = JSON.stringify([entry.workflowName ?? "", entry.check.name]); const kept = newestByCheck.get(key); // Re-setting a key a Map already holds keeps its first position, which is the order wanted. if (kept === undefined || isAtLeastAsNew(entry.at, kept.at)) newestByCheck.set(key, entry);