import type { Status, TileView } from "./types.ts"; import { ciDurationSub, SPARKLINE_HEIGHT } from "./tile-render-values.ts"; import { detailList } from "./detail-list.ts"; import { CI_RUNS_MAX, DUR_MAX_AGE_HOURS, DUR_MIN_RUNS, } from "./ci-run-limits.ts"; export interface TileLayoutFixture { label: string; view: TileView; wide?: boolean; subSelector?: string; } const DAY = 86_400_000; const history = () => ``; const twoLines = () => `
`; const trustStrip = (prefix: string, badEvery: number) => `
${ Array.from( { length: 160 }, (_, index) => ``, ).join("") }
`; const jobList = (rows: readonly (readonly [Status, string, string])[]) => detailList( rows.map(([status, name, detail]) => ({ status, name, detail, })), { subject: "Failing job details", focusKey: "jobs" }, ); const spendSub = (text: string) => `

${text}

`; // These are maximum-content loaded states expressed through the renderer's // public TileView contract. The registry test keeps the list complete and in // dashboard order. The browser test supplies these views to renderTile(). const TILE_LAYOUT_FIXTURE_INPUTS: readonly TileLayoutFixture[] = [ { label: "ci", view: { status: "bad", value: "3 failing", valueLabel: "3 failing", aside: `42 jobs · 33 repos`, hint: "every job ↗", href: "/ci", extra: jobList([ ["bad", "loom · Benchmarks", "failure · 3h ago"], ["bad", "labs · CFC properties audit", "failure · 6h ago"], ["bad", "infra · Terraform plan", "timed_out · 1d ago"], ["warn", "gvisor · workflows", "unreadable"], ]), }, }, { label: "labs ci trust", view: { status: "good", value: "90.4%", sub: "first-try green · 156 of last 160 runs", extra: trustStrip("runs", 10), duration: 30 * DAY, alignChartBottom: true, href: "/repos?name=labs", hint: "repository ↗", }, }, { label: "loom ci trust", view: { status: "warn", value: "73.8%", sub: "first-try green · last 160 runs", extra: trustStrip("loom-runs", 4), duration: 30 * DAY, alignChartBottom: true, href: "/repos?name=loom", hint: "repository ↗", }, }, { label: "weaver ci trust", view: { status: "good", value: "95.0%", sub: "first-try green · last 160 runs", extra: trustStrip("weaver-runs", 20), duration: 30 * DAY, alignChartBottom: true, href: "/repos?name=commonfabric-weaver", hint: "repository ↗", }, }, { label: "flaky tests", view: { status: "warn", value: "25 flaky tests", valueLabel: "25 flaky tests", sub: "60 days of runs · 3h old", extra: history(), duration: 18 * DAY, aside: `running`, hint: "flakes ↗", href: "/test-selection#flaky", }, }, { label: "labs ci duration", view: { status: "good", value: "17m", sub: ciDurationSub(CI_RUNS_MAX, DUR_MAX_AGE_HOURS), extra: history(), duration: 30 * DAY, hint: "jobs ↗", href: "/bench?repo=labs", }, }, { label: "loom ci duration", view: { status: "good", value: "6m", sub: ciDurationSub(DUR_MIN_RUNS), extra: history(), duration: 30 * DAY, hint: "jobs ↗", href: "/bench?repo=loom", }, }, { label: "weaver ci duration", view: { status: "good", value: "4m", sub: ciDurationSub(DUR_MIN_RUNS), extra: history(), duration: 3 * DAY, }, }, { label: "test selection", view: { status: "good", value: "2.9%", sub: "16m 48s of 9h 29m test time", extra: history(), duration: 18 * DAY, aside: `running12h old`, hint: "lanes ↗", href: "/test-selection", }, }, { label: "labs coverage debt", view: { status: "warn", value: "78,101 lines", valueLabel: "78,101 lines", sub: "+214 per day (median) · last 21 days", extra: history(), duration: 56 * DAY, }, }, { label: "all benchmarks", subSelector: ".benchmark-count", view: { status: "warn", value: "▲6%", extra: `
544 benchmarks · last 10 days
${twoLines()}`, duration: 30 * DAY, hint: "details ↗", href: "/bench", }, }, { label: "key benchmarks", subSelector: ".benchmark-count", view: { status: "warn", value: "▲6%", extra: `
2 benchmarks · last 10 days
${twoLines()}`, duration: 30 * DAY, hint: "metrics ↗", href: "/bench?view=runtime&repo=labs", }, }, { label: "production", view: { status: "bad", value: "commonfabric.com down", valueLabel: "commonfabric.com down", extra: detailList( [ "commonfabric.com", "estuary", "rapids", "bastion", "prod shell", "stage shell", "LLM", "sandbox", ].map((name) => ({ status: "bad" as Status, name, detail: "connection refused", href: `https://example.com/${name}`, })), { subject: "Production target details", focusKey: "targets" }, ), }, }, { label: "prod errors", view: { status: "good", value: "0.24%", sub: "12 err / 5000 spans · last 12h", extra: history(), duration: 30 * DAY, hint: "traces ↗", href: "https://example.com/traces", }, }, { label: "dau", view: { status: "good", value: "244", sub: "active identities · toolshed-production", extra: history(), duration: 30 * DAY, hint: "traces ↗", href: "https://example.com/identities", }, }, { label: "discord online", subSelector: ".sub", view: { status: "good", value: "37", extra: spendSub("team + visitors") + twoLines(), duration: 30 * DAY, }, }, { label: "model spend", subSelector: ".sub", view: { status: "good", value: "~$820/mo", valueLabel: "~$820/mo", aside: `$440 MTD`, extra: spendSub("OpenAI • Anthropic • OR $0") + twoLines(), duration: 30 * DAY, }, }, { label: "cloud spend", view: { status: "good", value: "~$410/mo", valueLabel: "~$410/mo", aside: `$220 MTD`, sub: "billing account spend", extra: history(), duration: 30 * DAY, }, }, { label: "github spend", subSelector: ".sub", view: { status: "good", value: "~$3059/mo", valueLabel: "~$3059/mo", aside: `$1644 MTD`, extra: spendSub("GitHub · Budget $3100") + history(), duration: 30 * DAY, hint: "billing ↗", href: "https://example.com/billing", }, }, { label: "github users", subSelector: ".sub", view: { status: "good", value: "14", extra: spendSub("members · collaborators") + twoLines(), duration: 30 * DAY, hint: "people ↗", href: "https://example.com/people", }, }, { label: "recent commits", wide: true, view: { status: "good" }, }, ] as const; export const TILE_LAYOUT_FIXTURES: readonly TileLayoutFixture[] = TILE_LAYOUT_FIXTURE_INPUTS;