diff --git a/apps/web/src/lib/deliveryPullRequest.test.ts b/apps/web/src/lib/deliveryPullRequest.test.ts
new file mode 100644
index 0000000000000..c6a8c0c158bf0
--- /dev/null
+++ b/apps/web/src/lib/deliveryPullRequest.test.ts
@@ -0,0 +1,43 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import { deliveryCiRun } from "./deliveryPullRequest";
+
+describe("deliveryCiRun", () => {
+ it("builds a GitHub Actions URL for a positive numeric run ID", () => {
+ 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(deliveryCiRun("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",
+ ])("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 9c8d6972bf046..77b1d8f84a524 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 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 (
+ parts.length !== 2 ||
+ !owner ||
+ !repo ||
+ /[^a-z0-9-]/i.test(owner) ||
+ owner.startsWith("-") ||
+ owner.endsWith("-") ||
+ /[^a-z0-9_.-]/i.test(repo) ||
+ repo === "." ||
+ repo === ".."
+ ) {
+ return { label, href: null };
+ }
+ 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 b91976696e732..c07ba09cf28fe 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 { deliveryCiRun, parseDeliveryPullRequestUrl } from "~/lib/deliveryPullRequest";
interface Delivery {
version: 1;
@@ -101,23 +103,46 @@ async function readPullRequestDelivery(value: string, signal: AbortSignal) {
}
}
+function CiRunLink({ repository, runId }: { repository: string; runId?: number | undefined }) {
+ const run = deliveryCiRun(repository, runId);
+ if (!run) return null;
+ if (!run.href) return ` · ${run.label}`;
+ return (
+ <>
+ {" · "}
+
+ {run.label}
+
+ >
+ );
+}
+
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"],
["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
+
+ >,
],
- ]
+ ] as const)
: []),
];
return (