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

Design: fold /flow into boards and drop the topbar Flow button #2759

Parked opened this
Closed without merging

scout/forge:scout/2693-design-fold-flow-into-boards-and-drop-th → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
9 files changed +60 −45
src/http/server.ts +2 −2
@@ -14,7 +14,7 @@ import { unsealReleased } from "../actions/sealed.ts";
1414 import { parentCallback, parentStart } from "./rp.ts";
1515 import { accessPage } from "../web/pages/access.ts";
1616 import { capacityPage, capacitySet } from "../web/pages/capacity.ts";
17 import { flowPage } from "../web/pages/flow.ts";
17 import { flowRedirect } from "../web/pages/flow.ts";
1818 import { systemPage } from "../web/pages/system.ts";
1919 import { telemetryPage, telemetrySet } from "../web/pages/telemetry.ts";
2020 import { contributePage } from "../web/pages/contribute.ts";
@@ -721,7 +721,7 @@ export function buildRouter(): Router<Handler> {
721721 // Every app on one canvas; a literal route, so it must sit above /:owner.
722722 router.add("GET", "/map", globalMapPage);
723723 // The pipeline's stages and its bottleneck, for a forge admin (#1554); literal, above /:owner.
724 router.add("GET", "/flow", flowPage);
724 router.add("GET", "/flow", flowRedirect);
725725 router.add("GET", "/system", systemPage);
726726 router.add("GET", "/contribute", contributePage);
727727 router.add("GET", "/settings/telemetry", telemetryPage);
src/web/layout.ts +1 −4
@@ -241,9 +241,6 @@ function userMenu(
241241 ]
242242 : []),
243243 { separator: true, label: "" },
244 ...(user.isAdmin
245 ? [{ label: "Flow", href: "/flow", icon: "activity" as const }]
246 : []),
247244 helpItem,
248245 themeForm(theme),
249246 { separator: true, label: "" },
@@ -334,7 +331,7 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html {
334331 : []),
335332 ...(ctx.auth.user?.isAdmin
336333 ? [
337 { t: "Flow", h: "/flow", c: "Go to" },
334 { t: "Flow", h: "/board#flow", c: "Go to" },
338335 { t: "System", h: "/system", c: "Go to" },
339336 { t: "Forges you sent", h: "/forges", c: "Go to" },
340337 { t: "Family of forges", h: "/family", c: "Go to" },
src/web/pages/board.ts +4 −2
@@ -14,6 +14,7 @@
1414 * pointer. The old big view (`/big`, every address it had) lands here.
1515 */
1616
17 import { flowCss, flowPanels } from "./flow.ts";
1718 import { sentinelNotice } from "../../crew/sentinel.ts";
1819 import { appsForRepos, type AppRecord } from "../../core/apps.ts";
1920 import { askMeasure } from "../../core/ask_ledger.ts";
@@ -245,7 +246,8 @@ export function boardPage(ctx: Ctx): Response {
245246 ${working(ctx, scope)} ${landed(ctx, scope)} ${decided(ctx, scope)}
246247 ${today(ctx, scope)}
247248 </div>
248 </div>`;
249 </div>
250 ${wall ? null : flowPanels(ctx)}`;
249251 return page({
250252 ctx,
251253 title: "Board",
@@ -1228,4 +1230,4 @@ ${widths}
12281230 .board[data-focus="working"] #working, .board[data-focus="landed"] #landed,
12291231 .board[data-focus="decided"] #decided, .board[data-focus="today"] #today { display: flex; }
12301232 }
1231 `;
1233 `.concat(flowCss);
src/web/pages/flow.ts +23 −15
@@ -1,5 +1,5 @@
11 /**
2 * /flow, for a forge admin: the pipeline from a ready issue to a live
2 * The flow panels on the board, for a forge admin (/flow now redirects here, #2693): the pipeline from a ready issue to a live
33 * deploy as rows, one per stage, each with how much is in it now, how long
44 * its oldest waiting item has waited, and the capacity that limits it
55 * (#1554). One sentence above names the stage with the longest wait — the
@@ -55,12 +55,10 @@ import type { QueueRow } from "../../flow/queue.ts";
5555 import { HOLDS } from "../../crew/held.ts";
5656 import { readHeld, type HeldRow } from "../../flow/held.ts";
5757 import type { Ctx } from "../../http/context.ts";
58 import { notFoundPage, signInFirst } from "../chrome.ts";
5958 import { html, type Html } from "../html.ts";
60 import { page } from "../layout.ts";
6159 import { badge, card } from "../ui.ts";
6260
63 const css = /* css */ `
61 export const flowCss = /* css */ `
6462 .flow-out { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
6563 .flow-out svg { width: 72px; height: 16px; }
6664 .flow-bar { fill: var(--muted-fg); }
@@ -91,7 +89,7 @@ function asked(url: URL): { key: PipelineKey; hour: number | null } | null {
9189 }
9290
9391 const outHref = (key: PipelineKey, hour: number | null): string =>
94 `/flow?out=${OUTFLOW[key].out}${hour === null ? "" : `&hour=${hour}`}#out`;
92 `/board?out=${OUTFLOW[key].out}${hour === null ? "" : `&hour=${hour}`}#out`;
9593
9694 const hourWords = (hour: number | null): string =>
9795 hour === null ? "in the last 24 hours" : hour === 0 ? "in the last hour" : `${hour}–${hour + 1} hours ago`;
@@ -123,11 +121,22 @@ function outCell(t: StageThroughput): Html {
123121 </div>`;
124122 }
125123
126 // GET /flow
127 export function flowPage(ctx: Ctx): Response {
128 if (!ctx.auth.user) return signInFirst(ctx);
124 // GET /flow: the panels moved to the board; `?out=` and `?hour=` ride along.
125 export function flowRedirect(ctx: Ctx): Response {
126 const to = new URL("/board", ctx.url);
127 for (const k of ["out", "hour"]) {
128 const v = ctx.url.searchParams.get(k);
129 if (v !== null) to.searchParams.set(k, v);
130 }
131 const hash = to.search === "" ? "#flow" : "#out";
132 return new Response(null, { status: 302, headers: { location: `${to.pathname}${to.search}${hash}` } });
133 }
134
135 /** The pipeline, bottleneck, held, queue and outflow panels; null unless the viewer may read telemetry. */
136 export function flowPanels(ctx: Ctx): Html | null {
137 if (!ctx.auth.user) return null;
129138 const reader = telemetryReader(ctx.app, ctx.auth.user);
130 if (!reader) return notFoundPage(ctx);
139 if (!reader) return null;
131140 noteRead(ctx.app, ctx.auth.user, reader, "flow");
132141 const now = Date.now();
133142 const stages = readPipeline(ctx.app.db, new Date(now));
@@ -142,9 +151,9 @@ export function flowPage(ctx: Ctx): Response {
142151 const onReviewer = requestedSays(requested.reviewer, "reviewer", now);
143152 const listed = asked(ctx.url);
144153 const shown = listed === null ? undefined : out.get(listed.key);
145 const body = html`<div class="page-head">
146 <h1>Flow</h1>
147 <p class="muted">
154 return html`<section id="flow" class="flow-panels" aria-labelledby="flow-h">
155 <h2 id="flow-h">Flow</h2>
156 <p class="muted">
148157 From a ready issue to a live deploy: what is in each stage now, how
149158 long its oldest has waited, and what limits it. The limits are set on
150159 <a href="/settings/capacity">Capacity</a> and in each repository's
@@ -152,7 +161,6 @@ export function flowPage(ctx: Ctx): Response {
152161 <a href="/resilience">Resilience</a>. Where an outside agent can
153162 help is on <a href="/contribute">Contribute</a>.
154163 </p>
155 </div>
156164 <p id="bottleneck" data-stage="${worst?.key ?? ""}">
157165 <strong>${verdict(stages, now)}</strong>
158166 </p>
@@ -214,8 +222,8 @@ export function flowPage(ctx: Ctx): Response {
214222 )}
215223 ${heldCard(readHeld(ctx.app, reader.kind === "owner", now))}
216224 ${queueCard(queuesFor(ctx.app, reader, new Date(now)))}
217 ${listed === null || shown === undefined ? null : outList(shown, listed.hour, now)}`;
218 return page({ ctx, title: "Flow", body, styleCss: css });
225 ${listed === null || shown === undefined ? null : outList(shown, listed.hour, now)}
226 </section>`;
219227 }
220228
221229 /** One segment per kind, as wide as its share: a picture only; the counts beside it are the words. */
test/conflict_sweep.test.ts +1 −1
@@ -43,7 +43,7 @@ async function flowDoors() {
4343 body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }),
4444 });
4545 const cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0] ?? "";
46 const page = await (await fetch(`${servers.url}/flow`, { headers: { cookie } })).text();
46 const page = await (await fetch(`${servers.url}/board`, { headers: { cookie } })).text();
4747 const res = await fetch(`${servers.url}/mcp`, {
4848 method: "POST",
4949 headers: {
test/flow-pipeline.test.ts +12 −6
@@ -239,7 +239,7 @@ describe("/flow: the forge shows its own bottleneck", () => {
239239
240240 test("an admin reads the stages as rows under the one sentence, linked from the header", async () => {
241241 const cookie = await login("alice");
242 const res = await get("/flow", cookie);
242 const res = await get("/board", cookie);
243243 expect(res.status).toBe(200);
244244 const page = await res.text();
245245 expect(page).toContain('id="bottleneck" data-stage="check-queue"');
@@ -248,15 +248,21 @@ describe("/flow: the forge shows its own bottleneck", () => {
248248 for (const key of ["ready", "building", "checking", "review", "approved", "landed", "live"])
249249 expect(page).toContain(`data-stage="${key}"`);
250250 expect(page).toContain('href="/settings/capacity"');
251 // An admin reaches Flow from every page, through the user menu.
252 expect(await (await get("/", cookie)).text()).toContain('href="/flow"');
251 // /flow itself lands on the board's panels.
252 const old = await fetch(`${servers.url}/flow`, { headers: { cookie }, redirect: "manual" });
253 expect(old.status).toBe(302);
254 expect(old.headers.get("location")).toBe("/board#flow");
255 // The user menu no longer carries a Flow button.
256 expect(await (await get("/", cookie)).text()).not.toContain('href="/flow"');
253257 });
254258
255259 test("nobody but a forge admin reads it", async () => {
256260 const bob = await login("bob");
257 expect((await get("/flow", bob)).status).toBe(404);
261 const seen = await (await get("/board", bob)).text();
262 expect(seen).not.toContain('id="bottleneck"');
263 expect(seen).not.toContain('id="flow"');
258264 expect(await (await get("/", bob)).text()).not.toContain('href="/flow"');
259 expect((await get("/flow", "")).status).not.toBe(200);
265 expect((await get("/board", "")).status).not.toBe(200);
260266 });
261267
262268 test("the top bar holds search, New and the user menu; Flow, help and theme live in menus", async () => {
@@ -269,7 +275,7 @@ describe("/flow: the forge shows its own bottleneck", () => {
269275 expect(bar.match(/<details/g)?.length).toBe(2);
270276 // They are still one open away, in the user menu.
271277 const panel = bar.slice(bar.lastIndexOf('<details'));
272 expect(panel).toContain('href="/flow"');
278 expect(panel).not.toContain('href="/flow"');
273279 expect(panel).toContain("data-help");
274280 expect(panel).toContain('action="/theme"');
275281 });
test/flow-throughput.test.ts +9 −9
@@ -176,7 +176,7 @@ describe("/flow: actual throughput per stage", () => {
176176 });
177177
178178 test("the page says it in the headline and beside each stage, and every count links to its items", async () => {
179 const res = await get("/flow");
179 const res = await get("/board");
180180 expect(res.status).toBe(200);
181181 const page = await res.text();
182182 const headline = page.match(/<p id="throughput">([\s\S]*?)<\/p>/)?.[1] ?? "";
@@ -186,15 +186,15 @@ describe("/flow: actual throughput per stage", () => {
186186 expect(throughputSays(readThroughput(app.db, PIPELINE, new Date(NOW)))).toBe(
187187 "landed 2 in the last hour · 6 in 24 h · median ask→live 3.5 h (24 h)",
188188 );
189 expect(headline).toContain('href="/flow?out=landed&amp;hour=0#out"');
190 expect(page).toMatch(/data-out="landed">\s*<a class="mono" href="\/flow\?out=landed&amp;hour=0#out" data-hour="0">2<\/a>/);
189 expect(headline).toContain('href="/board?out=landed&amp;hour=0#out"');
190 expect(page).toMatch(/data-out="landed">\s*<a class="mono" href="\/board\?out=landed&amp;hour=0#out" data-hour="0">2<\/a>/);
191191 expect(page).toContain('data-day="6">6 in 24 h');
192192 expect(page).toContain("2 passed · 1 failed");
193193 expect((page.match(/class="flow-bar"/g) ?? []).length).toBe(PIPELINE.length * 24);
194194 });
195195
196196 test("each sparkline is a picture only: hidden from assistive tech, no links or tab stops of its own", async () => {
197 const page = await (await get("/flow")).text();
197 const page = await (await get("/board")).text();
198198 const svgs = page.match(/<svg[\s\S]*?<\/svg>/g) ?? [];
199199 const sparks = svgs.filter((s) => s.includes('class="flow-bar"'));
200200 expect(sparks).toHaveLength(PIPELINE.length);
@@ -208,8 +208,8 @@ describe("/flow: actual throughput per stage", () => {
208208 for (const key of PIPELINE) {
209209 const out = { ready: "started", building: "opened", "check-queue": "check-started", checking: "checked",
210210 review: "reviewed", approved: "landed", landed: "released", live: "live" }[key];
211 expect(page).toContain(`href="/flow?out=${out}&amp;hour=0#out" data-hour="0"`);
212 expect(page).toMatch(new RegExp(`href="/flow\\?out=${out}#out" data-day=`));
211 expect(page).toContain(`href="/board?out=${out}&amp;hour=0#out" data-hour="0"`);
212 expect(page).toMatch(new RegExp(`href="/board\\?out=${out}#out" data-day=`));
213213 }
214214 });
215215
@@ -268,15 +268,15 @@ describe("/flow: actual throughput per stage", () => {
268268 });
269269
270270 test("following a count lists the items it counted; a bad ask lists nothing", async () => {
271 const hour = await (await get("/flow?out=landed&hour=0")).text();
271 const hour = await (await get("/board?out=landed&hour=0")).text();
272272 expect(hour).toContain('id="out"');
273273 expect(hour).toContain("2 landed in the last hour");
274274 expect(hour).toContain('href="/alice/shop/pulls/2"');
275275 expect(hour).toContain('href="/alice/shop/pulls/4"');
276276 expect(hour).not.toContain('href="/alice/shop/pulls/6"');
277 const day = await (await get("/flow?out=landed")).text();
277 const day = await (await get("/board?out=landed")).text();
278278 expect(day).toContain("6 landed in the last 24 hours");
279279 for (const bad of ["?out=nope", "?out=landed&hour=24", "?out=landed&hour=-1", "?out=landed&hour=1e1"])
280 expect(await (await get(`/flow${bad}`)).text()).not.toContain('id="out"');
280 expect(await (await get(`/board${bad}`)).text()).not.toContain('id="out"');
281281 });
282282 });
test/merge-queue.test.ts +1 −1
@@ -302,7 +302,7 @@ describe("the merge queue", () => {
302302 while (!queueStatus().some((q) => q.repoId === repo.id && q.queued === 2)) await Bun.sleep(5);
303303 const row = readQueues(app.db, new Date()).find((r) => r.repo === `alice/${repo.name}`);
304304 expect(row).toMatchObject({ queued: 2, gating: 1 });
305 const res = await fetch(`${servers.url}/flow`, {
305 const res = await fetch(`${servers.url}/board`, {
306306 headers: { cookie: await login() },
307307 redirect: "manual",
308308 });
test/system-telemetry.test.ts +7 −5
@@ -303,7 +303,7 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
303303 // Each check cell's memory beside its cap, and who holds the cap (#2410).
304304 expect(html).toContain('data-cap="8589934592" data-cap-by="kernel">of 8.0 GiB (kernel cap)');
305305 expect(html).toMatch(/id="cell-caps" data-by="(kernel|watch)"/);
306 const flowPage = await fetch(`${servers.url}/flow`, { headers: { cookie: await login("alice") } });
306 const flowPage = await fetch(`${servers.url}/board`, { headers: { cookie: await login("alice") } });
307307 expect(await flowPage.text()).toContain('id="duplicate-work" data-count="1"');
308308
309309 const reads = recentReads(app.db).filter((r) => r.username === "muse");
@@ -381,13 +381,15 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
381381 const session = new Session(app, { sshUsername: "zadminbot", remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user: adminbot });
382382 return forgeCommands(session)(ctx).find((c) => c.id === "flow");
383383 };
384 expect((await get(token, "/flow")).status).toBe(404);
384 expect(await (await get(token, "/board")).text()).not.toContain('id="flow"');
385385 expect(flowCommand()).toBeUndefined();
386386
387387 expect(setTelemetryGrant(app, alice, "zadminbot", true).ok).toBe(true);
388 const page = await get(token, "/flow");
388 const page = await get(token, "/board");
389389 expect(page.status).toBe(200);
390 const text = await page.text();
390 const whole = await page.text();
391 const text = whole.slice(whole.indexOf('id="flow"'));
392 expect(text).toContain('id="bottleneck"');
391393 // (the page's palette index lists every repo an admin can open; the telemetry body must not)
392394 expect(text).not.toContain("/alice/vault-of-secrets/pulls");
393395 expect(text).not.toContain("RUN1");
@@ -395,7 +397,7 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el
395397 expect(recentReads(app.db).some((r) => r.username === "zadminbot" && r.what === "flow")).toBe(true);
396398 // Revoked, the door closes again.
397399 setTelemetryGrant(app, alice, "zadminbot", false);
398 expect((await get(token, "/flow")).status).toBe(404);
400 expect(await (await get(token, "/board")).text()).not.toContain('id="flow"');
399401 });
400402
401403 test("in the terminal, the owner is offered System and Telemetry; nobody else is", () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs