admin: overview redesign, device scope, one formatting contract (milestone 39)
Gates / frontend (push) Successful in 1m57s
Gates / test (push) Successful in 2m34s
Gates / test-aarch64 (push) Successful in 8m9s
Gates / package (push) Successful in 7m14s
Gates / container (push) Successful in 17s
CI / gates (push) Successful in 18m17s
Release / guard (push) Successful in 33s
Gates / test-aarch64 (push) Successful in 7m22s
Gates / container (push) Successful in 11s
Release / gates (push) Successful in 10m35s
Gates / frontend (push) Successful in 2m8s
Gates / test (push) Successful in 2m16s
Gates / package (push) Successful in 44s
Release / publish (push) Successful in 10m4s

The Overview page takes the decided visual language (specs/ui-visual-redesign.md): four centred totals with their Activity links, a smoothed area chart of total and blocked queries with point hover and a tooltip centred beside the point, a stacked client chart in eight distinct hues plus one Other band that is always a series, and a card row with the cache hit rate, the query types as a single-hue ramp ring, and the upstream breakdown. The count axis grows its margin with the widest grouped tick and draws whole-number ticks only.

GET /api/overview takes a client parameter; the scoped read uses idx_query_log_ts and the cache keeps scoped slots. The device selector beside the period selector is URL state, so a scoped view is a link, and the tile links carry the scope into Activity. The route reduces a pasted IPv6 scope to the RFC 5952 spelling the logger stores, mapped addresses included, and drops anything that is not an address. A failed device list says so under the selector with a retry.

All measured quantities go through admin/src/lib/format.ts: grouped counts, two-decimal percentages, one-decimal rates, durations as the two largest nonzero units. Identifiers, configured values and preset labels render as written; the module header states that scope. A sweep test refuses toFixed, toLocaleString, Intl.NumberFormat and padStart anywhere else.

Chrome: one 4px radius from the metrics constants, shared Card with a prominent title and a one-line description on every panel, the settings form sections on the same card with a floated legend, the sidebar grouped into Monitoring and System with a status block (protection, queries per minute on Overview, uptime), keyboard-focusable table scroll wrappers, and the accent darkened to 5.43:1 on its wash.

Not built: the spec's ranked-list primitive, which has no consumer and no API rows. Codex reviewed sessions B to D over five rounds (thirty-three findings fixed, thirteen rejected as non-quantities); the owner skipped a sixth round.

Claude-Session: https://claude.ai/code/session_01VTgx3a1zz1R78o4K55kkwR
This commit is contained in:
2026-09-07 23:11:50 +02:00
parent e656670dd4
commit 85b8be50a0
77 changed files with 2869 additions and 1163 deletions
+107 -100
View File
@@ -1,110 +1,128 @@
/**
* The window's four headline numbers, each with the way into the rows behind it.
* The window's four headline numbers (ui-visual-redesign.md): centred 2.5rem
* numerals over lowercase captions, each with the way into the rows behind it.
* Colour is semantic and nothing else — the blocked count is red, the share is
* muted, the rest is ink — so a tile never implies a state it is not reporting.
*
* Neutral chrome throughout: no coloured accents, no per-tile tone. Emphasis is
* typographic, so the eye ranks the figures rather than the panels, and a tile
* never implies a state it is not reporting.
* On a phone the four tiles merge into one card: the three counts side by side
* and the share on a line under them, so the set fits above the fold.
*
* The Activity links carry the bounds the **overview response** returned, not
* bounds computed here — a client-computed window would send the reader to a
* slightly different span than the one they were just reading.
* slightly different span than the one they were just reading — and the client
* scope the page is under, so the rows they open are the rows the tile counted.
*/
import * as stylex from "@stylexjs/stylex";
import { Link } from "@tanstack/react-router";
import { formatMicros } from "@/lib/format";
import { formatCount, formatPercent } from "@/lib/format";
import type { OverviewTotals } from "@/lib/types";
import { styles as shared } from "@/ui/styles";
import { colors } from "@/ui/tokens.stylex";
import { colors, metrics } from "@/ui/tokens.stylex";
const numberFormat = new Intl.NumberFormat();
const NARROW = "@media (max-width: 800px)";
const styles = stylex.create({
/** Two columns on a phone, the whole set of four in one row from `md`. */
grid: {
display: "grid",
gap: "0.75rem",
gridTemplateColumns: {
default: "repeat(2, minmax(0, 1fr))",
"@media (min-width: 768px)": "repeat(4, minmax(0, 1fr))",
},
gap: { default: "1rem", [NARROW]: 0 },
gridTemplateColumns: { default: "repeat(4, minmax(0, 1fr))", [NARROW]: "repeat(3, minmax(0, 1fr))" },
margin: 0,
padding: 0,
listStyleType: "none",
borderRadius: { default: null, [NARROW]: metrics.radius },
borderWidth: { default: 0, [NARROW]: 1 },
borderStyle: "solid",
borderColor: colors.border,
backgroundColor: { default: null, [NARROW]: colors.surfaceRaised },
paddingInline: { default: 0, [NARROW]: "0.5rem" },
paddingBlock: { default: 0, [NARROW]: "1rem" },
},
tile: {
display: "flex",
flexDirection: "column",
gap: "0.125rem",
borderRadius: "0.25rem",
borderWidth: 1,
alignItems: "center",
gap: "0.375rem",
minWidth: 0,
borderRadius: metrics.radius,
borderWidth: { default: 1, [NARROW]: 0 },
borderStyle: "solid",
borderColor: colors.border,
backgroundColor: colors.surfaceRaised,
paddingInline: "1rem",
paddingBlock: "0.75rem",
paddingInline: { default: "1rem", [NARROW]: "0.25rem" },
paddingBlock: { default: "1.5rem", [NARROW]: 0 },
textAlign: "center",
},
label: {
/** The share drops under the three counts on a phone, divided from them by a hairline. */
shareTile: {
gridColumn: { default: null, [NARROW]: "1 / -1" },
marginTop: { default: 0, [NARROW]: "1rem" },
paddingTop: { default: null, [NARROW]: "1rem" },
borderTopWidth: { default: null, [NARROW]: 1 },
borderTopStyle: "solid",
borderTopColor: colors.border,
},
value: {
margin: 0,
fontSize: { default: "2.5rem", [NARROW]: "1.75rem" },
lineHeight: 1,
fontWeight: 400,
letterSpacing: "-0.02em",
color: colors.text,
},
valueBlocked: { color: colors.chartRed },
valueMuted: { color: colors.textMuted },
caption: {
margin: 0,
fontSize: "0.875rem",
lineHeight: "1.25rem",
color: colors.textMuted,
},
valueRow: {
display: "flex",
alignItems: "baseline",
gap: "0.5rem",
flexWrap: "wrap",
},
value: {
fontSize: "1.875rem",
lineHeight: "2.25rem",
fontWeight: 600,
},
detail: {
fontSize: "0.875rem",
lineHeight: "1.25rem",
color: colors.textSecondary,
},
footer: {
link: {
marginTop: "0.25rem",
fontSize: "0.75rem",
lineHeight: "1rem",
},
link: {
color: colors.primaryOnSurface,
textDecorationLine: "none",
},
});
function percentOf(part: number, total: number): string | null {
if (total === 0) return null;
return `${((part / total) * 100).toFixed(1)}%`;
}
function Tile({
label,
value,
detail,
footer,
caption,
tone,
style,
children,
}: {
label: string;
value: string;
detail?: string | null;
footer?: React.ReactNode;
caption: string;
tone?: "blocked" | "muted";
style?: stylex.StyleXStyles;
children?: React.ReactNode;
}) {
return (
<div {...stylex.props(styles.tile)}>
<dt {...stylex.props(styles.label)}>{label}</dt>
<dd {...stylex.props(styles.valueRow)}>
<span {...stylex.props(styles.value, shared.tabularNums)}>{value}</span>
{detail != null && <span {...stylex.props(styles.detail, shared.tabularNums)}>{detail}</span>}
</dd>
{footer !== undefined && <div {...stylex.props(styles.footer)}>{footer}</div>}
</div>
<li {...stylex.props(styles.tile, style)}>
<p
{...stylex.props(
styles.value,
shared.tabularNums,
tone === "blocked" && styles.valueBlocked,
tone === "muted" && styles.valueMuted,
)}
>
{value}
</p>
<p {...stylex.props(styles.caption)}>{caption}</p>
{children}
</li>
);
}
/** The window's totals with the bounds they were measured over. */
/** The window's totals with the bounds they were measured over and the scope they were read under. */
export interface StatTilesData extends OverviewTotals {
since: number;
until: number;
client: string | undefined;
}
export default function StatTiles({ stats }: { stats: StatTilesData }) {
@@ -113,50 +131,39 @@ export default function StatTiles({ stats }: { stats: StatTilesData }) {
since: stats.since,
until: stats.until,
domain: undefined,
client: undefined,
client: stats.client,
};
return (
<dl {...stylex.props(styles.grid)}>
<ul aria-label="Totals" {...stylex.props(styles.grid)}>
<Tile value={formatCount(stats.queries)} caption="queries">
<Link
to="/activity"
search={{ ...window, blocked: undefined }}
{...stylex.props(styles.link, shared.focusRing)}
>
Open in Activity
</Link>
</Tile>
<Tile value={formatCount(stats.blocked)} caption="blocked queries" tone="blocked">
<Link
to="/activity"
search={{ ...window, blocked: true }}
{...stylex.props(styles.link, shared.focusRing)}
>
Open blocked queries
</Link>
</Tile>
<Tile value={formatCount(stats.clients)} caption="active clients">
<Link to="/clients" {...stylex.props(styles.link, shared.focusRing)}>
Manage clients
</Link>
</Tile>
<Tile
label="Queries"
value={numberFormat.format(stats.queries)}
footer={
<Link
to="/activity"
search={{ ...window, blocked: undefined }}
{...stylex.props(styles.link, shared.focusRing)}
>
Open in Activity
</Link>
}
value={stats.queries === 0 ? "—" : formatPercent(stats.blocked / stats.queries)}
caption="of queries blocked"
tone="muted"
style={styles.shareTile}
/>
<Tile
label="Blocked"
value={numberFormat.format(stats.blocked)}
detail={percentOf(stats.blocked, stats.queries)}
footer={
<Link
to="/activity"
search={{ ...window, blocked: true }}
{...stylex.props(styles.link, shared.focusRing)}
>
Open blocked queries
</Link>
}
/>
<Tile
label="Clients"
value={numberFormat.format(stats.clients)}
footer={
<Link to="/clients" {...stylex.props(styles.link, shared.focusRing)}>
Manage clients
</Link>
}
/>
<Tile
label="Avg response"
value={stats.avg_response_time_us === null ? "—" : formatMicros(stats.avg_response_time_us)}
/>
</dl>
</ul>
);
}