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

Design: /system's btop panels use the design system, and the bt-* classes and sys-pair leave §5d #4123

Parked opened this
Closed without merging

scout/forge:scout/3866-design-system-s-btop-panels-use-the-desi → main 9 commits fork 1 thread · 1 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
4 files changed +49 −37
docs/DESIGN.md +1 −2
@@ -393,8 +393,7 @@ gone, so this list only shrinks.
393393 - **`style/base.ts`** — the page shell (topbar, main, footer) and the layout and text utilities every page leans on: `.bar` `.bare` `.foot` `.grow` `.hide-lg` `.hide-sm` `.js-only` `.live-pill` `.mark` `.mb` `.mt` `.muted` `.narrow` `.narrow-wide` `.num` `.reduced` `.shell` `.shell-wide` `.skip` `.small` `.spacer` `.sr-only` `.stack` `.stack-tight` `.topbar` `.topbar-tools` `.truncate` `.wordmark`
394394 - **`style/components.ts`** — parts of the §5 components that the table does not spell out — the palette's list, the menu's items, a dialog's head and foot, comments, the theme picker — and a few small helpers beside them: `.cat` `.clone` `.clone-text` `.comment` `.comment-body` `.comment-form` `.dash` `.dialog-body` `.dialog-foot` `.dialog-head` `.empty-title` `.error-note` `.field-row` `.form-actions` `.hex` `.ico` `.ico-loader` `.list` `.live-status` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.passkey` `.passkey-lead` `.passkey-note` `.passkey-off` `.passkey-on` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search`
395395 - **`style/components.ts`, settings rows** — a list whose rows are settings (limits, capacity): the `<ul class="list setting-list">` lets title and meta wrap instead of ellipsizing, and a row's controls take their own line under 640px. `.row-fields` is the form in that row's trail (input, Save, Default): always visible, never hover-gated, wrapping under the text before it would clip. Use both for any page whose rows show a name, a current value, and a control to change it; use `.row-actions` only for secondary actions (delete, wake, pin, revoke). Flags, telemetry, cloud, people, crew roles and subscription headroom/budget use `.row-fields`. Classes: `.row-fields` `.setting-list`
396 - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, following, lineage: `.about` `.act` `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.big` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.chart` `.chart-box` `.commit-body` `.commit-head` `.connect-more` `.connect-path` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.following` `.following-actions` `.following-eyebrow` `.following-foot` `.following-head` `.following-sentence` `.fork-bar` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.handoff` `.handoff-links` `.headroom` `.issue-head` `.issue-meta` `.lineage` `.lineage-children` `.lineage-here` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep`
397 - **`style/content.ts`, code view** — the source view and the syntax-highlight token classes `highlight-html.ts` builds as `tok-${kind}`: `.blob-view` `.ln` `.tok-attribute` `.tok-comment` `.tok-constant` `.tok-decorator` `.tok-deleted` `.tok-emphasis` `.tok-function` `.tok-heading` `.tok-inserted` `.tok-keyword` `.tok-link` `.tok-meta` `.tok-number` `.tok-operator` `.tok-plain` `.tok-property` `.tok-punctuation` `.tok-regex` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable`
396 >>>>>>> origin/main
398397 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
399398 - **`style/content.ts`, diff viewer** — the diff table: its gutters, line kinds, file head and inline review comments: `.add` `.del` `.dh` `.diff` `.diff-body` `.diff-head` `.diff-note` `.diff-path` `.diff-stat` `.diff-stub` `.diff-summary` `.diff-table` `.dl` `.dl-review` `.dn` `.dn-comment` `.nonl` `.rc-hidden` `.rc-resolve` `.rc-resolved` `.wd`
400399 - **`style/content.ts`, apps, runs, and the crew** — run pages, their logs and checks (a pull's look is §5's **look**): `.ln-forge` `.ln-pulse` `.ln-say` `.ln-tool` `.ln-you` `.log-tail-row` `.pinned-failures` `.pinned-slot` `.run-jump` `.run-live` `.run-steer` `.tests-bar` `.tests-words` `.txt` `.who`
src/web/pages/system.ts +26 −17
@@ -24,7 +24,7 @@ import { notFoundPage, signInFirst } from "../chrome.ts";
2424 import { html, raw, type Html } from "../html.ts";
2525 import { page } from "../layout.ts";
2626 import { systemLiveJs } from "../system-live.ts";
27 import { card, empty, pill } from "../ui.ts";
27 import { card, empty, meter, pill, row } from "../ui.ts";
2828
2929 /** A group's memory, and a cell's beside its cap and who holds the cap. */
3030 const memoryOf = (g: { rssBytes: number; capBytes: number | null; capBy: "kernel" | "watch" | null }): Html =>
@@ -38,21 +38,30 @@ const coresOf = (n: number | null): string => (n === null ? "—" : n.toFixed(2)
3838 const rateOf = (n: number | null): string => (n === null ? "—" : `${bytes(n)}/s`);
3939
4040 /** One line of the machine card: a name, a meter, its figure and (for a core) its history. */
41 const meterRow = (name: string, value: number | null, max: number, figure: string, history = ""): Html =>
42 html`<div class="bt-row"><span class="bt-name" title="${name}">${name}</span>
43 <meter class="bt-bar" aria-label="${name} ${figure}" min="0" max="${String(max)}" high="${String(max * 0.85)}" value="${String(value ?? 0)}">${figure}</meter>
44 <span class="bt-val">${figure}</span>${history ? html`<span class="bt-hist" aria-hidden="true">${history}</span>` : null}</div>`;
41 const meterRow = (name: string, value: number | null, max: number, figure: string, history = ""): Html => {
42 const share = max > 0 ? ((value ?? 0) / max) * 100 : 0;
43 return row({
outdated

Compute the percent once, then call meter(pct, label, pct >= 85 ? "attn" : undefined). This restores the old high=0.85*max warning that this change dropped.

44 title: name,
45 titleAttr: name,
46 meta: meter(share, `${name} ${figure}`, share >= 85 ? "attn" : undefined),
47 trail: html`<span class="mono">${figure}</span>${history ? html` <span class="mono" aria-hidden="true">${history}</span>` : null}`,
48 });
49 };
50
51 /** A line with a name and a figure and no bar: load, a disk's rates, a link's rates. */
52 const figureRow = (name: string, figure: string, data?: Record<string, string>): Html =>
53 row({ title: name, trail: html`<span class="mono">${figure}</span>`, ...(data ? { data } : {}) });
4554
4655 /** Processes grouped forge, crew, check, app, host; the client re-sorts them by CPU or memory (`system-live.ts`). */
4756 const KIND_ORDER = ["forge", "crew", "check", "app", "host"] as const;
4857 function procTable(v: SystemView): Html {
4958 const groups = KIND_ORDER.flatMap((k) => v.groups.filter((g) => g.kind === k));
50 return html`<div class="table-wrap"><table class="table bt-procs" aria-label="Processes by what launched them">
59 return html`<div class="table-wrap"><table class="table" data-dense aria-label="Processes by what launched them">
5160 <thead><tr><th scope="col">pid</th><th scope="col">command</th><th scope="col" class="num">cpu</th><th scope="col" class="num">mem</th><th scope="col" class="num">age</th></tr></thead>
5261 ${groups.map(
5362 (g) => html`<tbody data-kind="${g.kind}" data-cpu="${String(g.cpuCores ?? 0)}" data-mem="${String(g.rssBytes)}">
54 <tr class="bt-group"><th scope="colgroup" colspan="2">${g.label} <span class="muted">${String(g.procs)} procs</span></th>
55 <td class="num">${coresOf(g.cpuCores)}</td><td class="num">${memoryOf(g)}</td><td class="num">${span(g.oldestSeconds)}</td></tr>
63 <tr><th scope="colgroup" colspan="2"><strong>${g.label}</strong> <span class="muted">${String(g.procs)} procs</span></th>
64 <td class="num"><strong>${coresOf(g.cpuCores)}</strong></td><td class="num"><strong>${memoryOf(g)}</strong></td><td class="num"><strong>${span(g.oldestSeconds)}</strong></td></tr>
5665 ${g.top.map(
5766 (p) => html`<tr data-cpu="${String(p.cpuCores ?? 0)}" data-mem="${String(p.rssBytes)}"><td class="mono">${String(p.pid)}</td><td class="mono">${p.comm}</td>
5867 <td class="num mono">${coresOf(p.cpuCores)}</td><td class="num mono">${bytes(p.rssBytes)}</td><td class="num mono">${span(p.ageSeconds)}</td></tr>`,
@@ -76,7 +85,7 @@ function memorySection(ctx: Ctx): Html {
7685 );
7786 return hours.length === 0
7887 ? empty({ icon: "activity", title: "No samples yet", note: "The forge samples its memory every minute; the first hour appears shortly." })
79 : html`<div class="sys-pair">${series("RSS (MiB, hourly mean)", (h) => h.rssMean)}${series("JS heap (MiB, hourly mean)", (h) => h.heapMean)}</div>
88 : html`<div class="stack">${series("RSS (MiB, hourly mean)", (h) => h.rssMean)}${series("JS heap (MiB, hourly mean)", (h) => h.heapMean)}</div>
8089 <div class="table-scroll"><table class="table" aria-label="Forge memory by hour">
8190 <thead><tr><th scope="col">Hour (UTC)</th><th scope="col" class="num">RSS mean</th><th scope="col" class="num">RSS max</th><th scope="col" class="num">Heap mean</th><th scope="col" class="num">Heap max</th></tr></thead>
8291 <tbody>${hours.map((h) => html`<tr><td class="mono">${hhmm(h.at)}</td><td class="num mono">${mib(h.rssMean)}</td><td class="num mono">${mib(h.rssMax)}</td><td class="num mono">${mib(h.heapMean)}</td><td class="num mono">${mib(h.heapMax)}</td></tr>`)}</tbody>
@@ -112,15 +121,15 @@ export function regions(v: SystemView): Record<string, string> {
112121 ? html`${meterRow("mem", v.memory.usedBytes, v.memory.totalBytes, `${bytes(v.memory.usedBytes)} / ${bytes(v.memory.totalBytes)}`)}
113122 ${meterRow("swap", v.memory.swapUsedBytes, v.memory.swapTotalBytes, v.memory.swapTotalBytes === 0 ? "none" : `${bytes(v.memory.swapUsedBytes)} / ${bytes(v.memory.swapTotalBytes)}`)}`
114123 : null}
115 ${v.load ? html`<div class="bt-row"><span class="bt-name">load</span><span class="bt-val">${v.load.map((l) => l.toFixed(2)).join(" ")}</span></div>` : null}`,
124 ${v.load ? figureRow("load", v.load.map((l) => l.toFixed(2)).join(" ")) : null}`,
116125 temps: html`${v.temps.map((t) => `${t.chip} ${t.label} ${t.celsius.toFixed(0)}°C`).join(" · ")}`,
117126 "sys-disks": card(
118 html`<div class="bt-grid">
127 html`<ul class="list">
119128 ${v.disks.map((d) => meterRow(d.mount, d.usedBytes, d.totalBytes, `${bytes(d.usedBytes)} / ${bytes(d.totalBytes)} ${d.fs}`))}
120 ${v.io.map((d) => html`<div class="bt-row" data-io="${d.name}"><span class="bt-name">${d.name}</span><span class="bt-val">R ${rateOf(d.readBytesPerSecond)} W ${rateOf(d.writeBytesPerSecond)}</span></div>`)}
121 ${v.net.map((n) => html`<div class="bt-row" data-net="${n.name}"><span class="bt-name">${n.name}</span><span class="bt-val">↓ ${rateOf(n.rxBytesPerSecond)} ↑ ${rateOf(n.txBytesPerSecond)}</span></div>`)}
122 </div>`,
123 { head: html`<h2>Disks and network</h2>` },
129 ${v.io.map((d) => figureRow(d.name, `R ${rateOf(d.readBytesPerSecond)} W ${rateOf(d.writeBytesPerSecond)}`, { io: d.name }))}
130 ${v.net.map((n) => figureRow(n.name, `↓ ${rateOf(n.rxBytesPerSecond)} ↑ ${rateOf(n.txBytesPerSecond)}`, { net: n.name }))}
131 </ul>`,
132 { pad: false, head: html`<h2>Disks and network</h2>` },
124133 ),
125134 "sys-procs": procTable(v),
126135 };
@@ -171,8 +180,8 @@ export function systemPage(ctx: Ctx): Response {
171180 <div id="sys-dup">${at("sys-dup")}</div>
172181 ${card(
173182 html`<div id="summary" class="row-meta">${at("summary")}</div>
174 <div class="bt-grid" id="cores" aria-label="Per-core CPU, percent, with its last readings">${at("cores")}</div>
175 <div class="bt-grid" id="mem">${at("mem")}</div>
183 <ul class="list" id="cores" aria-label="Per-core CPU, percent, with its last readings">${at("cores")}</ul>
184 <ul class="list" id="mem">${at("mem")}</ul>
176185 ${caps}
177186 <p class="small mono" id="temps">${at("temps")}</p>`,
178187 { head: html`<h2>Machine</h2>` },
src/web/style/content.ts −18
@@ -340,27 +340,9 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
340340 .bform .qf > span { font-size: 12.5px; font-weight: 600; color: var(--fg); }
341341 .bform .btn { flex: none; }
342342 .boards-result .table { margin-top: 12px; }
343 .bt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 2px 16px; font-family: var(--mono); font-size: 12.5px; margin-top: 8px; }
344 .bt-row { display: grid; grid-template-columns: 10ch minmax(40px, 1fr) auto auto; align-items: center; gap: 8px; min-width: 0; }
345 .bt-row > .bt-val:last-child { grid-column: span 2; }
346 .bt-name { color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
347 .bt-val { text-align: right; white-space: nowrap; }
348 .bt-hist { color: var(--accent); letter-spacing: -1px; overflow: hidden; max-width: 15ch; }
349 .bt-bar { width: 100%; height: 8px; appearance: none; background: var(--muted); border: 0; border-radius: var(--radius-sm); overflow: hidden; }
350 .bt-bar::-webkit-meter-bar { background: var(--muted); border: 0; height: 8px; }
351 .bt-bar::-webkit-meter-optimum-value, .bt-bar::-webkit-meter-suboptimum-value { background: var(--accent); }
352 .bt-bar::-webkit-meter-even-less-good-value { background: var(--danger); }
353 .bt-bar::-moz-meter-bar { background: var(--accent); }
354 .bt-bar:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--accent); }
355 .bt-bar:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); }
356343 .table-wrap { overflow-x: auto; max-width: 100%; }
357344 #summary { display: flex; flex-wrap: wrap; gap: 6px; }
358345 #summary .pill { max-width: 100%; white-space: normal; }
359 .bt-procs { font-size: 12.5px; }
360 .bt-procs th, .bt-procs td { padding: 2px 8px; white-space: nowrap; }
361 .bt-group th, .bt-group td { background: var(--muted); font-weight: 600; }
362 .sys-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
363 .sys-pair .chart-box { max-width: none; }
364346 .bgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
365347 .bp-w2 { grid-column: span 2; }
366348 .bp-w3 { grid-column: span 3; }
test/system-btop.test.ts +22
@@ -69,6 +69,18 @@ describe("/system as btop", () => {
6969 expect(JSON.stringify(forAgent(v, (l) => l === "crew:atlas"))).toContain("crew:atlas");
7070 });
7171
72 test("a meter at 85% or more is marked attn; a quiet one is not", () => {
73 const r = raw(2000, 300);
74 r.disks[0]!.used = 90 * 2 ** 30;
75 r.memory!.available = 0.8 * 2 ** 30;
76 const hot = regions(buildSystem(raw(0, 100), r, roots, 1));
77 expect(hot["sys-disks"]).toMatch(/<meter[^>]*value="90"[^>]*data-tone="attn"/);
78 expect(hot["mem"]).toMatch(/<meter[^>]*value="90"[^>]*data-tone="attn"/);
79 expect(hot["mem"]).not.toMatch(/value="50"[^>]*data-tone/);
80 expect(regions(view)["sys-disks"]).not.toContain("data-tone");
81 expect(regions(view)["mem"]).not.toContain("data-tone");
82 });
83
7284 test("cores, memory, swap, load, disk and network rates are drawn from the sample", () => {
7385 const r = regions(view);
7486 expect(r["cores"]).toContain("cpu0");
@@ -106,6 +118,16 @@ describe("/system as btop", () => {
106118 expect(parseDiskstats(text, (n) => n === "nvme0n1")).toEqual([{ name: "nvme0n1", read: 8 * 512, write: 16 * 512 }]);
107119 });
108120
121 test("the panels use the design system's rows and meters, not the bt-* classes", async () => {
122 const r = regions(view);
123 const all = Object.values(r).join("\n");
124 expect(all).not.toMatch(/bt-(bar|grid|group|hist|name|procs|row|val)|sys-pair/);
125 expect(r["cores"]).toContain('class="row"');
126 expect(r["sys-disks"]).toContain("data-io=");
127 const src = await Bun.file("src/web/pages/system.ts").text();
128 expect(src).not.toMatch(/bt-(bar|grid|group|hist|name|procs|row|val)|sys-pair/);
129 });
130
109131 test("a meter has an accessible name, and the sort buttons need a script", async () => {
110132 const r = regions(view);
111133 expect(r["cores"]).toContain('aria-label="cpu0 ');

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs