From afdeafa99d4169afb3e7209830e597f31edb5e39 Mon Sep 17 00:00:00 2001 From: InTheta <17220028+InTheta@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:15:45 +0000 Subject: [PATCH 1/3] Link Delivery CI run IDs to GitHub Actions --- apps/web/src/routes/_chat.delivery.tsx | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/web/src/routes/_chat.delivery.tsx b/apps/web/src/routes/_chat.delivery.tsx index b91976696e732..28bdc3c00284b 100644 --- a/apps/web/src/routes/_chat.delivery.tsx +++ b/apps/web/src/routes/_chat.delivery.tsx @@ -101,6 +101,25 @@ async function readPullRequestDelivery(value: string, signal: AbortSignal) { } } +function CiRunLink({ repository, runId }: { repository: string; runId?: number | undefined }) { + if (typeof runId !== "number" || !Number.isSafeInteger(runId) || runId <= 0) return null; + + const repositoryPath = repository.split("/").map(encodeURIComponent).join("/"); + return ( + <> + {" · "} + + run {runId} + + + ); +} + function PullRequestEvidence({ delivery }: { delivery: PullRequestDelivery }) { const { pullRequest, candidate, qa, ci } = delivery; const fields = [ @@ -109,13 +128,22 @@ function PullRequestEvidence({ delivery }: { delivery: PullRequestDelivery }) { ["QA reviewed commit", qa.head ?? "Unavailable"], ["Independent QA", qa.freshness === "stale" ? `${qa.status} (stale)` : qa.status], ["CI tested commit", ci.head ?? "Unavailable"], - ["CI", ci.head && ci.head !== pullRequest.head ? "stale" : ci.status], + [ + "CI", + <> + {ci.head && ci.head !== pullRequest.head ? "stale" : ci.status} + + , + ], ...(delivery.previousCi && delivery.previousCi.head !== pullRequest.head ? [ ["Previous CI commit", delivery.previousCi.head], [ "Previous CI", - delivery.previousCi.runId ? `stale · run ${delivery.previousCi.runId}` : "stale", + <> + stale + + , ], ] : []), From 04b8c21f3e4e78483019655fbb4338dafd7a4fff Mon Sep 17 00:00:00 2001 From: InTheta <17220028+InTheta@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:20:16 +0000 Subject: [PATCH 2/3] Validate Delivery CI repository paths --- apps/web/src/lib/deliveryPullRequest.test.ts | 42 ++++++++++++++++++++ apps/web/src/lib/deliveryPullRequest.ts | 22 ++++++++++ apps/web/src/routes/_chat.delivery.tsx | 22 +++++----- 3 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 apps/web/src/lib/deliveryPullRequest.test.ts diff --git a/apps/web/src/lib/deliveryPullRequest.test.ts b/apps/web/src/lib/deliveryPullRequest.test.ts new file mode 100644 index 0000000000000..60530b8e87ff1 --- /dev/null +++ b/apps/web/src/lib/deliveryPullRequest.test.ts @@ -0,0 +1,42 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { deliveryCiRunUrl } from "./deliveryPullRequest"; + +describe("deliveryCiRunUrl", () => { + it("builds a GitHub Actions URL for a positive numeric run ID", () => { + expect(deliveryCiRunUrl("InTheta-tools/t3.code_fork", 43_772_162_509)).toBe( + "https://github.com/InTheta-tools/t3.code_fork/actions/runs/43772162509", + ); + }); + + it.each([undefined, null, "123", 0, -1, 1.5, Infinity, Number.MAX_SAFE_INTEGER + 1])( + "rejects invalid run ID %s", + (runId) => { + expect(deliveryCiRunUrl("InTheta/t3code", runId)).toBeNull(); + }, + ); + + it.each([ + "", + "InTheta", + "/t3code", + "InTheta/", + "./t3code", + "../t3code", + "InTheta/.", + "InTheta/..", + "InTheta/%2e%2e", + "InTheta/t3code/actions", + "InTheta//t3code", + "InTheta/t3code?x", + "InTheta/t3code#x", + "InTheta/t3code\n", + "InTheta\\other/t3code", + "https://example.org/t3code", + "//example.org/t3code", + "example.org/t3code", + "github.com@example.org/t3code", + ])("rejects invalid repository path %j", (repository) => { + expect(deliveryCiRunUrl(repository, 123)).toBeNull(); + }); +}); diff --git a/apps/web/src/lib/deliveryPullRequest.ts b/apps/web/src/lib/deliveryPullRequest.ts index 9c8d6972bf046..cbde01c6de68b 100644 --- a/apps/web/src/lib/deliveryPullRequest.ts +++ b/apps/web/src/lib/deliveryPullRequest.ts @@ -9,3 +9,25 @@ export function parseDeliveryPullRequestUrl(value: string) { return null; } } + +export function deliveryCiRunUrl(repository: string, runId: unknown): string | null { + const parts = repository.split("/"); + const [owner, repo] = parts; + if ( + parts.length !== 2 || + !owner || + !repo || + /[^a-z0-9-]/i.test(owner) || + owner.startsWith("-") || + owner.endsWith("-") || + /[^a-z0-9_.-]/i.test(repo) || + repo === "." || + repo === ".." || + typeof runId !== "number" || + !Number.isSafeInteger(runId) || + runId <= 0 + ) { + return null; + } + return `https://github.com/${owner}/${repo}/actions/runs/${runId}`; +} diff --git a/apps/web/src/routes/_chat.delivery.tsx b/apps/web/src/routes/_chat.delivery.tsx index 28bdc3c00284b..6cd54b90ada87 100644 --- a/apps/web/src/routes/_chat.delivery.tsx +++ b/apps/web/src/routes/_chat.delivery.tsx @@ -1,6 +1,8 @@ import { createFileRoute, useNavigate, useRouter, useRouterState } from "@tanstack/react-router"; -import { parseDeliveryPullRequestUrl } from "~/lib/deliveryPullRequest"; +import type { ReactNode } from "react"; + +import { deliveryCiRunUrl, parseDeliveryPullRequestUrl } from "~/lib/deliveryPullRequest"; interface Delivery { version: 1; @@ -102,18 +104,12 @@ async function readPullRequestDelivery(value: string, signal: AbortSignal) { } function CiRunLink({ repository, runId }: { repository: string; runId?: number | undefined }) { - if (typeof runId !== "number" || !Number.isSafeInteger(runId) || runId <= 0) return null; - - const repositoryPath = repository.split("/").map(encodeURIComponent).join("/"); + const href = deliveryCiRunUrl(repository, runId); + if (!href) return null; return ( <> {" · "} - + run {runId} @@ -122,7 +118,7 @@ function CiRunLink({ repository, runId }: { repository: string; runId?: number | function PullRequestEvidence({ delivery }: { delivery: PullRequestDelivery }) { const { pullRequest, candidate, qa, ci } = delivery; - const fields = [ + const fields: ReadonlyArray = [ ["Current PR commit", pullRequest.head], ["Verified candidate", candidate ?? "No managed candidate"], ["QA reviewed commit", qa.head ?? "Unavailable"], @@ -136,7 +132,7 @@ function PullRequestEvidence({ delivery }: { delivery: PullRequestDelivery }) { , ], ...(delivery.previousCi && delivery.previousCi.head !== pullRequest.head - ? [ + ? ([ ["Previous CI commit", delivery.previousCi.head], [ "Previous CI", @@ -145,7 +141,7 @@ function PullRequestEvidence({ delivery }: { delivery: PullRequestDelivery }) { , ], - ] + ] as const) : []), ]; return ( From 0b6f04075c1cb194ca178a696f089d2e3ebb5235 Mon Sep 17 00:00:00 2001 From: InTheta <17220028+InTheta@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:22:53 +0000 Subject: [PATCH 3/3] Keep Delivery CI run IDs visible without links --- apps/web/src/lib/deliveryPullRequest.test.ts | 17 +++++++++-------- apps/web/src/lib/deliveryPullRequest.ts | 14 +++++++------- apps/web/src/routes/_chat.delivery.tsx | 11 ++++++----- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/apps/web/src/lib/deliveryPullRequest.test.ts b/apps/web/src/lib/deliveryPullRequest.test.ts index 60530b8e87ff1..c6a8c0c158bf0 100644 --- a/apps/web/src/lib/deliveryPullRequest.test.ts +++ b/apps/web/src/lib/deliveryPullRequest.test.ts @@ -1,18 +1,19 @@ import { describe, expect, it } from "vite-plus/test"; -import { deliveryCiRunUrl } from "./deliveryPullRequest"; +import { deliveryCiRun } from "./deliveryPullRequest"; -describe("deliveryCiRunUrl", () => { +describe("deliveryCiRun", () => { it("builds a GitHub Actions URL for a positive numeric run ID", () => { - expect(deliveryCiRunUrl("InTheta-tools/t3.code_fork", 43_772_162_509)).toBe( - "https://github.com/InTheta-tools/t3.code_fork/actions/runs/43772162509", - ); + expect(deliveryCiRun("InTheta-tools/t3.code_fork", 43_772_162_509)).toEqual({ + label: "run 43772162509", + href: "https://github.com/InTheta-tools/t3.code_fork/actions/runs/43772162509", + }); }); it.each([undefined, null, "123", 0, -1, 1.5, Infinity, Number.MAX_SAFE_INTEGER + 1])( "rejects invalid run ID %s", (runId) => { - expect(deliveryCiRunUrl("InTheta/t3code", runId)).toBeNull(); + expect(deliveryCiRun("InTheta/t3code", runId)).toBeNull(); }, ); @@ -36,7 +37,7 @@ describe("deliveryCiRunUrl", () => { "//example.org/t3code", "example.org/t3code", "github.com@example.org/t3code", - ])("rejects invalid repository path %j", (repository) => { - expect(deliveryCiRunUrl(repository, 123)).toBeNull(); + ])("keeps the run label without a link for invalid repository path %j", (repository) => { + expect(deliveryCiRun(repository, 123)).toEqual({ label: "run 123", href: null }); }); }); diff --git a/apps/web/src/lib/deliveryPullRequest.ts b/apps/web/src/lib/deliveryPullRequest.ts index cbde01c6de68b..77b1d8f84a524 100644 --- a/apps/web/src/lib/deliveryPullRequest.ts +++ b/apps/web/src/lib/deliveryPullRequest.ts @@ -10,7 +10,10 @@ export function parseDeliveryPullRequestUrl(value: string) { } } -export function deliveryCiRunUrl(repository: string, runId: unknown): string | null { +export function deliveryCiRun(repository: string, runId: unknown) { + if (typeof runId !== "number" || !Number.isSafeInteger(runId) || runId <= 0) return null; + + const label = `run ${runId}`; const parts = repository.split("/"); const [owner, repo] = parts; if ( @@ -22,12 +25,9 @@ export function deliveryCiRunUrl(repository: string, runId: unknown): string | n owner.endsWith("-") || /[^a-z0-9_.-]/i.test(repo) || repo === "." || - repo === ".." || - typeof runId !== "number" || - !Number.isSafeInteger(runId) || - runId <= 0 + repo === ".." ) { - return null; + return { label, href: null }; } - return `https://github.com/${owner}/${repo}/actions/runs/${runId}`; + return { label, href: `https://github.com/${owner}/${repo}/actions/runs/${runId}` }; } diff --git a/apps/web/src/routes/_chat.delivery.tsx b/apps/web/src/routes/_chat.delivery.tsx index 6cd54b90ada87..c07ba09cf28fe 100644 --- a/apps/web/src/routes/_chat.delivery.tsx +++ b/apps/web/src/routes/_chat.delivery.tsx @@ -2,7 +2,7 @@ import { createFileRoute, useNavigate, useRouter, useRouterState } from "@tansta import type { ReactNode } from "react"; -import { deliveryCiRunUrl, parseDeliveryPullRequestUrl } from "~/lib/deliveryPullRequest"; +import { deliveryCiRun, parseDeliveryPullRequestUrl } from "~/lib/deliveryPullRequest"; interface Delivery { version: 1; @@ -104,13 +104,14 @@ async function readPullRequestDelivery(value: string, signal: AbortSignal) { } function CiRunLink({ repository, runId }: { repository: string; runId?: number | undefined }) { - const href = deliveryCiRunUrl(repository, runId); - if (!href) return null; + const run = deliveryCiRun(repository, runId); + if (!run) return null; + if (!run.href) return ` · ${run.label}`; return ( <> {" · "} - - run {runId} + + {run.label} );