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

When nothing needs the owner the home says 'All quiet' in one line and nothing is red #14073

Merged opened this

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

Merged

scout/forge:scout/14054-when-nothing-needs-the-owner-the-home-sa → main 6 commits fork 6 threads · 6 unresolved

  • Merged. scout/14054-when-nothing-needs-the-owner-the-home-sa was merged into main as b03a98a.

Review

Sign in to review this change.
4 files changed +58 −4
docs/design/areas/home-flow.md +1 −1
@@ -6,7 +6,7 @@
66 - `.hf-head`, `.hf-title`, `.hf-live` — the title, and beside it the stream's state ("Live: updates as it happens", or that it is reconnecting).
77 - `.hf-filter`, `.hf-filter-label` — the quiet filter to one app: a plain GET form, a select that submits itself and a Show button only when scripts are off.
88 - `.hf-tell` — the wrapper that keeps the box that tells the crew (`.tell-box`, §5's bar) to one row on a desk, its app picker a fixed width.
9 - `.hf-need`, `.hf-need-first` — the one quiet line, the last thing in the head and only when there is something to count: how many things are broken about the forge itself (a red main, a stopped landing or lane, a failed backup, no release, a release that is not serving), as a link to their list on `/asks#forge-broken`, with the first of them beside it in `.hf-need-first`, cut to one line; and how many people are stopped until this viewer changes a setting, as a link to `/asks#asked`. A healthy forge draws no line. A repository standing still, an approved pull that has not landed and what waits on a person are never on the home: they are on `/asks` and `/review`.
9 - `.hf-need`, `.hf-need-first` — the one quiet line, the last thing in the head and only when there is something to count: how many things are broken about the forge itself (a red main, a stopped landing or lane, a failed backup, no release, a release that is not serving), as a link to their list on `/asks#forge-broken`, with the first of them beside it in `.hf-need-first`, cut to one line; and how many people are stopped until this viewer changes a setting, as a link to `/asks#asked`. A healthy forge draws no `.hf-need`: its `.hf-live` line says "All quiet." in place of "Live: updates as it happens", with a visually hidden `.hf-live-state` ("Live: ") so the stream's state is words and not the dot's colour alone; a lost stream still says "Reconnecting", and a need line on the page drops the quiet words. The head never carries two lines. #14054 amends #13428 here: #13428 drew no words at all on a healthy home; it now says "All quiet." in the line it already had, and still carries no notice, role or banner. A repository standing still, an approved pull that has not landed and what waits on a person are never on the home: they are on `/asks` and `/review`.
1010 - `.hf-strip` — an admin's live region of figures, under the lanes.
1111 - `.hf-figs`, `.hf-fig`, `.hf-fig-label`, `.hf-fig-value`, `.hf-fig-note`, `.hf-fig-spark` — a figure: its name, its value with the unit in the value or the note, and a tiny trend where the data has one. Two across on a phone, five across from 720px.
1212 - `.hf-lanes` — one lane under the other on a phone, three by two on a tablet, six across on a desk.
src/web/pages/home_flow.ts +12 −2
@@ -274,12 +274,22 @@ export function brokenOf(picture: LanePicture | undefined, isAdmin: boolean, dat
274274 return [...(proof?.tone === "alarm" ? [{ says: proof.sentence, href: "/releases#proof" }] : []), ...(picture?.strip?.needs ?? [])];
275275 }
276276
277 /**
278 * The live line under the title: when nothing is broken and nobody is stopped it says so, in the
279 * same line, with the stream's state kept in words for a screen reader ("Live: All quiet.") so it
280 * is never the dot's colour alone.
281 */
282 export function liveLine(quiet: boolean): Html {
outdated

Principle 1 and a11y: 'All quiet.' replaces the words that said the stream is live; the state is now the dot's colour only. Keep a text for it (visually hidden 'Live').

283 return html`<p class="hf-live muted" id="hf-live" data-state="connecting"${quiet ? html` data-quiet="1"` : null}><span class="dot"></span>${quiet ? html`<span class="sr-only hf-live-state">Live: </span>` : null}<span class="hf-live-text">${quiet ? "All quiet." : "Updates as it happens"}</span></p>`;
284 }
285
277286 const things = (n: number, one: string, many: string): string => `${String(n)} ${n === 1 ? one : many}`;
outdated

Principle 1: this adds a second line to the head that says what the live line already implies. Fold into the existing live line rather than a new block.

278287
279288 /**
280289 * The one line, in the page's header: how many things are broken about the forge and how many
281290 * people are stopped, the problems link to the system page and the people to the board's "waiting
282 * for me" view. Nothing at all when there is nothing: a healthy forge's home opens on its lanes.
291 * for me" view. Nothing at all when there is nothing: the live line beside the title then says "All
292 * quiet." (see `liveLine`), so a healthy forge's home opens calm on its lanes with no second line.
283293 */
284294 export function needLine(broken: readonly { says: string; href: string }[], asked: number): Html | null {
285295 if (broken.length === 0 && asked === 0) return null;
@@ -529,7 +539,7 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited
529539 <header class="hf-head">
530540 <div class="hf-title">
531541 <h1>Your forge, right now</h1>
532 <p class="hf-live muted" id="hf-live" data-state="connecting"><span class="dot"></span><span class="hf-live-text">Updates as it happens</span></p>
542 ${liveLine(need === null)}
533543 </div>
534544 ${viewSwitch(view, only)}
535545 ${view === "lanes" ? filterForm(viewing?.repos ?? [], only, mine) : null}
src/web/pages/home_flow_client.ts +7 −1
@@ -107,7 +107,13 @@ export const homeFlowJs = /* js */ `
107107 var text = live.querySelector('.hf-live-text');
108108 var tone = TONES[e.detail.state];
109109 if (dot) { if (tone) dot.setAttribute('data-tone', tone); else dot.removeAttribute('data-tone'); }
110 if (text && WORDS[e.detail.state]) text.textContent = WORDS[e.detail.state];
110 // A need line on the page means the home is not quiet, whatever it was drawn as.
outdated

data-quiet is fixed at render; if a need line arrives while the stream is open this still writes 'All quiet.' beside it. Clear the attribute when the need line is drawn.

111 if (doc.querySelector('.hf-need')) live.removeAttribute('data-quiet');
112 var quiet = live.hasAttribute('data-quiet');
113 var said = live.querySelector('.hf-live-state');
114 if (said) { if (quiet) said.textContent = e.detail.state === 'open' ? 'Live: ' : ''; else said.remove(); }
115 var words = e.detail.state === 'open' && quiet ? 'All quiet.' : WORDS[e.detail.state];
116 if (text && words) text.textContent = words;
111117 });
112118
113119 // ---- the filter: the other apps come from data-apps when it is first used, then choosing one opens the page for it ----
test/home-quiet.test.ts +38
@@ -4,6 +4,7 @@
44 * line on its own settings page. The failure names the offending notice.
55 */
66 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdirSync, rmSync, writeFileSync } from "node:fs";
78 import { mkdtemp as mkTmp, rm as rmDir } from "node:fs/promises";
89 import { tmpdir } from "node:os";
910 import { join } from "node:path";
@@ -84,3 +85,40 @@ test("the detector names a notice, and spares plain content", () => {
8485 expect(noticesAbove('<div role="alert">x</div><div class="hf-lanes">y</div>')[0]).toContain("role=\"alert\"");
8586 expect(noticesAbove('<h1>Hi</h1><div class="hf-lanes"><div role="alert">x</div></div>')).toEqual([]);
8687 });
88
89 test("with nothing to decide and nothing failing the live line itself says 'All quiet.' and no second line is drawn", async () => {
90 const body = await (await fetch(`${servers.url}/`, { headers: { cookie } })).text();
91 expect(body.match(/All quiet\./g)?.length).toBe(1);
92 expect(body).toMatch(/id="hf-live"[^>]*data-quiet="1"[^>]*><span class="dot"><\/span><span class="sr-only hf-live-state">Live: <\/span><span class="hf-live-text">All quiet\.<\/span>/);
93 expect(body).not.toContain("hf-quiet");
94 expect(body).not.toContain('class="hf-need"');
95 });
96
97 test("the quiet line keeps the stream's state in words for a screen reader", async () => {
outdated

This failing-state test only calls needLine and liveLine on their own, and passes on main. Drive the page with a failing proof and assert the live line and the single link.

98 const body = await (await fetch(`${servers.url}/`, { headers: { cookie } })).text();
99 expect(body).toMatch(/<span class="dot"><\/span><span class="sr-only hf-live-state">Live: <\/span><span class="hf-live-text">All quiet\.<\/span>/);
100 });
101
102 test("a failing proof on the page: one need line with its one link, and the live line no longer says 'All quiet.'", async () => {
103 const dir = join(dataDir, "release");
104 mkdirSync(dir, { recursive: true });
105 writeFileSync(join(dir, "proof.json"), JSON.stringify({ version: "9.9.9", at: new Date().toISOString(), ok: false, failure: "the public address did not answer" }));
106 try {
107 const body = await (await fetch(`${servers.url}/`, { headers: { cookie } })).text();
108 expect(body).not.toContain("All quiet.");
109 expect(body).not.toContain("data-quiet");
110 expect(body).not.toContain("hf-live-state");
111 const need = [...body.matchAll(/<p class="hf-need"[\s\S]*?<\/p>/g)].map((m) => m[0]);
112 expect(need).toHaveLength(1);
113 expect(need[0]!.match(/<a /g)?.length).toBe(1);
114 expect(need[0]).toContain('href="/system"');
115 expect(need[0]).toContain("the public address did not answer");
116 } finally {
117 rmSync(join(dir, "proof.json"), { force: true });
118 }
119 });
120
121 test("the client drops the quiet words when a need line is on the page", async () => {

Non-blocking: this matches source text, not behaviour. Run the handler against a stub DOM, or drop it.

122 const { homeFlowJs } = await import("../src/web/pages/home_flow_client.ts");
123 expect(homeFlowJs).toContain("if (doc.querySelector('.hf-need')) live.removeAttribute('data-quiet');");
124 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs