Public: anyone can read this; the crew can change it.
The maintenance board's quiet duties collapse into one line: N duties ran, nothing to report #13353
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13332-the-maintenance-board-s-quiet-duties-col → main 9 commits fork 4 threads · 4 unresolved
6 files
changed +86
−6
docs/features/maintenance.md +7
| @@ -31,6 +31,13 @@ when it last ran (UTC), what it found ("nothing found" when it filed nothing), a | ||
| 31 | 31 | overdue when now is past its last slot plus one day plus 6 hours of grace (a night may run long); one |
| 32 | 32 | that never ran says so and gives its slot, and is not overdue. |
| 33 | 33 | |
| 34 | **Quiet duties fold.** A duty that ran on time and found nothing is quiet; `splitDuties` in | |
| 35 | `src/maintenance/duties.ts` decides it from `NOTHING_FOUND`, the same constant the duty's `found` is built | |
| 36 | from. On `/maintenance` the quiet ones sit behind one closed fold, "All 3 duties ran, nothing to report" (or | |
| 37 | "2 other duties ran, ..." when some have rows), and list their names when opened. Never-run, overdue, | |
| 38 | unfinished and finding duties keep their rows. The terminal's Maintenance screen folds them into one line | |
| 39 | the same way, naming the duties. Tests: `test/maintenance-calm.test.ts`. | |
| 40 | ||
| 34 | 41 | **Come back.** On boot `resumeAtBoot` acts only when the host has restarted since the prepare |
| 35 | 42 | (`/proc/sys/kernel/random/boot_id` differs from the one stored); a release roll of the process on |
| 36 | 43 | the same host boot keeps what the admin prepared. It then lifts the hold, unpauses the crew and |
src/maintenance/duties.ts +22 −2
| @@ -27,17 +27,20 @@ export interface Duty { | ||
| 27 | 27 | readonly says: string; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | /** What `found` says when a duty filed nothing; the one string every door compares against. */ | |
| 31 | export const NOTHING_FOUND = "nothing found"; | |
| 32 | ||
| 30 | 33 | const when = (ms: number): string => `${new Date(ms).toISOString().slice(0, 16).replace("T", " ")} UTC`; |
| 31 | 34 | |
| 32 | 35 | const oneLine = (s: string): string => { |
| 33 | 36 | const t = s.replace(/\s+/g, " ").trim().replace(/\.$/, ""); |
| 34 | return t === "" || /^(filed|found) nothing$/i.test(t) || /^read \d+ repositor(y|ies); filed nothing$/i.test(t) ? "nothing found" : t.slice(0, 160); | |
| 37 | return t === "" || /^(filed|found) nothing$/i.test(t) || /^read \d+ repositor(y|ies); filed nothing$/i.test(t) ? NOTHING_FOUND : t.slice(0, 160); | |
| 35 | 38 | }; |
| 36 | 39 | |
| 37 | 40 | export function dutyOf(name: string, slot: Slot, last: Last | undefined, now: number): Duty { |
| 38 | 41 | if (last === undefined) { |
| 39 | 42 | const at = `${String(slot.hour).padStart(2, "0")}:${String(slot.minute).padStart(2, "0")} UTC`; |
| 40 | return { name, lastRun: "never", found: "nothing found", overdue: false, detail: `never run; its slot is ${at} each night`, says: `${name}: never run; its slot is ${at} each night.` }; | |
| 43 | return { name, lastRun: "never", found: NOTHING_FOUND, overdue: false, detail: `never run; its slot is ${at} each night`, says: `${name}: never run; its slot is ${at} each night.` }; | |
| 41 | 44 | } |
| 42 | 45 | const overdue = now > last.slot + DAY + GRACE_MS; |
| 43 | 46 | const found = last.finishedAt === undefined ? "not finished" : oneLine(last.says); |
| @@ -56,3 +59,20 @@ export function duties(dataDir: string, now: number = Date.now()): Duty[] { | ||
| 56 | 59 | dutyOf(d.name, d.slot, readLast(dataDir, d.name), now), |
| 57 | 60 | ); |
| 58 | 61 | } |
| 62 | ||
| 63 | /** | |
| 64 | * Duties whose last run found nothing and is on time fold away; never-run, overdue, unfinished and | |
| 65 | * finding duties keep their rows. One rule for the page and the terminal. | |
| 66 | */ | |
| 67 | export function splitDuties<T extends Pick<Duty, "found" | "overdue" | "lastRun">>(all: readonly T[]): { quiet: T[]; loud: T[] } { | |
| 68 | const isQuiet = (d: T): boolean => d.found === NOTHING_FOUND && !d.overdue && d.lastRun !== "never"; | |
| 69 | return { quiet: all.filter(isQuiet), loud: all.filter((d) => !isQuiet(d)) }; | |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * The one calm sentence for the folded duties: "All 3 duties ran, ..." or "1 other duty ran, ...". | |
| 74 | */ | |
| 75 | export function quietLine(n: number, noneLoud: boolean): string { | |
| 76 | const count = `${String(n)} ${n === 1 ? "duty" : "duties"}`; | |
| 77 | return noneLoud ? `All ${count} ran, nothing to report` : `${String(n)} other ${n === 1 ? "duty" : "duties"} ran, nothing to report`; | |
| 78 | } |
src/tui/screens/maintenance.ts +7 −2
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | * refused by the service. Enter, Esc or q closes it. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { duties } from "../../maintenance/duties.ts"; | |
| 10 | import { duties, quietLine, splitDuties } from "../../maintenance/duties.ts"; | |
| 11 | 11 | import { ABOUT_TO_STOP_ROWS, prepare, resumeNow, status } from "../../maintenance/service.ts"; |
| 12 | 12 | import { probeStandby, withStandby, type Standby } from "../../maintenance/standby.ts"; |
| 13 | 13 | import type { Ctx, Screen } from "../app/app.ts"; |
| @@ -43,7 +43,12 @@ export function maintenanceLines(f: Session, standby?: Standby): string[] { | ||
| 43 | 43 | ...[...last.checks].sort((a, b) => Number(a.ok) - Number(b.ok)).flatMap((c) => wrap(`${c.ok ? "ok " : "FAILED"} ${c.name}: ${c.says}`, INNER)), |
| 44 | 44 | ] |
| 45 | 45 | : []; |
| 46 | const dutyLines = duties(f.app.config.dataDir).flatMap((d) => wrap(d.says, INNER)); | |
| 46 | // Quiet duties fold into one line, as on the page; the rest keep their lines. | |
| 47 | const { quiet, loud } = splitDuties(duties(f.app.config.dataDir)); | |
| 48 | const dutyLines = [ | |
| 49 | ...loud.flatMap((d) => wrap(d.says, INNER)), | |
| 50 | ...(quiet.length === 0 ? [] : wrap(`${quietLine(quiet.length, loud.length === 0)}: ${quiet.map((d) => d.name).join(", ")}`, INNER)), | |
| 51 | ]; | |
| 47 | 52 | return [...wrap(s.says, INNER), "", ...facts, ...checks, "", ...dutyLines]; |
| 48 | 53 | } |
| 49 | 54 |
src/web/pages/maintenance.ts +4 −2
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | import { notePhase, takeSessionTime } from "../../core/route_timing.ts"; |
| 8 | 8 | import { dutyStates, switchDuty } from "../../maintain/pause.ts"; |
| 9 | 9 | import { DISMISS_DAYS, REASON_MAX, dismiss, dismissals, dismissalWords } from "../../maintain/dismiss.ts"; |
| 10 | import { duties } from "../../maintenance/duties.ts"; | |
| 10 | import { duties, quietLine, splitDuties } from "../../maintenance/duties.ts"; | |
| 11 | 11 | import { statusWithStandby } from "../../maintenance/standby.ts"; |
| 12 | 12 | import { ABOUT_TO_STOP_ROWS, prepare, resumeNow, status } from "../../maintenance/service.ts"; |
| 13 | 13 | import type { Ctx } from "../../http/context.ts"; |
| @@ -56,6 +56,7 @@ export async function maintenancePage(ctx: Ctx): Promise<Response> { | ||
| 56 | 56 | const rendering = performance.now(); |
| 57 | 57 | const s = await statusWithStandby(status(ctx.app)); |
| 58 | 58 | const ran = duties(ctx.app.config.dataDir); |
| 59 | const { quiet, loud } = splitDuties(ran); | |
| 59 | 60 | const dismissed = dismissals(ctx.app.db); |
| 60 | 61 | const states = dutyStates(ctx.app.db); |
| 61 | 62 | const mergedPending = await mergedBranches(ctx.app, new Date()); |
| @@ -76,7 +77,8 @@ export async function maintenancePage(ctx: Ctx): Promise<Response> { | ||
| 76 | 77 | <div class="form-actions mb"><form method="post" action="/maintenance/resume">${btn("End maintenance now")}</form></div>`} |
| 77 | 78 | ${fold("maintenance-duties-fold", "Duties", `${String(ran.length)}${overdue + paused > 0 ? `, ${String(overdue + paused)} need you` : ""}`, overdue + paused > 0, |
| 78 | 79 | html`<dl id="maintenance-duties" class="status-rows"> |
| 79 | ${ran.map((d) => fact(d.name, html`${d.detail}${d.overdue ? html` ${badge("overdue", { tone: "danger" })}` : null}`))} | |
| 80 | ${loud.map((d) => fact(d.name, html`${d.detail}${d.overdue ? html` ${badge("overdue", { tone: "danger" })}` : null}`))} | |
| 81 | ${quiet.length === 0 ? null : disclosure(html`<span class="muted">${quietLine(quiet.length, loud.length === 0)}</span>`, html`<dl class="status-rows">${quiet.map((d) => fact(d.name, d.detail))}</dl>`, { id: "maintenance-quiet", extra: "mb" })} | |
| 80 | 82 | ${states.map((d) => { |
| 81 | 83 | const dm = dismissed.get(d.name); |
| 82 | 84 | const detail = dm === undefined ? d.detail : dm.active && !d.paused ? `on; ${dismissalWords(dm)}` : `${d.detail}; ${dismissalWords(dm)}`; |
src/web/style/components.ts +1
| @@ -817,6 +817,7 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 817 | 817 | } |
| 818 | 818 | .disclosure[open] > summary::before { transform: rotate(90deg); } |
| 819 | 819 | .disclosure > summary:hover { color: var(--accent); } |
| 820 | .disclosure > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); } | |
| 820 | 821 | /* A page's "? Help" (page_help.ts): a 44px target a thumb can hit, and a ring a keyboard can see. */ |
| 821 | 822 | .disclosure[data-page-help] > summary { width: fit-content; min-width: 44px; } |
| 822 | 823 | .disclosure[data-page-help] > summary::before { content: none; } |
test/maintenance-calm.test.ts +45
| @@ -8,6 +8,9 @@ import { createUser } from "../src/core/users.ts"; | ||
| 8 | 8 | import { serve, type Servers } from "../src/http/server.ts"; |
| 9 | 9 | import { dutyStates, setPaused } from "../src/maintain/pause.ts"; |
| 10 | 10 | import { needsYou } from "../src/web/pages/maintenance.ts"; |
| 11 | import { NOTHING_FOUND, quietLine, splitDuties } from "../src/maintenance/duties.ts"; | |
| 12 | import { maintenanceLines } from "../src/tui/screens/maintenance.ts"; | |
| 13 | import type { Session } from "../src/tui/session.ts"; | |
| 11 | 14 | import { JOBS } from "../src/nightly/jobs.ts"; |
| 12 | 15 | import { writeLast } from "../src/nightly/stamps.ts"; |
| 13 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| @@ -98,3 +101,45 @@ test("maintenance on shows End maintenance now right under the status line", asy | ||
| 98 | 101 | expect(html.indexOf('id="maintenance-duties-fold"')).toBeGreaterThan(end); |
| 99 | 102 | expect(html).toContain("maintenance is on"); |
| 100 | 103 | }); |
| 104 | ||
| 105 | test("quiet duties fold into one line; duties with findings keep their rows", () => { | |
| 106 | const d = (name: string, found: string, over = false) => ({ name, found, overdue: over, lastRun: "2026-01-01 00:00 UTC" }); | |
| 107 | const quiet = splitDuties([d("a", NOTHING_FOUND), d("b", NOTHING_FOUND)]); | |
| 108 | expect(quiet.quiet.length).toBe(2); | |
| 109 | expect(quiet.loud.length).toBe(0); | |
| 110 | expect(quietLine(2, true)).toBe("All 2 duties ran, nothing to report"); | |
| 111 | const one = splitDuties([d("a", "nothing found"), d("b", "filed 2 issues")]); | |
| 112 | expect(one.quiet.map((x) => x.name)).toEqual(["a"]); | |
| 113 | expect(one.loud.map((x) => x.name)).toEqual(["b"]); | |
| 114 | expect(quietLine(1, false)).toBe("1 other duty ran, nothing to report"); | |
| 115 | const all = splitDuties([d("a", "filed 1"), d("b", "not finished"), d("c", "nothing found", true)]); | |
| 116 | expect(all.quiet.length).toBe(0); | |
| 117 | expect(all.loud.length).toBe(3); | |
| 118 | }); | |
| 119 | ||
| 120 | const foldOf = (html: string): string => /<details[^>]*id="maintenance-quiet"(?![^>]*\sopen)[^>]*>([\s\S]*?)<\/details>/.exec(html)?.[1] ?? ""; | |
| 121 | ||
| 122 | test("on the page the quiet duties sit inside one closed fold and a finding duty stays outside it", async () => { | |
| 123 | const now = Date.now(); | |
outdated
This test only checks the fold exists and is closed. Assert the quiet duty name is inside the details and that a finding duty row is outside it. Add a terminal test too. |
||
| 124 | const [quiet, loud] = [JOBS[0]!.name, JOBS[1]!.name]; | |
| 125 | writeLast(dir, quiet, { slot: now, startedAt: now, finishedAt: now + 1000, says: "filed nothing" }); | |
| 126 | writeLast(dir, loud, { slot: now, startedAt: now, finishedAt: now + 1000, says: "filed 2 issues" }); | |
| 127 | const html = await get(); | |
| 128 | const fold = foldOf(html); | |
| 129 | expect(fold).toContain("1 other duty ran, nothing to report"); | |
| 130 | expect(fold).toContain(`<dt>${quiet}</dt>`); | |
| 131 | expect(fold).not.toContain(`<dt>${loud}</dt>`); | |
| 132 | expect(html).toContain(`<dt>${loud}</dt>`); | |
| 133 | expect(html).toContain("filed 2 issues"); | |
| 134 | }); | |
| 135 | ||
| 136 | test("the terminal folds the quiet duties into one line and keeps the finding duty's own", () => { | |
| 137 | const now = Date.now(); | |
| 138 | const [quiet, loud] = [JOBS[0]!.name, JOBS[1]!.name]; | |
| 139 | writeLast(dir, quiet, { slot: now, startedAt: now, finishedAt: now + 1000, says: "filed nothing" }); | |
| 140 | writeLast(dir, loud, { slot: now, startedAt: now, finishedAt: now + 1000, says: "filed 2 issues" }); | |
| 141 | const text = maintenanceLines({ app, db: app.db, user: { isAdmin: true, kind: "human" } } as unknown as Session).join(" "); | |
| 142 | expect(text).toContain("1 other duty ran, nothing to report"); | |
| 143 | expect(text).not.toContain(`${quiet}: last ran`); | |
| 144 | expect(text).toContain(`${loud}: last ran`); | |
| 145 | }); |
new above
offline
Principle 8 (plain words) and robustness: quiet is the literal string "nothing found". Share the constant with whatever produces
found, or add a boolean to the duty data.