Skip to content

Commit df08561

Browse files
committed
fix(pr): count cancelled runs as failing in the list rollup
The list rollup ignored cancelled runs while the client's detail rollup read them as failing, so a head with one cancelled run flapped between failing and a stale-checks banner once the two were compared. Both now agree, matching how GitHub's own rollup reads it. Also memoize the linked-thread reference so sidebar rows stop touching the shared summary cache every render.
1 parent 122e012 commit df08561

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎apps/server/src/pullRequest/gitHubPullRequestJson.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ describe("pull request list decoding", () => {
121121
{ statusCheckRollup: [{ context: "ci/legacy", state: "ERROR" }] },
122122
// Neither a pass, a failure nor a wait is no verdict rather than a green tick.
123123
{ statusCheckRollup: [{ name: "lint", status: "COMPLETED", conclusion: "SKIPPED" }] },
124+
// Cancelled reads as failing here and in the detail header, so the two never flap.
125+
{
126+
statusCheckRollup: [
127+
{ name: "lint", status: "COMPLETED", conclusion: "SUCCESS" },
128+
{ name: "test", status: "COMPLETED", conclusion: "CANCELLED" },
129+
],
130+
},
124131
{ statusCheckRollup: [] },
125132
{},
126133
]),
@@ -132,6 +139,7 @@ describe("pull request list decoding", () => {
132139
"passing",
133140
"failing",
134141
null,
142+
"failing",
135143
null,
136144
null,
137145
]);

‎apps/server/src/pullRequest/gitHubPullRequestJson.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,9 @@ function toCheckEntries(
14471447
* GitHub's own indicator reads: a run that has already gone red will not go green by finishing.
14481448
*
14491449
* Null rather than "passing" for a head commit with no checks at all, so a repository that runs
1450-
* none shows nothing instead of a green tick it never earned. Checks whose verdict is neither a
1451-
* pass, a failure nor a wait — skipped, cancelled, neutral — count towards neither.
1450+
* none shows nothing instead of a green tick it never earned. A cancelled run is a failure, as
1451+
* GitHub's own rollup and the client's detail rollup both read it; skipped and neutral count
1452+
* towards neither, so the row and the detail header never disagree about one head commit.
14521453
*
14531454
* Counted off the deduped checks rather than the raw rollup, so the word and the list under it
14541455
* cannot disagree: the run a re-run replaced is not a verdict twice. A row with no name at all is
@@ -1463,7 +1464,7 @@ function rollupChecksState(
14631464
...(raw ?? []).filter(isNamelessCheck).map((check) => toCheckStatus(check)),
14641465
];
14651466
if (statuses.length === 0) return null;
1466-
if (statuses.includes("failure")) return "failing";
1467+
if (statuses.includes("failure") || statuses.includes("cancelled")) return "failing";
14671468
if (statuses.includes("pending") || statuses.includes("action-required")) return "pending";
14681469
return statuses.includes("success") ? "passing" : null;
14691470
}

‎apps/web/src/components/ThreadStatusIndicators.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ export function useLinkedThreadPullRequest(
7676
);
7777
const fallback =
7878
current === null ? ((!supportsLinks ? linkedPullRequest : null) ?? branchPullRequest) : null;
79-
const host = fallback == null ? undefined : parseChangeRequestUrl(fallback.url)?.host;
80-
const reference =
81-
fallback == null ? null : { ...fallback, ...(host === undefined ? {} : { host }) };
79+
// Stable per link: the shared summary effect keys on this object, and a sidebar row must not
80+
// touch the cache on every render.
81+
const reference = useMemo(() => {
82+
if (fallback == null) return null;
83+
const host = parseChangeRequestUrl(fallback.url)?.host;
84+
return { ...fallback, ...(host === undefined ? {} : { host }) };
85+
}, [fallback]);
8286
const queried = useEnvironmentQuery(
8387
!enabled || environmentId === null || reference === null
8488
? null

0 commit comments

Comments
 (0)