Public: anyone can read this; the crew can change it.

Each home figure tile opens the board that draws it, at the tile's range, and shows its change against the previous period #17017

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16937-each-home-figure-tile-opens-the-board-th → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/16937-each-home-figure-tile-opens-the-board-th was merged into main as 8a4e70e.

Review

Sign in to review this change.
18 files changed +341 −44
docs/design/areas/home-flow.md +1
@@ -44,6 +44,7 @@ One section under the lanes or the table (`web/pages/home_figures.ts`), an admin
4444 - `.fg-grid` — the cards, as many 220px columns as fit.
4545 - `.fg-body` — the figures' live region; holds one row of cards (172px, summed from the card's own rules) before they arrive, so nothing below moves.
4646 - `.fg-card`, `.fg-label`, `.fg-value`, `.fg-n`, `.fg-unit`, `.fg-note` — a card: a name, the value with its unit, a note on two reserved lines so a row of cards is as tall as its tallest and nothing shifts. A card with a tone `attn` is the figure that is near or past a limit.
47 - `.fg-change` — a card's change against the window before it (`+12 vs prior 14 days`), muted, one 16px line; a card with no prior keeps the line as an empty `aria-hidden` block, so nothing is announced and no card changes height.
4748 - `.fg-chart`, `.fg-svg`, `.fg-line`, `.fg-area`, `.fg-base`, `.fg-dot`, `.fg-axis` — the one chart: a line over a faint area in the accent, scaled from zero to the series' own peak, a day with no value breaking the line; its two ends named underneath (`14 days ago`, `today`); a card with no daily series keeps the same 32px, empty.
4849 - `.fs`, `.fs-sum`, `.fs-svg`, `.fs-bar`, `.fs-count`, `.fs-base`, `.fs-h`, `.fs-slow`, `.fs-item`, `.fs-took`, `.fs-why`, `.fs-assume` — ship time under the cards (`web/pages/home_ship.ts`): a disclosure whose summary is the sentence (44px), a histogram drawn as SVG on the server in the muted foreground (seven fixed ranges, counts above the bars), the slowest tenth as a list of links with what the time went to, and the assumptions in a muted line. Closed by default; the live region reserves its row.
4950 - `.fg-reading` — the line a region shows before the first reading.
docs/features/living-home.md +4
@@ -27,3 +27,7 @@ The feed — the composer, the timeline, what is on you, since you were here —
2727 Under the figures, an admin's one card, "Crew, last 30 days": the days without a red main (`3 days without a red main`; "Main is red now" while it is), then a row per crew member who landed something: `4 landed · 75% green first pass · 25% rework`, each row a link to that member's page (`/settings/crew/<name>`). *First pass green* is the share of its landed pulls whose first finished check was green; *rework* the share that drew a change request or a revert; the counts are the scorecard's (`crewScorecards`). A forge where nothing landed says so in one calm sentence. It is shown, never notified: no alarm, no toast. A worker reads it with the figures (`src/flow/crew_card.ts`, every 30 s), so a request reads memory and the card redraws with the figures' region; nothing polls.
2828
2929 The terminal's home carries the same lines for an admin, under the figures: the streak, then one line per member (`src/flow/crew_card.ts`, `crewCardLines`).
30
31 ## Each figure tile opens its board (#16937)
32
33 A tile on the home's figures is a number, its change against the window before it, a chart, and a link to the one board that draws that figure at the tile's own window: Changes merged, Crew spend and Check time open `/boards/delivery?range=14d`; Visitors and Page speed open `/boards/reach?range=7d`; Open bugs opens Delivery's "Open bugs" panel. (`14d` is a board range like the others; `Delivery` is a starting board, offered on a forge's next boot.) The change reads `+12 vs prior 14 days`, `−3 vs prior 7 days` or `No change vs prior 14 days`, in the figure's own units and in the same quiet grey whichever way it swings: more is not always better, so nothing is red. A tile with nothing earlier to compare has no change line (the space is kept, so nothing moves). Check time's change is the median over the 14 days against the 14 before. The terminal has no tiles; open the same boards from its boards screen (`boards`), where `r` steps the range.
src/boards/guide.ts +3 −1
@@ -45,6 +45,8 @@ export const GUIDE: Readonly<Record<string, Guide>> = {
4545 queueVerdicts: { name: "Red merge batches", rows: "verdicts", kind: "events" },
4646 maintenanceRuns: { name: "Maintenance runs", rows: "duty runs", kind: "events" },
4747 maintenanceProbes: { name: "Maintenance probes", rows: "probe readings", kind: "samples", value: "number" },
48 checks: { name: "Check time", rows: "finished checks", kind: "samples", value: "minutes" },
49 bugs: { name: "Open bugs", rows: "open bugs", kind: "events" },
4850 stages: { name: "Work by stage", rows: "items entering a stage", kind: "events" },
4951 };
5052
@@ -72,7 +74,7 @@ const UNITS: Readonly<Record<string, string>> = {
7274 memory_bytes: "bytes", memory_bytes_max: "bytes", load: "runnable tasks", celsius: "°C", celsius_max: "°C",
7375 lag_ms: "ms", lag_ms_max: "ms", checks: "runs", agents: "runs", load_p75: "ms", inp_p75: "ms", reports: "reports",
7476 roll_probes: "probes", roll_non200: "probes", probes: "probes", pages: "pages", bad_in_row: "probes", worst_ms: "ms",
75 seconds_dark: "seconds", pull_number: "pull number", value: "a count, ms or score by metric",
77 seconds_dark: "seconds", minutes: "minutes", pull_number: "pull number", value: "a count, ms or score by metric",
7678 };
7779 const UNIT_OF: Readonly<Record<string, Readonly<Record<string, string>>>> = {
7880 reach: { value: "visitors, ms or a score, by metric" },
src/boards/panel_data.ts +1 −1
@@ -12,7 +12,7 @@ import { drawChart, usesSeries, type Cell, type Chart, type Mark } from "./chart
1212 import { BUCKETS, MAX_STEP, oldestTime, runQuery, type Answer, type Bucket, type Row } from "./query.ts";
1313 import type { Board, Panel } from "./store.ts";
1414
15 export const RANGE_MS = { "1h": 3_600_000, "6h": 21_600_000, "24h": 86_400_000, "7d": 604_800_000, "30d": 2_592_000_000 } as const;
15 export const RANGE_MS = { "1h": 3_600_000, "6h": 21_600_000, "24h": 86_400_000, "7d": 604_800_000, "14d": 1_209_600_000, "30d": 2_592_000_000 } as const;
1616 /** The steps a panel picks from on its own, in seconds: 1 min to a week. */
1717 export const STEPS = [60, 120, 300, 600, 900, 1800, 3600, 7200, 10_800, 21_600, 43_200, 86_400, 604_800] as const;
1818 /** About one point per two pixels of a chart's plot: more says nothing a reader can see. */
src/boards/sources.ts +22
@@ -396,6 +396,28 @@ export const SOURCES: Readonly<Record<string, Source>> = {
396396 at: "when the new process began serving, UTC",
397397 },
398398 },
399 // How long each finished check took (#16937): the home's Check time tile draws its days.
400 checks: {
401 table: "run",
402 owner: "repo_id",
403 select:
404 "SELECT repo_id, finished_at AS at, state, (julianday(finished_at) - julianday(started_at)) * 1440.0 AS minutes FROM run " +
405 "WHERE kind = 'check' AND state IN ('ok', 'failed') AND started_at IS NOT NULL AND finished_at IS NOT NULL AND finished_at >= started_at",
406 time: "at",
407 columns: { repo_id: "text", state: "text", minutes: "number", at: "time" },
408 docs: { minutes: "wall-clock minutes from start to finish", at: "when the check finished, UTC" },
409 },
410 // Open bugs (#16937): issues labelled bug and still open, by when they were opened.
411 bugs: {
412 table: "issue",
413 owner: "repo_id",
414 select:
415 "SELECT i.repo_id AS repo_id, i.created_at AS at FROM issue i JOIN issue_label il ON il.issue_id = i.id " +
416 "JOIN label l ON l.id = il.label_id AND l.name = 'bug' COLLATE NOCASE WHERE i.kind = 'issue' AND i.state = 'open'",
417 time: "at",
418 columns: { repo_id: "text", at: "time" },
419 docs: { at: "when the bug was opened, UTC" },
420 },
399421 // Red batches the merge queue named (#7639): a pull handed back, or a load red no pull is blamed for.
400422 queueVerdicts: {
401423 table: "queue_verdict",
src/boards/starting.ts +19 −5
@@ -1,9 +1,9 @@
11 /**
2 * The boards the forge offers a new install: Usage, Serving, Crew, Releases, Maintenance, Apps, App restarts, Security, Throughput, Forges and Reach. They are plain
3 * boards in `forge/boards` once written, so a person edits or deletes them
4 * like any other; `.offered` (a JSON list of slugs, committed with the
5 * boards) records what was offered so a deletion sticks and an edit is
6 * never overwritten. Each panel uses a source already in `sources.ts`.
2 * The boards the forge offers a new install: Usage, Serving, Crew, Releases, Maintenance, Apps, App
3 * restarts, Security, Throughput, Forges, Reach and Delivery. They are plain boards in
4 * `forge/boards` once written, so a person edits or deletes them like any other; `.offered` (a JSON
5 * list of slugs, committed with the boards) records what was offered so a deletion sticks and an
6 * edit is never overwritten. Each panel uses a source already in `sources.ts`.
77 */
88 import { repoDir } from "../git/repos.ts";
99 import { readerFor } from "../git/read.ts";
@@ -174,6 +174,20 @@ export const STARTING_BOARDS: Readonly<Record<string, Board>> = {
174174 panel("Slow to react per day (ms, slowest quarter)", "line", reach("inp_p75", "max", DAY), 2),
175175 ],
176176 },
177 // What the home's figure tiles draw (#16937): each tile opens this board, or Reach, at its own

Four tiles link to this board, but it only exists once offered at boot. On the preview /boards/delivery?range=14d returned 404. A tile must never link to a missing board.

178 // window.
179 delivery: {
180 title: "Delivery",
181 range: "14d",
182 refresh: "1m",
183 panels: [
184 panel("Changes merged per day", "bar", { source: "pulls", aggregate: "count", groupBy: DAY }, 2),
185 panel("Crew spend per day (USD)", "bar", { source: "runs", aggregate: "sum", column: "cost_usd", groupBy: DAY, filter: [{ column: "kind", op: "eq", value: "agent" }] }, 2),
186 panel("Check time per day (minutes, average)", "line", { source: "checks", aggregate: "avg", column: "minutes", groupBy: DAY }, 2),
187 // Open now, whatever the range: its own start reaches back to the first bug.
188 panel("Open bugs", "number", { source: "bugs", aggregate: "count", from: "1970-01-01T00:00:00.000Z" }),
189 ],
190 },
177191 forges: {
178192 title: "Forges",
179193 range: "30d",
src/boards/store.ts +1 −1
@@ -17,7 +17,7 @@ export const BOARDS_OWNER = "forge";
1717 export const BOARDS_REPO = "boards";
1818 const BRANCH = "main";
1919
20 export const RANGES = ["1h", "6h", "24h", "7d", "30d", "all"] as const;
20 export const RANGES = ["1h", "6h", "24h", "7d", "14d", "30d", "all"] as const;
2121 export const REFRESHES = ["off", "10s", "1m"] as const;
2222 export type Range = (typeof RANGES)[number];
2323 export type Refresh = (typeof REFRESHES)[number];
src/flow/figure_change.ts added +35
@@ -0,0 +1,35 @@
1 /**
2 * A figure's change against the window before it (#16937): "+12 vs prior 14 days". Pure
3 * over two numbers and the formatter that writes the figure. Calm by design: a swing is
4 * a direction and a size, never an alarm; whether more is better depends on the figure,
5 * so nothing here says good or bad. No line where there is nothing to compare.
6 */
7
8 export interface Change {
9 readonly text: string;
10 /**
11 * Only for a quiet mark beside the words; it carries no colour of its own that means good or bad.
12 */
13 readonly dir: "up" | "down" | "flat";
14 }
15
16 /**
17 * `now` against `prior`, both in the figure's unit and written by `write`; null when there is no
18 * prior or both are nothing.
19 */
20 export function changeAgainst(
21 now: number | null,
22 prior: number | null | undefined,
23 days: number,
24 write: (n: number) => string,
25 ): Change | null {
26 if (now === null || prior === null || prior === undefined) return null;
27 if (!Number.isFinite(now) || !Number.isFinite(prior)) return null;
28 if (now === 0 && prior === 0) return null;
29 const vs = `vs prior ${days} days`;
30 const diff = now - prior;
31 // A shift too small to show in the figure's own words is flat.
32 const shown = write(Math.abs(diff));
33 if (diff === 0 || write(now) === write(prior) || /^[$]?0(\.0+)?(ms)?$/.test(shown)) return { text: `No change ${vs}`, dir: "flat" };
34 return diff > 0 ? { text: `+${shown} ${vs}`, dir: "up" } : { text: `−${shown} ${vs}`, dir: "down" };
35 }
src/flow/figures.ts +41 −13
@@ -31,7 +31,7 @@ export interface Figures {
3131 /** The crew's spend at list price: today, against the daily ceiling, and per UTC day. */
3232 readonly spend: { readonly todayUsd: number; readonly ceilingUsd: number | null; readonly days: readonly number[]; readonly totalUsd: number };
3333 /** How long a finished check took: the median over 24 h and per UTC day (null for a day with none). */
34 readonly checks: { readonly medianMs: number | null; readonly days: readonly (number | null)[] };
34 readonly checks: { readonly medianMs: number | null; readonly days: readonly (number | null)[]; /** The median over the 14 days shown, for the change against the 14 before. */ readonly windowMs?: number | null };
3535 /** From the crew's first run on an issue to its closing as done, over 7 days (`ship_time.ts`). */
3636 readonly ship: ShipTime;
3737 readonly bugs: { readonly open: number; readonly overdue: number } | null;
@@ -45,14 +45,27 @@ export interface Figures {
4545 * (`crew_card.ts`).
4646 */
4747 readonly crew?: CrewCard;
48 /**
49 * The same figures over the window before the one shown (14 days before the last 14, 7 before the
50 * last 7); null where that window held nothing to compare (`figure_change.ts`).
51 */
52 readonly prior?: Prior;
4853 readonly backup: { readonly at: string | null; readonly state: "green" | "red" | "unknown" | null; readonly note: string };
4954 }
5055
51 /** The last `SERIES_DAYS` UTC days as `YYYY-MM-DD`, oldest first. */
52 function dayKeys(now: Date): string[] {
56 export interface Prior {
57 readonly shipped: number | null;
58 readonly visitors: number | null;
59 readonly spendUsd: number | null;
60 readonly checkMs: number | null;
61 readonly loadMs: number | null;
62 }
63
64 /** The last `n` UTC days as `YYYY-MM-DD`, oldest first. */
65 function dayKeys(now: Date, n = SERIES_DAYS): string[] {
5366 const keys: string[] = [];
5467 const midnight = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
55 for (let i = SERIES_DAYS - 1; i >= 0; i--) keys.push(new Date(midnight - i * DAY_MS).toISOString().slice(0, 10));
68 for (let i = n - 1; i >= 0; i--) keys.push(new Date(midnight - i * DAY_MS).toISOString().slice(0, 10));
5669 return keys;
5770 }
5871
@@ -63,10 +76,12 @@ function byDay<T>(keys: readonly string[], rows: readonly (readonly [string, T])
6376 }
6477
6578 export function readFigures(db: Database, now: Date, kpis: Kpis): Figures {
66 const keys = dayKeys(now);
67 const from = `${keys[0]}T00:00:00.000Z`;
68 const shipped = byDay(
69 keys,
79 // One pass per source over twice the window: the older half is the prior window.
80 const keys2 = dayKeys(now, 2 * SERIES_DAYS);
81 const keys = keys2.slice(SERIES_DAYS);
82 const from = `${keys2[0]}T00:00:00.000Z`;
83 const shipped2 = byDay(
84 keys2,
7085 db
7186 .query<[string, number], [string]>(
7287 `SELECT substr(p.merged_at, 1, 10), COUNT(*) FROM pull p JOIN issue i ON i.id = p.issue_id JOIN repo r ON r.id = i.repo_id
@@ -75,8 +90,8 @@ export function readFigures(db: Database, now: Date, kpis: Kpis): Figures {
7590 .values(from) as [string, number][],
7691 0,
7792 );
78 const spend = byDay(
79 keys,
93 const spend2 = byDay(
94 keys2,
8095 db
8196 .query<[string, number | null], [string]>(`SELECT substr(created_at, 1, 10), SUM(cost_usd) FROM run WHERE kind = 'agent' AND created_at >= ?1 GROUP BY 1`)
8297 .values(from)
@@ -95,14 +110,27 @@ export function readFigures(db: Database, now: Date, kpis: Kpis): Figures {
95110 if (list === undefined) took.set(d, [ms]);
96111 else list.push(ms);
97112 }
113 const [shipped, shippedBefore] = [shipped2.slice(SERIES_DAYS), shipped2.slice(0, SERIES_DAYS)];
114 const [spend, spendBefore] = [spend2.slice(SERIES_DAYS), spend2.slice(0, SERIES_DAYS)];
115 const sum = (xs: readonly number[]): number => xs.reduce((a, b) => a + b, 0);
116 const checkDays = keys.map((k) => median(took.get(k) ?? []));
117 const before = keys2.slice(0, SERIES_DAYS).flatMap((k) => took.get(k) ?? []);
98118 const r = kpis.reach;
119 const vd = r.visitorDays;
99120 const backupState = kpis.backup?.state ?? null;
100121 return {
101122 visitors: { today: r.visitorsToday, week: r.visitors7d, days: r.visitorDays, accountsToday: r.usersToday, accounts: r.usersTotal },
102123 speed: { load: r.loadP75, lcp: r.lcpP75, inp: r.inpP75 },
103 shipped: { days: shipped, total: shipped.reduce((a, b) => a + b, 0) },
104 spend: { todayUsd: kpis.spend.todayUsd, ceilingUsd: kpis.spend.ceilingUsd, days: spend, totalUsd: spend.reduce((a, b) => a + b, 0) },
105 checks: { medianMs: kpis.medianCheckMs, days: keys.map((k) => median(took.get(k) ?? [])) },
124 shipped: { days: shipped, total: sum(shipped) },
125 spend: { todayUsd: kpis.spend.todayUsd, ceilingUsd: kpis.spend.ceilingUsd, days: spend, totalUsd: sum(spend) },
126 checks: { medianMs: kpis.medianCheckMs, days: checkDays, windowMs: median(keys.flatMap((k) => took.get(k) ?? [])) },
127 prior: {
128 shipped: sum(shippedBefore) === 0 && sum(shipped) === 0 ? null : sum(shippedBefore),
129 visitors: vd.length >= 14 ? sum(vd.slice(-14, -7)) : null,
130 spendUsd: sum(spendBefore) === 0 ? null : sum(spendBefore),
131 checkMs: median(before),
132 loadMs: r.loadP75Prior ?? null,
133 },
106134 ship: readShipTime(db, now),
107135 crew: readCrewCard(db, now),
108136 maintenance: tally(readRuns(db), now),
src/flow/reach.ts +17 −8
@@ -24,12 +24,14 @@ export interface Reach {
2424 readonly visitorDays: readonly number[];
2525 /** Milliseconds; null when no page view in 7 days measured it. */
2626 readonly loadP75: number | null;
27 /** The same over the seven days before those (`figure_change.ts`); null with none. */
28 readonly loadP75Prior?: number | null;
2729 readonly inpP75: number | null;
2830 /** Largest contentful paint, the same window; null when none was measured. */
2931 readonly lcpP75: number | null;
3032 }
3133
32 export const NO_REACH: Reach = { usersToday: 0, usersTotal: 0, visitorsToday: 0, visitors7d: 0, visitorDays: new Array<number>(DAYS).fill(0), loadP75: null, inpP75: null, lcpP75: null };
34 export const NO_REACH: Reach = { usersToday: 0, usersTotal: 0, visitorsToday: 0, visitors7d: 0, visitorDays: new Array<number>(DAYS).fill(0), loadP75: null, loadP75Prior: null, inpP75: null, lcpP75: null };
3335
3436 /** The 75th percentile, nearest rank: the value at rank ⌈0.75·n⌉ of `values` sorted. */
3537 export function p75(values: number[]): number | null {
@@ -42,21 +44,26 @@ export function p75(values: number[]): number | null {
4244 * Page load and INP over the days since `fromDay`, read in one pass (#3693):
4345 * two counts and two sorted OFFSET reads cost home 70 ms on a month of views.
4446 */
45 function vitals(db: Database, fromDay: string): { load: number[]; inp: number[]; lcp: number[] } {
47 function vitals(db: Database, fromDay: string, priorFromDay: string): { load: number[]; inp: number[]; lcp: number[]; priorLoad: number[] } {
48 const priorLoad: number[] = [];
4649 const load: number[] = [];
4750 const inp: number[] = [];
4851 const lcp: number[] = [];
4952 // Rows as arrays: a week of views is tens of thousands, and objects cost.
50 for (const [l, i, c] of db
51 .query<[number | null, number | null, number | null], [string]>(
52 "SELECT load, inp, lcp FROM page_vital WHERE day >= ?1 AND (load IS NOT NULL OR inp IS NOT NULL OR lcp IS NOT NULL)",
53 for (const [l, i, c, d] of db
54 .query<[number | null, number | null, number | null, string], [string]>(
55 "SELECT load, inp, lcp, day FROM page_vital WHERE day >= ?1 AND (load IS NOT NULL OR inp IS NOT NULL OR lcp IS NOT NULL)",
5356 )
54 .values(fromDay) as [number | null, number | null, number | null][]) {
57 .values(priorFromDay) as [number | null, number | null, number | null, string][]) {
58 if (d < fromDay) {
59 if (l !== null) priorLoad.push(l);
60 continue;
61 }
5562 if (c !== null) lcp.push(c);
5663 if (l !== null) load.push(l);
5764 if (i !== null) inp.push(i);
5865 }
59 return { load, inp, lcp };
66 return { load, inp, lcp, priorLoad };
6067 }
6168
6269 export function readReach(db: Database, now: Date): Reach {
@@ -79,7 +86,8 @@ export function readReach(db: Database, now: Date): Reach {
7986 perDay.get(new Date(now.getTime() - (DAYS - 1 - i) * DAY_MS).toISOString().slice(0, 10)) ?? 0,
8087 );
8188 const days = month.filter((d) => d.day >= weekFrom);
82 const week = vitals(db, weekFrom);
89 const priorFrom = new Date(now.getTime() - 13 * DAY_MS).toISOString().slice(0, 10);
90 const week = vitals(db, weekFrom, priorFrom);
8391 return {
8492 usersToday: users.today,
8593 usersTotal: users.total,
@@ -87,6 +95,7 @@ export function readReach(db: Database, now: Date): Reach {
8795 visitorDays,
8896 visitors7d: days.reduce((a, d) => a + d.n, 0),
8997 loadP75: p75(week.load),
98 loadP75Prior: p75(week.priorLoad),
9099 inpP75: p75(week.inp),
91100 lcpP75: p75(week.lcp),
92101 };
src/web/pages/boards-view.ts +11 −2
@@ -10,6 +10,8 @@
1010 import { checkSlotsFold } from "./boards-slots.ts";
1111 import { CHART_NAMES } from "../../boards/chart.ts";
1212 import { isSlug, MAX_H, MAX_PANELS, MAX_TITLE, MAX_W, RANGES, type Board, type Panel } from "../../boards/store.ts";
13 import { STARTING_BOARDS } from "../../boards/starting.ts";
14 import { offerStartingBoards } from "../../actions/boards.ts";
1315 import type { App } from "../../app.ts";
1416 import type { Ctx } from "../../http/context.ts";
1517 import { driftSection } from "./boards-drift.ts";
@@ -199,7 +201,7 @@ function viewBar(slug: string, board: Board, view: View): Html {
199201 }
200202
201203 /** A board's range as words. */
202 const RANGE_WORDS: Readonly<Record<Board["range"], string>> = { "1h": "The last hour", "6h": "The last 6 hours", "24h": "The last 24 hours", "7d": "The last 7 days", "30d": "The last 30 days", all: "All of time" };
204 const RANGE_WORDS: Readonly<Record<Board["range"], string>> = { "1h": "The last hour", "6h": "The last 6 hours", "24h": "The last 24 hours", "7d": "The last 7 days", "14d": "The last 14 days", "30d": "The last 30 days", all: "All of time" };
203205
204206 function panelForm(slug: string, op: string, p: Panel | undefined, index: number, fields: Html): Html {
205207 const id = op === "edit" ? `panel-${String(index)}` : "panel-new";
@@ -279,7 +281,14 @@ export async function boardShow(ctx: Ctx): Promise<Response> {
279281 }
280282 // The board's file and every panel's rows are read by a worker and kept: no query and no git on
281283 // this thread.
282 const picture = await timePhaseAsync(ctx.request, "picture", () => boardPicture(ctx.app, slug, undefined, undefined, undefined, view.range ?? undefined));
284 const ask = () => boardPicture(ctx.app, slug, undefined, undefined, undefined, view.range ?? undefined);
285 let picture = await timePhaseAsync(ctx.request, "picture", ask);
286 // A starting board is written at boot, later than a tile that links to it can be clicked: the
287 // first ask for one that was never offered offers it. A deleted one is recorded as offered, so it
288 // stays deleted.
289 if (picture !== undefined && !isFailed(picture) && picture.board === null && slug in STARTING_BOARDS && (await offerStartingBoards(ctx.app)).includes(slug)) {
290 picture = await timePhaseAsync(ctx.request, "picture", ask);
291 }
283292 if (picture === undefined || isFailed(picture)) {
284293 return page({
285294 ctx,
src/web/pages/home_figures.ts +25 −7
@@ -25,6 +25,8 @@ import type { LanePicture } from "../../flow/lanes.ts";
2525 import { row, rowList } from "../ui.ts";
2626 import { html, raw, type Html } from "../html.ts";
2727 import { CREW_EMPTY, rowWords, streakWords, type CrewCard } from "../../flow/crew_card.ts";
28 import { changeAgainst, type Change } from "../../flow/figure_change.ts";
29 import { viewHref } from "../../boards/view_bar.ts";
2830 import { shipSection } from "./home_ship.ts";
2931
3032 /** The events that change a figure; they change by the minute, so these are few. */
@@ -87,8 +89,16 @@ interface Card {
8789 readonly ends?: readonly [string, string];
8890 readonly tone?: "attn";
8991 readonly href?: string;
92 /**
93 * Against the window before this one; the line is kept (empty) when there is none, so a card
94 * never changes height.
95 */
96 readonly change?: Change | null;
9097 }
9198
99 /** The board that draws a tile's figure, at the tile's window: the board's own range link. */
100 export const tileHref = (slug: string, days: 7 | 14): string => viewHref(`/boards/${slug}`, { range: days === 7 ? "7d" : "14d", live: null });
101
92102 function card(c: Card): Html {
93103 const drawn =
94104 c.series === undefined ? null : chart(c.series, c.seriesLabel ?? c.label);
@@ -97,6 +107,9 @@ function card(c: Card): Html {
97107 <span class="fg-n num">${c.value}</span
98108 ><span class="fg-unit">${c.unit}</span>
99109 </p>
110 ${c.change == null
outdated

Principle 8 and accessibility: this reuses the fg-axis paragraph and leaves it empty when there is no prior. Use a named component class (documented under docs/design/areas/) and keep the height without an empty readable paragraph.

111 ? html`<div class="fg-change" aria-hidden="true"></div>`
112 : html`<p class="fg-change" data-dir="${c.change.dir}">${c.change.text}</p>`}
100113 <p class="fg-note">${c.note}</p>
101114 <div class="fg-chart">${drawn}</div>
102115 <p class="fg-axis" aria-hidden="true">
@@ -145,7 +158,8 @@ export function cards(f: Figures, now: number): Card[] {
145158 series: f.shipped.days,
146159 seriesLabel: `Changes merged per day over 14 days, most ${count(peak)}`,
147160 ends: days(14),
148 href: "/board",
161 href: tileHref("delivery", 14),
162 change: changeAgainst(f.shipped.total, f.prior?.shipped, 14, count),
149163 },
150164 {
151165 label: "Visitors",
@@ -155,7 +169,8 @@ export function cards(f: Figures, now: number): Card[] {
155169 series: f.visitors.days,
156170 seriesLabel: `Visitors per day over ${f.visitors.days.length} days`,
157171 ends: days(f.visitors.days.length),
158 href: "/boards/reach",
172 href: tileHref("reach", 7),
173 change: changeAgainst(f.visitors.week, f.prior?.visitors, 7, count),
159174 },
160175 {
161176 label: "Crew spend",
@@ -171,7 +186,8 @@ export function cards(f: Figures, now: number): Card[] {
171186 ...(spendShare !== null && spendShare >= 0.9
172187 ? { tone: "attn" as const }
173188 : {}),
174 href: "/settings/crew",
189 href: tileHref("delivery", 14),
190 change: changeAgainst(f.spend.totalUsd, f.prior?.spendUsd, 14, money),
175191 },
176192 {
177193 label: "Check time",
@@ -180,11 +196,12 @@ export function cards(f: Figures, now: number): Card[] {
180196 f.checks.medianMs === null
181197 ? "no check finished in 24 hours"
182198 : "median, last 24 hours",
183 note: "How long a finished check took, per day below",
199 note: "Median over 14 days; per day below",
184200 series: f.checks.days.map((ms) => (ms === null ? null : ms / 60_000)),
185201 seriesLabel: "Median check time per day over 14 days, in minutes",
186202 ends: days(14),
187 href: "/boards",
203 href: tileHref("delivery", 14),
204 change: changeAgainst(f.checks.windowMs ?? null, f.prior?.checkMs, 14, duration),
188205 },
189206 {
190207 label: "Page speed",
@@ -200,7 +217,8 @@ export function cards(f: Figures, now: number): Card[] {
200217 ]
201218 .filter((p) => p !== null)
202219 .join(" · ") || "Reported by visitors' browsers over 7 days",
203 href: "/boards/reach",
220 href: tileHref("reach", 7),
221 change: changeAgainst(f.speed.load, f.prior?.loadMs, 7, pageTime),
204222 },
205223 ...(f.bugs === null
206224 ? []
@@ -214,7 +232,7 @@ export function cards(f: Figures, now: number): Card[] {
214232 ? `${count(f.bugs.overdue)} past their clock (4 h for high, 48 h otherwise)`
215233 : "None past their clock",
216234 ...(f.bugs.overdue > 0 ? { tone: "attn" as const } : {}),
217 href: "/boards",
235 href: tileHref("delivery", 14),
218236 },
219237 ]),
220238 // Quiet when the workers have found and fixed nothing: the home's first view is budgeted.
src/web/pages/home_flow_style.ts +1
@@ -248,6 +248,7 @@ export const homeFlowCss = /* css */ `
248248 .fg-area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
249249 .fg-base { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
250250 .fg-dot { fill: var(--accent); }
251 .fg-change { min-height: 16px; margin: 0; font-size: var(--fs-min); line-height: 16px; color: var(--muted-fg); }
251252 .fg-axis { display: flex; justify-content: space-between; gap: 8px; min-height: 16px; margin: 0; font-size: var(--fs-min); line-height: 16px; color: var(--muted-fg); }
252253 .fg-reading { margin: 0; color: var(--muted-fg); }
253254
test/boards-starting.test.ts +3 −3
@@ -36,10 +36,10 @@ test("a forge with no person to found the repo writes nothing", async () => {
3636 expect(await offerStartingBoards(bare)).toEqual([]);
3737 });
3838
39 test("a fresh boot writes the eleven starting boards, and every panel runs", async () => {
40 expect((await offerStartingBoards(app)).sort()).toEqual(["apps", "crew", "forges", "maintenance", "reach", "releases", "restarts", "security", "serving", "throughput", "usage"]);
39 test("a fresh boot writes the twelve starting boards, and every panel runs", async () => {
40 expect((await offerStartingBoards(app)).sort()).toEqual(["apps", "crew", "delivery", "forges", "maintenance", "reach", "releases", "restarts", "security", "serving", "throughput", "usage"]);
4141 const boards = await listBoards(app.reposRoot);
42 expect(boards.map((b) => b.slug)).toEqual(["apps", "crew", "forges", "maintenance", "reach", "releases", "restarts", "security", "serving", "throughput", "usage"]);
42 expect(boards.map((b) => b.slug)).toEqual(["apps", "crew", "delivery", "forges", "maintenance", "reach", "releases", "restarts", "security", "serving", "throughput", "usage"]);
4343 let panels = 0;
4444 for (const { board } of boards) {
4545 for (const p of board.panels) {
test/boards-view-bar.test.ts +2 −2
@@ -124,10 +124,10 @@ describe("the terminal's view", () => {
124124 expect(tui.screen.toText()).toContain("range 7d · refresh off");
125125 terminal.feed("v");
126126 await settleApp(tui);
127 expect(tui.screen.toText()).toContain("range 30d · refresh off · 1 panel · a view, not saved");
127 expect(tui.screen.toText()).toContain("range 14d · refresh off · 1 panel · a view, not saved");
128128 terminal.feed("l");
129129 await settleApp(tui);
130 expect(tui.screen.toText()).toContain("range 30d · refresh 10s");
130 expect(tui.screen.toText()).toContain("range 14d · refresh 10s");
131131 terminal.feed("l");
132132 await settleApp(tui);
133133 expect(tui.screen.toText()).toContain("refresh off");
test/home-figure-tiles.test.ts added +98
@@ -0,0 +1,98 @@
1 /**
2 * The home's figure tiles (#16937): each opens the board that draws its figure at its own window,
3 * and says its change against the window before it, calmly, with no line where there is nothing to
4 * compare.
5 */
6 import { expect, test } from "bun:test";
7 import { changeAgainst } from "../src/flow/figure_change.ts";
8 import type { Figures } from "../src/flow/figures.ts";
9 import { readParams } from "../src/boards/params.ts";
10 import { readView } from "../src/boards/view_bar.ts";
11 import { STARTING_BOARDS } from "../src/boards/starting.ts";
12 import { count, money } from "../src/flow/figure_format.ts";
13 import { cards } from "../src/web/pages/home_figures.ts";
14
15 const figures: Figures = {
16 visitors: { today: 12, week: 147, days: Array.from({ length: 30 }, () => 3), accountsToday: 1, accounts: 4 },
17 speed: { load: 1130, lcp: 2300, inp: 201 },
18 shipped: { days: Array.from({ length: 14 }, () => 1), total: 14 },
19 spend: { todayUsd: 39, ceilingUsd: 50, days: Array.from({ length: 14 }, () => 20), totalUsd: 280 },
20 checks: { medianMs: 8 * 60_000, days: Array.from({ length: 14 }, () => 5 * 60_000), windowMs: 6 * 60_000 },
21 ship: { days: 7, count: 0, medianMs: null, p90Ms: null, histogram: [], slowest: [] },
22 bugs: { open: 3, overdue: 0 },
23 prior: { shipped: 2, visitors: 100, spendUsd: 300, checkMs: 6 * 60_000, loadMs: 1130 },
24 backup: { at: null, state: null, note: "" },
25 };
26 const now = Date.parse("2026-11-13T12:00:00Z");
27
28 test("every figure tile opens a board's own page at its window, never an index or a settings page", () => {
29 const tiles = cards(figures, now).filter((c) => ["Shipped", "Visitors", "Crew spend", "Check time", "Page speed", "Open bugs"].includes(c.label));
30 expect(tiles).toHaveLength(6);
31 for (const c of tiles) {
32 const href = c.href ?? "";
33 expect(href).not.toMatch(/^\/boards?(\?|$)/);
34 expect(href).not.toMatch(/^\/settings/);
35 const url = new URL(href, "http://x");
36 const slug = url.pathname.replace(/^\/boards\//, "");
37 expect(Object.hasOwn(STARTING_BOARDS, slug)).toBe(true);
38 // The window rides in the board's own range parameter and is one the board reads.
39 expect(readView(url.searchParams).range).toBe(c.label === "Visitors" || c.label === "Page speed" ? "7d" : "14d");
40 expect(readParams(url.searchParams).source).toBeDefined();
41 }
42 });
43
44 test("the tile's board draws the tile's figure", () => {
45 const by = (label: string) => cards(figures, now).find((c) => c.label === label)!.href!.split("?")[0]!.replace("/boards/", "");
46 const titles = (slug: string) => STARTING_BOARDS[slug]!.panels.map((p) => p.title).join("|");
47 expect(titles(by("Shipped"))).toContain("Changes merged");
48 expect(titles(by("Crew spend"))).toContain("Crew spend");
49 expect(titles(by("Check time"))).toContain("Check time");
50 expect(titles(by("Open bugs"))).toContain("Open bugs");
51 expect(titles(by("Visitors"))).toContain("Visitors");
52 expect(titles(by("Page speed"))).toContain("Page load");
53 });
54
55 test("a change is up, down, flat or absent, in calm words", () => {
56 expect(changeAgainst(14, 2, 14, count)).toEqual({ text: "+12 vs prior 14 days", dir: "up" });
57 expect(changeAgainst(3, 10, 7, count)).toEqual({ text: "−7 vs prior 7 days", dir: "down" });
58 expect(changeAgainst(5, 5, 14, count)).toEqual({ text: "No change vs prior 14 days", dir: "flat" });
59 expect(changeAgainst(5, null, 14, count)).toBeNull();
60 expect(changeAgainst(5, undefined, 14, count)).toBeNull();
61 expect(changeAgainst(0, 0, 14, count)).toBeNull();
62 expect(changeAgainst(280, 300, 14, money)?.text).toBe("−$20.00 vs prior 14 days");
63 expect(changeAgainst(null, 4, 14, count)).toBeNull();
64 });
65
66 const withoutPrior = (f: Figures): Figures => {
67 const { prior: _p, ...rest } = f;
68 return rest;
69 };
70
71 test("the tiles carry the change, and keep an empty line where there is none", () => {
72 const by = (f: Figures, label: string) => cards(f, now).find((c) => c.label === label)!;
73 expect(by(figures, "Shipped").change?.text).toBe("+12 vs prior 14 days");
74 expect(by(figures, "Visitors").change?.text).toBe("+47 vs prior 7 days");
75 expect(by(figures, "Crew spend").change?.dir).toBe("down");
76 expect(by(figures, "Page speed").change?.dir).toBe("flat");
77 expect(by(withoutPrior(figures), "Shipped").change).toBeNull();
78 expect(by(figures, "Open bugs").change ?? null).toBeNull();
79 });
80
81 test("a forge with no history reads no prior and so draws no change", async () => {
82 const { mkdtemp, rm } = await import("node:fs/promises");
83 const { tmpdir } = await import("node:os");
84 const { join } = await import("node:path");
85 const { createApp } = await import("../src/app.ts");
86 const { readFigures } = await import("../src/flow/figures.ts");
87 const { NO_REACH } = await import("../src/flow/reach.ts");
88 const dir = await mkdtemp(join(tmpdir(), "forge-tiles-"));
89 try {
90 const app = createApp({ dataDir: dir, port: 0 });
91 const f = readFigures(app.db, new Date(now), { landedHours: [0], landed: 0, live: null, medianCheckMs: null, builders: { running: 0, slots: 0, idle: null }, spend: { todayUsd: 0, ceilingUsd: null }, backupAt: null, reach: NO_REACH });
92 expect(f.prior).toEqual({ shipped: null, visitors: 0, spendUsd: null, checkMs: null, loadMs: null });
93 expect(f.shipped.days).toHaveLength(14);
94 expect(cards(f, now).every((c) => (c.change ?? null) === null)).toBe(true);
95 } finally {
96 await rm(dir, { recursive: true, force: true });
97 }
98 });
test/home-no-shift.test.ts +2 −1
@@ -194,8 +194,9 @@ describe("the signed-in home", () => {
194194 need(px(css, ".fg-note", "min-height")) +
195195 need(px(css, ".fg-chart", "height")) +
196196 need(px(css, ".fg-chart", "margin-top")) +
197 need(px(css, ".fg-change", "min-height")) +
197198 need(px(css, ".fg-axis", "min-height")) +
198 4 * need(px(css, ".fg-card", "gap"));
199 5 * need(px(css, ".fg-card", "gap"));
199200 // The card's padding is "12px 16px": top and bottom make 24.
200201 expect(need(px(css, ".fg-body", "min-height"))).toBeGreaterThanOrEqual(card - 16 * 2 + 12);
201202 });
test/home-tile-board-offered.test.ts added +55
@@ -0,0 +1,55 @@
1 /**
2 * A tile on the home links to a starting board (#16937): the first ask for one that boot has not
3 * written yet offers it, so the link is never dead; a board that was offered and deleted stays
4 * gone.
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { deleteBoard } from "../src/actions/boards.ts";
11 import { createApp, type App } from "../src/app.ts";
12 import { readBoard } from "../src/boards/store.ts";
13 import { createSession } from "../src/core/sessions.ts";
14 import { createUser } from "../src/core/users.ts";
15 import { serve } from "../src/http/server.ts";
16 import { quietLogs } from "./helpers/globals.ts";
17
18 quietLogs();
19
20 let dir: string;
21 let app: App;
22 let servers: Awaited<ReturnType<typeof serve>>;
23 let cookie = "";
24 const get = (path: string) => fetch(`${servers.url}${path}`, { headers: { cookie }, redirect: "manual" });
25
26 beforeAll(async () => {
27 dir = await mkdtemp(join(tmpdir(), "forge-tile-board-"));
28 app = createApp({ dataDir: dir, port: 0 });
29 servers = await serve(app);
30 const made = await createUser(app.db, { origin: "seed", trusted: true, username: "carol", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
31 if (!made.ok) throw new Error(made.error);
32 cookie = `forge_session=${createSession(app.db, made.value.id).token}`;
33 }, 30_000);
34
35 afterAll(async () => {
36 await servers.stop?.();
37 app.close();
38 await rm(dir, { recursive: true, force: true });
39 });
40
41 test("the Delivery board is there on the path a tile uses, before any boot offered it", async () => {
42 expect(await readBoard(app.reposRoot, "delivery")).toBeUndefined();
43 const res = await get("/boards/delivery?range=14d");
44 expect(res.status).toBe(200);
45 expect(await res.text()).toContain("Changes merged per day");
46 expect(await readBoard(app.reposRoot, "delivery")).toBeDefined();
47 }, 30_000);
48
49 test("a deleted starting board is not offered again by a click, and a board that is no starting one stays 404", async () => {
50 const user = app.db.query<{ id: string }, []>("SELECT id FROM user LIMIT 1").get()!;
51 const { getUserById } = await import("../src/core/users.ts");
52 expect((await deleteBoard(app, getUserById(app.db, user.id)!, "delivery")).ok).toBe(true);
53 expect((await get("/boards/delivery?range=14d")).status).toBe(404);
54 expect((await get("/boards/nothing-here")).status).toBe(404);
55 }, 30_000);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs