Public: anyone can read this; the crew can change it.
Design: fold /flow into boards and drop the topbar Flow button #2759
scout/forge:scout/2693-design-fold-flow-into-boards-and-drop-th → main 1 commit fork
9 files
changed +60
−45
src/http/server.ts +2 −2
| @@ -14,7 +14,7 @@ import { unsealReleased } from "../actions/sealed.ts"; | ||
| 14 | 14 | import { parentCallback, parentStart } from "./rp.ts"; |
| 15 | 15 | import { accessPage } from "../web/pages/access.ts"; |
| 16 | 16 | import { capacityPage, capacitySet } from "../web/pages/capacity.ts"; |
| 17 | import { flowPage } from "../web/pages/flow.ts"; | |
| 17 | import { flowRedirect } from "../web/pages/flow.ts"; | |
| 18 | 18 | import { systemPage } from "../web/pages/system.ts"; |
| 19 | 19 | import { telemetryPage, telemetrySet } from "../web/pages/telemetry.ts"; |
| 20 | 20 | import { contributePage } from "../web/pages/contribute.ts"; |
| @@ -721,7 +721,7 @@ export function buildRouter(): Router<Handler> { | ||
| 721 | 721 | // Every app on one canvas; a literal route, so it must sit above /:owner. |
| 722 | 722 | router.add("GET", "/map", globalMapPage); |
| 723 | 723 | // 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); | |
| 725 | 725 | router.add("GET", "/system", systemPage); |
| 726 | 726 | router.add("GET", "/contribute", contributePage); |
| 727 | 727 | router.add("GET", "/settings/telemetry", telemetryPage); |
src/web/layout.ts +1 −4
| @@ -241,9 +241,6 @@ function userMenu( | ||
| 241 | 241 | ] |
| 242 | 242 | : []), |
| 243 | 243 | { separator: true, label: "" }, |
| 244 | ...(user.isAdmin | |
| 245 | ? [{ label: "Flow", href: "/flow", icon: "activity" as const }] | |
| 246 | : []), | |
| 247 | 244 | helpItem, |
| 248 | 245 | themeForm(theme), |
| 249 | 246 | { separator: true, label: "" }, |
| @@ -334,7 +331,7 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html { | ||
| 334 | 331 | : []), |
| 335 | 332 | ...(ctx.auth.user?.isAdmin |
| 336 | 333 | ? [ |
| 337 | { t: "Flow", h: "/flow", c: "Go to" }, | |
| 334 | { t: "Flow", h: "/board#flow", c: "Go to" }, | |
| 338 | 335 | { t: "System", h: "/system", c: "Go to" }, |
| 339 | 336 | { t: "Forges you sent", h: "/forges", c: "Go to" }, |
| 340 | 337 | { t: "Family of forges", h: "/family", c: "Go to" }, |
src/web/pages/board.ts +4 −2
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | * pointer. The old big view (`/big`, every address it had) lands here. |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | import { flowCss, flowPanels } from "./flow.ts"; | |
| 17 | 18 | import { sentinelNotice } from "../../crew/sentinel.ts"; |
| 18 | 19 | import { appsForRepos, type AppRecord } from "../../core/apps.ts"; |
| 19 | 20 | import { askMeasure } from "../../core/ask_ledger.ts"; |
| @@ -245,7 +246,8 @@ export function boardPage(ctx: Ctx): Response { | ||
| 245 | 246 | ${working(ctx, scope)} ${landed(ctx, scope)} ${decided(ctx, scope)} |
| 246 | 247 | ${today(ctx, scope)} |
| 247 | 248 | </div> |
| 248 | </div>`; | |
| 249 | </div> | |
| 250 | ${wall ? null : flowPanels(ctx)}`; | |
| 249 | 251 | return page({ |
| 250 | 252 | ctx, |
| 251 | 253 | title: "Board", |
| @@ -1228,4 +1230,4 @@ ${widths} | ||
| 1228 | 1230 | .board[data-focus="working"] #working, .board[data-focus="landed"] #landed, |
| 1229 | 1231 | .board[data-focus="decided"] #decided, .board[data-focus="today"] #today { display: flex; } |
| 1230 | 1232 | } |
| 1231 | `; | |
| 1233 | `.concat(flowCss); |
src/web/pages/flow.ts +23 −15
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /** |
| 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 | |
| 3 | 3 | * deploy as rows, one per stage, each with how much is in it now, how long |
| 4 | 4 | * its oldest waiting item has waited, and the capacity that limits it |
| 5 | 5 | * (#1554). One sentence above names the stage with the longest wait — the |
| @@ -55,12 +55,10 @@ import type { QueueRow } from "../../flow/queue.ts"; | ||
| 55 | 55 | import { HOLDS } from "../../crew/held.ts"; |
| 56 | 56 | import { readHeld, type HeldRow } from "../../flow/held.ts"; |
| 57 | 57 | import type { Ctx } from "../../http/context.ts"; |
| 58 | import { notFoundPage, signInFirst } from "../chrome.ts"; | |
| 59 | 58 | import { html, type Html } from "../html.ts"; |
| 60 | import { page } from "../layout.ts"; | |
| 61 | 59 | import { badge, card } from "../ui.ts"; |
| 62 | 60 | |
| 63 | const css = /* css */ ` | |
| 61 | export const flowCss = /* css */ ` | |
| 64 | 62 | .flow-out { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; } |
| 65 | 63 | .flow-out svg { width: 72px; height: 16px; } |
| 66 | 64 | .flow-bar { fill: var(--muted-fg); } |
| @@ -91,7 +89,7 @@ function asked(url: URL): { key: PipelineKey; hour: number | null } | null { | ||
| 91 | 89 | } |
| 92 | 90 | |
| 93 | 91 | 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`; | |
| 95 | 93 | |
| 96 | 94 | const hourWords = (hour: number | null): string => |
| 97 | 95 | 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 { | ||
| 123 | 121 | </div>`; |
| 124 | 122 | } |
| 125 | 123 | |
| 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; | |
| 129 | 138 | const reader = telemetryReader(ctx.app, ctx.auth.user); |
| 130 | if (!reader) return notFoundPage(ctx); | |
| 139 | if (!reader) return null; | |
| 131 | 140 | noteRead(ctx.app, ctx.auth.user, reader, "flow"); |
| 132 | 141 | const now = Date.now(); |
| 133 | 142 | const stages = readPipeline(ctx.app.db, new Date(now)); |
| @@ -142,9 +151,9 @@ export function flowPage(ctx: Ctx): Response { | ||
| 142 | 151 | const onReviewer = requestedSays(requested.reviewer, "reviewer", now); |
| 143 | 152 | const listed = asked(ctx.url); |
| 144 | 153 | 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"> | |
| 148 | 157 | From a ready issue to a live deploy: what is in each stage now, how |
| 149 | 158 | long its oldest has waited, and what limits it. The limits are set on |
| 150 | 159 | <a href="/settings/capacity">Capacity</a> and in each repository's |
| @@ -152,7 +161,6 @@ export function flowPage(ctx: Ctx): Response { | ||
| 152 | 161 | <a href="/resilience">Resilience</a>. Where an outside agent can |
| 153 | 162 | help is on <a href="/contribute">Contribute</a>. |
| 154 | 163 | </p> |
| 155 | </div> | |
| 156 | 164 | <p id="bottleneck" data-stage="${worst?.key ?? ""}"> |
| 157 | 165 | <strong>${verdict(stages, now)}</strong> |
| 158 | 166 | </p> |
| @@ -214,8 +222,8 @@ export function flowPage(ctx: Ctx): Response { | ||
| 214 | 222 | )} |
| 215 | 223 | ${heldCard(readHeld(ctx.app, reader.kind === "owner", now))} |
| 216 | 224 | ${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>`; | |
| 219 | 227 | } |
| 220 | 228 | |
| 221 | 229 | /** 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() { | ||
| 43 | 43 | body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }), |
| 44 | 44 | }); |
| 45 | 45 | 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(); | |
| 47 | 47 | const res = await fetch(`${servers.url}/mcp`, { |
| 48 | 48 | method: "POST", |
| 49 | 49 | headers: { |
test/flow-pipeline.test.ts +12 −6
| @@ -239,7 +239,7 @@ describe("/flow: the forge shows its own bottleneck", () => { | ||
| 239 | 239 | |
| 240 | 240 | test("an admin reads the stages as rows under the one sentence, linked from the header", async () => { |
| 241 | 241 | const cookie = await login("alice"); |
| 242 | const res = await get("/flow", cookie); | |
| 242 | const res = await get("/board", cookie); | |
| 243 | 243 | expect(res.status).toBe(200); |
| 244 | 244 | const page = await res.text(); |
| 245 | 245 | expect(page).toContain('id="bottleneck" data-stage="check-queue"'); |
| @@ -248,15 +248,21 @@ describe("/flow: the forge shows its own bottleneck", () => { | ||
| 248 | 248 | for (const key of ["ready", "building", "checking", "review", "approved", "landed", "live"]) |
| 249 | 249 | expect(page).toContain(`data-stage="${key}"`); |
| 250 | 250 | 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"'); | |
| 253 | 257 | }); |
| 254 | 258 | |
| 255 | 259 | test("nobody but a forge admin reads it", async () => { |
| 256 | 260 | 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"'); | |
| 258 | 264 | 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); | |
| 260 | 266 | }); |
| 261 | 267 | |
| 262 | 268 | 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", () => { | ||
| 269 | 275 | expect(bar.match(/<details/g)?.length).toBe(2); |
| 270 | 276 | // They are still one open away, in the user menu. |
| 271 | 277 | const panel = bar.slice(bar.lastIndexOf('<details')); |
| 272 | expect(panel).toContain('href="/flow"'); | |
| 278 | expect(panel).not.toContain('href="/flow"'); | |
| 273 | 279 | expect(panel).toContain("data-help"); |
| 274 | 280 | expect(panel).toContain('action="/theme"'); |
| 275 | 281 | }); |
test/flow-throughput.test.ts +9 −9
| @@ -176,7 +176,7 @@ describe("/flow: actual throughput per stage", () => { | ||
| 176 | 176 | }); |
| 177 | 177 | |
| 178 | 178 | 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"); | |
| 180 | 180 | expect(res.status).toBe(200); |
| 181 | 181 | const page = await res.text(); |
| 182 | 182 | const headline = page.match(/<p id="throughput">([\s\S]*?)<\/p>/)?.[1] ?? ""; |
| @@ -186,15 +186,15 @@ describe("/flow: actual throughput per stage", () => { | ||
| 186 | 186 | expect(throughputSays(readThroughput(app.db, PIPELINE, new Date(NOW)))).toBe( |
| 187 | 187 | "landed 2 in the last hour · 6 in 24 h · median ask→live 3.5 h (24 h)", |
| 188 | 188 | ); |
| 189 | expect(headline).toContain('href="/flow?out=landed&hour=0#out"'); | |
| 190 | expect(page).toMatch(/data-out="landed">\s*<a class="mono" href="\/flow\?out=landed&hour=0#out" data-hour="0">2<\/a>/); | |
| 189 | expect(headline).toContain('href="/board?out=landed&hour=0#out"'); | |
| 190 | expect(page).toMatch(/data-out="landed">\s*<a class="mono" href="\/board\?out=landed&hour=0#out" data-hour="0">2<\/a>/); | |
| 191 | 191 | expect(page).toContain('data-day="6">6 in 24 h'); |
| 192 | 192 | expect(page).toContain("2 passed · 1 failed"); |
| 193 | 193 | expect((page.match(/class="flow-bar"/g) ?? []).length).toBe(PIPELINE.length * 24); |
| 194 | 194 | }); |
| 195 | 195 | |
| 196 | 196 | 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(); | |
| 198 | 198 | const svgs = page.match(/<svg[\s\S]*?<\/svg>/g) ?? []; |
| 199 | 199 | const sparks = svgs.filter((s) => s.includes('class="flow-bar"')); |
| 200 | 200 | expect(sparks).toHaveLength(PIPELINE.length); |
| @@ -208,8 +208,8 @@ describe("/flow: actual throughput per stage", () => { | ||
| 208 | 208 | for (const key of PIPELINE) { |
| 209 | 209 | const out = { ready: "started", building: "opened", "check-queue": "check-started", checking: "checked", |
| 210 | 210 | review: "reviewed", approved: "landed", landed: "released", live: "live" }[key]; |
| 211 | expect(page).toContain(`href="/flow?out=${out}&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}&hour=0#out" data-hour="0"`); | |
| 212 | expect(page).toMatch(new RegExp(`href="/board\\?out=${out}#out" data-day=`)); | |
| 213 | 213 | } |
| 214 | 214 | }); |
| 215 | 215 | |
| @@ -268,15 +268,15 @@ describe("/flow: actual throughput per stage", () => { | ||
| 268 | 268 | }); |
| 269 | 269 | |
| 270 | 270 | 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(); | |
| 272 | 272 | expect(hour).toContain('id="out"'); |
| 273 | 273 | expect(hour).toContain("2 landed in the last hour"); |
| 274 | 274 | expect(hour).toContain('href="/alice/shop/pulls/2"'); |
| 275 | 275 | expect(hour).toContain('href="/alice/shop/pulls/4"'); |
| 276 | 276 | 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(); | |
| 278 | 278 | expect(day).toContain("6 landed in the last 24 hours"); |
| 279 | 279 | 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"'); | |
| 281 | 281 | }); |
| 282 | 282 | }); |
test/merge-queue.test.ts +1 −1
| @@ -302,7 +302,7 @@ describe("the merge queue", () => { | ||
| 302 | 302 | while (!queueStatus().some((q) => q.repoId === repo.id && q.queued === 2)) await Bun.sleep(5); |
| 303 | 303 | const row = readQueues(app.db, new Date()).find((r) => r.repo === `alice/${repo.name}`); |
| 304 | 304 | expect(row).toMatchObject({ queued: 2, gating: 1 }); |
| 305 | const res = await fetch(`${servers.url}/flow`, { | |
| 305 | const res = await fetch(`${servers.url}/board`, { | |
| 306 | 306 | headers: { cookie: await login() }, |
| 307 | 307 | redirect: "manual", |
| 308 | 308 | }); |
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 | ||
| 303 | 303 | // Each check cell's memory beside its cap, and who holds the cap (#2410). |
| 304 | 304 | expect(html).toContain('data-cap="8589934592" data-cap-by="kernel">of 8.0 GiB (kernel cap)'); |
| 305 | 305 | 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") } }); | |
| 307 | 307 | expect(await flowPage.text()).toContain('id="duplicate-work" data-count="1"'); |
| 308 | 308 | |
| 309 | 309 | 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 | ||
| 381 | 381 | const session = new Session(app, { sshUsername: "zadminbot", remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user: adminbot }); |
| 382 | 382 | return forgeCommands(session)(ctx).find((c) => c.id === "flow"); |
| 383 | 383 | }; |
| 384 | expect((await get(token, "/flow")).status).toBe(404); | |
| 384 | expect(await (await get(token, "/board")).text()).not.toContain('id="flow"'); | |
| 385 | 385 | expect(flowCommand()).toBeUndefined(); |
| 386 | 386 | |
| 387 | 387 | expect(setTelemetryGrant(app, alice, "zadminbot", true).ok).toBe(true); |
| 388 | const page = await get(token, "/flow"); | |
| 388 | const page = await get(token, "/board"); | |
| 389 | 389 | 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"'); | |
| 391 | 393 | // (the page's palette index lists every repo an admin can open; the telemetry body must not) |
| 392 | 394 | expect(text).not.toContain("/alice/vault-of-secrets/pulls"); |
| 393 | 395 | expect(text).not.toContain("RUN1"); |
| @@ -395,7 +397,7 @@ describe("telemetry:read: the owner grants it, an agent reads with it, nobody el | ||
| 395 | 397 | expect(recentReads(app.db).some((r) => r.username === "zadminbot" && r.what === "flow")).toBe(true); |
| 396 | 398 | // Revoked, the door closes again. |
| 397 | 399 | 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"'); | |
| 399 | 401 | }); |
| 400 | 402 | |
| 401 | 403 | test("in the terminal, the owner is offered System and Telemetry; nobody else is", () => { |
new above
offline