From a804af5f26c47dde72bbcc4747fa369d110831da Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 21:57:23 -0500 Subject: [PATCH 1/8] Pull requests overview: designed for a new install, a medium org and a big one The age chart is drawn at the width it is given, so its labels are the page's size, and only as tall as the ages it shows need. Under ten open pull requests it is a short list with each one's age instead of a plot. An external benchmark is one thin dashed line, only while the org has no percentile lines of its own. A mark's card shows on hover or focus and goes away after; the key names only the marks drawn; selecting the ones past p85 is a button. With no history, the strip and the conditions stop repeating "not enough history yet", failures and review health are one line instead of two empty panels, and the phone shows the open pull requests by age. Screenshot checks cover all three sizes at 1440, 1280, 1024 and 375, with no tooltip at rest and the chart never taller than its marks need. --- dashboard/e2e/prs-overview-sizes.spec.ts | 71 +++ dashboard/e2e/prs-overview-sizes.ts | 89 ++++ dashboard/e2e/prs-overview.spec.ts | 31 +- dashboard/src/app/prs/overview/charts.tsx | 504 ++++++++++++++-------- dashboard/src/app/prs/overview/page.tsx | 202 ++++++--- 5 files changed, 654 insertions(+), 243 deletions(-) create mode 100644 dashboard/e2e/prs-overview-sizes.spec.ts create mode 100644 dashboard/e2e/prs-overview-sizes.ts diff --git a/dashboard/e2e/prs-overview-sizes.spec.ts b/dashboard/e2e/prs-overview-sizes.spec.ts new file mode 100644 index 00000000..fa3a75cf --- /dev/null +++ b/dashboard/e2e/prs-overview-sizes.spec.ts @@ -0,0 +1,71 @@ +import fs from "node:fs"; +import path from "node:path"; +import { expect, test } from "@playwright/test"; +import { mockOverview } from "./prs-overview-mock"; +import { sized, type Size } from "./prs-overview-sizes"; + +// The overview at three sizes of org (one repo with three open pull requests +// and no history; 14 repos and about 40 open; about 300 open) and four widths. +// Each is captured, and the layout rules hold at every one: no tooltip is +// visible until something is hovered or focused, the age chart is never +// taller than its marks need, and a handful of pull requests is a list, not +// an empty plot. + +const SHOTS_DIR = process.env.E2E_SHOTS_DIR || path.join("test-results", "overview-sizes"); +const TAG = process.env.E2E_SHOTS_TAG || "after"; +const WIDTHS = [1440, 1280, 1024, 375]; +const SIZES: Size[] = ["sparse", "medium", "big"]; + +for (const size of SIZES) { + for (const width of WIDTHS) { + test(`overview, ${size} org at ${width}px: captured, nothing floating at rest, the chart sized to its marks`, async ({ page }) => { + await page.setViewportSize({ width, height: 900 }); + await mockOverview(page, () => sized(size)); + await page.goto("/prs/overview?org=acme"); + await expect(page.getByTestId("overview-summary")).toBeVisible(); + await page.mouse.move(0, 0); + fs.mkdirSync(SHOTS_DIR, { recursive: true }); + await page.screenshot({ path: path.join(SHOTS_DIR, `org-polish-${TAG}-${size}-${width}.png`), fullPage: true }); + if (width >= 640) await page.getByTestId("overview-aging").screenshot({ path: path.join(SHOTS_DIR, `org-polish-${TAG}-${size}-${width}-aging.png`) }); + + // Nothing floats over the page until a mark is hovered or focused. + await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(0); + + if (width >= 640) { + const aging = page.getByTestId("overview-aging"); + await expect(aging).toBeVisible(); + const marks = sized(size).aging.dots.length; + if (marks < 10) { + // A few pull requests are a list with their ages, not a plot. + await expect(aging.getByTestId("aging-chart")).toHaveCount(0); + await expect(aging.getByTestId("aging-row")).toHaveCount(marks); + } else { + const chart = aging.getByTestId("aging-chart"); + const box = await chart.boundingBox(); + expect(box && box.height, "the chart is never taller than 320px").toBeLessThanOrEqual(320); + // Axis words are body size or smaller. + const sizes = await chart.locator("text").evaluateAll((els) => els.map((e) => parseFloat(getComputedStyle(e).fontSize) * (e.getBoundingClientRect().height / Math.max(1, (e as SVGTextElement).getBBox().height)))); + expect(Math.max(...sizes), "axis labels are at most 13px on screen").toBeLessThanOrEqual(13.5); + // A mark shows its tooltip on hover, and it goes away after. + await chart.getByTestId("aging-dot").first().hover(); + await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(1); + await page.mouse.move(0, 0); + await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(0); + } + // The legend names only what is drawn. + const legend = aging.getByTestId("aging-legend"); + if ((await legend.count()) > 0) { + for (const item of await legend.locator("[data-mark]").all()) { + const mark = await item.getAttribute("data-mark"); + expect(await aging.locator(`[data-marks~="${mark}"]`).count(), `legend item ${mark} is drawn`).toBeGreaterThan(0); + } + } + } + + // No sideways scroll at any width. + const sideways = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); + expect(sideways).toBeLessThanOrEqual(1); + + }); + } +} diff --git a/dashboard/e2e/prs-overview-sizes.ts b/dashboard/e2e/prs-overview-sizes.ts new file mode 100644 index 00000000..7c357346 --- /dev/null +++ b/dashboard/e2e/prs-overview-sizes.ts @@ -0,0 +1,89 @@ +// The overview at three sizes of org, for the layout and screenshot checks: +// a new install with one repo, three open pull requests and no history; a +// medium org (14 repos, about 40 open); and a big one (14 repos, about 300 +// open, more than the chart shows). Invented data, from the bookstore. + +import type { OverviewDot, PrStage, PrsOverview } from "../src/lib/api"; +import { overview } from "./prs-overview-data"; + +export type Size = "sparse" | "medium" | "big"; + +const H = 3600; +const D = 86_400; + +/** One repo, three open pull requests, no history: the first day of an install. */ +function sparse(): PrsOverview { + const o = overview("empty"); + const repo = "acme/bookstore"; + const mk = (n: number, stage: PrStage, state: string, state_label: string, age: number, who: "person" | "coderhelm" | "bot", title: string): OverviewDot => ({ + key: `${repo}#${n}`, + repo, + number: n, + title, + stage, + state, + state_label, + age_secs: age, + coderhelm: who === "coderhelm", + author_type: who, + band: null, + idle: false, + main_blocked: false, + }); + const dots = [ + mk(12, "first_review", "needs_review", "Needs review", 40 * 60, "person", "Add the paperback filter to search"), + mk(11, "in_review", "changes_requested", "Changes requested", 5 * H, "coderhelm", "Round cart totals per currency"), + mk(9, "approved", "checks_running", "Checks running", 2 * D + 3 * H, "person", "Show stock per warehouse on the book page"), + ]; + const stages: Partial> = { first_review: 1, in_review: 1, approved: 1 }; + o.scope = { ...o.scope, repos: 1, repos_read: 1 }; + o.open = 3; + o.drafts = 0; + o.aging = { ...o.aging, dots, shown: 3, total: 3 }; + o.strip = o.strip.map((c) => ({ ...c, count: stages[c.stage as PrStage] ?? 0, delta: null, spark: null, past_p85: 0 })); + o.turns = { person: 2, coderhelm: 1, machines: 0, nobody: 0 }; + o.thresholds = { ...o.thresholds, cycle: null, first_review: null, external: true }; + o.history = { ...o.history, days: 0, weeks: 0, young: true, merged_90d: 0 }; + o.summary = { + ...o.summary, + verdict: { ...o.summary.verdict, state: "quiet", word: "Quiet", parts: [{ t: "3 open pull requests in bookstore, none waiting longer than a couple of days." }] }, + attention: [], + quiet: { repos: 1, open: 3, parts: [{ t: "Nothing needs you: no pull request is idle or blocked." }] }, + coderhelm: { ...o.summary.coderhelm, parts: [{ t: "One pull request of its own in review; nothing merged yet." }] }, + }; + o.coderhelm = { + author: { ...o.coderhelm.author, opened: 1, merged: 0, closed_unmerged: 0, open: 1, merge_rate: null, p50_merge_secs: null, waiting_on_people: null }, + fixer: { fixed: 0, merged: 0, closed_unmerged: 0, open: 0 }, + reviewer: { reviewed: 2, findings: null, verified_rate: null, p50_first_look_secs: 4 * 60 }, + runs: null, + exceptions: { ...o.coderhelm.exceptions, needs_decision: 0, oldest_secs: null, reworked: null, merges: null, cost_per_merged: null }, + }; + o.security = { ...o.security, dependency: null }; + o.stale = { ...o.stale, stale: 0, past_usual: 0, on_author: 0, on_reviewer: 0, abandoned: { count: 0, oldest_secs: null }, zombie: 0, drift: null, draft_p85_secs: null, archive_candidates: 0 }; + o.repos = [{ ...o.repos[0], repo, open: 3, stages, past_p85: 0, health: "healthy", why: "3 open, none past usual.", link: { overview: `repo=${repo}` } }]; + return o; +} + +/** About 300 open across 14 repos: the chart shows the oldest it can. */ +function big(): PrsOverview { + const o = overview("bad"); + const base = o.aging.dots; + const dots: OverviewDot[] = []; + for (let k = 0; k < 5; k++) { + for (const d of base) { + const number = d.number + 1000 * (k + 1); + dots.push({ ...d, number, key: `${d.repo}#${number}`, age_secs: Math.round(d.age_secs * (0.6 + 0.2 * k)) }); + } + } + o.aging = { ...o.aging, dots: dots.slice(0, 200), shown: 200, total: dots.length }; + o.open = dots.length; + o.strip = o.strip.map((c) => ({ ...c, count: c.count * 5, past_p85: (c.past_p85 ?? 0) * 5 })); + o.repos = o.repos.map((r) => ({ ...r, open: r.open * 5, past_p85: r.past_p85 * 5 })); + return o; +} + +export function sized(size: Size): PrsOverview { + if (size === "sparse") return sparse(); + if (size === "big") return big(); + return overview("normal"); +} diff --git a/dashboard/e2e/prs-overview.spec.ts b/dashboard/e2e/prs-overview.spec.ts index 7403a7f6..fa7d702d 100644 --- a/dashboard/e2e/prs-overview.spec.ts +++ b/dashboard/e2e/prs-overview.spec.ts @@ -169,8 +169,35 @@ test("not enough history yet: young data says so instead of a zero", async ({ pa await open(page, "young"); await expect(page.getByTestId("history-note")).toContainText("1 week"); await expect(page.getByTestId("not-yet").first()).toBeVisible(); - await expect(page.getByTestId("aging-external")).toBeVisible(); - await expect(page.getByTestId("aging-band").first()).toBeAttached(); + // The org has percentile lines of its own, so no external benchmark is drawn. + await expect(page.getByTestId("aging-line-p85")).toBeAttached(); + await expect(page.getByTestId("aging-band")).toHaveCount(0); +}); + +test("without lines of its own, an external benchmark is one thin dashed line, labeled as external", async ({ page }) => { + await open(page, () => { + const o = overview("young"); + o.thresholds = { ...o.thresholds, cycle: null, external: true }; + return o; + }); + await expect(page.getByTestId("aging-external")).toContainText("external benchmarks"); + const band = page.getByTestId("aging-band").first(); + await expect(band).toBeAttached(); + await expect(band.locator("line")).toHaveAttribute("stroke-width", "1"); + await expect(band.locator("line")).toHaveAttribute("stroke-dasharray", "3 3"); +}); + +test("a tooltip shows on hover or focus only, and the legend names only what is drawn", async ({ page }) => { + await open(page, "normal"); + await expect(page.locator('[role="tooltip"]')).toHaveCount(0); + const dot = page.getByTestId("aging-dot").first(); + await dot.focus(); + await expect(page.getByRole("tooltip")).toBeVisible(); + await page.getByTestId("aging-select-past").focus(); + await expect(page.locator('[role="tooltip"]')).toHaveCount(0); + // The normal week has no main blocked: its key isn't in the legend. + await expect(page.getByTestId("aging-legend").locator('[data-mark="blocked"]')).toHaveCount(0); + await expect(page.getByTestId("aging-legend").locator('[data-mark="person"]')).toBeVisible(); }); test("a backfill in progress shows how far it has read", async ({ page }) => { diff --git a/dashboard/src/app/prs/overview/charts.tsx b/dashboard/src/app/prs/overview/charts.tsx index 91a38645..affa96e2 100644 --- a/dashboard/src/app/prs/overview/charts.tsx +++ b/dashboard/src/app/prs/overview/charts.tsx @@ -9,9 +9,9 @@ // Every mark carries its meaning in words or shape; colour only repeats it. import Link from "next/link"; -import { useMemo, useRef, useState, type PointerEvent as ReactPointerEvent } from "react"; +import { useEffect, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from "react"; import type { OverviewDot, OverviewPercentiles, PrStage, PrsOverview } from "@/lib/api"; -import { focusRing } from "@/components/ui"; +import { focusRing, smallSecondaryButton } from "@/components/ui"; import { dur, durLong, STAGE_FILL, STAGES, stageLook, type Scope, prHref } from "./model"; /** A word-sized line of up to 8 weekly values; nothing when there are fewer than 2. */ @@ -89,8 +89,8 @@ function jitter(key: string): number { /** Which percentile a dot's age is past: its fill steps up one lightness per line. */ const BAND_CLASS: Record = { - none: "fill-zinc-500 stroke-zinc-300", - p50: "fill-amber-200/70 stroke-amber-100", + none: "fill-zinc-400 stroke-zinc-200", + p50: "fill-zinc-300 stroke-zinc-100", p85: "fill-amber-400 stroke-amber-200", p95: "fill-orange-500 stroke-orange-200", }; @@ -131,13 +131,93 @@ export function bubbleUp(selected: OverviewDot[], all: OverviewDot[]): string { return `${s.charAt(0).toUpperCase()}${s.slice(1)}.`; } +/** Under this many open pull requests the ages read better as a list than a plot. */ +export const AGING_LIST_UNDER = 10; + +/** The marks a pull request draws with, as words the legend can match. */ +function marksOf(d: OverviewDot): string[] { + const m = [d.coderhelm ? "coderhelm" : d.author_type === "bot" ? "bot" : "person"]; + if (d.band === "p85" || d.band === "p95") m.push(d.band); + if (d.idle) m.push("idle"); + if (d.main_blocked) m.push("blocked"); + return m; +} + +function dotLabel(d: OverviewDot): string { + const look = stageLook(d.stage); + return `${d.repo}#${d.number} ${d.title}. ${d.state_label || look.label}, open ${durLong(d.age_secs)}${d.band ? `, past the ${d.band}` : ""}${d.idle ? ", idle" : ""}${d.main_blocked ? ", blocked by a red main" : ""}. ${d.coderhelm ? "CoderHelm's" : d.author_type === "bot" ? "A bot's" : "A person's"} pull request.`; +} + +/** One mark's shape, drawn at a point (also the legend's swatches). */ +function Mark({ d, cx, cy, cls }: { d: Pick; cx: number; cy: number; cls: string }) { + return ( + <> + {d.main_blocked && } + {d.coderhelm ? ( + + ) : d.author_type === "bot" ? ( + + ) : ( + + )} + + ); +} + +const LEGEND: { mark: string; label: string; swatch: ReactNode }[] = [ + { mark: "person", label: "A person's", swatch: }, + { mark: "coderhelm", label: "CoderHelm's", swatch: }, + { mark: "bot", label: "Other bots'", swatch: }, + { mark: "p85", label: "Past p85", swatch: }, + { mark: "p95", label: "Past p95", swatch: }, + { mark: "idle", label: "Idle", swatch: }, + { mark: "blocked", label: "Blocked by red main", swatch: <> }, + { mark: "external", label: "External benchmark", swatch: }, +]; + +/** The key: only the marks that are drawn, wrapping under the title. */ +function Legend({ present }: { present: Set }) { + const items = LEGEND.filter((l) => present.has(l.mark)); + if (items.length < 2) return null; + return ( +
    + {items.map((l) => ( +
  • + + {l.label} +
  • + ))} +
+ ); +} + +/** The width an element is drawn at, followed as it changes. */ +function useWidth(fallback: number): [React.RefObject, number] { + const ref = useRef(null); + const [w, setW] = useState(fallback); + useEffect(() => { + const el = ref.current; + if (!el) return; + const read = () => setW(Math.max(240, Math.round(el.getBoundingClientRect().width))); + read(); + const ro = new ResizeObserver(read); + ro.observe(el); + return () => ro.disconnect(); + }, []); + return [ref, w]; +} + /** * Vacanti's aging chart: the six stages as columns, each open pull request a * mark at its age since ready for review (log scale), a hexagon for * CoderHelm's and a circle for people's, with the scope's p50, p85 and p95 - * cycle-time lines. Each mark is a link to the pull request's detail. Drag - * across the chart (or press "Past p85") to select a cluster and read what - * it has more of. + * cycle-time lines. Drawn at the width it is given, so its words stay the + * size of the page's, and only as tall as the ages it shows need. An external + * benchmark is a thin dashed line, and only while the scope has no lines of + * its own. Hover or focus a mark to read it; drag across the chart (or use + * the button) to select a cluster and read what it has more of. */ export function AgingChart({ overview, @@ -150,27 +230,33 @@ export function AgingChart({ }) { const dots = overview.aging.dots; const lines = overview.thresholds.cycle; - const bands = overview.thresholds.external ? overview.thresholds.bands : []; - const W = 640; - const H = 300; - const pad = { l: 34, r: 62, t: 10, b: 26 }; - const maxAge = Math.max(14 * DAY, ...dots.map((d) => d.age_secs), lines?.p95 ?? 0); - const minAge = HOUR / 2; - const y = (secs: number) => { - const v = Math.log(Math.max(minAge, secs)) - Math.log(minAge); - const top = Math.log(maxAge * 1.15) - Math.log(minAge); - return pad.t + (H - pad.t - pad.b) * (1 - v / top); - }; + const bands = !lines && overview.thresholds.external ? overview.thresholds.bands : []; + const [wrapRef, W] = useWidth(640); + const narrow = W < 520; + const pad = { l: 36, r: lines || bands.length ? 58 : 12, t: 10, b: 24 }; + + const ages = dots.map((d) => d.age_secs); + const refs = [...(lines ? [lines.p50, lines.p85, lines.p95 ?? 0] : []), ...bands.map((b) => b.secs)].filter((v) => v > 0); + const lo = Math.max(10 * 60, Math.min(...ages, ...refs) / 1.6); + const hi = Math.max(...ages, ...refs, 2 * HOUR) * 1.3; + const span10 = Math.log(hi) - Math.log(lo); + // Height: about 26px per tick the ages cross, between 150 and 260. + const ticks = TICKS.filter((t) => t >= lo && t <= hi); + const plotH = Math.min(260, Math.max(150, 26 * (ticks.length + 2))); + const H = plotH + pad.t + pad.b; + const inner = { top: pad.t + 6, bottom: pad.t + plotH - 6 }; + const y = (secs: number) => inner.bottom - ((Math.log(Math.max(lo, secs)) - Math.log(lo)) / span10) * (inner.bottom - inner.top); const colW = (W - pad.l - pad.r) / STAGES.length; const x = (stage: string, key: string) => { const i = Math.max(0, STAGES.findIndex((s) => s.stage === stage)); - return pad.l + colW * i + colW * (0.18 + 0.64 * jitter(key)); + return pad.l + colW * i + colW * (0.2 + 0.6 * jitter(key)); }; - const placed = useMemo(() => dots.map((d) => ({ d, cx: x(d.stage, d.key), cy: y(d.age_secs) })), [dots]); // eslint-disable-line react-hooks/exhaustive-deps + const placed = dots.map((d) => ({ d, cx: x(d.stage, d.key), cy: y(d.age_secs) })); const svgRef = useRef(null); const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null); const [picked, setPicked] = useState | null>(null); + const [tip, setTip] = useState<{ d: OverviewDot; cx: number; cy: number } | null>(null); const toLocal = (e: ReactPointerEvent) => { const r = svgRef.current!.getBoundingClientRect(); @@ -186,7 +272,9 @@ export function AgingChart({ onBrush({ dots: sel, sentence: bubbleUp(sel, dots) }); }; - const tickLabels = TICKS.filter((t) => t <= maxAge * 1.15); + const present = new Set(dots.flatMap(marksOf)); + if (bands.length) present.add("external"); + const past = dots.filter((d) => d.band === "p85" || d.band === "p95"); const lineDefs = lines ? ([ ["p50", lines.p50], @@ -197,177 +285,225 @@ export function AgingChart({ return (
- { - if ((e.target as Element).closest("a")) return; - const { px, py } = toLocal(e); - setDrag({ x0: px, y0: py, x1: px, y1: py }); - (e.currentTarget as Element).setPointerCapture?.(e.pointerId); - }} - onPointerMove={(e) => { - if (!drag) return; - const { px, py } = toLocal(e); - setDrag({ ...drag, x1: px, y1: py }); - }} - onPointerUp={() => { - if (!drag) return; - const [xa, xb] = [Math.min(drag.x0, drag.x1), Math.max(drag.x0, drag.x1)]; - const [ya, yb] = [Math.min(drag.y0, drag.y1), Math.max(drag.y0, drag.y1)]; - setDrag(null); - if (xb - xa < 4 && yb - ya < 4) { - select(null); - return; - } - select(new Set(placed.filter((p) => p.cx >= xa && p.cx <= xb && p.cy >= ya && p.cy <= yb).map((p) => p.d.key))); - }} - > - {/* Columns */} - {STAGES.map((s, i) => ( - - {i > 0 && } - - {s.short} - - - ))} - {/* Age ticks */} - {tickLabels.map((t) => ( - - - - {dur(t)} - - - ))} - {/* External context bands, faint and labeled as external */} - {bands.map((b) => ( - - - {`${b.label}, ${durLong(b.secs)} (external: ${b.source})`} - - ))} - {/* The scope's own percentile lines */} - {lineDefs.map(([name, v]) => - v == null ? null : ( - - - - {`${name} ${dur(v)}`} - - - ), - )} - {/* One mark per open pull request */} - {placed.map(({ d, cx, cy }) => { - const look = stageLook(d.stage); - const label = `${d.repo}#${d.number} ${d.title}. ${d.state_label || look.label}, open ${durLong(d.age_secs)}${d.band ? `, past the ${d.band}` : ""}${d.idle ? ", idle" : ""}${d.main_blocked ? ", blocked by a red main" : ""}. ${d.coderhelm ? "CoderHelm's" : d.author_type === "bot" ? "A bot's" : "A person's"} pull request.`; - // Idle past the stage p85: hollow, keeping its band's outline. - const cls = `${BAND_CLASS[d.band ?? "none"]} ${d.idle ? "!fill-zinc-950" : ""} ${picked && !picked.has(d.key) ? "opacity-30" : ""}`; - return ( - - {label} - {d.main_blocked && } - {d.coderhelm ? ( - - ) : d.author_type === "bot" ? ( - - ) : ( - - )} - - ); - })} - {drag && ( - - )} - -
- - - A person's - - - - CoderHelm's - - - - Other bots' - - - - Past p85 - - - - Past p95 - - - - Idle - - - - Blocked by red main - - {bands.length > 0 && ( - - +
+
+ +
+ {past.length > 0 && ( + )} -
+
setTip(null)}> + { + if ((e.target as Element).closest("a")) return; + const { px, py } = toLocal(e); + setDrag({ x0: px, y0: py, x1: px, y1: py }); + (e.currentTarget as Element).setPointerCapture?.(e.pointerId); + }} + onPointerMove={(e) => { + if (!drag) return; + const { px, py } = toLocal(e); + setDrag({ ...drag, x1: px, y1: py }); + }} + onPointerUp={() => { + if (!drag) return; + const [xa, xb] = [Math.min(drag.x0, drag.x1), Math.max(drag.x0, drag.x1)]; + const [ya, yb] = [Math.min(drag.y0, drag.y1), Math.max(drag.y0, drag.y1)]; + setDrag(null); + if (xb - xa < 4 && yb - ya < 4) { + select(null); + return; + } + select(new Set(placed.filter((p) => p.cx >= xa && p.cx <= xb && p.cy >= ya && p.cy <= yb).map((p) => p.d.key))); }} - data-testid="aging-select-past" > - {picked ? "Clear selection" : "Select past p85"} - + {/* Columns */} + {STAGES.map((s, i) => ( + + {i > 0 && } + + {narrow ? s.short.split(" ")[0] : s.short} + + + ))} + {/* Age ticks */} + {ticks.map((t) => ( + + + + {dur(t)} + + + ))} + {/* External context: a thin dashed line, only without lines of the scope's own */} + {bands.map((b) => ( + + + + {`ext ${dur(b.secs)}`} + + {`${b.label}, ${durLong(b.secs)} (external: ${b.source})`} + + ))} + {/* The scope's own percentile lines */} + {lineDefs.map(([name, v]) => + v == null ? null : ( + + + + {`${name} ${dur(v)}`} + + + ), + )} + {/* One mark per open pull request */} + {placed.map(({ d, cx, cy }) => { + // Idle past the stage p85: hollow, keeping its band's outline. + const cls = `${BAND_CLASS[d.band ?? "none"]} ${d.idle ? "!fill-zinc-950" : ""} ${picked && !picked.has(d.key) ? "opacity-25" : ""}`; + const show = () => setTip({ d, cx, cy }); + return ( + setTip(null)} + > + {/* A larger, invisible target than the mark itself */} + + + + ); + })} + {drag && ( + + )} + + {tip && }
); } +/** A mark's card, inside the plot: above the mark, or below it near the top. */ +function Tip({ d, cx, cy, width }: { d: OverviewDot; cx: number; cy: number; width: number }) { + const below = cy < 84; + const left = Math.min(Math.max(cx, 120), width - 120); + return ( +
+ {d.title} + + {d.repo.split("/")[1] ?? d.repo}#{d.number} · {d.state_label || stageLook(d.stage).label} + + + open {durLong(d.age_secs)} + {d.band ? ` · past ${d.band}` : ""} + {d.idle ? " · idle" : ""} + {d.main_blocked ? " · red main" : ""} + +
+ ); +} + +/** + * A few open pull requests as rows, oldest first: each one's age on a shared + * scale, with the p85 tick when the scope has one. Used instead of the chart + * when there are too few to plot. + */ +export function AgingList({ overview, scope }: { overview: PrsOverview; scope: Scope }) { + const dots = [...overview.aging.dots].sort((a, b) => b.age_secs - a.age_secs); + const lines = overview.thresholds.cycle; + const ages = dots.map((d) => d.age_secs); + const lo = Math.max(10 * 60, Math.min(...ages) / 2); + const hi = Math.max(...ages, lines?.p95 ?? 0, DAY) * 1.25; + const at = (s: number) => `${(((Math.log(Math.max(lo, s)) - Math.log(lo)) / (Math.log(hi) - Math.log(lo))) * 100).toFixed(1)}%`; + return ( +
    + {dots.map((d) => { + const look = stageLook(d.stage); + const old = d.band === "p85" || d.band === "p95"; + return ( +
  • + + + + {d.title} + + {d.repo.split("/")[1] ?? d.repo}#{d.number} · {d.state_label || look.label} + {d.coderhelm ? " · CoderHelm's" : ""} + {old ? · past {d.band} : null} + + +
  • + ); + })} +
+ ); +} + /** Review requests against reviews done per week, the gap between them shaded. */ export function QueueFlow({ weeks }: { weeks: { week: string; requests: number; done: number }[] }) { const W = 260; diff --git a/dashboard/src/app/prs/overview/page.tsx b/dashboard/src/app/prs/overview/page.tsx index d5cf4be8..3a388504 100644 --- a/dashboard/src/app/prs/overview/page.tsx +++ b/dashboard/src/app/prs/overview/page.tsx @@ -14,7 +14,7 @@ import { ChevronRightIcon } from "@/components/icons"; import { focusRing, linkButton } from "@/components/ui"; import { AnyLink, Card, NotYet } from "./parts"; import { EventsPanel, FailuresPanel, phoneSentences, ReviewPanel, SecurityPanel, StalePanel } from "./panels"; -import { AgingChart, CycleScatter, MixBar, MixLegend, QueueFlow, Sparkline, StageFlow, type Brushed } from "./charts"; +import { AgingChart, AgingList, AGING_LIST_UNDER, CycleScatter, MixBar, MixLegend, QueueFlow, Sparkline, StageFlow, type Brushed } from "./charts"; import { dur, durLong, @@ -433,19 +433,19 @@ function Strip({ o, scope, phone }: { o: PrsOverview; scope: Scope; phone?: bool {look.short} - {c.count} + {c.count} {c.delta != null ? ( {signed(c.delta)} ) : ( - !phone && + !phone && !o.history.young && )} - {!phone && ( + {!phone && (c.spark || c.past_p85) ? ( {c.spark ? : } {c.past_p85 ? {c.past_p85} past p85 : null} - )} + ) : null} ); @@ -473,29 +473,42 @@ function Strip({ o, scope, phone }: { o: PrsOverview; scope: Scope; phone?: bool /** The staleness states over the same open PRs: stale (by whose turn), abandoned, zombie, drift, blocked by main. */ function Conditions({ o, scope }: { o: PrsOverview; scope: Scope }) { const c = o.conditions; - const item = (label: string, n: number | null, q: string | null, path: string, extra?: string) => ( - - {label}{" "} - {n == null ? ( - - ) : q ? ( - - {n} - - ) : ( - {n} - )} - {extra && {extra}} - - ); + const pending: string[] = []; + const item = (label: string, n: number | null, q: string | null, extra?: string) => { + if (n == null) { + pending.push(label); + return null; + } + return ( + + {label}{" "} + {q && n > 0 ? ( + + {n} + + ) : ( + 0 ? "text-zinc-50" : "text-zinc-400"}`}>{n} + )} + {extra && n > 0 && {extra}} + + ); + }; + const items = [ + item("stale", c.stale?.count ?? null, "view=stale", c.stale ? `(reviewer ${c.stale.reviewer}, author ${c.stale.author}${c.stale.delta != null ? `, ${signed(c.stale.delta)}` : ""})` : undefined), + item("abandoned?", c.abandoned, "view=stale&past=p95"), + item("zombie", c.zombie, null), + item("high drift", c.high_drift, null), + item("blocked by main", c.blocked_by_main, "state=checks_failing"), + ]; return (

Condition: - {item("stale", c.stale?.count ?? null, "view=stale", "stale", c.stale ? `(reviewer ${c.stale.reviewer}, author ${c.stale.author}${c.stale.delta != null ? `, ${signed(c.stale.delta)}` : ""})` : undefined)} - {item("abandoned?", c.abandoned, "view=stale&past=p95", "abandoned")} - {item("zombie", c.zombie, null, "zombie")} - {item("high drift", c.high_drift, null, "high_drift")} - {item("blocked by main", c.blocked_by_main, "state=checks_failing", "blocked_by_main")} + {items} + {pending.length > 0 && ( + missingFor(o, `conditions.${p === "abandoned?" ? "abandoned" : p.replace(/ /g, "_")}`)?.text).filter(Boolean).join(" ")}> + {pending.join(" and ")}: not enough history yet + + )}

); } @@ -511,39 +524,50 @@ function TurnLink({ scope, q, label, n }: { scope: Scope; q: string; label: stri function Aging({ o, scope }: { o: PrsOverview; scope: Scope }) { const [brush, setBrush] = useState(null); const t = o.thresholds; + const n = o.aging.dots.length; + const list = n > 0 && n < AGING_LIST_UNDER; + const bands = !t.cycle && t.external && t.bands.length > 0 && !list; return ( + Age of open PRs {o.aging.total} + + } aside={ t.cycle ? ( - Lines: {t.scope === "repo" && !t.inherited ? "this repo's" : "the org's"} merged PRs, 90 days{t.inherited ? " (this repo has under 30 merges, so the org's)" : ""} + Lines: {t.scope === "repo" && !t.inherited ? "this repo's" : "the org's"} merged PRs, 90 days{t.inherited ? " (the org's: under 30 merges here)" : ""} - ) : ( - - ) + ) : n > 0 ? ( + No percentile lines until PRs merge here + ) : null } > - {t.external && ( + {bands && (

- {o.history.weeks < t.min_weeks ? `${o.history.weeks} of ${t.min_weeks} weeks of history: ` : ""}the shaded bands are external benchmarks, labeled as such, not this org's numbers. + Dashed blue lines are external benchmarks, not this org's numbers.

)} - {o.aging.dots.length === 0 ? ( -

No open pull requests.

+ {n === 0 ? ( +

No open pull requests.

+ ) : list ? ( + ) : ( )} {o.aging.shown < o.aging.total && ( -

+

Showing the {o.aging.shown} oldest of {o.aging.total}.

)} -

- {brush?.sentence ?? ""} -

+ {!list && n > 0 && ( +

+ {brush?.sentence ?? ""} +

+ )}
); } @@ -875,6 +899,18 @@ function RepoViews({ o }: { o: PrsOverview }) { ); } +/** Failures and review health before anything has merged: one line, not two empty frames. */ +function PendingPanels() { + return ( +
+

Failures and review health

+

+ These fill in once pull requests merge here: CI first-try rate, flaky checks, main red time and reverts; review coverage, wait for a first review, and quick approvals. +

+
+ ); +} + function HistoryNote({ o }: { o: PrsOverview }) { const b = o.history.backfill; if (b && !b.done) { @@ -889,7 +925,9 @@ function HistoryNote({ o }: { o: PrsOverview }) { return (

{o.history.young - ? `CoderHelm has ${o.history.weeks === 1 ? "1 week" : `${o.history.weeks} weeks`} of pull request history here. Week-over-week changes and 8-week ranges need ${o.thresholds.min_weeks}; until then they say "not enough history yet", and the percentile lines stand beside external benchmarks.` + ? o.history.weeks === 0 + ? "CoderHelm is new here, so there is no pull request history yet. Changes week over week, percentile lines and the failure and review numbers fill in as pull requests merge." + : `CoderHelm has ${o.history.weeks === 1 ? "1 week" : `${o.history.weeks} weeks`} of pull request history here. Week-over-week changes and 8-week ranges need ${o.thresholds.min_weeks}; until then they say "not enough history yet".` : `This repo has fewer than ${o.thresholds.min_merged} merges in 90 days, so its thresholds are the org's.`}

); @@ -899,6 +937,10 @@ function OverviewBody({ data, scope }: { data?: PrsOverview; scope?: Scope }) { if (!data || !scope) return ; const o = data; const ph = phoneSentences(o); + // Nothing has merged yet: failures and review health have nothing to say. + const noHistory = o.history.merged_90d === 0; + // A handful of open PRs: their ages are a short list, the width of the page. + const few = o.aging.dots.length < AGING_LIST_UNDER; return ( <> @@ -910,17 +952,50 @@ function OverviewBody({ data, scope }: { data?: PrsOverview; scope?: Scope }) {
-
-
- -
- -
-
- - - -
+ {few ? ( + <> +
+ +
+ {noHistory && ( +
+ +
+ )} +
+ + + {!noHistory && ( + <> + + + + )} +
+ + ) : ( + <> +
+
+ +
+ +
+
+ {noHistory ? ( +
+ +
+ ) : ( + <> + + + + )} + +
+ + )}
@@ -931,17 +1006,30 @@ function OverviewBody({ data, scope }: { data?: PrsOverview; scope?: Scope }) { {/* Phone: priority order; each panel one sentence that opens it. */}
- + {few ? ( + o.aging.dots.length > 0 && ( + + + + ) + ) : ( + + )} + {noHistory && }
- - - - - - + {!noHistory && ( + <> + + + + + + + + )} From 75c0fa8702245cf59948075abe80c2b217085300 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sat, 5 Dec 2026 22:12:51 -0500 Subject: [PATCH 2/8] Dashboard design tokens: one type ramp, a 4px spacing scale, radii and semantic colors The root font size was 18px, so every Tailwind size rendered on a fraction (13.5, 15.75, 20.25, 27px) and spacing on a 4.5px grid; pages added their own arbitrary sizes and raw palette colors on top. The root is back to the browser's 16px and src/app/tokens.css defines the system: - a seven-step ramp (13, 15, 16, 18, 20, 24, 32px), each with a fixed line height on the 4px grid, three weights, and semantic text styles (text-page-title, text-section-title, text-body, text-caption, text-data, text-numeric, text-display); - radii (4, 6, 8, 12px), two elevations for floating surfaces; - semantic colors for surfaces, lines, text and status (good, warn, bad, info, severe, done, accent) as --ch-* variables named in @theme, ready for a light theme; src/lib/tokens.ts mirrors them for charts and QR codes. The UI lint fails an arbitrary font size, an off-ramp weight, an arbitrary or off-scale padding, margin or gap, a raw hex color outside the token files, and a tokens.ts value that drifts from tokens.css; palette classes are counted against a baseline that only goes down. A rare real case is allowed with a ui-lint-allow comment that says why. The shell and every shared component move onto the tokens; buttons and fields share one height and radius; PageHeader draws the one title style and the first block under it sits 24px below on every page. Pages under src/app move in their own change (TOKENS_LATER in the lint). DESIGN.md is the guide, and e2e/design-tokens.spec.ts checks what renders on the shell and three pages at 1440 and 375 wide. --- dashboard/DESIGN.md | 130 ++++++++ dashboard/e2e/design-tokens.spec.ts | 106 +++++++ dashboard/scripts/ui-lint-allow.json | 2 +- dashboard/scripts/ui-lint.mjs | 148 ++++++++- dashboard/src/app/globals.css | 58 ++-- dashboard/src/app/layout.tsx | 2 +- dashboard/src/app/not-found.tsx | 6 +- dashboard/src/app/tokens.css | 259 ++++++++++++++++ dashboard/src/components/activity-summary.tsx | 16 +- dashboard/src/components/agent-approval.tsx | 26 +- dashboard/src/components/autofix-words.tsx | 8 +- .../src/components/aws-install-options.tsx | 64 ++-- dashboard/src/components/aws-permissions.tsx | 70 ++--- dashboard/src/components/brand-icons.tsx | 3 +- dashboard/src/components/callout.tsx | 14 +- dashboard/src/components/charts.tsx | 25 +- dashboard/src/components/chat-channels.tsx | 20 +- dashboard/src/components/chat-markdown.tsx | 36 +-- dashboard/src/components/chat-nav.tsx | 6 +- dashboard/src/components/check-list.tsx | 18 +- dashboard/src/components/client-shell.tsx | 289 +++++++++--------- dashboard/src/components/close-run-dialog.tsx | 22 +- dashboard/src/components/code-block.tsx | 32 +- dashboard/src/components/combobox.tsx | 32 +- dashboard/src/components/command-palette.tsx | 42 +-- dashboard/src/components/connections.tsx | 52 ++-- dashboard/src/components/custom-roles.tsx | 14 +- .../src/components/data-source-activity.tsx | 22 +- .../src/components/data-source-flow-shell.tsx | 4 +- .../src/components/data-source-kinds.tsx | 10 +- dashboard/src/components/data-table.tsx | 16 +- dashboard/src/components/deliveries.tsx | 108 +++---- .../src/components/delivery-overview.tsx | 73 ++--- dashboard/src/components/diff.tsx | 34 +-- dashboard/src/components/disclosure.tsx | 4 +- dashboard/src/components/domain-section.tsx | 52 ++-- dashboard/src/components/drawer.tsx | 14 +- dashboard/src/components/empty-state.tsx | 8 +- dashboard/src/components/field.tsx | 2 +- dashboard/src/components/file-path.tsx | 4 +- dashboard/src/components/findings-notify.tsx | 6 +- dashboard/src/components/follow-scroll.tsx | 2 +- .../src/components/hidden-fields-editor.tsx | 12 +- .../src/components/hidden-suggestions.tsx | 14 +- .../src/components/hybrid-app-choice.tsx | 8 +- dashboard/src/components/hybrid-jira-link.tsx | 42 +-- dashboard/src/components/hybrid-section.tsx | 128 ++++---- dashboard/src/components/infra-reads.tsx | 2 +- dashboard/src/components/install-checks.tsx | 18 +- .../src/components/integration-panel.tsx | 40 +-- .../src/components/knowledge/add-flow.tsx | 192 ++++++------ .../components/knowledge/app-map-source.tsx | 30 +- dashboard/src/components/knowledge/ask.tsx | 60 ++-- .../src/components/knowledge/base-parts.tsx | 50 +-- .../src/components/knowledge/builtin.tsx | 130 ++++---- .../src/components/knowledge/connections.tsx | 46 +-- .../src/components/knowledge/content.tsx | 72 ++--- .../src/components/knowledge/history.tsx | 60 ++-- .../src/components/knowledge/import-steps.tsx | 100 +++--- dashboard/src/components/knowledge/logos.tsx | 21 +- dashboard/src/components/knowledge/picker.tsx | 118 +++---- .../src/components/knowledge/readers.tsx | 12 +- .../src/components/knowledge/source-card.tsx | 20 +- .../src/components/knowledge/sync-limits.tsx | 18 +- .../components/knowledge/token-connect.tsx | 34 +-- dashboard/src/components/knowledge/usage.tsx | 42 +-- dashboard/src/components/list/list.tsx | 60 ++-- dashboard/src/components/list/status.tsx | 20 +- dashboard/src/components/list/toolbar.tsx | 24 +- dashboard/src/components/load-more.tsx | 2 +- dashboard/src/components/log-group-picker.tsx | 18 +- dashboard/src/components/markdown-editor.tsx | 49 +-- dashboard/src/components/markdown.tsx | 38 +-- dashboard/src/components/mcp-server-panel.tsx | 28 +- dashboard/src/components/mcp-servers.tsx | 62 ++-- dashboard/src/components/menu-search.tsx | 10 +- dashboard/src/components/menu.tsx | 6 +- dashboard/src/components/mermaid-diagram.tsx | 21 +- dashboard/src/components/modal.tsx | 18 +- dashboard/src/components/models-section.tsx | 32 +- dashboard/src/components/native-access.tsx | 12 +- dashboard/src/components/native-update.tsx | 18 +- dashboard/src/components/page.tsx | 18 +- .../src/components/permission-check-note.tsx | 4 +- dashboard/src/components/phone-bar.tsx | 16 +- dashboard/src/components/popover.tsx | 2 +- .../src/components/preview-access-dialog.tsx | 22 +- .../src/components/private-network-panel.tsx | 28 +- dashboard/src/components/problem.tsx | 10 +- dashboard/src/components/recovered.tsx | 2 +- dashboard/src/components/redirect.tsx | 2 +- .../src/components/replace-authenticator.tsx | 25 +- dashboard/src/components/repo-combobox.tsx | 2 +- dashboard/src/components/reset-data.tsx | 8 +- dashboard/src/components/resolved-repo.tsx | 24 +- dashboard/src/components/role-editor.tsx | 78 ++--- dashboard/src/components/roles-matrix.tsx | 62 ++-- dashboard/src/components/run-trigger.tsx | 6 +- dashboard/src/components/section-nav.tsx | 8 +- dashboard/src/components/segmented.tsx | 6 +- dashboard/src/components/select.tsx | 24 +- dashboard/src/components/settings-nav.tsx | 14 +- dashboard/src/components/settings-scope.tsx | 6 +- dashboard/src/components/settings/code.tsx | 2 +- dashboard/src/components/settings/field.tsx | 6 +- dashboard/src/components/settings/row.tsx | 14 +- .../src/components/settings/save-bar.tsx | 4 +- dashboard/src/components/settings/section.tsx | 8 +- dashboard/src/components/settings/switch.tsx | 4 +- dashboard/src/components/setup-banner.tsx | 4 +- dashboard/src/components/setup-checklist.tsx | 14 +- dashboard/src/components/setup-marks.tsx | 2 +- dashboard/src/components/sign-in-apps.tsx | 18 +- dashboard/src/components/sign-in-card.tsx | 12 +- dashboard/src/components/skeleton.tsx | 12 +- .../src/components/staging-cms-dialog.tsx | 18 +- dashboard/src/components/stat-tile.tsx | 14 +- dashboard/src/components/stepper.tsx | 16 +- dashboard/src/components/streaming-cursor.tsx | 2 +- dashboard/src/components/suggest-input.tsx | 2 +- dashboard/src/components/support-access.tsx | 38 +-- dashboard/src/components/support.tsx | 168 +++++----- dashboard/src/components/tabs.tsx | 6 +- dashboard/src/components/teams-webhook.tsx | 4 +- dashboard/src/components/tests/common.tsx | 24 +- dashboard/src/components/tests/coverage.tsx | 60 ++-- dashboard/src/components/tests/quarantine.tsx | 44 +-- dashboard/src/components/tests/settings.tsx | 50 +-- dashboard/src/components/tests/setup.tsx | 70 ++--- dashboard/src/components/tests/test-list.tsx | 6 +- dashboard/src/components/tests/trends.tsx | 29 +- dashboard/src/components/tests/views.tsx | 14 +- dashboard/src/components/thinking-block.tsx | 10 +- dashboard/src/components/toast.tsx | 6 +- dashboard/src/components/token-meters.tsx | 6 +- dashboard/src/components/tool-call-card.tsx | 28 +- dashboard/src/components/tools.tsx | 16 +- dashboard/src/components/top-bar.tsx | 18 +- dashboard/src/components/two-factor-setup.tsx | 15 +- dashboard/src/components/ui.ts | 18 +- .../src/components/uninstall-section.tsx | 14 +- dashboard/src/components/update-ready.tsx | 4 +- dashboard/src/components/work-used.tsx | 32 +- dashboard/src/lib/boot-recovery.ts | 1 + dashboard/src/lib/highlight.ts | 1 + dashboard/src/lib/link-preview.ts | 3 +- dashboard/src/lib/setup.ts | 6 +- dashboard/src/lib/support.ts | 14 +- dashboard/src/lib/tokens.ts | 43 +++ dashboard/src/lib/usage.ts | 2 +- 150 files changed, 2756 insertions(+), 2059 deletions(-) create mode 100644 dashboard/DESIGN.md create mode 100644 dashboard/e2e/design-tokens.spec.ts create mode 100644 dashboard/src/app/tokens.css create mode 100644 dashboard/src/lib/tokens.ts diff --git a/dashboard/DESIGN.md b/dashboard/DESIGN.md new file mode 100644 index 00000000..6f2c6e81 --- /dev/null +++ b/dashboard/DESIGN.md @@ -0,0 +1,130 @@ +# Dashboard design system + +One type ramp, one spacing scale, a handful of radii and semantic colors, so +every page reads as the same product. The values live in +[`src/app/tokens.css`](src/app/tokens.css) (CSS variables plus Tailwind's +`@theme`); code that cannot take a class (charts, QR codes, Mermaid, the +highlighter) reads the same values from [`src/lib/tokens.ts`](src/lib/tokens.ts). +`npm run lint` holds the rest of the code to them. + +## Type + +The root is the browser's 16px, so `1rem` is 16px. Seven sizes, each with a +fixed line height on the 4px grid: + +| Class | Size / line height | Use | +|---|---|---| +| `text-xs` | 13 / 18 | captions, metadata, badges, table headers, timestamps | +| `text-sm` | 15 / 22 | body, controls, list rows, section titles (16 / 24 on a phone) | +| `text-base` | 16 / 24 | lead text; fields on a phone | +| `text-lg` | 18 / 26 | the title of a card that is the page's subject | +| `text-xl` | 20 / 28 | a dialog's or an empty state's title | +| `text-2xl` | 24 / 32 | the page title (`` draws it) | +| `text-3xl` | 32 / 40 | a headline number on a stat tile | + +Three weights: `font-normal` (400) for reading, `font-medium` (500) for +labels, buttons and names, `font-semibold` (600) for titles. Nothing bolder. + +Semantic styles, size and weight only (add the color separately): + +| Class | What it is | +|---|---| +| `text-page-title` | 24 / 32 semibold, tracking tight | +| `text-section-title` | 15 / 22 semibold (``) | +| `text-body` | 15 / 22 normal | +| `text-caption` | 13 / 18 normal; pair with `text-fg-muted` | +| `text-data` | 13 / 18 mono, tabular numbers: ids, shas, durations in tables | +| `text-numeric` | tabular, lining figures for counts that line up | +| `text-display` | 32 / 40 semibold, tabular: a headline number | +| `text-code-inline` | 0.9em: inline code inside running text | + +"Secondary" text is body size in `text-fg-muted`. + +## Spacing + +Tailwind's steps on a 4px grid. Padding, margin and gap use only: +`0, px, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24` +(0 to 96px). A value built from a token or the safe area +(`pb-[calc(var(--bottom-bar)+1rem)]`) is fine; `mt-[7px]` and `p-3.5` are not. + +The page rhythm, the same on every page: + +- the shell's gutter: 16px on a phone, 32px from `md:` (`
`); +- ``, then **24px**, then the content (globals.css holds the + first block under the header to it, whatever margin it asks for); +- **40px** between titled sections (`
`, `mt-10`); +- **12px** from a section's heading to its body; +- cards pad **16px** (`cardClass`, `p-4`); a list row pads `px-4 py-3`; +- **8px** between related controls (`gap-2`), **12px** between groups (`gap-3`). + +## Radii + +| Class | Size | Use | +|---|---|---| +| `rounded-sm` | 4px | badges, chips, keys, inline code | +| `rounded-md` | 6px | buttons, fields, menu items | +| `rounded-lg` | 8px | cards, panels, list boxes, menus, popovers, toasts | +| `rounded-xl` | 12px | dialogs and sheets | +| `rounded-full` | | pills, dots, avatars | + +## Colors + +Semantic names only; the palette (`zinc-400`, `amber-300`) is counted by the +lint and may only go down. Values are in `:root` so a light theme later +redefines `--ch-*` and nothing else changes. + +| Role | Classes | +|---|---| +| Surfaces | `bg-canvas` (page), `bg-surface` (card), `bg-raised` (menu, dialog, sheet), `bg-inset` (a well inside a card), `bg-control` / `bg-control-hover` (secondary button, chip), `bg-hover` (row and ghost hover), `bg-inverse` / `bg-inverse-hover` (primary button), `bg-scrim` (behind a dialog) | +| Lines | `border-line` (cards, dividers), `border-line-strong` (fields), `border-line-emphasis` (hover, selected) | +| Text | `text-fg-strong` (titles), `text-fg` (body), `text-fg-secondary`, `text-fg-muted` (secondary, captions), `text-fg-subtle` (15px and up only), `text-fg-disabled` (disabled only), `text-fg-inverse` (on `bg-inverse`) | +| Status | `good`, `warn`, `bad`, `info`, plus `severe` (high severity) and `done` (merged, pull requests): `text-warn`, `text-warn-strong`, `bg-warn-solid` (dots, bars), `bg-warn-soft`, `border-warn-line` | +| Accent | CoderHelm blue: `text-accent`, `bg-accent-solid`, `bg-accent-soft`, `border-accent-line` | +| Charts | `SERIES` / `CHART` from `src/lib/tokens.ts`; `bg-chart-1`, `bg-chart-2` for legends | + +A badge is `rounded-sm border border--line bg--soft px-1.5 text-xs text-`. + +## Elevation + +Only what floats casts a shadow: `shadow-popover` (menus, popovers, +toasts) and `shadow-dialog` (dialogs, sheets). Cards on the page have a +border and no shadow. + +## Components + +Use the shared pieces before writing classes: ``, ``, +`
`, ``, `cardClass` (components/page.tsx); +`buttonClass(variant, size)` and `inputClass` (components/ui.ts); +``, ``, `