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

Home: a crew scorecard (landed, first-pass green, rework rate per member) and a streak of days without a red main, shown never notified #16885

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16849-home-a-crew-scorecard-landed-first-pass → main 0 commits fork 4 threads · 4 unresolved

  • Merged. scout/16849-home-a-crew-scorecard-landed-first-pass was merged into main as a47fae8.

Review

Sign in to review this change.
9 files changed +330 −5
docs/design/areas/home-flow.md +4
@@ -47,3 +47,7 @@ One section under the lanes or the table (`web/pages/home_figures.ts`), an admin
4747 - `.fg-chart`, `.fg-svg`, `.fg-line`, `.fg-area`, `.fg-base`, `.fg-dot`, `.fg-axis` — the one chart: a line over a faint area in the accent, scaled from zero to the series' own peak, a day with no value breaking the line; its two ends named underneath (`14 days ago`, `today`); a card with no daily series keeps the same 32px, empty.
4848 - `.fs`, `.fs-sum`, `.fs-svg`, `.fs-bar`, `.fs-count`, `.fs-base`, `.fs-h`, `.fs-slow`, `.fs-item`, `.fs-took`, `.fs-why`, `.fs-assume` — ship time under the cards (`web/pages/home_ship.ts`): a disclosure whose summary is the sentence (44px), a histogram drawn as SVG on the server in the muted foreground (seven fixed ranges, counts above the bars), the slowest tenth as a list of links with what the time went to, and the assumptions in a muted line. Closed by default; the live region reserves its row.
4949 - `.fg-reading` — the line a region shows before the first reading.
50
51 ## The crew card
52
outdated

Update this once .cc loses its border: it should not describe the card as a bordered section.

53 Inside the figures' live region, under the ship section (`crewSection` in `web/pages/home_figures.ts`), an admin's: `.cc` is a plain section with a 16px margin above it, no border or box; `.cc-title` its name, `.cc-streak` the days without a red main, the members as the shared bare `rowList` of `row`s (each a link to the member's page, the figures in words), and `.cc-empty` the calm sentence when nothing landed.
docs/design/attention-budget.json +5 −5
@@ -1,16 +1,16 @@
11 {
22 "home": {
33 "390": {
4 "words": 339,
5 "blocks": 55,
4 "words": 352,
5 "blocks": 58,
66 "colours": 7
77 },
88 "1280": {
9 "words": 339,
10 "blocks": 55,
9 "words": 352,
10 "blocks": 58,
1111 "colours": 7
1212 },
13 "note": "Raised by 11 words and 1 block for the first-week line (To start: three links), shown to an admin in a forge's first week only (#13460); by 27 words and 4 blocks for the Ship time card and its one-line disclosure (#14649); and by 15 words and 1 block for the slots under the lanes, an admin's figures to set from the keyboard (Bridge v1)."
13 "note": "Raised by 11 words and 1 block for the first-week line (To start: three links), shown to an admin in a forge's first week only (#13460); by 27 words and 4 blocks for the Ship time card and its one-line disclosure (#14649); and by 15 words and 1 block for the slots under the lanes, an admin's figures to set from the keyboard (Bridge v1); and by 13 words and 3 blocks for the Crew card under the ship time (#16849)."
1414 },
1515 "repository": {
1616 "390": {
docs/features/living-home.md +6
@@ -21,3 +21,9 @@ The feed — the composer, the timeline, what is on you, since you were here —
2121 - **Slots** in "Crew running" are `crew.concurrency` (`crewConcurrency` in `src/flow/slot_cap.ts`), or the repositories' slots when those are fewer. Home and the terminal read the same figure.
2222 - **Dropped on purpose** from the old tiles: the ones the strip or a lane already says (shipped per hour, the live version, builders running, the week), and the Traffic, Reporting browsers and Accounts tiles; the same numbers stay on `/settings/traffic`, `/boards/reach` and the KPI probe.
2323 - **Page speed** shows the 75th-percentile page load and, under it, `LCP … · INP …` over seven days from the first-party beacon: LCP is how long the main content takes to show, INP how long a tap takes to answer.
24
25 ## The crew card (#16849)
26
27 Under the figures, an admin's one card, "Crew, last 30 days": the days without a red main (`3 days without a red main`; "Main is red now" while it is), then a row per crew member who landed something: `4 landed · 75% green first pass · 25% rework`, each row a link to that member's page (`/settings/crew/<name>`). *First pass green* is the share of its landed pulls whose first finished check was green; *rework* the share that drew a change request or a revert; the counts are the scorecard's (`crewScorecards`). A forge where nothing landed says so in one calm sentence. It is shown, never notified: no alarm, no toast. A worker reads it with the figures (`src/flow/crew_card.ts`, every 30 s), so a request reads memory and the card redraws with the figures' region; nothing polls.
28
29 The terminal's home carries the same lines for an admin, under the figures: the streak, then one line per member (`src/flow/crew_card.ts`, `crewCardLines`).
src/flow/crew_card.ts added +136
@@ -0,0 +1,136 @@
1 /**
2 * The crew card (#16849): per crew member, over the last `RECENT_DAYS`, the pulls that landed, the
3 * share of those whose first finished check was green, and the share that needed rework (a change
4 * requested, or taken back by a merged pull); and beside them the days since main last went red.
5 * Plain data: the lanes' worker reads it with the slow part and keeps it 30 s for the page; the
6 * terminal dashboard reads it on each render (a handful of indexed queries).
7 *
8 * The counts are the scorecard's (`core/scorecard.ts`, the pulls an agent opened in the window and
9 * their landings); only the two shares are read here, over the same pulls. Never notified: it is a
10 * card to look at, not an alarm (`alarm_red_main.ts` is the alarm).
11 */
12
13 import type { Database } from "bun:sqlite";
14 import { crewScorecards, recentWindow, RECENT_DAYS } from "../core/scorecard.ts";
15 import { getRepo } from "../core/repos.ts";
16 import { ownRepoPath } from "../kernel/own_repo.ts";
17
18 export interface CrewRow {
19 readonly username: string;
20 /** Pulls it opened in the window that merged. */
21 readonly landed: number;
22 /** Of those, the share (0–1) whose first finished check was green. */
23 readonly firstPassGreen: number;
24 /** Of those, the share (0–1) that drew a change request or a revert. */
25 readonly rework: number;
26 }
27
28 export interface CrewCard {
29 /** Members who landed something in the window, most landed first. */
30 readonly rows: readonly CrewRow[];
31 /** Whole days since main's last red check; null when main has no check on record. */
32 readonly streakDays: number | null;
33 /** Main's latest finished check is red: the streak is broken now, whatever `streakDays` says. */
34 readonly red: boolean;
35 readonly days: number;
outdated

A cap added with nothing asking for it. Remove it, or justify it in the pull.

36 }
37
38 const DAY_MS = 86_400_000;
39
40 export function readCrewCard(db: Database, now: Date): CrewCard {
41 const window = recentWindow(now.getTime());
42 const cards = crewScorecards(db, window);
43 const since = window.since!.toISOString();
44 const shares = new Map(
45 db
46 .query<{ id: string; username: string; green: number; reworked: number }, [string]>(
47 `SELECT user.id AS id, user.username AS username,
48 SUM(COALESCE((SELECT run.state = 'ok' FROM run
49 WHERE run.issue_id = issue.id AND run.kind = 'check'
50 AND run.state IN ('ok', 'failed')
51 ORDER BY run.id LIMIT 1), 0)) AS green,
52 SUM(EXISTS (SELECT 1 FROM review
53 WHERE review.issue_id = issue.id AND review.state = 'changes_requested')
54 OR EXISTS (SELECT 1 FROM pull AS back
55 WHERE back.reverts_issue_id = issue.id
56 AND back.merged_at IS NOT NULL)) AS reworked
57 FROM issue
58 JOIN pull ON pull.issue_id = issue.id AND pull.merged_at IS NOT NULL
59 JOIN user ON user.id = issue.author_id AND user.is_agent = 1
60 WHERE issue.created_at >= ?1
61 GROUP BY user.id`,
62 )
63 .all(since)
64 .map((r) => [r.id, r]),
65 );
66 const rows: CrewRow[] = [];
67 for (const [id, card] of cards) {
68 const s = shares.get(id);
69 if (s === undefined || card.landed === 0) continue;
70 rows.push({
71 username: s.username,
72 landed: card.landed,
73 firstPassGreen: s.green / card.landed,
74 rework: s.reworked / card.landed,
75 });
76 }
77 rows.sort((a, b) => b.landed - a.landed || a.username.localeCompare(b.username));
78 return { rows, ...streak(db, now), days: RECENT_DAYS };
79 }
80
81 /** Whole days main has gone without a red check, from its own repository's default branch. */
82 function streak(db: Database, now: Date): { streakDays: number | null; red: boolean } {
83 const none = { streakDays: null, red: false };
84 const [owner, name] = ownRepoPath().split("/");
85 const repo = owner && name ? getRepo(db, owner, name) : undefined;
86 if (repo === undefined) return none;
87 const main = (state: string): string => `SELECT MAX(r.id) AS id, MAX(COALESCE(r.finished_at, r.created_at)) AS at
88 FROM run r WHERE r.repo_id = ?1 AND r.kind = 'check' AND r.issue_id IS NULL
89 AND r.env = ?2 AND r.state ${state}`;
90 const args: [string, string] = [repo.id, repo.defaultBranch];
91 const last = db.query<{ id: string | null; at: string | null }, [string, string]>(main("IN ('ok', 'failed')")).get(...args);
92 if (last?.id == null) return none;
93 const red = db.query<{ id: string | null; at: string | null }, [string, string]>(main("= 'failed'")).get(...args);
94 if (red?.id == null) {
95 const first = db
96 .query<{ at: string | null }, [string, string]>(
97 `SELECT MIN(COALESCE(r.finished_at, r.created_at)) AS at FROM run r
98 WHERE r.repo_id = ?1 AND r.kind = 'check' AND r.issue_id IS NULL AND r.env = ?2`,
99 )
100 .get(...args);
101 return first?.at == null ? none : { streakDays: wholeDays(now, first.at), red: false };
102 }
103 // The latest finished check is the red one: main is red now.
104 if (red.id === last.id) return { streakDays: 0, red: true };
105 return { streakDays: wholeDays(now, red.at!), red: false };
106 }
107
108 const wholeDays = (now: Date, iso: string): number => Math.max(0, Math.floor((now.getTime() - Date.parse(iso)) / DAY_MS));
outdated

Principle 8: "Main is red now, or went red today" is two answers in one sentence. Separate red-now from a zero-day streak (streakDays cannot tell them apart) and say one plain thing for each.

109
110 const pct = (share: number): string => `${Math.round(share * 100)}%`;
111
112 /** The streak in words: both doors say it the same way. */
113 export function streakWords(days: number | null, red: boolean): string {
114 if (red) return "Main is red now";
115 if (days === null) return "No main check on record yet";
116 if (days === 0) return "Main went red today";
117 return `${days} ${days === 1 ? "day" : "days"} without a red main`;
118 }
119
120 /** A member's line in words. */
121 export function rowWords(r: CrewRow): string {
122 return `${r.landed} landed · ${pct(r.firstPassGreen)} green first pass · ${pct(r.rework)} rework`;
123 }
124
125 /** The empty card's sentence. */
126 export const CREW_EMPTY = "Nothing has landed from the crew in the last 30 days.";
127
128 /** The card as terminal lines: the streak, then a line per member; or the calm empty sentence. */
129 export function crewCardLines(card: CrewCard): string[] {
130 // A forge with no main check and no landed work has nothing to say here.
131 if (card.rows.length === 0 && card.streakDays === null) return [];
132 const head = `Crew, ${card.days} days: ${streakWords(card.streakDays, card.red)}`;
133 // Empty is one line, so a quiet forge's dashboard keeps its height.
134 if (card.rows.length === 0) return [`${head}. ${CREW_EMPTY}`];
135 return [head, ...card.rows.map((r) => ` ${r.username}: ${rowWords(r)}`)];
136 }
src/flow/figures.ts +7
@@ -14,6 +14,7 @@ import { readRuns, tally } from "../maintain/effect.ts";
1414 import type { Database } from "bun:sqlite";
1515 import { median } from "./pipeline.ts";
1616 import type { Kpis } from "./kpis.ts";
17 import { readCrewCard, type CrewCard } from "./crew_card.ts";
1718 import { readShipTime, type ShipTime } from "./ship_time.ts";
1819
1920 /** Days the daily series cover, today last. */
@@ -39,6 +40,11 @@ export interface Figures {
3940 * (`maintain/effect.ts`).
4041 */
4142 readonly maintenance?: { readonly open: number; readonly fixed: number };
43 /**
44 * The crew card: landed, first-pass green and rework per member, and the red-main streak
45 * (`crew_card.ts`).
46 */
47 readonly crew?: CrewCard;
4248 readonly backup: { readonly at: string | null; readonly state: "green" | "red" | "unknown" | null; readonly note: string };
4349 }
4450
@@ -98,6 +104,7 @@ export function readFigures(db: Database, now: Date, kpis: Kpis): Figures {
98104 spend: { todayUsd: kpis.spend.todayUsd, ceilingUsd: kpis.spend.ceilingUsd, days: spend, totalUsd: spend.reduce((a, b) => a + b, 0) },
99105 checks: { medianMs: kpis.medianCheckMs, days: keys.map((k) => median(took.get(k) ?? [])) },
100106 ship: readShipTime(db, now),
107 crew: readCrewCard(db, now),
101108 maintenance: tally(readRuns(db), now),
102109 bugs: kpis.bugs === undefined ? null : { open: kpis.bugs.open, overdue: kpis.bugs.overdue },
103110 backup: { at: kpis.backupAt, state: backupState, note: kpis.backup?.note ?? "" },
src/tui/screens/dashboard.ts +2
@@ -152,6 +152,7 @@ import { issueScreen } from "./issue.ts";
152152 import { listPinned } from "../../actions/board-pins.ts";
153153 import { migrateScreen } from "./migrate.ts";
154154 import { newRepoScreen } from "./newrepo.ts";
155 import { crewCardLines, readCrewCard } from "../../flow/crew_card.ts";
155156 import { firedAlarms } from "../../flow/alarms.ts";
156157 import { lastClearedNote } from "../../flow/clog_tick.ts";
157158 import { forgeCeiling } from "../../flow/ceiling.ts";
@@ -588,6 +589,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
588589 ...kpiLines(readKpis(f.db, now, { ...kpiForge(f.app), idle: () => idleReason(f.app, now) }), commit === null ? null : { sha: commit, since: ago(BOOTED) }),
589590 ...shipTimeLines(f.db, now),
590591 vitalsLine(readVitals(f.db, now)),
592 ...crewCardLines(readCrewCard(f.db, now)),
591593 ...firedAlarms(f.db, now, { ceilingUsd: forgeCeiling(f.app.config), dataDir: f.app.config.dataDir }).map((a) => a.says),
592594 ...(cleared === undefined ? [] : [cleared]),
593595 ];
src/web/pages/home_figures.ts +18
@@ -22,7 +22,9 @@ import {
2222 } from "../../flow/figure_format.ts";
2323 import type { Figures } from "../../flow/figures.ts";
2424 import type { LanePicture } from "../../flow/lanes.ts";
25 import { row, rowList } from "../ui.ts";
2526 import { html, raw, type Html } from "../html.ts";
27 import { CREW_EMPTY, rowWords, streakWords, type CrewCard } from "../../flow/crew_card.ts";
2628 import { shipSection } from "./home_ship.ts";
2729
2830 /** The events that change a figure; they change by the minute, so these are few. */
@@ -253,6 +255,21 @@ export function cards(f: Figures, now: number): Card[] {
253255 ];
254256 }
255257
258 /**
259 * The crew card: the red-main streak, then a row per member linking to their page; calm when empty.
260 * Shown, never notified.
261 */
262 export function crewSection(c: CrewCard | undefined): Html | null {
263 if (c === undefined) return null;
264 return html`<section class="cc" aria-labelledby="cc-title">
265 <h3 class="cc-title" id="cc-title">Crew, last ${c.days} days</h3>
266 <p class="cc-streak num">${streakWords(c.streakDays, c.red)}</p>
267 ${c.rows.length === 0
268 ? html`<p class="cc-empty muted">${CREW_EMPTY}</p>`
269 : rowList(c.rows.map((r) => row({ href: `/settings/crew/${encodeURIComponent(r.username)}`, title: r.username, meta: html`${rowWords(r)}` })), { bare: true, label: "Crew members" })}
270 </section>`;
271 }
272
256273 /** The cards in their grid: the live region's body. */
257274 export function figuresGrid(picture: LanePicture, now: number): Html {
258275 const f = picture.figures;
@@ -275,6 +292,7 @@ export function figuresGrid(picture: LanePicture, now: number): Html {
275292 >
276293 <div class="fg-grid">${cards(f, now).map(card)}</div>
277294 ${shipSection(f.ship)}
295 ${crewSection(f.crew)}
278296 </div>`;
279297 }
280298
src/web/pages/home_flow_style.ts +4
@@ -221,6 +221,10 @@ export const homeFlowCss = /* css */ `
221221 .fg-sum::-webkit-details-marker { display: none; }
222222 .fg-sum::before { content: ""; flex: none; width: 8px; height: 8px; margin-left: 4px; border-right: 1.5px solid var(--muted-fg); border-bottom: 1.5px solid var(--muted-fg); transform: rotate(-45deg); transition: transform var(--dur-2) var(--ease); }
223223 .fg[open] > .fg-sum::before { transform: rotate(45deg); }
224 .cc { margin-top: 16px; }
225 .cc-title { margin: 0; font-size: 14px; }
226 .cc-streak { margin: 4px 0 8px; }
227 .cc-empty { margin: 0; }
224228 .fg-title { margin: 0; font-size: 16px; }
225229 .fg-hint { font-size: var(--fs-min); color: var(--muted-fg); }
226230 .fg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
test/crew-card.test.ts added +148
@@ -0,0 +1,148 @@
1 /**
2 * The home's crew card (#16849): landed, first-pass green and rework per member, the red-main
3 * streak, calm when empty, an admin's alone, and drawn from the worker's picture.
4 */
5 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { createIssue } from "../src/core/issues.ts";
11 import { submitReview } from "../src/core/reviews.ts";
12 import { claimRun, createRun, finishRun } from "../src/core/runs.ts";
13 import { createUser, getUserByName } from "../src/core/users.ts";
14 import { createForgeApp } from "../src/tui/forge.ts";
15 import { dashboardScreen } from "../src/tui/screens/dashboard.ts";
16 import { headlessTerminal } from "../src/tui/term/terminal.ts";
17 import { settleApp } from "./helpers/tui.ts";
18 import { crewCardLines, readCrewCard, streakWords } from "../src/flow/crew_card.ts";
19 import { crewSection } from "../src/web/pages/home_figures.ts";
20 import { serve, type Servers } from "../src/http/server.ts";
21 import { adminCookie } from "./helpers/admin.ts";
22 import { quietLogs } from "./helpers/globals.ts";
23
24 quietLogs();
25
26 describe("the crew card", () => {
27 let dataDir: string;
28 let app: App;
29 let servers: Servers;
30 let repoId = "";
31 let agentId = "";
32 let adminId = "";
33 let cookie = "";
34 const prior = process.env.FORGE_SENTINEL_REPO;
35
36 function pull(authorId: string, merged: boolean): string {
37 const issue = createIssue(app.db, { repoId, authorId, title: "p", kind: "pull" });
38 if (!issue.ok) throw new Error(issue.error);
39 app.db
40 .query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at)
41 VALUES (?1, 'main', ?2, 'a', 'b', ?3)`)
42 .run(issue.value.id, `h${issue.value.number}`, merged ? new Date().toISOString() : null);
43 return issue.value.id;
44 }
45 function check(issueId: string | undefined, state: "ok" | "failed", at?: string): void {
46 const run = createRun(app.db, { repoId, kind: "check", ...(issueId ? { issueId } : { env: "main" }) });
47 claimRun(app.db, run.id);
48 finishRun(app.db, run.id, { state, summary: state });
49 if (at) app.db.query(`UPDATE run SET finished_at = ?2 WHERE id = ?1`).run(run.id, at);
50 }
51
52 beforeAll(async () => {
53 dataDir = await mkdtemp(join(tmpdir(), "forge-crewcard-"));
54 app = createApp({ dataDir, port: 0 });
55 servers = await serve(app);
56 cookie = await adminCookie(app, { username: "ada", email: "[email protected]", password: "analytical-engine" });
57 adminId = getUserByName(app.db, "ada")!.id;
58 const headers = { cookie, "content-type": "application/json" };
59 repoId = ((await fetch(`${servers.url}/api/v1/repos`, { method: "POST", headers, body: JSON.stringify({ name: "hello", visibility: "public" }) }).then((r) => r.json())) as { id: string }).id;
60 await fetch(`${servers.url}/api/v1/agents`, { method: "POST", headers, body: JSON.stringify({ username: "smith", model: "opus" }) });
61 agentId = getUserByName(app.db, "smith")!.id;
62 process.env.FORGE_SENTINEL_REPO = "ada/hello";
63 });
64 afterAll(async () => {
65 if (prior === undefined) delete process.env.FORGE_SENTINEL_REPO;
66 else process.env.FORGE_SENTINEL_REPO = prior;
67 servers.stop();
68 await rm(dataDir, { recursive: true, force: true });
69 });
70
71 test("empty: no rows, a calm sentence, no streak before any main check", () => {
72 const card = readCrewCard(app.db, new Date());
73 expect(card.rows).toEqual([]);
74 expect(card.streakDays).toBeNull();
75 expect(card.red).toBe(false);
76 expect(crewCardLines(card)).toEqual([]);
77 expect(String(crewSection(card))).toContain("Nothing has landed");
78 });
79
80 test("landed, first-pass green and rework per member, over merged pulls only", () => {
81 const a = pull(agentId, true);
82 check(a, "ok");
83 const b = pull(agentId, true);
84 check(b, "failed");
85 check(b, "ok");
86 const c = pull(agentId, true);
87 check(c, "ok");
88 submitReview(app.db, { issueId: c, authorId: adminId, state: "changes_requested", body: "no", commitOid: "b" });
89 const d = pull(agentId, true);
90 check(d, "ok");
91 pull(agentId, false); // not landed: not counted
92 const row = readCrewCard(app.db, new Date()).rows[0]!;
93 expect(row.username).toBe("smith");
94 expect(row.landed).toBe(4);
95 expect(row.firstPassGreen).toBeCloseTo(3 / 4);
96 expect(row.rework).toBeCloseTo(1 / 4);
97 expect(crewCardLines(readCrewCard(app.db, new Date()))[1]).toContain("4 landed · 75% green first pass · 25% rework");
98 expect(String(crewSection(readCrewCard(app.db, new Date())))).toContain('href="/settings/crew/smith"');
99 });
100
101 test("the streak counts days since main's last red; red now and red today read apart", () => {
102 const now = new Date();
103 check(undefined, "ok", new Date(now.getTime() - 9 * 86_400_000).toISOString());
104 check(undefined, "failed", new Date(now.getTime() - 4 * 86_400_000 - 3_600_000).toISOString());
105 check(undefined, "ok", new Date(now.getTime() - 3_600_000).toISOString());
106 expect(readCrewCard(app.db, now).streakDays).toBe(4);
107 expect(readCrewCard(app.db, now).red).toBe(false);
108 expect(streakWords(4, false)).toBe("4 days without a red main");
109 expect(streakWords(1, false)).toBe("1 day without a red main");
110 expect(streakWords(0, false)).toBe("Main went red today");
111 check(undefined, "failed");
112 const red = readCrewCard(app.db, now);
113 expect(red.streakDays).toBe(0);
114 expect(red.red).toBe(true);
115 expect(streakWords(red.streakDays, red.red)).toBe("Main is red now");
116 });
117
118 test("the figures region answers an admin and refuses a visitor", async () => {
119 await createUser(app.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase" });
120 const res = await fetch(`${servers.url}/live/figures`, { headers: { cookie } });
121 expect(res.status).toBe(200);
122 // The picture is read by the worker; until it has read, the card says it is reading.
123 const text = await res.text();
124 expect(text.includes("Crew, last 30 days") || text.includes("Reading the figures")).toBe(true);
125 const anon = await fetch(`${servers.url}/live/figures`, { redirect: "manual" });
126 expect(anon.status).toBe(404);
127 });
128
129 async function dashboardText(username: string): Promise<string> {
130 const user = getUserByName(app.db, username)!;
131 const { app: tui, session } = createForgeApp(
132 app,
133 { sshUsername: username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user },
134 { terminal: headlessTerminal(120, 60), exitHooks: false },
135 );
136 tui.start();
137 tui.ctx.push(dashboardScreen(session, tui.ctx));
138 await settleApp(tui);
139 const text = tui.screen.toText();
140 tui.stop?.();
141 return text;
142 }
143
144 test("the terminal dashboard shows an admin the streak line and a guest not", async () => {
145 expect(await dashboardText("ada")).toContain("Crew, 30 days: Main is red now");
146 expect(await dashboardText("bob")).not.toContain("Crew, 30 days");
147 });
148 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs