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 #4022

Parked opened this
Closed without merging

scout/forge:scout/3866-design-system-s-btop-panels-use-the-desi → main 5 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
4 files changed +34 −35
docs/DESIGN.md +1 −1
@@ -393,7 +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` `.hero` `.hero-terminal` `.issue-head` `.issue-meta` `.kv` `.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`
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` `.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` `.hero` `.hero-terminal` `.issue-head` `.issue-meta` `.kv` `.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` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep`
397397 - **`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`
398398 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
399399 - **`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`
src/web/pages/system.ts +23 −16
@@ -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 =>
@@ -39,20 +39,27 @@ const rateOf = (n: number | null): string => (n === null ? "—" : `${bytes(n)}/
3939
4040 /** One line of the machine card: a name, a meter, its figure and (for a core) its history. */
4141 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>`;
42 row({
43 title: name,
44 titleAttr: name,
45 meta: meter(max > 0 ? ((value ?? 0) / max) * 100 : 0, `${name} ${figure}`),
46 trail: html`<span class="mono">${figure}</span>${history ? html` <span class="mono" aria-hidden="true">${history}</span>` : null}`,
47 });
48
49 /** A line with a name and a figure and no bar: load, a disk's rates, a link's rates. */
50 const figureRow = (name: string, figure: string, data?: Record<string, string>): Html =>
51 row({ title: name, trail: html`<span class="mono">${figure}</span>`, ...(data ? { data } : {}) });
4552
4653 /** Processes grouped forge, crew, check, app, host; the client re-sorts them by CPU or memory (`system-live.ts`). */
4754 const KIND_ORDER = ["forge", "crew", "check", "app", "host"] as const;
4855 function procTable(v: SystemView): Html {
4956 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">
57 return html`<div class="table-wrap"><table class="table" data-dense aria-label="Processes by what launched them">
5158 <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>
5259 ${groups.map(
5360 (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>
61 <tr><th scope="colgroup" colspan="2"><strong>${g.label}</strong> <span class="muted">${String(g.procs)} procs</span></th>
62 <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>
5663 ${g.top.map(
5764 (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>
5865 <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 +83,7 @@ function memorySection(ctx: Ctx): Html {
7683 );
7784 return hours.length === 0
7885 ? 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>
86 : html`<div class="stack">${series("RSS (MiB, hourly mean)", (h) => h.rssMean)}${series("JS heap (MiB, hourly mean)", (h) => h.heapMean)}</div>
8087 <div class="table-scroll"><table class="table" aria-label="Forge memory by hour">
8188 <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>
8289 <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 +119,15 @@ export function regions(v: SystemView): Record<string, string> {
112119 ? html`${meterRow("mem", v.memory.usedBytes, v.memory.totalBytes, `${bytes(v.memory.usedBytes)} / ${bytes(v.memory.totalBytes)}`)}
113120 ${meterRow("swap", v.memory.swapUsedBytes, v.memory.swapTotalBytes, v.memory.swapTotalBytes === 0 ? "none" : `${bytes(v.memory.swapUsedBytes)} / ${bytes(v.memory.swapTotalBytes)}`)}`
114121 : 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}`,
122 ${v.load ? figureRow("load", v.load.map((l) => l.toFixed(2)).join(" ")) : null}`,
116123 temps: html`${v.temps.map((t) => `${t.chip} ${t.label} ${t.celsius.toFixed(0)}°C`).join(" · ")}`,
117124 "sys-disks": card(
118 html`<div class="bt-grid">
125 html`<ul class="list">
119126 ${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>` },
127 ${v.io.map((d) => figureRow(d.name, `R ${rateOf(d.readBytesPerSecond)} W ${rateOf(d.writeBytesPerSecond)}`, { io: d.name }))}
128 ${v.net.map((n) => figureRow(n.name, `↓ ${rateOf(n.rxBytesPerSecond)} ↑ ${rateOf(n.txBytesPerSecond)}`, { net: n.name }))}
129 </ul>`,
130 { pad: false, head: html`<h2>Disks and network</h2>` },
124131 ),
125132 "sys-procs": procTable(v),
126133 };
@@ -171,8 +178,8 @@ export function systemPage(ctx: Ctx): Response {
171178 <div id="sys-dup">${at("sys-dup")}</div>
172179 ${card(
173180 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>
181 <ul class="list" id="cores" aria-label="Per-core CPU, percent, with its last readings">${at("cores")}</ul>
182 <ul class="list" id="mem">${at("mem")}</ul>
176183 ${caps}
177184 <p class="small mono" id="temps">${at("temps")}</p>`,
178185 { head: html`<h2>Machine</h2>` },
src/web/style/content.ts −18
@@ -344,27 +344,9 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
344344 .bform .qf > span { font-size: 12.5px; font-weight: 600; color: var(--fg); }
345345 .bform .btn { flex: none; }
346346 .boards-result .table { margin-top: 12px; }
347 .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; }
348 .bt-row { display: grid; grid-template-columns: 10ch minmax(40px, 1fr) auto auto; align-items: center; gap: 8px; min-width: 0; }
349 .bt-row > .bt-val:last-child { grid-column: span 2; }
350 .bt-name { color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
351 .bt-val { text-align: right; white-space: nowrap; }
352 .bt-hist { color: var(--accent); letter-spacing: -1px; overflow: hidden; max-width: 15ch; }
353 .bt-bar { width: 100%; height: 8px; appearance: none; background: var(--muted); border: 0; border-radius: var(--radius-sm); overflow: hidden; }
354 .bt-bar::-webkit-meter-bar { background: var(--muted); border: 0; height: 8px; }
355 .bt-bar::-webkit-meter-optimum-value, .bt-bar::-webkit-meter-suboptimum-value { background: var(--accent); }
356 .bt-bar::-webkit-meter-even-less-good-value { background: var(--danger); }
357 .bt-bar::-moz-meter-bar { background: var(--accent); }
358 .bt-bar:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--accent); }
359 .bt-bar:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); }
360347 .table-wrap { overflow-x: auto; max-width: 100%; }
361348 #summary { display: flex; flex-wrap: wrap; gap: 6px; }
362349 #summary .pill { max-width: 100%; white-space: normal; }
363 .bt-procs { font-size: 12.5px; }
364 .bt-procs th, .bt-procs td { padding: 2px 8px; white-space: nowrap; }
365 .bt-group th, .bt-group td { background: var(--muted); font-weight: 600; }
366 .sys-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
367 .sys-pair .chart-box { max-width: none; }
368350 .bgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
369351 .bp-w2 { grid-column: span 2; }
370352 .bp-w3 { grid-column: span 3; }
test/system-btop.test.ts +10
@@ -106,6 +106,16 @@ describe("/system as btop", () => {
106106 expect(parseDiskstats(text, (n) => n === "nvme0n1")).toEqual([{ name: "nvme0n1", read: 8 * 512, write: 16 * 512 }]);
107107 });
108108
109 test("the panels use the design system's rows and meters, not the bt-* classes", async () => {
110 const r = regions(view);
111 const all = Object.values(r).join("\n");
112 expect(all).not.toMatch(/bt-(bar|grid|group|hist|name|procs|row|val)|sys-pair/);
113 expect(r["cores"]).toContain('class="row"');
114 expect(r["sys-disks"]).toContain("data-io=");
115 const src = await Bun.file("src/web/pages/system.ts").text();
116 expect(src).not.toMatch(/bt-(bar|grid|group|hist|name|procs|row|val)|sys-pair/);
117 });
118
109119 test("a meter has an accessible name, and the sort buttons need a script", async () => {
110120 const r = regions(view);
111121 expect(r["cores"]).toContain('aria-label="cpu0 ');

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs