@devries-cameron20 / t3code Mirror · read-only / commits / 03c1a76de9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 23:15 UTC

fix(pull-request): prioritize failed checks (#12274)

Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Akash Moradiya committed Oct 20, 2026 at 10:25 UTC 03c1a76de90e8e4bf9320e4f278a4ab6f5ee4b00
10 files changed +107 -33
packages/source-control-bitbucket/src/server/BitbucketPullRequestApi.test.ts
+24 -3
@@ -568,18 +568,39 @@ layer("BitbucketPullRequestApi.layer", (it) => {
568 const next = "https://api.bitbucket.org/2.0/statuses?page=2";
569 mockedRequest
570 .mockReturnValueOnce(
571 - Effect.succeed(response(valuePage([{ name: "Build", state: "SUCCESSFUL" }], next))),
571 + Effect.succeed(
572 + response(
573 + valuePage(
574 + [
575 + { name: "Build", state: "SUCCESSFUL" },
576 + { name: "Tests", state: "STOPPED" },
577 + ],
578 + next,
579 + ),
580 + ),
581 + ),
582 )
583 .mockReturnValueOnce(
574 - Effect.succeed(response(valuePage([{ name: "Lint", state: "FAILED" }]))),
584 + Effect.succeed(
585 + response(
586 + valuePage([
587 + { name: "Lint", state: "FAILED" },
588 + { name: "Deploy", state: "INPROGRESS" },
589 + { name: "Audit", state: "FAILED" },
590 + ]),
591 + ),
592 + ),
593 );
594 const api = yield* BitbucketPullRequestApi.BitbucketPullRequestApi;
595
596 const checks = yield* api.listChecks({ repository: "acme/web", number: 7 });
597
598 expect(checks.map((check) => [check.name, check.status])).toEqual([
581 - ["Build", "success"],
599 + ["Tests", "cancelled"],
600 ["Lint", "failure"],
601 + ["Audit", "failure"],
602 + ["Build", "success"],
603 + ["Deploy", "pending"],
604 ]);
605 expect(callAt(1).url).toBe(next);
606 }),
packages/source-control-bitbucket/src/server/BitbucketPullRequestApi.ts
+2 -1
@@ -23,6 +23,7 @@ import type {
23
24 import * as BitbucketApi from "./BitbucketApi.ts";
25 import { parseDiffFileRevisions } from "@t3tools/source-control-core/server/diffFileRevisions";
26 +import { sortChecks } from "@t3tools/source-control-core/server/pullRequestChecks";
27 import {
28 buildReviewThreads,
29 decodeCommentsJson,
@@ -671,7 +672,7 @@ export const make = Effect.gen(function* () {
672 decode: decodeStatusesJson,
673 items: [],
674 prepend: false,
674 - }),
675 + }).pipe(Effect.map(sortChecks)),
676 ),
677
678 listReviewerCandidates: (input) =>
packages/source-control-bitbucket/src/server/bitbucketPullRequestJson.test.ts
+1 -1
@@ -350,8 +350,8 @@ describe("decodeStatusesJson", () => {
350 );
351
352 expect(decoded.items.map((check) => [check.name, check.status])).toEqual([
353 - ["build / Pipeline", "success"],
353 ["deploy / Pipeline", "failure"],
354 + ["build / Pipeline", "success"],
355 ]);
356 });
357 });
packages/source-control-core/src/server/pullRequestChecks.test.ts
+21 -2
@@ -133,6 +133,25 @@ describe("dedupeChecks", () => {
133 ]);
134 });
135
136 + it("puts failed and cancelled checks first, preserving each group's order after reruns", () => {
137 + const checks = dedupeChecks([
138 + entry("lint", "failure", { at: "2026-08-11T16:00:00Z" }),
139 + entry("integration", "cancelled"),
140 + entry("types", "pending"),
141 + entry("unit", "failure"),
142 + entry("format", "success"),
143 + entry("lint", "success", { at: "2026-08-11T18:00:00Z" }),
144 + ]);
145 +
146 + expect(checks.map((check) => [check.name, check.status])).toEqual([
147 + ["integration", "cancelled"],
148 + ["unit", "failure"],
149 + ["lint", "success"],
150 + ["types", "pending"],
151 + ["format", "success"],
152 + ]);
153 + });
154 +
155 it("keeps distinct workflow and check pairs even when their names join to the same text", () => {
156 const checks = dedupeChecks([
157 entry("Linux tests", "success", {
@@ -181,8 +200,8 @@ describe("dedupeChecks", () => {
200 ]);
201
202 expect(checks.map((check) => [check.name, check.status])).toEqual([
184 - ["CI / build", "success"],
203 ["Release / build", "failure"],
204 + ["CI / build", "success"],
205 ]);
206 });
207
@@ -193,6 +212,6 @@ describe("dedupeChecks", () => {
212 entry("build", "failure", { workflowName: "CI", at: "2026-08-11T16:00:00Z" }),
213 ]);
214
196 - expect(checks.map((check) => check.name)).toEqual(["build", "CI / build"]);
215 + expect(checks.map((check) => check.name)).toEqual(["CI / build", "build"]);
216 });
217 });
packages/source-control-core/src/server/pullRequestChecks.ts
+18 -6
@@ -36,6 +36,16 @@ function isAtLeastAsNew(candidate: string | null, kept: string | null): boolean
36 );
37 }
38
39 +export function sortChecks(
40 + checks: ReadonlyArray<PullRequestCheck>,
41 +): ReadonlyArray<PullRequestCheck> {
42 + return checks.toSorted(
43 + (a, b) =>
44 + Number(b.status === "failure" || b.status === "cancelled") -
45 + Number(a.status === "failure" || a.status === "cancelled"),
46 + );
47 +}
48 +
49 /**
50 * A host's rollup is a list of runs, not a list of checks: while a workflow is being re-run — or
51 * while a second run of it is already live — the same check arrives twice, and both copies reach
@@ -61,10 +71,12 @@ export function dedupeChecks(
71 for (const entry of survivors) {
72 countsByName.set(entry.check.name, (countsByName.get(entry.check.name) ?? 0) + 1);
73 }
64 - return survivors.map((entry) => {
65 - const workflowName = entry.workflowName ?? "";
66 - return workflowName.length > 0 && (countsByName.get(entry.check.name) ?? 0) > 1
67 - ? { ...entry.check, name: `${workflowName} / ${entry.check.name}` }
68 - : entry.check;
69 - });
74 + return sortChecks(
75 + survivors.map((entry) => {
76 + const workflowName = entry.workflowName ?? "";
77 + return workflowName.length > 0 && (countsByName.get(entry.check.name) ?? 0) > 1
78 + ? { ...entry.check, name: `${workflowName} / ${entry.check.name}` }
79 + : entry.check;
80 + }),
81 + );
82 }
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+12 -6
@@ -240,11 +240,17 @@ it.effect.each([
240 for (const checks of [summary.checks, detail.checks]) {
241 assert.deepStrictEqual(
242 checks.map((check) => [check.name, check.status, check.required]),
243 - [
244 - ["ci/required-build", "success", supported ? true : undefined],
245 - ["ci/optional-lint", supported ? "failure" : "success", undefined],
246 - [missing, "pending", supported ? true : undefined],
247 - ],
243 + supported
244 + ? [
245 + ["ci/optional-lint", "failure", undefined],
246 + ["ci/required-build", "success", true],
247 + [missing, "pending", true],
248 + ]
249 + : [
250 + ["ci/required-build", "success", undefined],
251 + ["ci/optional-lint", "success", undefined],
252 + [missing, "pending", undefined],
253 + ],
254 );
255 if (!supported) {
256 assert.strictEqual(
@@ -298,8 +304,8 @@ it.effect.each([
304 assert.deepStrictEqual(
305 checks.map((check) => [check.name, check.status, check.required]),
306 [
301 - ["ci/required-build", "success", undefined],
307 ["ci/optional-lint", "failure", undefined],
308 + ["ci/required-build", "success", undefined],
309 ],
310 );
311 }
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.test.ts
+1 -1
@@ -646,7 +646,7 @@ describe("GitCafePullRequestProvider", () => {
646 });
647 assert.deepStrictEqual(
648 detail.checks.map((check) => check.name),
649 - ["early", "late"],
649 + ["late", "early"],
650 );
651 assert.deepStrictEqual(
652 detail.reviewers.map((reviewer) => reviewer.login),
packages/source-control-gitcafe/src/server/gitCafePullRequestJson.test.ts
+18 -6
@@ -494,8 +494,12 @@ describe("toDiff", () => {
494
495 describe("toChecks", () => {
496 it("maps GitCafe's status and conclusion onto the shared check states", () => {
497 - const check = (status: string, conclusion: string | null) => ({
498 - name: `${status}-${conclusion}`,
497 + const check = (
498 + status: string,
499 + conclusion: string | null,
500 + name = `${status}-${conclusion}`,
501 + ) => ({
502 + name,
503 status,
504 conclusion,
505 summary: null,
@@ -506,16 +510,24 @@ describe("toChecks", () => {
510 items: [
511 check("queued", null),
512 check("in_progress", null),
509 - check("completed", "success"),
513 + check("completed", "success", "Build"),
514 + check("completed", "cancelled"),
515 check("completed", "action_required"),
511 - check("completed", "timed_out"),
516 + check("completed", "timed_out", "Build"),
517 ],
518 next: null,
519 }),
520 );
521 assert.deepStrictEqual(
517 - checks.map((item) => item.status),
518 - ["pending", "pending", "success", "action-required", "failure"],
522 + checks.map((item) => [item.name, item.status]),
523 + [
524 + ["completed-cancelled", "cancelled"],
525 + ["Build", "failure"],
526 + ["queued-null", "pending"],
527 + ["in_progress-null", "pending"],
528 + ["Build", "success"],
529 + ["completed-action_required", "action-required"],
530 + ],
531 );
532 });
533 });
packages/source-control-gitcafe/src/server/gitCafePullRequestJson.ts
+9 -6
@@ -1,4 +1,5 @@
1 import { quoteGitPatchPath } from "@t3tools/shared/gitPatchPath";
2 +import { sortChecks } from "@t3tools/source-control-core/server/pullRequestChecks";
3 import * as DateTime from "effect/DateTime";
4 import * as Schema from "effect/Schema";
5 import {
@@ -549,10 +550,12 @@ function checkStatus(check: (typeof GitCafeChecks.Type.items)[number]): PullRequ
550 }
551
552 export function toChecks(checks: typeof GitCafeChecks.Type): ReadonlyArray<PullRequestCheck> {
552 - return checks.items.map((check) => ({
553 - name: check.name,
554 - status: checkStatus(check),
555 - description: check.summary,
556 - url: check.detailsUrl,
557 - }));
553 + return sortChecks(
554 + checks.items.map((check) => ({
555 + name: check.name,
556 + status: checkStatus(check),
557 + description: check.summary,
558 + url: check.detailsUrl,
559 + })),
560 + );
561 }
packages/source-control-github/src/server/gitHubPullRequestJson.test.ts
+1 -1
@@ -623,8 +623,8 @@ describe("pull request detail decoding", () => {
623 check({ __typename: "StatusContext", context: "ci/legacy", state: "SUCCESS" }),
624 ]);
625 expect(detail.checks.map((check) => [check.name, check.status])).toEqual([
626 - ["build", "pending"],
626 ["test", "failure"],
627 + ["build", "pending"],
628 ["ci/legacy", "success"],
629 ]);
630 });