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

Design: account for /map #2754

Parked opened this
Closed without merging

mason/forge:mason/2695-design-account-for-map → main 2 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
6 files changed +71 −123
docs/design/audit.md +7
@@ -59,6 +59,13 @@ Machine routes are not pages and have no entry: `/audit.csv`,
5959 - `/asked` — `studio/asked_page.ts` · what I answered, as a record · `/asks` · none seen.
6060 - `/flow` — `pages/flow.ts` · the pipeline from ready issue to live deploy, and the bottleneck · `/system`, `/board`, `/` · none seen. A topbar button points here.
6161 - `/map` — `pages/map.ts` (1,806 lines) · the dependency map of work across the forge · `/board`, issue dependency lists, `/:owner/:name/map` · colours 3, sizes 12: the largest private vocabulary.
62 **Accounted for (#2695):** it is the only place that draws the whole shape:
63 chain depth, the critical path, ready ranked by what it frees, blockers
64 ranked by what they hold up, and 14 days of open against closed. Cut: the
65 lanes' spend bar and crew avatars and the repository map's spend and slots
66 line, all of which the board's Today and Now regions show; the assignee's
67 hue disc on each card (the name is already there). Sizes are on the
68 scale and the page has no colour literals.
6269 - `/audit` — `pages/audit.ts` · every app's contract, who can do what · the app page's one-line policy · none seen. Names the audit of apps, not this document.
6370 - `/releases` — `pages/releases.ts` · the forge's kept releases and rollback · `/settings/backups` (both are "go back") · none seen.
6471 - `/contribute` — `pages/contribute.ts` · what this forge is and where outside work is welcome, open to anyone · `/llms.txt`, MCP `contribute` tool · none seen.
docs/design/baseline.json −14
@@ -8,10 +8,6 @@
88 "colour": 0,
99 "size": 1
1010 },
11 "src/web/pages/map.ts": {
12 "colour": 3,
13 "size": 12
14 },
1511 "src/web/standards.ts": {
1612 "colour": 2,
1713 "size": 0
@@ -23,10 +19,6 @@
2319 "src/web/style/components.ts": {
2420 "colour": 3,
2521 "size": 2
26 },
27 "src/web/style/content.ts": {
28 "colour": 19,
29 "size": 31
3022 }
3123 },
3224 "classes": [
@@ -406,7 +398,6 @@
406398 "map-flow",
407399 "map-lane",
408400 "map-lane-caret",
409 "map-lane-crew",
410401 "map-lane-head",
411402 "map-lane-name",
412403 "map-lane-word",
@@ -418,15 +409,10 @@
418409 "map-node",
419410 "map-pillars",
420411 "map-rule",
421 "map-spend",
422 "map-spend-fill",
423 "map-spend-track",
424412 "map-svg",
425413 "map-title",
426414 "map-tool",
427415 "map-tools",
428 "map-who",
429 "map-who-i",
430416 "map-who-n",
431417 "map-word",
432418 "map-wrap",
src/web/pages/map.ts +46 −98
@@ -18,6 +18,13 @@
1818 * hundred issues this handles is not one a person reads. The global map at
1919 * `/map` is the same drawing once per repository the viewer can see, one
2020 * lane each, at one scale, so a column means the same thing in every lane.
21 *
22 * Why it is a page (#2695): an issue's dependency list shows one issue's
23 * neighbours, and the board shows runs, landings and spend. Neither shows
24 * the shape, meaning how deep each chain is, which chain is critical, what is
25 * ready ranked by what finishing it frees, and how many issues each
26 * blocker holds up. That is all the map draws. Spend, slots and
27 * who is working are the board's, so the map does not repeat them.
2128 */
2229
2330 import { mayViewId, sealedScope } from "../../core/sealed.ts";
@@ -58,7 +65,7 @@ import {
5865 import { liveRegionsJs } from "../client.ts";
5966 import { html, type Html } from "../html.ts";
6067 import { page } from "../layout.ts";
61 import { avatar, hueOf, icon } from "../ui.ts";
68 import { icon } from "../ui.ts";
6269 import { autonomyStatus, type AutonomyStatus } from "../../crew/autonomy.ts";
6370 import {
6471 parkedTwice,
@@ -576,6 +583,8 @@ const GUTTER_LEAN = GX / 2 / (W + GX);
576583 const RULE = 30;
577584 /** Characters of title per line at the card's type size, conservatively. */
578585 const LINE = 26;
586 /** A card word's advance per letter at the micro size, to set its dot before it. */
587 const WORD_CH = 6.3;
579588
580589 function trim(text: string, max: number): string {
581590 return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;
@@ -676,7 +685,7 @@ function node(
676685 const bottom = py + H - 11;
677686 const number = `#${n.issue.number}`;
678687 const who = n.issue.assigneeName;
679 const whoX = left + 9 + number.length * 6.4;
688 const whoX = left + 8 + number.length * 6.6;
680689 return html`<a
681690 class="map-node"
682691 data-state="${word}"
@@ -711,21 +720,20 @@ function node(
711720 </text>
712721 <text class="map-meta" x="${left}" y="${bottom}">${number}</text>
713722 ${who
714 ? html`<g class="map-who" data-h="${hueOf(who)}">
715 <circle cx="${whoX + 7}" cy="${bottom - 4}" r="7" />
716 <text class="map-who-i" x="${whoX + 7}" y="${bottom - 1}"
717 >${who[0]}</text
718 >
719 <text class="map-who-n" x="${whoX + 19}" y="${bottom}"
720 >${trim(who, 11)}</text
721 >
722 </g>`
723 ? html`<text class="map-who-n" x="${whoX}" y="${bottom}"
724 >${trim(who, 11)}</text
725 >`
723726 : null}
727 ${word === "done"
728 ? null
729 : html`<circle
730 class="map-dot"
731 cx="${px + W - 16 - word.length * WORD_CH}"
732 cy="${bottom - 4}"
733 r="2.5"
734 />`}
724735 <text class="map-word" x="${px + W - 12}" y="${bottom}" text-anchor="end">
725 ${word === "done"
726 ? null
727 : html`<tspan class="map-dot" dy="-1">●</tspan
728 ><tspan dy="1"> </tspan>`}${word}
736 ${word}
729737 </text>
730738 </a>`;
731739 }
@@ -1089,17 +1097,11 @@ function chart(points: DayPoint[]): Html {
10891097 </section>`;
10901098 }
10911099
1092 const hueRules = Array.from(
1093 { length: 12 },
1094 (_, i) => `.map-who[data-h="${i}"] { --hue: ${i * 30 + 8}; }`,
1095 ).join("\n");
1096
10971100 export const mapCss = /* css */ `
10981101 .map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 272px; gap: 24px; align-items: start; margin-top: 4px; }
10991102 @media (max-width: 860px) { .map-wrap { grid-template-columns: 1fr; } }
11001103 .map-main { min-width: 0; }
11011104 .map-autonomy { flex-basis: 100%; color: var(--muted-fg); text-wrap: pretty; }
1102 .map-autonomy .ico { color: var(--faint); vertical-align: -3px; margin-right: 2px; }
11031105
11041106 /* ---- the canvas ---- */
11051107 .map-canvas { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
@@ -1110,7 +1112,7 @@ export const mapCss = /* css */ `
11101112 .map-canvas.is-view .map-svg { height: 100%; }
11111113 .map-svg text { font-family: var(--font); pointer-events: none; }
11121114 .map-tools { position: absolute; top: 8px; right: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); box-shadow: var(--shadow-1); overflow: hidden; }
1113 .map-tool { min-width: 26px; height: 24px; padding: 0 7px; border: 0; background: transparent; color: var(--muted-fg); font-size: 12px; font-weight: 550; line-height: 1; cursor: pointer; }
1115 .map-tool { min-width: 26px; height: 24px; padding: 0 7px; border: 0; background: transparent; color: var(--muted-fg); font-size: 12.5px; font-weight: 550; line-height: 1; cursor: pointer; }
11141116 .map-tool + .map-tool { border-left: 1px solid var(--border); }
11151117 .map-tool:hover { background: var(--muted); color: var(--fg); }
11161118 .map-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@@ -1136,12 +1138,10 @@ export const mapCss = /* css */ `
11361138 .map-node[data-state="deferred"] .map-card { fill: none; stroke-dasharray: 4 3; }
11371139 .map-node[data-state="deferred"] .map-title { fill: var(--muted-fg); }
11381140 .map-node[data-state="blocked"] .map-title { fill: var(--muted-fg); }
1139 .map-meta { font-size: 11px; fill: var(--faint); font-variant-numeric: tabular-nums; }
1140 .map-who circle { fill: color-mix(in srgb, hsl(var(--hue, 220) 62% 52%) 22%, var(--card)); stroke: color-mix(in srgb, hsl(var(--hue, 220) 62% 52%) 30%, transparent); }
1141 .map-who-i { font-size: 8px; font-weight: 650; text-transform: uppercase; fill: color-mix(in srgb, hsl(var(--hue, 220) 62% 42%) 88%, var(--fg)); }
1142 .map-who-n { font-size: 11px; fill: var(--muted-fg); }
1143 .map-word { font-size: 11px; font-weight: 550; fill: var(--muted-fg); }
1144 .map-word .map-dot { font-size: 7px; fill: var(--faint); }
1141 .map-meta { font-size: 11.5px; fill: var(--faint); font-variant-numeric: tabular-nums; }
1142 .map-who-n { font-size: 11.5px; fill: var(--muted-fg); }
1143 .map-word { font-size: 11.5px; font-weight: 550; fill: var(--muted-fg); }
1144 .map-dot { fill: var(--faint); }
11451145 .map-node[data-state="ready"] .map-dot { fill: var(--success); }
11461146 .map-node[data-state="working"] .map-dot { fill: var(--accent); }
11471147 .map-node[data-state="working"] .map-word { fill: var(--accent); }
@@ -1157,10 +1157,10 @@ export const mapCss = /* css */ `
11571157 .map-edge-crit { stroke: var(--accent); }
11581158 .map-edge-done { opacity: .45; }
11591159 .map-rule line { stroke: var(--border); stroke-width: 1; }
1160 .map-rule text { font-size: 10.5px; fill: var(--faint); letter-spacing: .02em; }
1160 .map-rule text { font-size: 11.5px; fill: var(--faint); letter-spacing: .02em; }
11611161
11621162 /* ---- the line under a drawing ---- */
1163 .map-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 2px 0; font-size: 12px; color: var(--muted-fg); }
1163 .map-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 2px 0; font-size: 12.5px; color: var(--muted-fg); }
11641164 .map-counts b { font-weight: 550; color: var(--fg); font-variant-numeric: tabular-nums; }
11651165 .map-counts i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--faint); }
11661166 .map-counts i[data-state="ready"] { background: var(--success); }
@@ -1172,12 +1172,12 @@ export const mapCss = /* css */ `
11721172
11731173 /* ---- beside the drawing ---- */
11741174 .map-list h2 { font-size: 13px; margin: 0 0 6px; }
1175 .map-list ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; list-style: decimal; }
1175 .map-list ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13px; list-style: decimal; }
11761176 .map-list ol li::marker { color: var(--faint); font-variant-numeric: tabular-nums; }
11771177 .map-list li span { display: block; }
11781178 .map-list + .map-list { margin-top: 18px; }
11791179 .map-ask { display: block; }
1180 .map-pillars ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13.5px; }
1180 .map-pillars ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
11811181 .map-chart { width: 100%; height: auto; display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
11821182 .map-level { fill: none; stroke: var(--accent); stroke-width: 1.5; }
11831183 .map-flow { fill: color-mix(in srgb, var(--fg) 14%, transparent); }
@@ -1193,15 +1193,8 @@ export const mapCss = /* css */ `
11931193 .map-lane[open] > .map-lane-head .map-lane-caret { transform: rotate(90deg); }
11941194 .map-lane-name { font-weight: 620; font-size: 15px; letter-spacing: -0.01em; }
11951195 .map-lane-name .muted { font-weight: 500; }
1196 .map-lane-word { font-size: 12px; color: var(--muted-fg); padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; line-height: 18px; }
1196 .map-lane-word { font-size: 11.5px; color: var(--muted-fg); padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; line-height: 18px; }
11971197 .map-lane-word[data-autonomy="autonomous"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
1198 .map-spend { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted-fg); font-variant-numeric: tabular-nums; }
1199 .map-spend svg { width: 72px; height: 4px; border-radius: 2px; overflow: hidden; }
1200 .map-spend-track { fill: var(--muted); }
1201 .map-spend-fill { fill: var(--muted-fg); }
1202 .map-spend[data-near="1"] .map-spend-fill { fill: var(--attn); }
1203 .map-lane-crew { display: inline-flex; align-items: center; gap: 4px; }
1204 .map-lane-crew .avatar { box-shadow: 0 0 0 2px var(--card); }
12051198 .map-lane-head .map-counts { margin: 0 0 0 auto; }
12061199 .map-lane[data-idle="1"] > .map-lane-head .map-lane-name { color: var(--muted-fg); font-weight: 560; }
12071200 .map-lane > .map-canvas, .map-lane > .map-empty { border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
@@ -1209,7 +1202,6 @@ export const mapCss = /* css */ `
12091202 .map-lane-head { gap: 6px 10px; }
12101203 .map-lane-head .map-counts { margin-left: 0; flex-basis: 100%; }
12111204 }
1212 ${hueRules}
12131205 `;
12141206
12151207 /**
@@ -1368,26 +1360,14 @@ export const mapViewJs = /* js */ `
13681360 })();
13691361 `;
13701362
1371 /** One line on how the repository runs itself, when it does. */
1372 function autonomyLine(ctx: Ctx, repo: Repo): Html | null {
1373 if (repo.autonomy === "off")
1374 return repo.crewOutsiders
1375 ? html`<p class="small map-autonomy">${OUTSIDERS_NOTE}</p>`
1376 : null;
1377 const s = autonomyStatus(ctx.app, repo);
1378 const paused =
1379 s.paused === "ceiling"
1380 ? " · paused at the ceiling until 00:00 UTC"
1381 : s.paused === "no crew"
1382 ? " · paused: no crew"
1383 : s.paused === "nobody"
1384 ? " · paused: nobody to act as"
1385 : "";
1386 const line = `${repo.autonomy === "autonomous" ? "Autonomous" : "Assisted"} · $${s.spentTodayUsd.toFixed(2)} of $${s.ceilingUsd.toFixed(0)} today · ${s.active} of ${s.slots} slots${paused} · ${repo.crewOutsiders ? "anyone signed in directs the crew" : "only writers direct the crew"}`;
1387 return html`<p class="small map-autonomy">
1388 ${icon("play")} ${line} ·
1389 <a href="${repoBase(repo)}/settings/autonomy">settings</a>
1390 </p>`;
1363 /**
1364 * Who may direct the crew, when the owner opened that to anyone signed in.
1365 * Spend, slots and pauses are the board's (`/board`, its Today region).
1366 */
1367 function outsidersLine(repo: Repo): Html | null {
1368 return repo.crewOutsiders
1369 ? html`<p class="small map-autonomy">${OUTSIDERS_NOTE}</p>`
1370 : null;
13911371 }
13921372
13931373 const LIVE_KINDS = "run.*,issue.*,pull.*";
@@ -1428,7 +1408,7 @@ export async function mapPage(ctx: Ctx): Promise<Response> {
14281408 is the least work that still has to happen in order.
14291409 <a href="${repoBase(repo)}/milestones">How far each milestone is</a>.
14301410 </p>
1431 ${autonomyLine(ctx, repo)}
1411 ${outsidersLine(repo)}
14321412 </div>
14331413 <div
14341414 class="map-wrap"
@@ -1691,29 +1671,10 @@ export function globalLanes(app: App, viewer: User | undefined): Lane[] {
16911671 );
16921672 }
16931673
1694 /** "$1.20 of $10", as one string so nothing wraps inside it. */
1695 function spendWords(status: AutonomyStatus): string {
1696 return `$${status.spentTodayUsd.toFixed(2)} of $${status.ceilingUsd.toFixed(0)}`;
1697 }
1698
1699 function spendBar(status: AutonomyStatus): Html {
1700 const share =
1701 status.ceilingUsd > 0 ? status.spentTodayUsd / status.ceilingUsd : 0;
1702 const pct = Math.max(0, Math.min(100, share * 100));
1703 return html`<span
1704 class="map-spend"
1705 ${share >= 0.9 ? html`data-near="1"` : null}
1706 title="Spent today against the day's ceiling"
1707 >
1708 <svg viewBox="0 0 100 4" preserveAspectRatio="none" aria-hidden="true">
1709 <rect class="map-spend-track" width="100" height="4" />
1710 <rect class="map-spend-fill" width="${pct.toFixed(1)}" height="4" />
1711 </svg>
1712 <span>${spendWords(status)}</span>
1713 </span>`;
1714 }
1715
1716 /** A lane: the repository's name, how it runs itself, who is on it, and its map. */
1674 /**
1675 * A lane: the repository's name, how it runs itself, its words counted, and
1676 * its map. Who is working and what today cost are the board's (`/board`).
1677 */
17171678 export function laneHtml(lane: Lane, width: number): Html {
17181679 const { repo } = lane;
17191680 const id = `lane-${repo.ownerName}-${repo.name}`;
@@ -1732,19 +1693,6 @@ export function laneHtml(lane: Lane, width: number): Html {
17321693 <span class="map-lane-word" data-autonomy="${repo.autonomy}"
17331694 >${repo.autonomy}</span
17341695 >
1735 ${lane.status === undefined ? null : spendBar(lane.status)}
1736 ${lane.workers.length === 0
1737 ? null
1738 : html`<span
1739 class="map-lane-crew"
1740 title="Working: ${lane.workers.join(", ")}"
1741 >${lane.workers.slice(0, 5).map((w) => avatar(w))}${lane.workers
1742 .length > 5
1743 ? html`<span class="muted small"
1744 >+${lane.workers.length - 5}</span
1745 >`
1746 : null}</span
1747 >`}
17481696 ${countsLine(lane.counts)}
17491697 </summary>
17501698 ${drawMap(
src/web/studio/cost_line.ts +1 −1
@@ -22,6 +22,6 @@ export function costLine(db: Database, writable: readonly Repo[]): Html | null {
2222 const noun = `app${writable.length === 1 ? "" : "s"}`;
2323 const sentence = `$${spentUsd.toFixed(2)} spent today across ${writable.length} ${noun} you can write`;
2424 return html`<p class="small muted studio-cost">
25 ${sentence} · ${paused} paused at <a href="/map">their ceiling</a>
25 ${sentence} · ${paused} paused at <a href="/board">their ceiling</a>
2626 </p>`;
2727 }
test/map.test.ts +16 −9
@@ -299,7 +299,7 @@ describe("the map, per app and across the forge", () => {
299299 const dormant = await repoOf(alice, "dormant", ["Rewrite the loader"]);
300300 park(alice, dormant.issues[0]!);
301301 // bob/secret: bob's own, which alice cannot see and bob can; assisted,
302 // with no crew, so the spend bar has a ceiling to draw against.
302 // with no crew and a ceiling the map leaves to the board.
303303 const secret = await repoOf(bob, "secret", ["Rotate the keys"]);
304304 const on = await updateRepoSettings(app, bob, secret.repo, {
305305 autonomy: "assisted",
@@ -337,9 +337,18 @@ describe("the map, per app and across the forge", () => {
337337 expect(card("Input mapping")).toContain('data-state="ready"');
338338 expect(card("Physics step")).toContain('data-state="waiting"');
339339 expect(card("Shader hot reload")).toContain('data-state="parked"');
340 // Who: the assignee's initial and name on the card.
340 // Who: the assignee's name on the card.
341341 expect(page).toContain('class="map-who-n"');
342342 expect(page).toMatch(/class="map-who-n"[^>]*>scout</);
343 // The word's dot is drawn, not a glyph sized below the type scale;
344 // a done card has none.
345 const whole = (title: string) =>
346 page.match(
347 new RegExp(`<a[^>]*class="map-node"(?:(?!</a>)[\\s\\S])*${title}[\\s\\S]*?</a>`),
348 )?.[0] ?? "";
349 expect(whole("Write the docs")).toMatch(/<circle\s+class="map-dot"/);
350 expect(whole("Old bootstrap")).toContain("map-word");
351 expect(whole("Old bootstrap")).not.toContain("map-dot");
343352 // The chain 1 → 2 is the critical path, in the accent.
344353 expect(page).toContain('class="map-edge map-edge-crit"');
345354 // The edge from a done issue recedes with it.
@@ -392,14 +401,12 @@ describe("the map, per app and across the forge", () => {
392401 );
393402 const lane = (id: string) =>
394403 page.match(new RegExp(`<details[^>]*id="${id}"[^>]*>`))?.[0] ?? "";
395 // engine has the crew on it: open, with who is working in its header.
404 // engine has the crew on it: open. Who is working is the board's.
396405 expect(lane("lane-alice-engine")).toMatch(/\sopen\s*>/);
397406 expect(lane("lane-alice-engine")).not.toContain("data-idle");
398407 expect(page).toContain('href="/alice/engine/map"');
399408 expect(page).toContain("Extract renderer");
400 expect(page).toMatch(
401 /class="map-lane-crew"[^>]*>[\s\S]*?class="avatar"[^>]*>s</,
402 );
409 expect(page).not.toContain("map-lane-crew");
403410 expect(page).toContain('data-autonomy="off"');
404411 // dormant has nothing ready and nobody working: it folds to its header.
405412 expect(lane("lane-alice-dormant")).toContain('data-idle="1"');
@@ -417,11 +424,11 @@ describe("the map, per app and across the forge", () => {
417424 // A repository with nothing to draw is not a lane.
418425 expect(page).not.toContain('href="/alice/bare/map"');
419426 // The forge's admin reads every repository, so bob's is a lane here,
420 // with today's spend drawn against its ceiling …
427 // its autonomy named, and today's spend left to the board …
421428 expect(page).toContain('href="/bob/secret/map"');
422429 expect(page).toContain('data-autonomy="assisted"');
423 expect(page).toContain('class="map-spend-fill" width="0.0"');
424 expect(page).toContain("$0.00 of $10");
430 expect(page).not.toContain("map-spend");
431 expect(page).not.toContain("$0.00 of $10");
425432
426433 // … and bob, who is nobody's admin, sees his own and not alice's.
427434 const bobs = await (
test/studio-search.test.ts +1 −1
@@ -455,7 +455,7 @@ describe("the studio home says what the crew cost you today", () => {
455455 const html = await home(aliceCookie);
456456 expect(html).toContain("$8.00 spent today across 2 apps you can write");
457457 expect(html).toContain("1 paused at");
458 expect(html).toMatch(/<a href="\/map">their ceiling<\/a>/);
458 expect(html).toMatch(/<a href="\/board">their ceiling<\/a>/);
459459 });
460460
461461 test("a viewer who can only read sees no figure at all", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs