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

The home page shows the forge's KPIs, never a to-do list for the owner; the owner pins board panels to it #2671

Parked opened this in answer to
Closed without merging

scout/forge:scout/2665-the-home-page-shows-the-forge-s-kpis-nev → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
22 files changed +542 −41
README.md +1
@@ -1434,6 +1434,7 @@ work here.
14341434 A board with a refresh redraws its grid on that beat through the live-region swap
14351435 (`/boards/:slug/live`, etag'd). The same doors are in the API: `GET /api/v1/boards`, `GET|PUT|DELETE /api/v1/boards/:slug`
14361436 (an agent or anyone but an admin is 403; a panel whose query cannot run is refused with 422). The same four doors are MCP tools (`boards`, `board_write`, `board_delete`; `boards` with a `slug` reads one) and, for the same person, a **Boards** screen in the terminal that lists boards and shows a board's panels as text. No dependency was added.
1437 **The owner's home** (a person who is an admin) is the forge's vital signs, never a list of what waits on them: landings per hour (merged pulls into a default branch, last 24 h, as a sparkline), the live version and when it went live, median check time, builders at work of slots, today's spend of the daily ceiling, and the age of the last off-box backup, each linking to the board or page it comes from, and wrapping at 360 px. Every panel on a board has **Pin to home**; pinned panels draw under the KPIs, with Up/Down/Unpin, in the owner's order (`POST /home/panels`; one `user_setting` row of `board:place` pairs, so at most about five pins). What waits on the owner is on `/asks`, reached on purpose.
14371438 - **Issues** — labels, threaded comments, close/reopen, markdown.
14381439 - **Pull requests** — open from a branch, a **beautiful diff viewer** (syntax
14391440 highlighting composed with intra-line word highlighting, mobile-first,
src/core/home_panels.ts added +57
@@ -0,0 +1,57 @@
1 /**
2 * The board panels an owner pinned to their home, in their order. One
3 * `user_setting` row of `slug:index` pairs: a pin names a panel by its board
4 * and place, and a pin whose panel is gone is skipped when drawn, never an
5 * error. The row is bounded (`setUserSetting` keeps 200 characters), so a pin
6 * that would not fit is refused.
7 */
8 import type { Database } from "bun:sqlite";
9 import { isSlug } from "../boards/store.ts";
10 import { getUserSetting, setUserSetting } from "./settings.ts";
11
12 const KEY = "home_panels";
13 const MAX_LEN = 200;
14
15 export interface PanelPin {
16 readonly slug: string;
17 readonly index: number;
18 }
19
20 export const samePin = (a: PanelPin, b: PanelPin): boolean => a.slug === b.slug && a.index === b.index;
21
22 export function pinsOf(db: Database, userId: string): PanelPin[] {
23 const out: PanelPin[] = [];
24 for (const part of (getUserSetting(db, userId, KEY) ?? "").split(";")) {
25 const [slug = "", n = ""] = part.split(":");
26 const index = /^\d{1,2}$/.test(n) ? Number(n) : -1;
27 if (isSlug(slug) && index >= 0) out.push({ slug, index });
28 }
29 return out;
30 }
31
32 const save = (db: Database, userId: string, pins: readonly PanelPin[]): boolean => {
33 const value = pins.map((p) => `${p.slug}:${p.index}`).join(";");
34 if (value.length > MAX_LEN) return false;
35 setUserSetting(db, userId, KEY, value);
36 return true;
37 };
38
39 /** Pin (idempotent, at the end); false when it does not fit. */
40 export function pinPanel(db: Database, userId: string, pin: PanelPin): boolean {
41 const pins = pinsOf(db, userId);
42 return pins.some((p) => samePin(p, pin)) || save(db, userId, [...pins, pin]);
43 }
44
45 export function unpinPanel(db: Database, userId: string, pin: PanelPin): void {
46 save(db, userId, pinsOf(db, userId).filter((p) => !samePin(p, pin)));
47 }
48
49 /** Move a pin one place earlier (-1) or later (1) in the owner's order. */
50 export function movePin(db: Database, userId: string, pin: PanelPin, by: -1 | 1): void {
51 const pins = pinsOf(db, userId);
52 const at = pins.findIndex((p) => samePin(p, pin));
53 const to = at + by;
54 if (at < 0 || to < 0 || to >= pins.length) return;
55 [pins[at], pins[to]] = [pins[to]!, pins[at]!];
56 save(db, userId, pins);
57 }
src/core/kpis.ts added +148
@@ -0,0 +1,148 @@
1 /**
2 * The forge's vital signs, read live for the owner's home: real landings per
3 * hour, the live version, median check time, builders at work, today's spend,
4 * the age of the last off-box backup. Plain data out — a label, a value, a
5 * note, the page it comes from — so the page only draws. A handful of grouped
6 * queries and two small files; nothing is cached or shelled out.
7 */
8 import type { Database } from "bun:sqlite";
9 import { dayStart, getAccountCeiling } from "./account_ceiling.ts";
10 import { lastMirror } from "../snapshot/mirror.ts";
11 import { running } from "../kernel/version.ts";
12
13 export interface Kpi {
14 readonly key: string;
15 readonly label: string;
16 readonly value: string;
17 readonly note: string;
18 /** The board or page this number comes from. */
19 readonly href: string;
20 /** Twenty-four hourly counts, oldest first, for a sparkline. */
21 readonly spark?: readonly number[];
22 }
23
24 const HOUR = 3_600_000;
25
26 /** Merged pulls into a default branch, by hour for the last 24 h, oldest first. */
27 export function landingsByHour(db: Database, now: number): number[] {
28 const first = Math.floor(now / HOUR) * HOUR - 23 * HOUR;
29 const rows = db
30 .query<{ at: string }, [string]>(
31 `SELECT p.merged_at AS at FROM pull p
32 JOIN issue i ON i.id = p.issue_id JOIN repo r ON r.id = i.repo_id
33 WHERE p.merged_at >= ?1 AND p.base_branch = r.default_branch`,
34 )
35 .all(new Date(first).toISOString());
36 const counts = new Array<number>(24).fill(0);
37 for (const { at } of rows) {
38 const slot = Math.floor((Date.parse(at) - first) / HOUR);
39 if (slot >= 0 && slot < 24) counts[slot] = (counts[slot] ?? 0) + 1;
40 }
41 return counts;
42 }
43
44 /** The median of finished checks' wall time over the last day, in ms, or undefined. */
45 export function medianCheckMs(db: Database, now: number): number | undefined {
46 const rows = db
47 .query<{ started_at: string; finished_at: string }, [string]>(
48 `SELECT started_at, finished_at FROM run
49 WHERE kind = 'check' AND started_at IS NOT NULL AND finished_at >= ?1
50 ORDER BY finished_at DESC LIMIT 500`,
51 )
52 .all(new Date(now - 24 * HOUR).toISOString());
53 const spans = rows
54 .map((r) => Date.parse(r.finished_at) - Date.parse(r.started_at))
55 .filter((n) => Number.isFinite(n) && n >= 0)
56 .sort((a, b) => a - b);
57 if (spans.length === 0) return undefined;
58 const mid = Math.floor(spans.length / 2);
59 return spans.length % 2 === 1 ? spans[mid]! : (spans[mid - 1]! + spans[mid]!) / 2;
60 }
61
62 const span = (ms: number): string => {
63 const s = Math.round(ms / 1000);
64 if (s < 90) return `${s}s`;
65 const m = Math.round(s / 60);
66 return m < 90 ? `${m} min` : `${(m / 60).toFixed(1)} h`;
67 };
68
69 const age = (iso: string, now: number): string => {
70 const ms = now - Date.parse(iso);
71 return Number.isFinite(ms) ? `${span(Math.max(0, ms))} ago` : "unknown";
72 };
73
74 const usd = (n: number): string => `$${n.toFixed(n < 100 ? 2 : 0)}`;
75
76 export function readKpis(
77 db: Database,
78 dataDir: string,
79 userId: string,
80 booted: string,
81 now = Date.now(),
82 ): Kpi[] {
83 const spark = landingsByHour(db, now);
84 const total = spark.reduce((a, b) => a + b, 0);
85 const live = running();
86 const check = medianCheckMs(db, now);
87 const busy =
88 db.query<{ n: number }, []>("SELECT COUNT(*) AS n FROM run WHERE kind = 'agent' AND state = 'running'").get()?.n ?? 0;
89 const slots =
90 db
91 .query<{ n: number | null }, []>("SELECT SUM(autonomy_slots) AS n FROM repo WHERE autonomy != 'off'")
92 .get()?.n ?? 0;
93 const spent =
94 db
95 .query<{ n: number }, [string, string]>(
96 `SELECT COALESCE(SUM(u.cost_usd), 0) AS n FROM usage u JOIN repo r ON r.id = u.repo_id
97 WHERE r.owner_id = ?1 AND u.at >= ?2`,
98 )
99 .get(userId, dayStart(new Date(now)))?.n ?? 0;
100 const ceiling = getAccountCeiling(db, userId);
101 const mirror = lastMirror(dataDir);
102 const synced = mirror?.syncedAt;
103 return [
104 {
105 key: "landings",
106 label: "Landings per hour",
107 value: (total / 24).toFixed(1),
108 note: `${total} in the last 24 h`,
109 href: "/boards/data?source=stages&fcolumn=stage&fop=eq&fvalue=4+merged&by=hour&chart=bar",
110 spark,
111 },
112 {
113 key: "live",
114 label: "Live version",
115 value: live.version,
116 note: `live ${age(booted, now)}`,
117 href: "/releases",
118 },
119 {
120 key: "check",
121 label: "Median check",
122 value: check === undefined ? "none" : span(check),
123 note: "finished in the last 24 h",
124 href: "/boards/data?source=runs&fcolumn=kind&fop=eq&fvalue=check&by=day&chart=bar",
125 },
126 {
127 key: "builders",
128 label: "Builders at work",
129 value: `${busy} of ${slots}`,
130 note: "running now, of slots",
131 href: "/flow",
132 },
133 {
134 key: "spend",
135 label: "Spent today",
136 value: ceiling === undefined ? usd(spent) : `${usd(spent)} of ${usd(ceiling.dailyUsd)}`,
137 note: ceiling === undefined ? "no daily ceiling set" : "of today's ceiling",
138 href: "/boards/data?source=spend&aggregate=sum&column=cost_usd&by=day&chart=bar",
139 },
140 {
141 key: "backup",
142 label: "Off-box backup",
143 value: synced === undefined ? "none" : age(synced, now),
144 note: synced === undefined ? "no copy kept elsewhere" : "last confirmed good",
145 href: "/settings/backups",
146 },
147 ];
148 }
src/http/server.ts +2
@@ -23,6 +23,7 @@ import { usagePage } from "../web/pages/usage.ts";
2323 import { domainsPage } from "../web/pages/domains.ts";
2424 import { resiliencePage } from "../web/pages/resilience.ts";
2525 import { limitsPage, limitsSet, quotasSet, signupSet, inviteMint, inviteRevoke } from "../web/pages/admin-limits.ts";
26 import { homePanels } from "../web/studio/home_owner.ts";
2627 import { boardsPage } from "../web/pages/boards.ts";
2728 import { boardNew, boardPin, boardPost } from "../web/pages/boards-edit.ts";
2829 import { boardLive, boardShow, boardsList } from "../web/pages/boards-view.ts";
@@ -810,6 +811,7 @@ export function buildRouter(): Router<Handler> {
810811 router.add("GET", "/boards", boardsList);
811812 router.add("GET", "/boards/data", boardsPage);
812813 router.add("POST", "/boards/new", boardNew);
814 router.add("POST", "/home/panels", homePanels);
813815 router.add("POST", "/boards/pin", boardPin);
814816 router.add("GET", "/boards/:slug", boardShow);
815817 router.add("GET", "/boards/:slug/live", boardLive);
src/web/pages/board.ts +2 −2
@@ -394,7 +394,7 @@ function reviewStrip(ctx: Ctx, scope: BoardScope): Html | null {
394394 if (!none && waits.length === 0) return [];
395395 const oldest = waits.map((w) => w.since).sort()[0];
396396 return [
397 html`<a class="board-asks" href="/#needs-you"
397 html`<a class="board-asks" href="/asks"
398398 ><b>${repo.name}</b>: ${none ? "No reviewer: agent pulls wait for you" : "agent pulls wait for your review"}${waits.length === 0
399399 ? null
400400 : html` · <b>${waits.length}</b> waiting since ${oldest!.slice(0, 10)}`}</a
@@ -421,7 +421,7 @@ function asksStrip(ctx: Ctx): Html | null {
421421 const since = new Date(Date.now() - ASKS_WINDOW_DAYS * 86_400_000).toISOString();
422422 const m = askMeasure(ctx.app.db, user.id, since);
423423 if (m.raised + m.acted + m.dismissed + m.expired === 0) return null;
424 return html`<a class="board-asks" id="asks-measure" href="/#needs-you"
424 return html`<a class="board-asks" id="asks-measure" href="/asks"
425425 >Asks, ${ASKS_WINDOW_DAYS} days: <b>${m.raised}</b> raised · <b>${m.acted}</b> acted
426426 on · <b>${m.dismissed}</b> dismissed · <b>${m.expired}</b> went by themselves</a
427427 >`;
src/web/pages/boards-view.ts +18 −6
@@ -7,6 +7,7 @@
77 * the same swap the wall uses, no client framework. Every form posts to
88 * `boards-edit.ts`. Anyone but a person who is an admin gets the not-found page.
99 */
10 import { pinsOf, samePin, type PanelPin } from "../../core/home_panels.ts";
1011 import { listAllBoards, showBoard } from "../../actions/boards.ts";
1112 import { CHART_NAMES } from "../../boards/chart.ts";
1213 import { MAX_H, MAX_PANELS, MAX_TITLE, MAX_W, RANGES, REFRESHES, type Board, type Panel } from "../../boards/store.ts";
@@ -31,7 +32,8 @@ function ranged(query: Record<string, unknown>, range: Board["range"]): Record<s
3132 return { ...query, from: new Date(Date.now() - RANGE_MS[range]).toISOString() };
3233 }
3334
34 function drawPanel(app: App, board: Board, panel: Panel): Html {
35 /** One panel's card; `controls` sit in its head beside "explore". */
36 export function drawPanel(app: App, board: Board, panel: Panel, controls: Html | null = null): Html {
3537 const answer = runFor(app.db, panel.chart, ranged(panel.query, board.range));
3638 const q = paramsOf(panel.query, panel.chart);
3739 const body = !answer.ok
@@ -40,13 +42,13 @@ function drawPanel(app: App, board: Board, panel: Panel): Html {
4042 const explore = new URLSearchParams(Object.entries(q).filter(([k, v]) => v !== "" && k !== "rows"));
4143 return html`<div class="card bp-w${String(panel.w)} bp-h${String(panel.h)}">
4244 <div class="card-head"><h2>${panel.title}</h2>
43 <a class="muted small" href="/boards/data?${explore.toString()}">explore</a></div>
45 <a class="muted small" href="/boards/data?${explore.toString()}">explore</a>${controls}</div>
4446 <div class="card-body">${body}</div>
4547 </div>`;
4648 }
4749
4850 /** The grid alone: what the page shows and what the live address answers with. */
49 function grid(app: App, slug: string, board: Board): Html {
51 function grid(app: App, slug: string, board: Board, pins: readonly PanelPin[]): Html {
5052 const every = board.refresh === "off" ? null : EVERY[board.refresh];
5153 return html`<section
5254 class="bgrid"
@@ -57,10 +59,20 @@ function grid(app: App, slug: string, board: Board): Html {
5759 >
5860 ${board.panels.length === 0
5961 ? html`<p class="muted">No panels yet. Add one below.</p>`
60 : board.panels.map((p) => drawPanel(app, board, p))}
62 : board.panels.map((p, index) => {
63 const pinned = pins.some((x) => samePin(x, { slug, index }));
64 return drawPanel(app, board, p, html`<form method="post" action="/home/panels" class="inline">
65 <input type="hidden" name="slug" value="${slug}" /><input type="hidden" name="index" value="${String(index)}" />
66 <input type="hidden" name="back" value="/boards/${slug}" />
67 <button class="btn btn-sm btn-ghost" name="action" value="${pinned ? "unpin" : "pin"}"
68 >${pinned ? "Unpin from home" : "Pin to home"}</button>
69 </form>`);
70 })}
6171 </section>`;
6272 }
6373
74 const pinsFor = (ctx: Ctx): PanelPin[] => (ctx.auth.user ? pinsOf(ctx.app.db, ctx.auth.user.id) : []);
75
6476 const denied = (ctx: Ctx) => {
6577 const u = ctx.auth.user;
6678 return u?.isAdmin !== true || u.kind === "agent";
@@ -163,7 +175,7 @@ export async function boardShow(ctx: Ctx): Promise<Response> {
163175 title: board.title,
164176 body: html`<div class="page-head"><h1>${board.title}</h1>
165177 ${btn("All boards", { href: "/boards", variant: "ghost" })}</div>
166 ${grid(ctx.app, slug, board)}
178 ${grid(ctx.app, slug, board, pinsFor(ctx))}
167179 ${manage(slug, board, queryFields(readParams(ctx.url.searchParams)))}`,
168180 scriptJs: liveRegionsJs,
169181 });
@@ -175,5 +187,5 @@ export async function boardLive(ctx: Ctx): Promise<Response> {
175187 const slug = ctx.params.slug ?? "";
176188 const shown = await showBoard(ctx.app, ctx.auth.user, slug);
177189 if (!shown.ok) return fragment(html``, { status: 404 });
178 return fragment(grid(ctx.app, slug, shown.value), { request: ctx.request });
190 return fragment(grid(ctx.app, slug, shown.value, pinsFor(ctx)), { request: ctx.request });
179191 }
src/web/pages/site.ts +4
@@ -24,6 +24,7 @@ import { hasAnyUser, verifyPasswordThrottled, type User } from "../../core/users
2424 import { isThemeName } from "../../design/themes.ts";
2525 import { cookieValue, crossOrigin, type Ctx } from "../../http/context.ts";
2626 import { studioDoor, studioHome } from "../studio/home.ts";
27 import { isOwner } from "../studio/home_owner.ts";
2728 import { homeTop } from "../studio/asks_page.ts";
2829 import { edgeLoginUrl } from "../../http/edge.ts";
2930 import { sshCommand } from "../../ssh/command.ts";
@@ -208,6 +209,9 @@ export function terminalCard(ctx: Ctx): Html {
208209 export async function home(ctx: Ctx): Promise<Response> {
209210 const user = ctx.auth.user;
210211 if (user === undefined) return studioDoor(ctx);
212 // A bulk step's receipt belongs to the asks, which the owner's home leaves out.
213 if (isOwner(user) && (ctx.url.searchParams.has("op") || ctx.url.searchParams.has("decided")))
214 return redirect(`/asks${ctx.url.search}`);
211215 return await studioHome(ctx, user, homeTop(ctx));
212216 }
213217
src/web/studio/asks_page.ts +7 −2
@@ -28,6 +28,7 @@ import type { Degraded } from "../../kernel/vitals.ts";
2828 import type { Ctx } from "../../http/context.ts";
2929 import type { User } from "../../core/users.ts";
3030 import { onYouAnswer, studioHome } from "./home.ts";
31 import { isOwner } from "./home_owner.ts";
3132 import { notFoundPage, repoBase, signInFirst } from "../chrome.ts";
3233 import { backTo, field, readForm } from "../form.ts";
3334 import { MAX_BODY } from "../../core/issues.ts";
@@ -334,7 +335,11 @@ export interface AsksTop {
334335
335336 /** GET /asks — the home, scrolled to what needs you; `?op=<id>` (a bulk
336337 * action's receipt) rides along. */
337 export function asksPage(ctx: Ctx): Response {
338 export async function asksPage(ctx: Ctx): Promise<Response> {
339 const user = ctx.auth.user;
340 // The owner's home shows no list; their asks are here, on request.
341 if (user !== undefined && isOwner(user))
342 return await studioHome(ctx, user, homeTop(ctx), true);
338343 const op = ctx.url.searchParams.get("op");
339344 return redirect(
340345 op === null
@@ -492,7 +497,7 @@ export function needsYouSection(
492497 async function asksScreen(ctx: Ctx, top: AsksTop): Promise<Response> {
493498 const user = ctx.auth.user;
494499 if (!user) return signInFirst(ctx);
495 return await studioHome(ctx, user, top);
500 return await studioHome(ctx, user, top, isOwner(user));
496501 }
497502
498503 // ---- many at once: select, preview, do it, undo — all on this screen ----
src/web/studio/home.ts +16 −2
@@ -46,6 +46,7 @@ import {
4646 } from "../pages/site.ts";
4747 import { writableAppsOf } from "./asks.ts";
4848 import { needsYouSection, type AsksTop } from "./asks_page.ts";
49 import { isOwner, kpiRow, pinnedPanels } from "./home_owner.ts";
4950 import { flowCards } from "./flow_card.ts";
5051 import { composer, feedJs, feedNote, feedRegion } from "./feed.ts";
5152 import { homeTabs } from "./home_tabs.ts";
@@ -206,8 +207,20 @@ export async function studioHome(
206207 ctx: Ctx,
207208 user: User,
208209 top?: AsksTop,
210 onlyAsks = false,
209211 ): Promise<Response> {
210 const needsYou = needsYouSection(ctx, user, top);
212 const owner = isOwner(user);
213 // The owner's home never lists what waits on them; `/asks` does, on purpose.
214 if (owner && onlyAsks) {
215 const needs = needsYouSection(ctx, user, top);
216 return page({
217 ctx,
218 title: "Asks",
219 body: html`<h1>Asks</h1>${onYouRegion(ctx, user, undefined, needs.body)}`,
220 scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${needs.scriptJs}`,
221 });
222 }
223 const needsYou = owner ? { body: html``, scriptJs: "" } : needsYouSection(ctx, user, top);
211224 const { repos: appRepos } = writableAppsOf(ctx, user);
212225 // A spawned forge says where it lives: the address its person shares.
213226 const spawned = await spawnedOrg(ctx.app);
@@ -253,10 +266,11 @@ export async function studioHome(
253266 <a href="/">Just my apps</a>
254267 </p>`,
255268 )}
269 ${owner ? kpiRow(ctx, user) : null} ${owner ? await pinnedPanels(ctx, user) : null}
256270 ${homeTabs("feed")}
257271 <div class="dash">
258272 <div class="dash-main stack">
259 ${onYouRegion(ctx, user, undefined, needsYou.body)} ${composer(ctx, user)}
273 ${owner ? null : onYouRegion(ctx, user, undefined, needsYou.body)} ${composer(ctx, user)}
260274 <div class="bar feed-head">
261275 <span class="spacer"></span>
262276 <a class="small muted" href="/asked">What you asked for</a>
src/web/studio/home_owner.ts added +94
@@ -0,0 +1,94 @@
1 /**
2 * The owner's home: the forge's vital signs, then the board panels the owner
3 * pinned, in their order. Never a list of what waits on the owner — that
4 * list is `/asks`, reached on purpose. The owner is a person who administers
5 * the forge (boards are theirs alone). `POST /home/panels` pins, unpins and
6 * moves a pinned panel; same-origin checked by `readForm`.
7 */
8 import { showBoard } from "../../actions/boards.ts";
9 import { movePin, pinPanel, pinsOf, unpinPanel } from "../../core/home_panels.ts";
10 import { readKpis, type Kpi } from "../../core/kpis.ts";
11 import type { User } from "../../core/users.ts";
12 import type { Ctx } from "../../http/context.ts";
13 import { BOOTED } from "../../release/gate.ts";
14 import { notFoundPage } from "../chrome.ts";
15 import { isLocalPath } from "../flash.ts";
16 import { field, readForm } from "../form.ts";
17 import { html, type Html } from "../html.ts";
18 import { flashTo } from "../layout.ts";
19 import { drawPanel } from "../pages/boards-view.ts";
20 import { isSlug } from "../../boards/store.ts";
21
22 /** A person who administers the forge: the one whose home is the vital signs. */
23 export const isOwner = (user: User): boolean => user.isAdmin && user.kind !== "agent";
24
25 function spark(counts: readonly number[]): Html {
26 const top = Math.max(1, ...counts);
27 const pts = counts.map((n, i) => `${((i / (counts.length - 1)) * 100).toFixed(1)},${(18 - (n / top) * 16 - 1).toFixed(1)}`);
28 return html`<svg viewBox="0 0 100 18" preserveAspectRatio="none" aria-hidden="true"><polyline points="${pts.join(" ")}" /></svg>`;
29 }
30
31 function tile(k: Kpi): Html {
32 return html`<li><a class="kpi" id="kpi-${k.key}" href="${k.href}">
33 <span class="kpi-label">${k.label}</span>
34 <span class="kpi-value">${k.value}</span>
35 ${k.spark ? spark(k.spark) : null}
36 <span class="kpi-note">${k.note}</span>
37 </a></li>`;
38 }
39
40 export function kpiRow(ctx: Ctx, user: User): Html {
41 const kpis = readKpis(ctx.app.db, ctx.app.config.dataDir, user.id, BOOTED);
42 return html`<ul class="kpis" aria-label="How the forge is">${kpis.map(tile)}</ul>`;
43 }
44
45 const IDX = /^\d{1,2}$/;
46
47 /** The pinned panels, drawn; a pin whose board or panel is gone is skipped. */
48 export async function pinnedPanels(ctx: Ctx, user: User): Promise<Html | null> {
49 const pins = pinsOf(ctx.app.db, user.id);
50 const cards: Html[] = [];
51 for (const pin of pins) {
52 const shown = await showBoard(ctx.app, user, pin.slug);
53 const panel = shown.ok ? shown.value.panels[pin.index] : undefined;
54 if (!shown.ok || panel === undefined) continue;
55 const act = (action: string, label: string) =>
56 html`<button class="btn btn-sm btn-ghost" name="action" value="${action}">${label}</button>`;
57 cards.push(
58 drawPanel(ctx.app, shown.value, panel, html`<form method="post" action="/home/panels" class="inline">
59 <input type="hidden" name="slug" value="${pin.slug}" /><input type="hidden" name="index" value="${String(pin.index)}" />
60 <input type="hidden" name="back" value="/" />
61 ${act("up", "Up")} ${act("down", "Down")} ${act("unpin", "Unpin")}
62 </form>`),
63 );
64 }
65 return cards.length === 0 ? null : html`<section class="bgrid home-pins" aria-label="Pinned panels">${cards}</section>`;
66 }
67
68 // POST /home/panels
69 export async function homePanels(ctx: Ctx): Promise<Response> {
70 const form = await readForm(ctx, "admin");
71 if (form instanceof Response) return form;
72 const user = ctx.auth.user;
73 if (user === undefined || !isOwner(user)) return notFoundPage(ctx);
74 const slug = field(form, "slug");
75 const index = field(form, "index");
76 const action = field(form, "action");
77 const asked = field(form, "back");
78 const back = isLocalPath(asked) ? asked : "/";
79 if (!isSlug(slug) || !IDX.test(index)) return notFoundPage(ctx);
80 const pin = { slug, index: Number(index) };
81 const db = ctx.app.db;
82 if (action === "pin") {
83 const shown = await showBoard(ctx.app, user, slug);
84 if (!shown.ok || shown.value.panels[pin.index] === undefined) return notFoundPage(ctx);
85 return pinPanel(db, user.id, pin)
86 ? flashTo(ctx, back, { message: "Pinned to home." })
87 : flashTo(ctx, back, { tone: "danger", message: "Too many pins; unpin one first." });
88 }
89 if (action === "unpin") unpinPanel(db, user.id, pin);
90 else if (action === "up") movePin(db, user.id, pin, -1);
91 else if (action === "down") movePin(db, user.id, pin, 1);
92 else return notFoundPage(ctx);
93 return flashTo(ctx, back, { message: action === "unpin" ? "Unpinned." : "Moved." });
94 }
src/web/style/content.ts +11
@@ -1311,4 +1311,15 @@ textarea.editor:focus { outline: none; }
13111311 .ask-more-acts[open] > summary { display: none; }
13121312 .ask-more-acts > .btn { min-height: 44px; flex: 1 1 auto; }
13131313 }
1314
1315 /* The owner's home: a row of vital signs that wraps, then pinned panels. */
1316 .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
1317 .kpi { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: inherit; text-decoration: none; min-width: 0; min-height: 84px; }
1318 .kpi:hover { border-color: var(--border-strong); }
1319 .kpi-label { display: block; font-size: 12px; color: var(--muted-fg); }
1320 .kpi-value { display: block; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
1321 .kpi-note { display: block; font-size: 12px; color: var(--muted-fg); }
1322 .kpi svg { display: block; width: 100%; height: 18px; }
1323 .kpi polyline { fill: none; stroke: currentColor; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
1324 .home-pins { margin-bottom: 16px; }
13141325 `;
test/asks-bulk.test.ts +1 −1
@@ -77,7 +77,7 @@ describe("acting on many asks at once", () => {
7777 const location = res.headers.get("location");
7878 if (res.status === 303 && location !== null) {
7979 expect(location).toStartWith("/?op=");
80 const next = await fetch(`${servers.url}${location}`, { headers, redirect: "manual" });
80 const next = await fetch(`${servers.url}${location}`, { headers, redirect: "follow" });
8181 expect(next.status).toBe(200);
8282 return (await next.text()).replace(/\s+/g, " ");
8383 }
test/asks-expiry.test.ts +7 −7
@@ -126,7 +126,7 @@ describe("asks that expire, hold and collapse", () => {
126126 pears = await botPull("pears", [{ path: "PEARS.md", content: "pears\n" }]);
127127 green(apples);
128128 green(pears);
129 const page = await get("/");
129 const page = await get("/asks");
130130 expect(sentence(page)).toBe("1 thing needs you");
131131 expect(headerCount(page)).toBe(1);
132132 expect(page).toContain("2 green changes wait for your look");
@@ -152,7 +152,7 @@ describe("asks that expire, hold and collapse", () => {
152152 // card at all, so there is nothing to mute.
153153 const fragment = await get("/live/feed");
154154 expect(fragment).not.toContain('data-kind="ask"');
155 const home = await get("/");
155 const home = await get("/asks");
156156 expect(home).toContain('<section id="needs-you"');
157157 const at = home.indexOf('<section id="needs-you"');
158158 expect(home.slice(at, home.indexOf("</section>", at))).not.toContain(
@@ -169,7 +169,7 @@ describe("asks that expire, hold and collapse", () => {
169169 repoId: repo.id,
170170 actorId: null,
171171 });
172 let page = await get("/");
172 let page = await get("/asks");
173173 expect(sentence(page)).toBe("All fine");
174174 expect(headerCount(page)).toBe(0);
175175 expect(askLinesFor(app.db, aliceUser)).toHaveLength(0);
@@ -179,7 +179,7 @@ describe("asks that expire, hold and collapse", () => {
179179 // A new check on one of them: that one asks again, on its own.
180180 await tick();
181181 green(apples);
182 page = await get("/");
182 page = await get("/asks");
183183 expect(sentence(page)).toBe("1 thing needs you");
184184 const pinned = page.slice(
185185 page.indexOf('<section id="needs-you"'),
@@ -203,7 +203,7 @@ describe("asks that expire, hold and collapse", () => {
203203 repoId: repo.id,
204204 actorId: null,
205205 });
206 expect(sentence(await get("/"))).toBe("All fine");
206 expect(sentence(await get("/asks"))).toBe("All fine");
207207 // The merge box is the change's Files step (#628).
208208 const change = await get(
209209 `/${repo.ownerName}/${repo.name}/pulls/${apples.number}/files`,
@@ -231,7 +231,7 @@ describe("asks that expire, hold and collapse", () => {
231231 });
232232 await sweepStaleAsks(app);
233233 expect(askLinesFor(app.db, aliceUser)).toHaveLength(0);
234 expect(sentence(await get("/"))).toBe("All fine");
234 expect(sentence(await get("/asks"))).toBe("All fine");
235235 // The feed and the MCP's asks carry no green line for it either.
236236 expect(
237237 readFeed(app.db, aliceUser, { limit: 50 }).items.some(
@@ -241,7 +241,7 @@ describe("asks that expire, hold and collapse", () => {
241241 expect(JSON.stringify(asksAnswer({ app, auth: { user: aliceUser } } as never, aliceUser))).not.toContain("is green");
242242 // Assigned to alice, the home's one list says it conflicts, never ready.
243243 setAssignee(app.db, plums.id, aliceUser.id);
244 const home = await get("/");
244 const home = await get("/asks");
245245 expect(home).toContain("conflicts with main");
246246 expect(askLinesFor(app.db, aliceUser).map((l) => l.waitingFor.word)).toEqual(["conflicts with main"]);
247247 // Its own page still says why it cannot ship.
test/asks-mute.test.ts +1 −1
@@ -60,7 +60,7 @@ describe("muting a repository's asks", () => {
6060 return ((await res.json()) as { rows: unknown[] }).rows;
6161 };
6262 const home = async () =>
63 await fetch(`${servers.url}/`, { headers: headers(cookie) }).then((r) => r.text());
63 await fetch(`${servers.url}/asks`, { headers: headers(cookie) }).then((r) => r.text());
6464
6565 const signIn = async (username: string) => {
6666 const res = await fetch(`${servers.url}/signin`, {
test/asks-rank.test.ts +4 −4
@@ -204,7 +204,7 @@ describe("asks that earn their place", () => {
204204 expect(row.words).toEqual(ASK_WORDS.look);
205205 expect(row.words.options.length).toBeGreaterThan(0);
206206 }
207 const asks = await page("/");
207 const asks = await page("/asks");
208208 expect(asks).toContain("If nobody acts, it waits; nothing ships.");
209209 expect(asks).toContain("<b>security</b>");
210210 // The long sentence the card used to repeat is gone.
@@ -236,7 +236,7 @@ describe("asks that earn their place", () => {
236236 for (const name of ["r4", "r5", "r6"])
237237 await greenPull(name, `Work in ${name}`);
238238 // What needs you is pinned on the home (#634): count its own cards.
239 const home = await page("/");
239 const home = await page("/asks");
240240 const asks = home.slice(home.indexOf('<section id="needs-you"'));
241241 const cards = (s: string) => (s.match(/class="card[" ]/g) ?? []).length;
242242 // Two before the phone's "more", three more inside it before the wide
@@ -340,7 +340,7 @@ describe("asks that earn their place", () => {
340340 expect((await mcpAsks()).measure.raised).toBe(6);
341341 });
342342 test("a phone's ask is a full-width row: kind and repo on one line, the decider apart, the rest behind More", async () => {
343 const home = await page("/");
343 const home = await page("/asks");
344344 const asks = home.slice(home.indexOf('<section id="needs-you"'));
345345 expect(asks).toContain("ask-card");
346346 expect(asks).toContain('<b class="ask-kind">');
@@ -357,7 +357,7 @@ describe("asks that earn their place", () => {
357357 // The security pull went red above; a new green one joins it in a row of two.
358358 check(security, "ok");
359359 await greenPull("security", "Another change here");
360 const asks = await page("/");
360 const asks = await page("/asks");
361361 expect(asks).toContain("2 green changes wait for your look");
362362 expect(asks).toContain("<b>security</b>: \u201cWiden the board id\u201d");
363363 // On a phone the row is its head line, its two asks one tap away; a
test/asks-waiting-for.test.ts +1 −1
@@ -150,7 +150,7 @@ describe("the word on a row", () => {
150150 expect(text).toContain("ready to land");
151151 expect(text).toContain("waitingFor");
152152
153 const page = await (await fetch(`${servers.url}/`, { headers: { cookie } })).text();
153 const page = await (await fetch(`${servers.url}/asks`, { headers: { cookie } })).text();
154154 expect(page).toContain('data-waiting="ready to land"');
155155 expect(page).toContain('<span class="sr-only">waiting for </span>ready to land');
156156 expect(page).toContain("ready to land · on you");
test/asks.test.ts +10 −10
@@ -104,10 +104,10 @@ describe("the asks page", () => {
104104 });
105105
106106 test("when nothing asks, it says All fine, and so does the header", async () => {
107 const page = await get(alice, "/");
107 const page = await get(alice, "/asks");
108108 expect(sentence(page)).toBe("All fine");
109109 expect(headerCount(page)).toBe(0);
110 expect(await get(alice, "/")).not.toContain('<section id="needs-you"');
110 expect(await get(alice, "/asks")).not.toContain('<section id="needs-you"');
111111 });
112112
113113 test("/asks lands on the home's pinned needs-you, and a signed-out reader there gets the door, no asks", async () => {
@@ -146,7 +146,7 @@ describe("the asks page", () => {
146146 claimRun(app.db, run.id);
147147 finishRun(app.db, run.id, { state: "failed", summary: "red" });
148148 // Failed but the crew is still trying: that is working, not an ask.
149 expect(sentence(await get(alice, "/"))).toBe("All fine");
149 expect(sentence(await get(alice, "/asks"))).toBe("All fine");
150150 recordDecision(app.db, {
151151 kind: "retry",
152152 repoId: repo.id,
@@ -157,13 +157,13 @@ describe("the asks page", () => {
157157 by: "rule",
158158 ms: 1,
159159 });
160 const page = await get(alice, "/");
160 const page = await get(alice, "/asks");
161161 expect(sentence(page)).toBe("1 thing needs you");
162162 expect(page).toContain("Bot did a thing");
163163 expect(headerCount(page)).toBe(1);
164164 // The home counts it in the header's Asks link; the dev dashboard's
165165 // own "needs you" line went with the dashboard (#625).
166 const home = await get(alice, "/");
166 const home = await get(alice, "/asks");
167167 expect(headerCount(home)).toBe(1);
168168 // Bob can read the public repository but cannot write it: not his ask.
169169 expect(sentence(await get(bob, "/"))).toBe("All fine");
@@ -174,7 +174,7 @@ describe("the asks page", () => {
174174 app.db
175175 .query("UPDATE run SET created_at = ?1 WHERE state = 'queued'")
176176 .run(new Date(Date.now() - 3 * 3_600_000).toISOString());
177 const admin = await get(alice, "/");
177 const admin = await get(alice, "/asks");
178178 expect(admin).toContain("behind one lane");
179179 expect(sentence(admin)).toBe("2 things need you");
180180 expect(headerCount(admin)).toBe(2);
@@ -224,17 +224,17 @@ describe("the asks page", () => {
224224 ms: 1,
225225 });
226226 const card = `id="ask-stopped:${pull.id}"`;
227 expect(await get(alice, "/")).toContain(card);
227 expect(await get(alice, "/asks")).toContain(card);
228228 // The re-run passes: the stop is answered, and the pull is green.
229229 check("ok");
230230 resolveOpen(app.db, pull.id, "retry", "green");
231 const green = await get(alice, "/");
231 const green = await get(alice, "/asks");
232232 expect(green).not.toContain(card);
233233 expect(green).toContain(`id="ask-look:${pull.id}"`);
234234 // Red again, before anything new is decided: the old stop is spent, and
235235 // the crew's tries are what the card is counted from.
236236 check("failed");
237 expect(await get(alice, "/")).not.toContain(card);
237 expect(await get(alice, "/asks")).not.toContain(card);
238238 });
239239
240240 test("a green change's card says what its tests did", async () => {
@@ -309,7 +309,7 @@ describe("the asks page", () => {
309309 expect(card.says).toContain("alice");
310310 expect(card.says).toContain("checks.concurrency");
311311 expect(ASK_WORDS.setting.options).toEqual(["Keep", "Put back"]);
312 const page = await get(alice, "/");
312 const page = await get(alice, "/asks");
313313 expect(page).toContain("Keep");
314314 expect(page).toContain("Put back");
315315 // not for a person who cannot put it back
test/holds.test.ts +1 −1
@@ -741,7 +741,7 @@ describe("a hold is set, shown and lifted", () => {
741741 // What needs you, pinned on the home (#634), is the part to read: the
742742 // feed below it may well mention the change as news.
743743 const asks = async (cookie: string) => {
744 const home = await page("/", cookie);
744 const home = await page("/asks", cookie);
745745 const at = home.indexOf('<section id="needs-you"');
746746 return at === -1 ? "" : home.slice(at, home.indexOf("</section>", at));
747747 };
test/home-kpis.test.ts added +149
@@ -0,0 +1,149 @@
1 /**
2 * The owner's home (#2665): KPIs read live, never a to-do list; a board
3 * panel pinned to it appears under them in order, and unpinning removes it.
4 * The asks stay one deliberate step away, on /asks.
5 */
6 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { createApp } from "../src/app.ts";
11 import { makeBoard, changeBoard } from "../src/actions/boards.ts";
12 import { landingsByHour, medianCheckMs, readKpis } from "../src/core/kpis.ts";
13 import { movePin, pinPanel, pinsOf, unpinPanel } from "../src/core/home_panels.ts";
14 import { createToken } from "../src/core/tokens.ts";
15 import { createUser } from "../src/core/users.ts";
16 import { serve } from "../src/http/server.ts";
17
18 let dir: string;
19 let app: ReturnType<typeof createApp>;
20 let servers: Awaited<ReturnType<typeof serve>>;
21 let admin: { id: string };
22 const tok: Record<string, string> = {};
23 const get = (path: string, who: string) =>
24 fetch(servers.url + path, { headers: { authorization: `Bearer ${tok[who]}` }, redirect: "manual" });
25 const post = (path: string, who: string, body: Record<string, string>) =>
26 fetch(servers.url + path, {
27 method: "POST",
28 headers: { authorization: `Bearer ${tok[who]}`, "content-type": "application/x-www-form-urlencoded" },
29 body: new URLSearchParams(body),
30 redirect: "manual",
31 });
32
33 beforeAll(async () => {
34 dir = await mkdtemp(join(tmpdir(), "forge-home-kpis-"));
35 app = createApp({ dataDir: dir, port: 0 });
36 servers = await serve(app);
37 const mk = async (username: string, adminIfFirst?: boolean) => {
38 const r = await createUser(app.db, {
39 origin: "seed", trusted: true, username, email: `${username}@forge.local`,
40 password: "a-good-passphrase", ...(adminIfFirst ? { adminIfFirst } : {}),
41 });
42 if (!r.ok) throw new Error(r.error);
43 return r.value;
44 };
45 const alice = await mk("alice", true);
46 const bob = await mk("bob");
47 admin = alice;
48 tok.admin = createToken(app.db, alice.id, "t", "admin").token;
49 tok.bob = createToken(app.db, bob.id, "t", "admin").token;
50 const made = await makeBoard(app, alice, "Speed");
51 if (!made.ok) throw new Error(String(made.error));
52 const added = await changeBoard(app, alice, made.value, {
53 kind: "add",
54 panel: { title: "Runs a day", chart: "bar", query: { source: "runs", aggregate: "count", groupBy: { bucket: "day" } }, w: 1, h: 1 },
55 });
56 if (!added.ok) throw new Error(String(added.error));
57 });
58
59 afterAll(async () => {
60 servers.stop();
61 app.close();
62 await rm(dir, { recursive: true, force: true });
63 });
64
65 describe("the owner's home", () => {
66 test("shows the six KPIs, each linking to where it comes from, and no asks list", async () => {
67 const res = await get("/", "admin");
68 expect(res.status).toBe(200);
69 const body = await res.text();
70 for (const k of ["landings", "live", "check", "builders", "spend", "backup"])
71 expect(body).toMatch(new RegExp(`id="kpi-${k}" href="/[^"]+"`));
72 expect(body).not.toContain('id="needs-you"');
73 expect(body).not.toContain('id="live-on-you"');
74 expect(body).not.toContain("asks-sentence");
75 });
76
77 test("the asks stay reachable on /asks, and a receipt on / goes there", async () => {
78 const asks = await get("/asks", "admin");
79 expect(asks.status).toBe(200);
80 expect(await asks.text()).toContain("asks-sentence");
81 const receipt = await get("/?op=x", "admin");
82 expect(receipt.status).toBe(303);
83 expect(receipt.headers.get("location")).toBe("/asks?op=x");
84 });
85
86 test("another person's home keeps its asks list region", async () => {
87 expect(await (await get("/", "bob")).text()).toContain('id="live-on-you"');
88 });
89
90 test("a pinned panel appears on home, in order, and unpinning removes it", async () => {
91 const board = await (await get("/boards/speed", "admin")).text();
92 expect(board).toContain("Pin to home");
93 const pinned = await post("/home/panels", "admin", { slug: "speed", index: "0", action: "pin", back: "/boards/speed" });
94 expect(pinned.status).toBe(303);
95 expect(pinned.headers.get("location")).toStartWith("/boards/speed");
96 expect(await (await get("/boards/speed", "admin")).text()).toContain("Unpin from home");
97 const home = await (await get("/", "admin")).text();
98 expect(home).toContain("Runs a day");
99 expect(home).toContain('aria-label="Pinned panels"');
100 await post("/home/panels", "admin", { slug: "speed", index: "0", action: "unpin" });
101 expect(await (await get("/", "admin")).text()).not.toContain("Runs a day");
102 });
103
104 test("pinning is the owner's alone, same-origin only, and names a real panel", async () => {
105 expect((await post("/home/panels", "bob", { slug: "speed", index: "0", action: "pin" })).status).toBe(404);
106 expect((await post("/home/panels", "admin", { slug: "speed", index: "7", action: "pin" })).status).toBe(404);
107 expect((await post("/home/panels", "admin", { slug: "../x", index: "0", action: "pin" })).status).toBe(404);
108 const cross = await fetch(servers.url + "/home/panels", {
109 method: "POST",
110 headers: { authorization: `Bearer ${tok.admin}`, origin: "https://evil.example", "content-type": "application/x-www-form-urlencoded" },
111 body: new URLSearchParams({ slug: "speed", index: "0", action: "pin" }),
112 });
113 expect(cross.status).toBe(403);
114 expect(pinsOf(app.db, admin.id)).toEqual([]);
115 const off = await post("/home/panels", "admin", { slug: "speed", index: "0", action: "pin", back: "//evil.example" });
116 expect(off.headers.get("location")).toStartWith("/");
117 expect(off.headers.get("location")).not.toStartWith("//");
118 unpinPanel(app.db, admin.id, { slug: "speed", index: 0 });
119 });
120
121 test("pins keep the owner's order and a pin that does not fit is refused", () => {
122 expect(pinPanel(app.db, admin.id, { slug: "a", index: 0 })).toBe(true);
123 expect(pinPanel(app.db, admin.id, { slug: "b", index: 1 })).toBe(true);
124 movePin(app.db, admin.id, { slug: "b", index: 1 }, -1);
125 expect(pinsOf(app.db, admin.id).map((p) => p.slug)).toEqual(["b", "a"]);
126 const fits = ["x", "y", "z", "w", "v"].map((c) => pinPanel(app.db, admin.id, { slug: c.repeat(40), index: 0 }));
127 expect(fits).toContain(false);
128 expect(fits[0]).toBe(true);
129 });
130 });
131
132 describe("the KPIs", () => {
133 test("landings count merged pulls by hour; the median check is of finished checks", () => {
134 const now = Date.parse("2026-10-19T12:30:00Z");
135 app.db.run("INSERT INTO repo (id, owner_id, name) VALUES ('rk', ?, 'k')", [admin.id]);
136 const run = app.db.prepare(
137 "INSERT INTO run (id, repo_id, kind, state, created_at, started_at, finished_at) VALUES (?1, 'rk', 'check', 'ok', ?2, ?2, ?3)",
138 );
139 run.run("c1", "2026-10-19T11:00:00.000Z", "2026-10-19T11:00:10.000Z");
140 run.run("c2", "2026-10-19T11:10:00.000Z", "2026-10-19T11:10:30.000Z");
141 run.run("c3", "2026-10-19T11:20:00.000Z", "2026-10-19T11:21:00.000Z");
142 expect(medianCheckMs(app.db, now)).toBe(30_000);
143 expect(landingsByHour(app.db, now)).toHaveLength(24);
144 const kpis = readKpis(app.db, dir, admin.id, "2026-10-19T12:00:00.000Z", now);
145 expect(kpis.find((k) => k.key === "check")?.value).toBe("30s");
146 expect(kpis.find((k) => k.key === "backup")?.value).toBe("none");
147 expect(kpis.find((k) => k.key === "live")?.note).toBe("live 30 min ago");
148 });
149 });
test/review-wait.test.ts +1 −1
@@ -34,7 +34,7 @@ describe("a green agent pull and its reviewer", () => {
3434
3535 const home = async (): Promise<string> =>
3636 (
37 await (await fetch(`${servers.url}/`, { headers: { cookie } })).text()
37 await (await fetch(`${servers.url}/asks`, { headers: { cookie } })).text()
3838 ).replace(/\s+/g, " ");
3939 const wordCtx = (): WordCtx => ({ db: app.db }) as unknown as WordCtx;
4040
test/studio-door.test.ts +6 −2
@@ -613,7 +613,10 @@ describe("the studio home keeps itself current", () => {
613613 expect(res.headers.get("referrer-policy")).toBe("same-origin");
614614 const home = await res.text();
615615 expect(home).toMatch(/id="live-apps"\s*\n?\s*data-live="/);
616 expect(home).toMatch(/id="live-on-you"\s*\n?\s*data-live="/);
616 // The owner's home lists nothing that waits on them; /asks does.
617 expect(home).not.toContain('id="live-on-you"');
618 const asks = await (await fetch(`${base}/asks`, { headers: { cookie: `${cookie}; forge_mode=studio` } })).text();
619 expect(asks).toMatch(/id="live-on-you"\s*\n?\s*data-live="/);
617620 expect(home).toContain("new EventSource('/events')");
618621 expect(home).toContain("Write the README");
619622 });
@@ -628,7 +631,8 @@ describe("the studio home keeps itself current", () => {
628631 test("each region on the home has an address of its own, answering with that region alone and 304 when it has not changed", async () => {
629632 const page = await (await get()).text();
630633 expect(page).toContain('data-live-src="/live/apps"');
631 expect(page).toContain('data-live-src="/live/on-you"');
634 const asks = await (await fetch(`${base}/asks`, { headers: { cookie: `${cookie}; forge_mode=studio` } })).text();
635 expect(asks).toContain('data-live-src="/live/on-you"');
632636
633637 const headers = { cookie: `${cookie}; forge_mode=studio` };
634638 const apps = await fetch(`${base}/live/apps`, { headers });
test/web-apps.test.ts +1 −1
@@ -824,7 +824,7 @@ describe("apps, runs and the crew on the web", () => {
824824 form: { assignee: "alice" },
825825 });
826826 expect(assigned.status).toBe(303);
827 const dash = await bodyOf(alice, "/");
827 const dash = await bodyOf(alice, "/asks");
828828 expect(dash).toContain('<section id="needs-you"');
829829 expect(dash).toMatch(/<h2 id="asks-sentence">\d+ things? needs? you<\/h2>/);
830830 expect(dash).toContain("Say hello");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs