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

The home opens on its lanes; a repository standing still is listed on /asks, where it can be turned off #13651

Merged opened this

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

Merged

trevato/home-is-the-kanban → main 2 commits 2 threads · 2 unresolved

  • Merged. trevato/home-is-the-kanban was merged into main as 37ea77d.

Review

Sign in to review this change.
28 files changed +533 −248
docs/MCP.md +1 −1
@@ -124,7 +124,7 @@ bytes in `tools/list`. After changing a tool run `bun scripts/mcp-table.ts`;
124124 | `flow` | `bugs`, `cpu`, `drift`, `growth` | Pipeline (admin); `q`: `/fleet` rows, `action` plans an op, `apply` does it; `kind:bugs`; `repo`: why stuck | 530 |
125125 | `follow_mode` | — | How a fork follows its parent: take updates, tell me, or don't follow | 281 |
126126 | `following` | — | Where a fork stands against what it follows: in step, behind, ahead, diverged | 243 |
127 | `forge` | — | How is my forge? What needs you, recommended; `apply` takes them | 291 |
127 | `forge` | — | How is my forge? What needs you, recommended; `apply` takes them | 297 |
128128 | `forge_proposals` | — | What this forge proposed to its parent; `reachable` false if it is silent | 245 |
129129 | `forge_view` | — | The forge as one picture: counts, apps, runs with stations, health | 282 |
130130 | `forges` | `refused`, `clients` | Forges sent from here (admin), the client list, or one forge's plan | 610 |
docs/design/areas/blocked.md +1 −1
@@ -4,4 +4,4 @@ One sentence and one way through, drawn by `blockedNote` in `src/web/blocked.ts`
44
55 On a hosted forge's Connected accounts the note sits first under "Connect an account", and under it `.list.setting-list` rows say how each ask stands (`src/web/pages/origin-reach.ts`): the name, an outline or toned `.badge`, the sentence as the row's meta, and at most one action in the trail.
66
7 On the host, the home's line carries the two answers beside its sentence in `.hf-need-acts` (an inline row of `sm` buttons; their forms are siblings of the paragraph, since a paragraph holds no form), and `.hf-need > .dot + a` keeps a long sentence beside its dot. `/forges` and Settings, Hosted forges use `.row` children with `form.row-fields` in the trail, and the add box is `.field-row` (`src/web/pages/hosted-forges.ts`).
7 On `/asks`, a row under "Stopped until you answer" carries its answer beside its sentence in `.hf-need-acts` (an inline row of `sm` buttons; their forms are siblings of the paragraph, since a paragraph holds no form). `/forges` and Settings, Hosted forges use `.row` children with `form.row-fields` in the trail, and the add box is `.field-row` (`src/web/pages/hosted-forges.ts`).
docs/design/areas/home-flow.md +4 −4
@@ -1,13 +1,13 @@
11 # The pipeline home
22
3 `/` (`src/web/pages/home_flow.ts`, styled by `src/web/pages/home_flow_style.ts`) answers "what is my forge doing right now" on one screen: six lanes of tiles, a strip of figures above them, one line of hosted forges below. Every colour is a token, every size is on the type scale, every space on the spacing scale; the lanes are the one layout no other component draws, the tiles are small cards.
3 `/` (`src/web/pages/home_flow.ts`, styled by `src/web/pages/home_flow_style.ts`) answers "what is my forge doing right now" on one screen: six lanes of tiles first, on every width, then the box that tells the crew, a strip of figures and one line of hosted forges below them. Nothing sits above the lanes but the page's own header. Every colour is a token, every size is on the type scale, every space on the spacing scale; the lanes are the one layout no other component draws, the tiles are small cards.
44
5 - `.hf` — the page column: head, strip, lanes, forges line, in that order, 16px apart.
5 - `.hf` — the page column: head, lanes, tell box, strip, forges line, in that order, 16px apart.
66 - `.hf-head`, `.hf-title`, `.hf-live` — the title, and beside it the stream's state ("Live: updates as it happens", or that it is reconnecting).
77 - `.hf-filter`, `.hf-filter-label` — the quiet filter to one app: a plain GET form, a select that submits itself and a Show button only when scripts are off.
88 - `.hf-tell` — the wrapper that keeps the box that tells the crew (`.tell-box`, §5's bar) to one row on a desk, its app picker a fixed width.
9 - `.hf-need-sep` — the middle dot between the two things that may need the owner on the one line.
10 - `.hf-strip` — the one live region over the figures. It holds either the calm line `.hf-calm` ("Nothing needs you right now.") or, only for a real need (a red main, a stopped forge or landing line, a failed proof), the one line `.hf-need` with `.hf-need-more`.
9 - `.hf-need`, `.hf-need-first` — the one quiet line, the last thing in the head and only when there is something to count: how many things are broken about the forge itself (a red main, a stopped landing or lane, a failed backup, no release, a release that is not serving), as a link to their list on `/asks#forge-broken`, with the first of them beside it in `.hf-need-first`, cut to one line; and how many people are stopped until this viewer changes a setting, as a link to `/asks#asked`. A healthy forge draws no line. A repository standing still, an approved pull that has not landed and what waits on a person are never on the home: they are on `/asks` and `/review`.
10 - `.hf-strip` — an admin's live region of figures, under the lanes.
1111 - `.hf-figs`, `.hf-fig`, `.hf-fig-label`, `.hf-fig-value`, `.hf-fig-note`, `.hf-fig-spark` — a figure: its name, its value with the unit in the value or the note, and a tiny trend where the data has one. Two across on a phone, five across from 720px.
1212 - `.hf-lanes` — one lane under the other on a phone, three by two on a tablet, six across on a desk.
1313 - `.lane` — one lane, a live region of its own (`data-live`, `data-live-src="/live/lane?s=<lane>"`) so one event redraws one lane. Its `data-tone` (quiet, flowing, waiting, stuck) draws the top edge; `data-count` is the number in the head.
docs/features/blocked-by.md +1 −1
@@ -37,7 +37,7 @@ A reader who cannot change it is offered one action, and there are two, by who h
3737 What happens when a person presses the button:
3838
3939 1. One row is kept (`admin_ask`): who, what, for which account or repository. A repeat is the same ask.
40 2. The one who answers sees it on their home page's line: "bob asks for a model grant for bob (2 minutes ago)", linked to the control, with **Not now** beside it. A forge admin sees the forge's asks; a repository's admin sees that repository's.
40 2. The one who answers sees it counted in their home page's one line ("1 person is stopped until you answer"), which links to `/asks`. There it is listed under "Stopped until you answer": "bob asks for a model grant for bob (2 minutes ago)", linked to the control, with **Not now** beside it. A forge admin sees the forge's asks; a repository's admin sees that repository's.
4141 3. When the thing is there (the grant exists, the key is saved, the email is verified) the ask is done by itself. `GET /api/v1/asks/admin` is how the asker, or an agent, reads how it stands.
4242
4343 On a page the button is `askButton` (`src/web/blocked.ts`): it submits one hidden form the layout draws for every signed-in reader, so it works inside a paragraph, a flash or another form. An API answer carries `blockedFields`; an MCP refusal is built with `badBlocked` and carries the same fields as `structuredContent`.
docs/features/stuck-pile.md +9 −5
@@ -1,8 +1,12 @@
1 # A repository stuck behind its pulls (#12611)
1 # A repository standing still behind its pulls (#12611)
22
3 A repository is **stuck** when it has at least three open pulls and every one is red (its latest check on its head failed) or untouched for three days. Its ready issues cannot start while those pulls hold them (`open_pull`), and nothing says so.
3 A repository **stands still** when it has at least three open pulls and every one is red (its latest check on its head failed) or untouched for three days. Its ready issues cannot start while those pulls hold them (`open_pull`). This is a place to explore, so some repositories will: it is said calmly, in one place, and never on the home page. A repository that is turned off (archived) is never counted.
44
5 - **Needs stack.** `flow/stuck_pile.ts` finds it; `actions/needs.ts` raises it once, by name, for whoever writes to the repository: `/asks`-style stack, the terminal's "How is my forge?" (`r` re-checks all, `h` hands all to builders, `c` closes all after asking for a reason; each shows its plan, a dry run, and acts only on a yes) and the MCP `forge` tool.
6 - **Home.** One lane of its own above the lanes (`pileRegion` in `web/pages/home_flow.ts`): one sentence, then a row per pull with days old, days untouched, red, and why no builder is on it (a person holds or is assigned it, a person opened it, it is approved, its check has not finished or never ran).
7 - **Choices** (`crew/stuck_pile.ts`, a person's word only, a writer's access): re-check all on today's main (at most 50 a call, the check queue's own order), hand all to the builder that opened each, or close all with a reason (their issues go back to ready, unassigned). Web: `POST /:owner/:name/stuck` with `choice` (`recheck`, `builders`, `close`) and `reason`, then back to the page the form was on (`next`: the home or the repository's pulls). MCP: `forge {apply: "stuck:<repo id>", choice, reason?, dryRun?}`, planned first unless `dryRun: false`.
5 It is said in one sentence on every door (`pileSentence`): "trevato/scratchpad: 38 pulls nobody has touched since 2 Nov. Nothing new can start there until they move."
6
7 - **Needs stack.** `flow/stuck_pile.ts` finds it; `actions/needs.ts` raises it once, by name, for whoever writes to the repository: the terminal's "How is my forge?" (`r` re-checks its pulls, `h` hands them to builders, `c` closes them after asking for a reason, `o` turns the app off; each shows its plan, a dry run, and acts only on a yes) and the MCP `forge` tool.
8 - **Its page.** `/asks`, under "Standing still" (`web/studio/standing.ts`): a row per repository with the sentence and its choices as buttons, then a row per approved pull a week old that has not landed, linked to the pull. The home page (`/`) shows none of this: its lanes come first, and its one line counts only what is broken about the forge itself.
9 - **Choices** (`crew/stuck_pile.ts`, a person's word only, a writer's access): re-check its pulls on today's main (at most 50 a call, the check queue's own order), hand each to the builder that opened it, close them with a reason (their issues go back to ready, unassigned), or turn the app off. Web: `POST /:owner/:name/stuck` with `choice` (`recheck`, `builders`, `close`, `off`) and `reason`, then back to the page the form was on (`next`: `/asks` or the repository's pulls). MCP: `forge {apply: "stuck:<repo id>", choice, reason?, dryRun?}`, planned first unless `dryRun: false`.
10 - **Turn this app off.** Not a new mechanism: it is the repository's archive (`setArchived`, the MCP `archive` tool, Settings). The app, its previews and its crew stop; the repository and its data stay; It takes the repository's admin, and over MCP an admin token, as `archive` does.
11 - **Turn it back on.** Turning off is not asked twice; the way back is offered in the same place instead. On `/asks` the app's row becomes "owner/name is off." with one button, **Turn it back on** (the repository's own restore, `POST /:owner/:name/settings/archive`). The MCP answer carries `undo`, the exact call (`archive {repo, archived: false, dryRun: false}`). In the terminal the toast names the key: `u`. Back on, the app is counted again and the crew may be given work there (`turnBackOn`). Restore in the repository's settings does the same at any later time.
812 - **A re-check says where it stands.** `POST …/pulls/:n/checks` (page and API) answers `Check queued at the current head: place 3 of 12.`, and the pull's checks line shows the place while it waits (`checks/place.ts`, in the order checks were asked; a rebase's check or a pull a red main holds may be passed over). When nothing can be queued the refusal names why: no head, owner suspended, a guest's fork, a head awaiting a writer's approval, or no declared check.
src/actions/ask_admin.ts +2 −2
@@ -2,8 +2,8 @@
22 * A person asks whoever can change something to change it
33 * (`docs/features/blocked-by.md`). It is the forge's own half of "ask the
44 * host" (`ask_host.ts`): the same `Blocked` value offers it, a repeat is the
5 * same ask, and the one who answers sees it on the home's line with the link
6 * to the exact control.
5 * same ask, and the one who answers sees it counted on the home's line and
6 * listed on `/asks` with the link to the exact control.
77 *
88 * - `askAdmin` records the ask. Anyone signed in may ask; what they may ask
99 * for is the fixed list in `blocked_words.ts`, and the subject is checked
src/actions/needs.ts +22 −12
@@ -1,8 +1,10 @@
11 /**
2 * The one stack of what needs the owner (#12183): the home page's needs-you
3 * count, `/asks`, the terminal and the MCP `forge` tool all read `needsStack`,
4 * which is the asks' own rows (`askLinesFor`) plus the forge's own needs,
5 * each with a recommended choice derived from state — never a default.
2 * The one stack of what needs the owner (#12183): `/asks`, the terminal and
3 * the MCP `forge` tool all read `needsStack`, which is the asks' own rows
4 * (`askLinesFor`) plus the forge's own needs, each with a recommended choice
5 * derived from state — never a default. The home page draws none of it: a
6 * repository standing still and an approved pull that has not landed are
7 * listed on `/asks` (`standingNeeds`), the terminal and the tool.
68 * Applying "recommended" goes through the asks' bulk actions (`asks_bulk.ts`),
79 * so the preview, the per-row access check, the receipt and the undo are theirs.
810 */
@@ -15,8 +17,9 @@ import { newestAgentRun } from "../core/runs.ts";
1517 import { STALE_DAYS } from "../web/studio/review_set.ts";
1618 import { askStackFor, type askLinesFor } from "../web/studio/asks.ts";
1719 import { weekOld } from "../flow/oldest_approved.ts";
18 import { pileLine, stuckReposCached } from "../flow/stuck_pile.ts";
20 import { pileSentence, stuckReposCached } from "../flow/stuck_pile.ts";
1921 import { backlogs, heldForAPerson, waitingSaid } from "../crew/backlog.ts";
22 import { OFF_SAYS } from "../crew/stuck_pile.ts";
2023 import { drillNow } from "./backups_now.ts";
2124 import { builderOf, giveBack, handBack } from "./give_back.ts";
2225 import { getIssueById } from "../core/issues.ts";
@@ -239,8 +242,8 @@ function approvedNeeds(ctx: Home): Need[] {
239242 );
240243 }
241244
242 /** The three choices on a stuck repository (`crew/stuck_pile.ts`), in the order offered. */
243 export const STUCK_CHOICES = ["Re-check all on today's main", "Hand all to builders", "Close all with a reason"] as const;
245 /** The choices on a repository standing still (`crew/stuck_pile.ts`), in the order offered. */
246 export const STUCK_CHOICES = ["Re-check its pulls", "Hand its pulls to builders", "Close its stale pulls", "Turn this app off"] as const;
244247
245248 /**
246249 * A repository stuck behind its own pulls (#12611), raised once by name for whoever may write
@@ -255,13 +258,13 @@ function stuckNeeds(ctx: Home, user: User): Need[] {
255258 if (repo === undefined || !canWrite(ctx.app.db, repo, user)) continue;
256259 out.push({
257260 id: `stuck:${s.repoId}`,
258 sentence: `${s.ref} is stuck: ${s.open} open pulls, ${s.red} red, ${s.untouched} untouched. ${pileLine()}`,
259 why: "work finished enough to have a pull, parked behind a red nobody is looking at",
260 waits: "nothing is built or landed there until the pile moves",
261 sentence: pileSentence(s),
262 why: "this is a place to explore, and some apps do not work out: its pulls wait, and its ready issues wait behind them",
263 waits: "nothing is built or landed there until its pulls move or the app is turned off",
261264 choices: [...STUCK_CHOICES],
262265 recommended: needsDecision(
263 `${s.ref}: re-check all, hand all to builders, or close all?`,
264 "each choice moves many pulls; re-checking is the gentlest, closing sets their issues ready again",
266 `${s.ref}: re-check its pulls, hand them to builders, close them, or turn the app off?`,
267 `each choice moves many pulls; re-checking is the gentlest, closing sets their issues ready again. ${OFF_SAYS}`,
265268 STUCK_CHOICES,
266269 ),
267270 link: `/${s.owner}/${s.name}/pulls`,
@@ -307,6 +310,13 @@ function stillNeeds(ctx: Home, user: User): Need[] {
307310 return out;
308311 }
309312
313 /**
314 * What stands still, for `/asks`' own section: each repository behind its pulls, then (an
315 * admin's) each approved pull a week old. The same rows, ids and words the terminal and the
316 * MCP `forge` tool read in `needsStack`.
317 */
318 export const standingNeeds = (ctx: Home, user: User): Need[] => [...stuckNeeds(ctx, user), ...(user.isAdmin ? approvedNeeds(ctx) : [])];
319
310320 /** The stack: the forge's own needs first (an admin's), then the asks, most consequential first. */
311321 export function needsStack(ctx: Home, user: User, chips?: Chips): Need[] {
312322 const db = ctx.app.db;
src/crew/stuck_pile.ts +42 −6
@@ -1,15 +1,21 @@
11 /**
2 * The three things a person may do about a repository stuck behind its pulls
2 * What a person may do about a repository standing still behind its pulls
33 * (#12611, `flow/stuck_pile.ts`): ask every pull's check again on today's
4 * main, hand every pull to the crew member that built it, or close every pull
5 * with a reason, which sets the issues they closed back to ready. Each takes
6 * a person's word (never an agent's), a writer's access, and answers what it
7 * did to each pull and why it left one alone. `dryRun` answers the plan only.
4 * main, hand every pull to the crew member that built it, close every pull
5 * with a reason, which sets the issues they closed back to ready, or turn the
6 * app off. Off is the repository's own archive (`setArchived`), nothing new:
7 * the app and its previews stop, the crew starts nothing there, the repository
8 * and its data stay, and waking it turns it back on (`turnBackOn`, offered in
9 * the same place on every door, in place of a question before). Each takes a person's
10 * word (never an agent's), a writer's access (an admin's to turn it off), and
11 * answers what it did to each pull and why it left one alone. `dryRun` answers
12 * the plan only.
813 */
914
1015 import type { App } from "../app.ts";
1116 import { addComment, assignIssue, setIssueState } from "../actions/issues.ts";
1217 import { builderOf, handBack } from "../actions/give_back.ts";
18 import { setArchived } from "../actions/repos.ts";
1319 import { askCheck } from "../checks/again.ts";
1420 import { RECHECK_MAX } from "../checks/recheck.ts";
1521 import { getIssue, getIssueById } from "../core/issues.ts";
@@ -18,7 +24,7 @@ import { canWrite, getRepoById } from "../core/repos.ts";
1824 import type { User } from "../core/users.ts";
1925 import { pileRows, readStuckRepos, whyNoBuilder } from "../flow/stuck_pile.ts";
2026
21 export const PILE_CHOICES = ["recheck", "builders", "close"] as const;
27 export const PILE_CHOICES = ["recheck", "builders", "close", "off"] as const;
2228 export type PileChoice = (typeof PILE_CHOICES)[number];
2329
2430 /** The longest reason taken. */
@@ -31,8 +37,30 @@ export interface PileDone {
3137 readonly acted: number[];
3238 /** Pull numbers left, each with why. */
3339 readonly left: { pull: number; why: string }[];
40 /** `owner/name`, for the one choice that is about the repository and not its pulls: off. */
41 readonly ref?: string;
42 /** For an app turned off: the MCP call that turns it back on (`backOnCall`). */
43 readonly undo?: string;
3444 }
3545
46 /** The MCP call that turns an app back on: the `archive` tool, waking it. */
47 export const backOnCall = (ref: string): string => `archive {repo:"${ref}", archived:false, dryRun:false}`;
48
49 /**
50 * Turn an app back on: the undo of off, and the repository's own wake (`setArchived`), nothing
51 * new. Its admin's, a person's. The app comes back from its default branch on the same data, the
52 * crew may start work there again, and it is counted again.
53 */
54 export async function turnBackOn(app: App, user: User, repoId: string): Promise<{ ref: string } | { error: string }> {
55 const repo = getRepoById(app.db, repoId);
56 if (repo === undefined || user.kind !== "user") return { error: "not found" };
57 const on = await setArchived(app, user, repo, false, false);
58 return on.ok ? { ref: `${repo.ownerName}/${repo.name}` } : { error: "only an admin of that repository turns it back on" };
59 }
60
61 /** What turning an app off does, in one sentence: said before it is done, on every door. */
62 export const OFF_SAYS = "Turning it off stops the app, its previews and its crew; the repository and its data stay, and it can be turned back on at any time.";
63
outdated

Archiving is the one choice here that stops a whole app. Require a confirmation step on every door that can reach it. The page needs a second step, and a test must fail if a single POST archives.

3664 export const isPileChoice = (v: unknown): v is PileChoice => PILE_CHOICES.includes(v as PileChoice);
3765
3866 /** The default reason a close carries. */
@@ -50,6 +78,12 @@ export async function takePileChoice(
5078 const repo = getRepoById(app.db, repoId);
5179 if (repo === undefined || user.kind !== "user" || !canWrite(app.db, repo, user)) return { error: "not found" };
5280 if (!readStuckRepos(app.db).some((s) => s.repoId === repo.id)) return { error: "that repository is not stuck any more" };
81 if (choice === "off") {
82 const off = await setArchived(app, user, repo, true, dryRun);
83 if (!off.ok) return { error: "only an admin of that repository turns it off" };
84 const ref = `${repo.ownerName}/${repo.name}`;
85 return { choice, dryRun, acted: [], left: [], ref, ...(dryRun ? {} : { undo: backOnCall(ref) }) };
86 }
5387 const reason = (opts.reason ?? "").trim().slice(0, REASON_MAX) || closeReason(user.username);
5488 const acted: number[] = [];
5589 const left: { pull: number; why: string }[] = [];
@@ -100,6 +134,7 @@ export async function takePileChoice(
100134
101135 /** What a person is told after a choice: what was done to how many pulls, and what was left. */
102136 export function pileWords(done: PileDone): string {
137 if (done.choice === "off") return `${done.ref ?? "The app"} is off: nothing runs there, and its repository and data are kept.`;
103138 const verb = { recheck: "Check asked for", builders: "Handed to the crew:", close: "Closed:" }[done.choice];
104139 const left = done.left.length === 0 ? "" : ` ${done.left.length} left alone (${done.left[0]!.why}${done.left.length > 1 ? ", and others" : ""}).`;
105140 return `${verb} ${done.acted.length} ${done.acted.length === 1 ? "pull" : "pulls"}.${left}`;
@@ -107,6 +142,7 @@ export function pileWords(done: PileDone): string {
107142
108143 /** What a dry run says it would do, one line, then the first pulls it would leave and why. */
109144 export function pilePlan(done: PileDone): string[] {
145 if (done.choice === "off") return [`Turn ${done.ref ?? "the app"} off.`, OFF_SAYS];
110146 const verb = { recheck: "Ask the check again on", builders: "Hand to the crew", close: "Close" }[done.choice];
111147 const lines = [`${verb} ${done.acted.length} ${done.acted.length === 1 ? "pull" : "pulls"}.`];
112148 for (const l of done.left.slice(0, 3)) lines.push(`Leave #${l.pull}: ${l.why}.`);
src/flow/alarms.ts +8
@@ -40,6 +40,14 @@ function redMainHref(db: Database): string {
4040 return red ? redHref(red) : "/boards";
4141 }
4242
43 /**
44 * The alarms that say the forge itself is broken or its data is at risk: main is red, landing
45 * or the lane has stopped, the backup failed, no release will go out. The only alarms the home
46 * page counts (one line, `web/pages/home_flow.ts`) and `/asks` lists under "The forge". An
47 * approved pull that sits (`stuck`) is not one: it is work standing still, listed on `/asks`.
48 */
49 export const FORGE_BROKEN: ReadonlySet<FiredAlarm["key"]> = new Set(["red_main", "landing_stopped", "lane_stopped", "backup", "no_release"]);
50
4351 export function firedAlarms(
4452 db: Database,
4553 now: Date,
src/flow/lanes_read.ts +2 −11
@@ -23,7 +23,7 @@ import { listAutonomousRepos } from "../core/repos.ts";
2323 import { STARVATION_MS } from "../kernel/budgets.ts";
2424 import { reviewSummariesFor } from "../core/reviews.ts";
2525 import { weekShare } from "../crew/week_read.ts";
26 import { firedAlarms } from "./alarms.ts";
26 import { FORGE_BROKEN, firedAlarms } from "./alarms.ts";
2727 import { readBuilders, readKpis } from "./kpis.ts";
2828 import { readFigures, type Figures } from "./figures.ts";
2929 import { readLeadTime, type LeadTime } from "./lead_time.ts";
@@ -656,20 +656,11 @@ export function readSlow(
656656 [string]
657657 >(`SELECT SUM(cost_usd) AS usd FROM run WHERE kind = 'agent' AND created_at >= ?1`)
658658 .get(new Date(now.getTime() - 7 * 86_400_000).toISOString());
659 const REAL = new Set([
660 "red_main",
661 "landing_stopped",
662 "lane_stopped",
663 "stuck",
664 "unreachable",
665 "backup",
666 "no_release",
667 ]);
668659 const needs = firedAlarms(db, now, {
669660 dataDir: forge.dataDir,
670661 ceilingUsd: forge.ceilingUsd,
671662 })
672 .filter((a) => REAL.has(a.key))
663 .filter((a) => FORGE_BROKEN.has(a.key))
673664 .map((a) => ({ says: a.says, href: a.href }));
674665 return {
675666 asked: asked.items,
src/flow/oldest_approved.ts +4 −2
@@ -2,8 +2,9 @@
22 * Approved and waiting (#6422, for #5930; named for #12440): the approved,
33 * unlanded pulls and how long each has waited since its latest approval. A pull
44 * whose latest approval is followed by a changes-requested verdict does not
5 * count. The one definition of the rule: the oldest (the tick's clog figure)
6 * and the week-old (the needs stack) both read it.
5 * count, nor does one in a repository that is turned off (archived). The one
6 * definition of the rule: the oldest (the tick's clog figure) and the week-old
7 * (the needs stack) both read it.
78 */
89
910 import type { Database } from "bun:sqlite";
@@ -38,6 +39,7 @@ export function approvedPulls(db: Database, now = new Date(), publicOnly = false
3839 JOIN (SELECT issue_id, MAX(created_at) AS at FROM review WHERE state = 'approved' GROUP BY issue_id) a
3940 ON a.issue_id = i.id
4041 WHERE (?1 = 0 OR r.visibility = 'public') AND i.state = 'open' AND p.merged_at IS NULL AND a.at <= ?2
42 AND r.archived_at IS NULL
4143 AND NOT EXISTS (SELECT 1 FROM review c WHERE c.issue_id = i.id AND c.state = 'changes_requested' AND c.created_at > a.at)
4244 ORDER BY a.at ASC, i.number ASC
4345 LIMIT ?3`,
src/flow/stuck_pile.ts +22 −5
@@ -5,8 +5,9 @@
55 * pulls (`open_pull`), the reds wait for a builder or a person, and no one is
66 * told. One read names each such repository, its pulls oldest first with
77 * their ages, and why each sits. The needs stack raises it once
8 * (`actions/needs.ts`), the home shows it as a pile of its own
9 * (`pileRegion` in `web/pages/home_flow.ts`), and `crew/stuck_pile.ts` takes the three choices.
8 * (`actions/needs.ts`), `/asks` lists it under "Standing still"
9 * (`web/studio/standing.ts`), never the home, and `crew/stuck_pile.ts` takes
10 * the choices. A repository that is turned off (archived) is never one.
1011 */
1112
1213 import type { Database } from "bun:sqlite";
@@ -44,6 +45,8 @@ export interface StuckRepo {
4445 /** Open pulls untouched past `UNTOUCHED_DAYS`. */
4546 readonly untouched: number;
4647 readonly oldestDays: number;
48 /** When anything last touched any of its pulls (ISO). */
49 readonly touchedAt: string;
4750 /** Oldest first, at most `PILE_LISTED`. */
4851 readonly pulls: readonly PilePull[];
4952 }
@@ -77,7 +80,7 @@ export const PILE_SQL = `SELECT i.id AS id, i.number AS number, i.title AS title
7780 EXISTS (SELECT 1 FROM review v WHERE v.issue_id = i.id AND v.state = 'approved') AS approved
7881 FROM issue i JOIN pull p ON p.issue_id = i.id
7982 JOIN repo r ON r.id = i.repo_id JOIN user o ON o.id = r.owner_id
80 WHERE i.state = 'open' AND i.kind = 'pull' AND p.merged_at IS NULL`;
83 WHERE i.state = 'open' AND i.kind = 'pull' AND p.merged_at IS NULL AND r.archived_at IS NULL`;
8184
8285 /**
8386 * Why a builder is not sent to this pull, from what is on the row; empty when one may be.
@@ -131,14 +134,28 @@ export function readStuckRepos(db: Database, now = new Date()): StuckRepo[] {
131134 red: pulls.filter((p) => p.red).length,
132135 untouched: pulls.filter((p) => p.idleDays >= UNTOUCHED_DAYS).length,
133136 oldestDays: Math.max(...pulls.map((p) => p.ageDays)),
137 touchedAt: rows.reduce((at, r) => (r.touched > at ? r.touched : at), ""),
134138 pulls: pulls.slice(0, PILE_LISTED),
135139 });
136140 }
137141 return out.sort((a, b) => b.oldestDays - a.oldestDays || a.ref.localeCompare(b.ref));
138142 }
139143
140 /** The one sentence under the heading: what the pile costs. The counts are the lane's own. */
141 export const pileLine = (): string => "Every open pull is red or untouched, so its ready issues cannot start.";
144 const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] as const;
145
146 /**
147 * What is true of a repository standing still, said calmly: how many pulls, since what day
148 * nobody has touched them, and what that holds up. Every door says this one sentence.
149 */
150 export function pileSentence(s: Pick<StuckRepo, "ref" | "open" | "red" | "untouched" | "touchedAt">): string {
151 const at = new Date(s.touchedAt);
152 const day = `${at.getUTCDate()} ${MONTHS[at.getUTCMonth()]}`;
153 const pulls = `${s.open} ${s.open === 1 ? "pull" : "pulls"}`;
154 const held = "Nothing new can start there until they move.";
155 if (s.red === 0) return `${s.ref}: ${pulls} nobody has touched since ${day}. ${held}`;
156 if (s.untouched === s.open) return `${s.ref}: ${pulls} nobody has touched since ${day}, ${s.red} with a failing check. ${held}`;
157 return `${s.ref}: ${pulls}, ${s.red} with a failing check, the rest untouched for ${UNTOUCHED_DAYS} days or more. ${held}`;
158 }
142159
143160 /** How long one read serves every request. */
144161 export const PILE_TTL_MS = 30_000;
src/http/mcp/tools/forge.ts +4 −2
@@ -1,6 +1,7 @@
11 import { crewNow } from "../../../actions/crew_now.ts";
22 import { takePileChoice, isPileChoice, PILE_CHOICES } from "../../../crew/stuck_pile.ts";
33 import { applyRecommended, forgeSays, needsStack } from "../../../actions/needs.ts";
4 import { scopeAllows } from "../../../core/tokens.ts";
45 import { good, bad, type Tool } from "../shared.ts";
56
67 export const tool: Tool = {
@@ -16,7 +17,7 @@ export const tool: Tool = {
1617 },
1718 },
1819 doc:
19 "`{ apply?, dryRun? }`: `{ says, needs, recommended }`: one or two sentences, then what needs you (the home page's own stack, most consequential first: `sentence`, `why`, `choices`, `recommended` with `reason`, `undo`, `safe`, and the `ask` to put to the owner when not), and the call that applies them. A stuck repository (every open pull red or untouched) is a need named `stuck:<id>`: `{ apply: \"stuck:<id>\", choice: \"recheck\" | \"builders\" | \"close\", reason? }` takes one choice over all its pulls (planned first, `dryRun` true unless `false`), answering `acted` and `left` with why. `apply: \"recommended\"` (or one need's `id`) takes the recommended choice of each safe need (a close the crew advised, a restore drill, a stopped run or assigned issue handed to the crew) and answers `done` with what each did; a ship is never one (a merge has no undo), nor a need with no safe default: those say `Needs your decision` with their real `options`, and are listed under `left` by name; planned first (`dryRun` is true unless `false`); each receipt names its undo (`asks_act` `undo`)",
20 "`{ apply?, dryRun? }`: `{ says, needs, recommended }`: one or two sentences, then what needs you (the stack `/asks` shows, most consequential first: `sentence`, `why`, `choices`, `recommended` with `reason`, `undo`, `safe`, and the `ask` to put to the owner when not), and the call that applies them. A repository standing still (every open pull red or untouched; never one that is turned off) is a need named `stuck:<id>`: `{ apply: \"stuck:<id>\", choice: \"recheck\" | \"builders\" | \"close\" | \"off\", reason? }` takes one choice (planned first, `dryRun` true unless `false`), answering `acted` and `left` with why. `off` turns the app off, which is `archive` by another door: the app, its previews and its crew stop, the repository and its data stay, and the answer's `undo` is the exact call that turns it back on (`archive { repo, archived: false, dryRun: false }`); like `archive`, it takes the repository's admin and an admin token. `apply: \"recommended\"` (or one need's `id`) takes the recommended choice of each safe need (a close the crew advised, a restore drill, a stopped run or assigned issue handed to the crew) and answers `done` with what each did; a ship is never one (a merge has no undo), nor a need with no safe default: those say `Needs your decision` with their real `options`, and are listed under `left` by name; planned first (`dryRun` is true unless `false`); each receipt names its undo (`asks_act` `undo`)",
2021 writes: true,
2122 dryByDefault: true,
2223 readsWithout: "apply",
@@ -25,7 +26,8 @@ export const tool: Tool = {
2526 const choice = args["choice"];
2627 if (choice !== undefined) {
2728 if (typeof apply !== "string" || !apply.startsWith("stuck:") || !isPileChoice(choice))
28 return bad("invalid", "choice is recheck, builders or close, and apply is the stuck need's id");
29 return bad("invalid", "choice is recheck, builders, close or off, and apply is the stuck need's id");
30 if (choice === "off" && args["dryRun"] === false && !scopeAllows(ctx.auth.scope ?? "ro", "admin")) return bad("forbidden", "turning an app off needs an admin token");
2931 const reason = typeof args["reason"] === "string" ? args["reason"] : undefined;
3032 const done = await takePileChoice(ctx.app, user, apply.slice(6), choice, { dryRun: args["dryRun"] !== false, ...(reason === undefined ? {} : { reason }) });
3133 return "error" in done ? bad("not_found", done.error) : good(done);
src/tui/screens/needs.ts +18 −5
@@ -1,5 +1,5 @@
11 /**
2 * "How is my forge?" in the terminal (#12183): the stack the home page and the
2 * "How is my forge?" in the terminal (#12183): the stack `/asks` and the
33 * MCP `forge` tool show (`needsStack`), one row per need with the recommended
44 * choice under it. Anyone signed in sees their own stack, gated by the same
55 * reads as the page. `a` takes the recommended choice of the need under the
@@ -12,7 +12,7 @@
1212 import { crewNow } from "../../actions/crew_now.ts";
1313 import { applyRecommended, forgeSays, needsStack, type Need } from "../../actions/needs.ts";
1414 import type { Ctx, Screen } from "../app/app.ts";
15 import { pilePlan, pileWords, takePileChoice, type PileChoice } from "../../crew/stuck_pile.ts";
15 import { pilePlan, pileWords, takePileChoice, turnBackOn, type PileChoice } from "../../crew/stuck_pile.ts";
1616 import { binding } from "../app/keys.ts";
1717 import type { Session } from "../session.ts";
1818 import { style } from "../term/style.ts";
@@ -43,6 +43,8 @@ export function needsScreen(f: Session, ctx: Ctx): Screen {
4343 const state = new ListState();
4444 let stack = stackFor(f);
4545 let running = runningFor(f);
46 /** The app `o` turned off last on this screen: what `u` turns back on. */
47 let off: string | undefined;
4648 const reload = (): void => {
4749 stack = stackFor(f);
4850 running = runningFor(f);
@@ -65,7 +67,8 @@ export function needsScreen(f: Session, ctx: Ctx): Screen {
6567 if (i !== 0) return;
6668 runAsync(ctx, async () => {
6769 const done = await takePileChoice(f.app, f.user!, repoId, choice, opts);
68 ctx.toast("error" in done ? done.error : pileWords(done), "error" in done ? "danger" : undefined);
70 if (!("error" in done) && choice === "off") off = repoId;
71 ctx.toast("error" in done ? done.error : `${pileWords(done)}${choice === "off" ? " Press u to turn it back on." : ""}`, "error" in done ? "danger" : undefined);
6972 reload();
7073 });
7174 },
@@ -74,7 +77,7 @@ export function needsScreen(f: Session, ctx: Ctx): Screen {
7477 });
7578 const screen: Screen = {
7679 title: "How is my forge?",
77 keys: [binding(["j", "k"], "move cursor"), binding(["a"], "take the recommended choice"), binding(["r"], "stuck repository: re-check all"), binding(["h"], "stuck repository: hand all to builders"), binding(["c"], "stuck repository: close all")],
80 keys: [binding(["j", "k"], "move cursor"), binding(["a"], "take the recommended choice"), binding(["r"], "standing still: re-check its pulls"), binding(["h"], "standing still: hand its pulls to builders"), binding(["c"], "standing still: close its stale pulls"), binding(["o"], "standing still: turn this app off"), binding(["u"], "turn the app back on that o turned off")],
7881 async load(signal) {
7982 live(f, signal, {}, reload);
8083 },
@@ -96,7 +99,7 @@ export function needsScreen(f: Session, ctx: Ctx): Screen {
9699 if (e.ctrl || e.alt) return false;
97100 const at = stack[state.index];
98101 // A stuck repository's choices over all its pulls: each is planned first and asked.
99 const pick = { r: "recheck", h: "builders", c: "close" }[e.key] as PileChoice | undefined;
102 const pick = { r: "recheck", h: "builders", c: "close", o: "off" }[e.key] as PileChoice | undefined;
100103 if (pick !== undefined && at?.id.startsWith("stuck:") && f.user !== undefined) {
101104 if (pick !== "close") planning(at, pick);
102105 else
@@ -112,6 +115,16 @@ export function needsScreen(f: Session, ctx: Ctx): Screen {
112115 );
113116 return true;
114117 }
118 if (e.key === "u" && off !== undefined && f.user !== undefined) {
119 const repoId = off;
120 runAsync(ctx, async () => {
121 const on = await turnBackOn(f.app, f.user!, repoId);
122 if (!("error" in on)) off = undefined;
123 ctx.toast("error" in on ? on.error : `${on.ref} is back on.`, "error" in on ? "danger" : undefined);
124 reload();
125 });
126 return true;
127 }
115128 if (e.key !== "a") return false;
116129 const why = whyNot(f, at);
117130 if (why !== "" || at === undefined || f.user === undefined) {
src/web/pages/home_flow.ts +45 −120
@@ -22,7 +22,6 @@ import { lastHeard, MAX_CHILDREN, QUIET_MS } from "../../spawn/heartbeat.ts";
2222 import { cellsHere, isAwakeBody } from "../../spawn/host.ts";
2323 import { forgeCeiling } from "../../flow/ceiling.ts";
2424 import { count, duration, money } from "../../flow/figure_format.ts";
25 import { waitingWords } from "../../flow/kpi_words.ts";
2625 import {
2726 LANES,
2827 LANE_HOLDS,
@@ -58,16 +57,11 @@ import { readableNotes } from "../../actions/desk.ts";
5857 import { deskStrip } from "../desk_strip.ts";
5958 import { heldLine } from "../studio/held.ts";
6059 import { interruptedOutLine } from "../studio/interrupted_out.ts";
61 import { canWrite, getRepoById, listReposWritableTo } from "../../core/repos.ts";
62 import type { Database } from "bun:sqlite";
63 import type { User } from "../../core/users.ts";
64 import { pileLine, stuckReposCached } from "../../flow/stuck_pile.ts";
65 import { btn, field } from "../ui.ts";
60 import { listReposWritableTo } from "../../core/repos.ts";
6661 import { chart, figuresGrid, figuresSection } from "./home_figures.ts";
6762 import { tellBox } from "../studio/living.ts";
6863 import { requestsCard } from "../requests_card.ts";
69 import { adminAskNeed } from "../studio/ask_admin.ts";
70 import { asksToAnswer, type AskView } from "../../actions/ask_admin.ts";
64 import { asksToAnswer } from "../../actions/ask_admin.ts";
7165 import { whereOf } from "../../spawn/where.ts";
7266 import { untoldAnswer, markTold } from "../../core/requests.ts";
7367 import { YOURE_IN_MESSAGE } from "../../actions/users.ts";
@@ -222,50 +216,13 @@ export function laneRegion(
222216 }
223217
224218
225 /**
226 * A repository stuck behind its own pulls (#12611): one lane of its own, not counted in the
227 * lanes above. A heading and a count, one sentence of what it costs, a row per pull, and the three
228 * choices over all of them. Only for repositories this person writes to.
229 */
230 export function pileRegion(db: Database, user: User, now: number): Html | null {
231 const piles = stuckReposCached(db, new Date(now)).filter((s) => {
232 const repo = getRepoById(db, s.repoId);
233 return repo !== undefined && canWrite(db, repo, user);
234 });
235 if (piles.length === 0) return null;
236 const sections = piles.map((s) => {
237 const base = `/${s.owner}/${s.name}`;
238 const rows = s.pulls.map((p) => {
239 const facts = [`${String(p.ageDays)} d old`, `untouched ${String(p.idleDays)} d`, ...(p.red ? ["red"] : []), ...(p.why === "" ? [] : [p.why])];
240 return html`<li><a href="${base}/pulls/${String(p.number)}">#${String(p.number)} ${p.title}</a> <span class="muted small">${facts.join(", ")}</span></li>`;
241 });
242 return html`<section class="lane" data-lane="pile" data-tone="stuck" data-count="${String(s.open)}" aria-label="${s.ref} is stuck">
243 <header class="lane-head">
244 <h2 class="lane-name"><a class="lane-name-link" href="${base}/pulls">${s.ref} is stuck</a></h2>
245 <span class="lane-count num" aria-hidden="true">${String(s.open)}</span>
246 </header>
247 <p class="lane-health">${pileLine()}</p>
248 <form class="row-fields" method="post" action="${base}/stuck">
249 <input type="hidden" name="next" value="/" />
250 ${field({ name: "reason", label: "Reason, said on each closed pull", maxlength: 300, id: `pile-reason-${s.name}` })}
251 ${btn("Re-check all on today's main", { size: "sm", name: "choice", value: "recheck" })}
252 ${btn("Hand all to builders", { size: "sm", name: "choice", value: "builders" })}
253 ${btn("Close all", { size: "sm", name: "choice", value: "close" })}
254 </form>
255 <ul class="list setting-list">${rows}</ul>
256 ${s.open > s.pulls.length ? html`<p class="muted small">${String(s.open - s.pulls.length)} more not listed</p>` : null}
257 </section>`;
258 });
259 return html`<div id="hf-pile">${sections}</div>`;
260 }
261
262219 /** What the lanes' reading needs of the forge. */
263220 const pictureOptions = (app: App): PictureOptions => ({ dataDir: app.config.dataDir, ceilingUsd: forgeCeiling(app.config) });
264221 const optionsOf = (ctx: Ctx, user: { readonly id: string } | undefined = ctx.auth.user): PictureOptions => ({ ...pictureOptions(ctx.app), ...(user === undefined ? {} : { viewer: user.id }) });
265222
266223 const healthOf = (view: LaneView, picture: LanePicture, now: number): Health => laneHealth(view, { now, builders: picture.builders, moved: picture.moved, idle: picture.idle });
267224
268 // ---- the strip: today's figures, and the one line that needs the owner ----
225 // ---- the header's one line, and the strip: today's figures ----
269226
270227 export function proofWords(proof: Proof | undefined, version: string, since?: string): { text: string; tone: "attn" | null } {
271228 // A proof under way says so and when it began, so no release goes a quarter hour unspoken.
@@ -292,86 +249,52 @@ function weekFigure(strip: StripPart): { value: string; note: string; attn: bool
292249 }
293250
294251 /**
295 * One thing that needs this person: an alarm (red: something is not working) or a notice (it can
296 * wait, and is not on fire).
297 */
298 interface Need {
299 readonly says: string;
300 readonly href: string;
301 readonly tone: "alarm" | "notice";
302 /** The answers a need can be given where it is read: buttons, beside its sentence. */
303 readonly after?: Html;
304 /** The forms those buttons submit, drawn after the line (a paragraph holds no form). */
305 readonly forms?: Html;
306 }
307
308 /**
309 * Who the strip is drawn for. It names only work waiting on this person and what the forge itself
310 * has stopped doing (a failing proof, an alarm). A setting that needs attention (no model key, a
311 * hosted forge's ask to reach a host, a forge proposed for archive, a forge in this process) is one
312 * line on its own settings page, never on / (#13428).
252 * Who the home is drawn for. Its one line counts only what is broken about the forge itself (a
253 * failing proof, a fired alarm of `FORGE_BROKEN`) and the people stopped until this viewer changes
254 * a setting. Work standing still (a repository behind its pulls, an approved pull that has not
255 * landed), what waits on this person, and a setting that needs attention are never on /: they are
256 * on `/asks`, `/review` and their settings pages (#13428).
313257 */
314258 interface StripViewer {
315 readonly id: string;
316259 readonly isAdmin: boolean;
317 /**
318 * What people here asked this viewer, as one who can change it, to change
319 * (`actions/ask_admin.ts`).
320 */
321 readonly asked?: readonly AskView[];
260 }
261
262 /** What is broken about the forge, for an admin: the proof's alarm, then the picture's alarms. */
263 export function brokenOf(picture: LanePicture | undefined, isAdmin: boolean, dataDir: string, now: number): { says: string; href: string }[] {
264 if (!isAdmin) return [];
265 const proof = proofNotice(dataDir, running().version, now);
266 return [...(proof?.tone === "alarm" ? [{ says: proof.sentence, href: "/releases#proof" }] : []), ...(picture?.strip?.needs ?? [])];
267 }
268
269 const things = (n: number, one: string, many: string): string => `${String(n)} ${n === 1 ? one : many}`;
270
271 /**
272 * The one line, in the page's header: how many things are broken about the forge and how many
273 * people are stopped, each count a link to its list on `/asks`. Nothing at all when there is
274 * nothing: a healthy forge's home opens on its lanes.
275 */
276 export function needLine(broken: readonly { says: string; href: string }[], asked: number): Html | null {
277 if (broken.length === 0 && asked === 0) return null;
278 return html`<p class="hf-need" id="hf-need" role="status"><span class="dot" data-tone="${broken.length === 0 ? "attn" : "danger"}"></span>${
279 broken.length === 0 ? null : html`<a href="/asks#forge-broken">${things(broken.length, "problem", "problems")} with the forge</a><span class="hf-need-first">${broken[0]!.says}</span>`
280 }${asked === 0 ? null : html`<a href="/asks#asked">${things(asked, "person is", "people are")} stopped until you answer</a>`}</p>`;
322281 }
323282
324283 /**
325 * What needs this person, most pressing first: alarms, then notices, then what waits on them. One
326 * line says the first two; the proof's own record is on /releases.
284 * The strip, under the lanes: for an admin, five figures, each with its unit and, where the data
285 * has one, a trend. Everyone else gets none: the figures are the forge's.
327286 */
328 function needsOf(picture: LanePicture, viewer: StripViewer, dataDir: string, now: number): Need[] {
329 const proof = viewer.isAdmin ? proofNotice(dataDir, running().version, now) : undefined;
330 const asks = picture.asks[viewer.id];
331 const waiting = asks === undefined ? null : waitingWords(asks.count, asks.oldest, new Date(now));
332 const alarms: Need[] = [
333 ...(proof?.tone === "alarm" ? [{ says: proof.sentence, href: "/releases#proof", tone: "alarm" as const }] : []),
334 ...(viewer.isAdmin ? (picture.strip?.needs ?? []).map((n) => ({ says: n.says, href: n.href, tone: "alarm" as const })) : []),
335 ];
336 return [
337 ...alarms,
338 // A person here is stopped until one who can change it does: theirs to answer, admin or not.
339 ...(viewer.asked ?? []).map((a, n) => ({ ...adminAskNeed(a, n), tone: "notice" as const })),
340 ...(proof?.tone === "notice" ? [{ says: proof.sentence, href: "/releases#proof", tone: "notice" as const }] : []),
341 ...(waiting === null ? [] : [{ says: waiting, href: "/review", tone: "notice" as const }]),
342 ];
343 }
344
345 /**
346 * The one line: what needs this person, at most two things, never a list; or that nothing does. Red
347 * only when something is not working.
348 */
349 function needLine(needs: readonly Need[]): Html {
350 if (needs.length === 0) return html`<p class="hf-calm"><span class="dot" data-tone="success"></span>Nothing needs you right now.</p>`;
351 const [first, second] = needs;
352 const more = needs.length - 2;
353 const tone = first!.tone;
354 return html`<p class="hf-need" data-tone="${tone}" role="status"><span class="dot" data-tone="${tone === "alarm" ? "danger" : "attn"}"></span><a href="${first!.href}">${first!.says}</a>${first!.after ?? null}${second === undefined ? null : html`<span class="hf-need-sep" aria-hidden="true">·</span><a href="${second.href}">${second.says}</a>${second.after ?? null}`}${more > 0 ? html` <a class="hf-need-more" href="/boards">and ${String(more)} more</a>` : null}</p>${first!.forms ?? null}${second?.forms ?? null}`;
355 }
356
357 /**
358 * The strip: the one line that needs this person and, for an admin, five
359 * figures, each with its unit and, where the data has one, a trend. Everyone
360 * else gets the line alone: the figures are the forge's.
361 */
362 export function stripRegion(picture: LanePicture, viewer: StripViewer, dataDir: string, now: number): Html {
287 export function stripRegion(picture: LanePicture, viewer: StripViewer, dataDir: string, now: number): Html | null {
288 if (!viewer.isAdmin) return null;
363289 const strip = picture.strip;
364290 const version = running().version;
365291 const proof = proofWords(lastProof(dataDir), version, provingSince(dataDir, version));
366 const needs = needLine(needsOf(picture, viewer, dataDir, now));
367 if (!viewer.isAdmin) return html`<section class="hf-strip" id="hf-strip" aria-label="What needs you" data-live="${STRIP_LIVE}" data-live-src="/live/strip">${needs}</section>`;
368292 const b = picture.builders;
369293 // The reason is only said while a slot is free: a busy crew has none.
370294 const idle = b.slots > 0 && b.running < b.slots ? picture.idle : null;
371295 const week = strip === null ? null : weekFigure(strip);
372296 const lead = strip?.lead.medianHours ?? null;
373297 return html`<section class="hf-strip" id="hf-strip" aria-label="Today's figures" data-live="${STRIP_LIVE}" data-live-src="/live/strip">
374 ${needs}
375298 <div class="hf-figs">
376299 ${fig("Shipped in 24 hours", strip === null ? "—" : count(strip.landed), strip?.landed === 1 ? "change landed on main" : "changes landed on main", "/board", strip === null ? null : chart([...strip.landedHours].reverse(), "Changes landed per hour over the last 24 hours"))}
377300 ${fig("Median open to landed", lead === null ? "—" : duration(lead * 3_600_000), lead === null ? "nothing landed in 24 hours" : `median of ${count(strip!.lead.landed)} ${strip!.lead.landed === 1 ? "change" : "changes"}, 24 hours`, "/boards")}
@@ -403,10 +326,10 @@ export function readingLane(key: LaneKey, only: string | null): Html {
403326 /**
404327 * The strip before the picture exists. For the owner it draws the loaded strip's own figures
405328 * (same labels, links and classes, "—" for the value), so the two are the same height; anyone else
406 * gets the one line alone, as the loaded strip does.
329 * gets none, as with the loaded strip.
407330 */
408 export const readingStrip = (wide: boolean): Html =>
409 html`<section class="hf-strip" id="hf-strip" data-reading aria-busy="true" aria-label="${wide ? "Today's figures" : "What needs you"}" data-live="${STRIP_LIVE}" data-live-src="/live/strip"><p class="hf-calm"><span class="dot"></span>Reading today's figures…</p>${wide ? html`<div class="hf-figs">${READING_FIGS.map(([label, href]) => fig(label, "—", "\u00a0", href))}</div>` : null}</section>`;
331 export const readingStrip = (wide: boolean): Html | null =>
332 wide ? html`<section class="hf-strip" id="hf-strip" data-reading aria-busy="true" aria-label="Today's figures" data-live="${STRIP_LIVE}" data-live-src="/live/strip"><div class="hf-figs">${READING_FIGS.map(([label, href]) => fig(label, "—", "\u00a0", href))}</div></section>` : null;
410333 const READING_FIGS: readonly (readonly [string, string])[] = [
411334 ["Shipped in 24 hours", "/board"],
412335 ["Median open to landed", "/boards"],
@@ -549,8 +472,9 @@ function viewSwitch(view: "lanes" | "table", only: string | null): Html {
549472 </nav>`;
550473 }
551474
552 // GET / (signed in) — the home: the lanes, or the table of the same items. Called by the root
553 // route, and `/home` redirects here.
475 // GET / (signed in) — the home: the lanes, or the table of the same items, first on every width;
476 // nothing sits above them but the page's own header. Called by the root route, and `/home`
477 // redirects here.
554478 export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited<ReturnType<typeof spawnedForge>> }): Promise<Response> {
555479 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
556480 const user = ctx.auth.user;
@@ -565,7 +489,8 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited
565489 // or lean.
566490 const spawned = known !== undefined ? known.spawned : await timePhaseAsync(ctx.request, "spawned", () => spawnedForge(ctx.app));
567491 const wide = user.isAdmin && spawned === undefined;
568 const strip = picture === undefined ? readingStrip(wide) : stripRegion(picture, { id: user.id, isAdmin: wide, asked: asksToAnswer(ctx.app, user) }, ctx.app.config.dataDir, now);
492 const strip = picture === undefined ? readingStrip(wide) : stripRegion(picture, { isAdmin: wide }, ctx.app.config.dataDir, now);
493 const need = needLine(brokenOf(picture, wide, ctx.app.config.dataDir, now), new Set(asksToAnswer(ctx.app, user).map((a) => a.username)).size);
569494 // What the old home also carried and is not a lane: the box that tells the crew (with Notes and
570495 // Talk), the welcome after an account is allowed, a
571496 // spawned forge's address, and a stranger's request for an account. Setting notices (no key,
@@ -600,14 +525,14 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited
600525 </div>
601526 ${viewSwitch(view, only)}
602527 ${view === "lanes" ? filterForm(viewing?.repos ?? [], only) : null}
528 ${need}
603529 </header>
530 ${main}
604531 ${before}
605532 ${strip}
606533 ${deskStrip(ctx.app.db, readableNotes(ctx.app, ctx.auth.user))}
607534 ${stopped}
608535 ${after}
609 ${pileRegion(ctx.app.db, user, now)}
610 ${main}
611536 ${wide ? figuresSection(picture, now) : null}
612537 ${forges}
613538 <p class="hf-foot small muted">
@@ -688,7 +613,7 @@ export async function liveLaneFragment(ctx: Ctx): Promise<Response> {
688613 return res;
689614 }
690615
691 // GET /live/strip — the figures and the one line, alone.
616 // GET /live/strip — an admin's figures, alone; no one else has a strip.
692617 export async function liveStripFragment(ctx: Ctx): Promise<Response> {
693618 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
694619 const user = ctx.auth.user;
@@ -700,7 +625,7 @@ export async function liveStripFragment(ctx: Ctx): Promise<Response> {
700625 const picture = await timePhaseAsync(ctx.request, "picture", () => lanePicture(ctx.app.db, optionsOf(ctx, user), "lane", now));
701626 const rendering = performance.now();
702627 const wide = user.isAdmin && (await spawnedForge(ctx.app)) === undefined;
703 const res = fragment(picture === undefined ? readingStrip(wide) : stripRegion(picture, { id: user.id, isAdmin: wide, asked: asksToAnswer(ctx.app, user) }, ctx.app.config.dataDir, now), { request: ctx.request });
628 const res = fragment((picture === undefined ? readingStrip(wide) : stripRegion(picture, { isAdmin: wide }, ctx.app.config.dataDir, now)) ?? html``, { request: ctx.request, ...(wide ? {} : { status: 404 }) });
704629 notePhase(ctx.request, "render", performance.now() - rendering);
705630 return res;
706631 }
src/web/pages/home_flow_style.ts +5 −11
@@ -22,11 +22,10 @@ export const homeFlowCss = /* css */ `
2222
2323 /* ---- the strip ---- */
2424 .hf-strip { display: flex; flex-direction: column; gap: 8px; }
25 .hf-head + .hf-strip { margin-top: -8px; }
26 .hf-calm, .hf-need, .hf-forges { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 24px; font-size: 13px; color: var(--muted-fg); }
27 .hf-need { min-height: 44px; padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border)); border-radius: var(--radius); background: color-mix(in srgb, var(--danger) 8%, var(--card)); font-size: 14px; color: var(--fg); }
28 .hf-need a { text-decoration: underline; text-underline-offset: 2px; }
29 .hf-need-more { color: var(--muted-fg); white-space: nowrap; }
25 .hf-need, .hf-forges { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 24px; font-size: 13px; color: var(--muted-fg); }
26 .hf-need { flex: 1 1 100%; min-width: 0; }
27 .hf-need a { flex: none; color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
28 .hf-need-first { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3029 .hf-figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-1); }
3130 .hf-fig { position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0; min-height: 44px; padding: 12px 16px; background: var(--card); box-shadow: 0 0 0 0.5px var(--border); }
3231 .hf-fig:hover { background: var(--muted); color: var(--fg); }
@@ -202,13 +201,8 @@ export const homeFlowCss = /* css */ `
202201 }
203202
204203 /* ---- the figures ---- */
205 .hf-need { flex-wrap: wrap; }
206 .hf-need-sep { color: var(--muted-fg); }
207 /* The answers a need can be given where it is read (web/pages/hosted-forges.ts). */
204 /* The answers an ask can be given where it is read (/asks, web/studio/standing.ts). */
208205 .hf-need-acts { display: inline-flex; align-items: center; gap: 8px; }
209 /* A long sentence wraps beside its dot, never under it. */
210 .hf-need > .dot + a { max-width: calc(100% - 24px); }
211 .hf-need[data-tone="notice"] { border-color: var(--border); background: var(--card); }
212206 .fg { display: flex; flex-direction: column; gap: 8px; }
213207 .fg-sum { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; list-style: none; }
214208 .fg-sum::-webkit-details-marker { display: none; }
src/web/pages/pull.ts +10 −6
@@ -96,7 +96,7 @@ import { field, readForm } from "../form.ts";
9696 import { teamHoldRefusal, waitingOnTeams } from "../../core/teams_words.ts";
9797 import { teamsHolding, teamVerdicts, type TeamVerdict } from "../../core/issue_teams.ts";
9898 import { html, raw, when, type Html } from "../html.ts";
99 import { flashTo, fragment, page } from "../layout.ts";
99 import { flashTo, fragment, page, redirect } from "../layout.ts";
100100 import { liveRegionsJs } from "../client.ts";
101101 import { liveClientJs, liveMount } from "../live.ts";
102102 import {
@@ -1575,8 +1575,8 @@ export async function pullChecksSubmit(ctx: Ctx): Promise<Response> {
15751575 );
15761576 }
15771577
1578 // POST /:owner/:name/stuck — one choice over every pull of a stuck repository (#12611):
1579 // `choice` is recheck, builders or close, `reason` is said on a close.
1578 // POST /:owner/:name/stuck — one choice about a repository standing still (#12611):
1579 // `choice` is recheck, builders, close or off (turn the app off), `reason` is said on a close.
15801580 export async function stuckSubmit(ctx: Ctx): Promise<Response> {
15811581 const repo = loadRepo(ctx);
15821582 if (!repo) return notFoundPage(ctx);
@@ -1585,11 +1585,15 @@ export async function stuckSubmit(ctx: Ctx): Promise<Response> {
15851585 const form = await readForm(ctx, "rw");
15861586 if (form instanceof Response) return form;
15871587 const choice = field(form, "choice");
1588 // Back to where the form was: the home, or this repository's pulls; nothing else is honoured.
1589 const dest = field(form, "next") === `${repoBase(repo)}/pulls` ? `${repoBase(repo)}/pulls` : "/";
1590 if (!isPileChoice(choice)) return flashTo(ctx, dest, { tone: "danger", message: "Choose re-check, hand to builders or close." });
1588 // Back to where the form was: the asks page, or this repository's pulls; nothing else is
1589 // honoured, and anything else goes home.
1590 const next = field(form, "next");
1591 const dest = next === "/asks" || next === `${repoBase(repo)}/pulls` ? next : "/";
1592 if (!isPileChoice(choice)) return flashTo(ctx, dest, { tone: "danger", message: "Choose re-check, hand to builders, close, or turn the app off." });
15911593 const reason = field(form, "reason");
15921594 const done = await takePileChoice(ctx.app, ctx.auth.user, repo.id, choice, reason === "" ? {} : { reason });
1595 // Turned off from /asks, the page comes back with the app's row saying so and the way back on.
1596 if (!("error" in done) && done.choice === "off" && dest === "/asks") return redirect(`/asks?off=${encodeURIComponent(repo.id)}#standing`);
15931597 return flashTo(
15941598 ctx,
15951599 dest,
src/web/studio/ask_admin.ts +6 −5
@@ -29,7 +29,7 @@ export async function askAdminSubmit(ctx: Ctx): Promise<Response> {
2929 message:
3030 asked.value.state === "later"
3131 ? "They put this aside earlier today, so it was not raised again. It is still on their list."
32 : `Asked. ${asked.value.repoId === null ? "This forge's admins" : "The repository's admins"} see it on their home page, with the link to where it is changed.`,
32 : `Asked. ${asked.value.repoId === null ? "This forge's admins" : "The repository's admins"} see it counted on their home page and listed on their asks page, with the link to where it is changed.`,
3333 }
3434 : { tone: "danger", message: ASK_ADMIN_WORDS[asked.error] },
3535 );
@@ -51,16 +51,17 @@ export async function askAdminLater(ctx: Ctx): Promise<Response> {
5151 }
5252
5353 /**
54 * One waiting ask as the home's line says it: the sentence links to the exact control, with "Not
55 * now" beside it; `n` keeps the form ids apart.
54 * One waiting ask as `/asks` says it (`standing.ts`; the home only counts them): the sentence
55 * links to the exact control, with "Not now" beside it; `n` keeps the form ids apart and `back`
56 * is the page the answer returns to.
5657 */
57 export function adminAskNeed(a: AskView, n: number): { says: string; href: string; after: Html; forms: Html } {
58 export function adminAskNeed(a: AskView, n: number, back = "/asks"): { says: string; href: string; after: Html; forms: Html } {
5859 return {
5960 says: `${a.sentence} (${agoWords(a.lastAt)})`,
6061 href: a.href,
6162 after: html`<span class="hf-need-acts">${btn("Not now", { size: "sm", variant: "ghost", form: `ask-later-${n}`, label: `Put aside what ${a.username} asked for` })}</span>`,
6263 forms: html`<form method="post" action="/asks/admin/later" id="ask-later-${n}" hidden>
63 <input type="hidden" name="username" value="${a.username}" /><input type="hidden" name="want" value="${a.want}" /><input type="hidden" name="subject" value="${a.subject}" /><input type="hidden" name="back" value="/" />
64 <input type="hidden" name="username" value="${a.username}" /><input type="hidden" name="want" value="${a.want}" /><input type="hidden" name="subject" value="${a.subject}" /><input type="hidden" name="back" value="${back}" />
6465 </form>`,
6566 };
6667 }
src/web/studio/asks_page.ts +2 −1
@@ -49,6 +49,7 @@ import {
4949 ownerFactRepoIds,
5050 } from "../../core/repos.ts";
5151 import { html, type Html } from "../html.ts";
52 import { standingSections } from "./standing.ts";
5253 import { noteLine } from "./note.ts";
5354 import { page, redirect } from "../layout.ts";
5455 import { emptyList } from "../empty_words.ts";
@@ -467,7 +468,7 @@ function renderAsks(ctx: Ctx, top: AsksTop | undefined): Response {
467468 const response = page({
468469 ctx,
469470 title: "Asks",
470 body: html`<div class="stack"><h1 class="sr-only">Asks</h1>${muteFlash(ctx, user)}${onYouRegion(ctx, user, undefined, section.body)}<p class="small muted"><a href="/review">Review: one row per ask</a></p></div>`,
471 body: html`<div class="stack"><h1 class="sr-only">Asks</h1>${muteFlash(ctx, user)}${onYouRegion(ctx, user, undefined, section.body)}${standingSections(ctx, user)}<p class="small muted"><a href="/review">Review: one row per ask</a></p></div>`,
471472 scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${section.scriptJs}`,
472473 });
473474 notePhase(ctx.request, "render", performance.now() - rendering);
src/web/studio/standing.ts added +100
@@ -0,0 +1,100 @@
1 /**
2 * What `/asks` lists that the home page does not draw: the forge's own problems, the people
3 * stopped until this viewer changes a setting, and what stands still (a repository behind its
4 * pulls, an approved pull that has not landed). The home's one line counts the first two and links
5 * here (`needLine` in `web/pages/home_flow.ts`); the third is never on the home. Each row leads to
6 * the exact control, and a repository standing still offers its choices as buttons
7 * (`POST /:owner/:name/stuck`, `crew/stuck_pile.ts`), the last of them turning the app off.
8 */
9 import { asksToAnswer } from "../../actions/ask_admin.ts";
10 import { standingNeeds, STUCK_CHOICES } from "../../actions/needs.ts";
11 import { canAdmin, getRepoById } from "../../core/repos.ts";
12 import type { User } from "../../core/users.ts";
13 import { OFF_SAYS, PILE_CHOICES } from "../../crew/stuck_pile.ts";
14 import { FORGE_BROKEN } from "../../flow/alarms.ts";
15 import { forgeCeiling } from "../../flow/ceiling.ts";
16 import type { Ctx } from "../../http/context.ts";
17 import { running } from "../../kernel/version.ts";
18 import { proofNotice } from "../../release/prove.ts";
19 import { html, type Html } from "../html.ts";
20 import { btn } from "../ui.ts";
21 import { cachedAlarms } from "./alarm_lines.ts";
22 import { adminAskNeed } from "./ask_admin.ts";
23
24 /**
25 * What is broken about the forge itself, for an admin: the proof's alarm and the fired alarms of
26 * `FORGE_BROKEN`, each linked to where it is acted on. The list the home's count links to.
27 */
28 function brokenSection(ctx: Ctx, user: User, now: number): Html | null {
29 if (!user.isAdmin) return null;
30 const proof = proofNotice(ctx.app.config.dataDir, running().version, now);
31 const rows = [
32 ...(proof?.tone === "alarm" ? [{ says: proof.sentence, href: "/releases#proof" }] : []),
33 ...cachedAlarms(ctx.app.db, new Date(now), forgeCeiling(ctx.app.config), ctx.app.config.dataDir).filter((a) => FORGE_BROKEN.has(a.key)),
34 ];
35 if (rows.length === 0) return null;
36 return html`<section class="stack" id="forge-broken">
37 <h2>Problems with the forge</h2>
38 <ul class="list setting-list">${rows.map((r) => html`<li><a href="${r.href}">${r.says}</a></li>`)}</ul>
39 </section>`;
40 }
41
42 /** The people stopped until this viewer changes a setting, each with its control and "Not now". */
43 function askedSection(ctx: Ctx, user: User): Html | null {
44 const asked = asksToAnswer(ctx.app, user).map((a, n) => adminAskNeed(a, n, "/asks"));
45 if (asked.length === 0) return null;
46 return html`<section class="stack" id="asked">
47 <h2>Stopped until you answer</h2>
48 ${asked.map((a) => html`<p class="bar"><a href="${a.href}">${a.says}</a>${a.after}</p>${a.forms}`)}
49 </section>`;
50 }
51
52 /**
53 * The row an app turned off a moment ago leaves where its row was (`?off=<repo id>`, set by
54 * `stuckSubmit`): that it is off, and one button that turns it back on through the repository's
55 * own restore (`POST /:owner/:name/settings/archive`). Nothing for a repository that is not off or
56 * that this viewer does not administer.
57 */
58 function offRow(ctx: Ctx, user: User): Html | null {
59 const repo = getRepoById(ctx.app.db, ctx.url.searchParams.get("off") ?? "");
60 if (repo === undefined || repo.archivedAt === null || !canAdmin(ctx.app.db, repo, user)) return null;
61 const ref = `${repo.ownerName}/${repo.name}`;
62 return html`<form class="bar" method="post" action="/${ref}/settings/archive" data-standing-off="${repo.id}" role="status">
63 <input type="hidden" name="archived" value="0" /><input type="hidden" name="to" value="/asks" />
64 <span>${ref} is off.</span>
65 ${btn("Turn it back on", { size: "sm" })}
66 </form>`;
67 }
68
69 /**
70 * What stands still: a row per repository behind its pulls with its choices, then a row per
71 * approved pull a week old. Turning an app off is offered to one who administers it, with one
72 * sentence of what that does; it is not asked twice, and the app's row then offers the way back.
73 */
74 function stillSection(ctx: Ctx, user: User): Html | null {
75 const needs = standingNeeds(ctx, user);
76 const off = offRow(ctx, user);
77 if (needs.length === 0 && off === null) return null;
78 const piles = needs.filter((n) => n.id.startsWith("stuck:"));
79 const rows = needs.map((n) => {
80 if (!n.id.startsWith("stuck:")) return html`<p><a href="${n.link}">${n.sentence}</a></p>`;
81 const repo = getRepoById(ctx.app.db, n.id.slice(6));
82 const base = n.link.slice(0, -"/pulls".length);
83 return html`<div class="stack" data-standing="${n.id}">
84 <p>${n.sentence} <a href="${n.link}">See them</a></p>
85 <form class="bar" method="post" action="${base}/stuck">
86 <input type="hidden" name="next" value="/asks" />
87 ${PILE_CHOICES.map((choice, i) => (choice === "off" && (repo === undefined || !canAdmin(ctx.app.db, repo, user)) ? null : btn(STUCK_CHOICES[i]!, { size: "sm", name: "choice", value: choice })))}
88 </form>
89 </div>`;
90 });
91 return html`<section class="stack" id="standing">
92 <h2>Standing still</h2>
93 ${off} ${rows} ${piles.length === 0 ? null : html`<p class="muted small">${OFF_SAYS}</p>`}
94 </section>`;
95 }
96
97 /** The three sections, in the order the home's line counts them; nothing when all are empty. */
98 export function standingSections(ctx: Ctx, user: User, now = Date.now()): Html {
99 return html`${brokenSection(ctx, user, now)}${askedSection(ctx, user)}${stillSection(ctx, user)}`;
100 }
test/ask-admin.test.ts +9 −3
@@ -169,7 +169,7 @@ test("an ask about a repository reaches that repository's admins, and only for a
169169 });
170170 });
171171
172 test("the page: a guest presses the button, the admin's home says it with the link, and Not now puts it aside", async () => {
172 test("the page: a guest presses the button, the admin's home counts it, /asks says it with the link, and Not now puts it aside", async () => {
173173 const { app } = world;
174174 const form = (fields: Record<string, string>) => ({ method: "POST", body: new URLSearchParams(fields), headers: { "content-type": "application/x-www-form-urlencoded" } });
175175 const stateOf = () => app.db.query<{ state: string }, []>("SELECT state FROM admin_ask WHERE want = 'crew_key'").get()?.state;
@@ -181,9 +181,15 @@ test("the page: a guest presses the button, the admin's home says it with the li
181181 const pressed = await get(world, world.viewers.newcomer, "/asks/admin", form({ ask: "crew_key", back: "/settings" }));
182182 expect(pressed.final).toBe("/settings");
183183 expect(stateOf()).toBe("asked");
184 // The home counts it in its one line and links to the list; the list says it, with the control.
184185 const home = await get(world, world.viewers.admin, "/");
185 expect(home.body.includes("carol asks for a model key: the crew cannot start without one")).toBe(true);
186 expect(home.body.includes('href="/settings/crew#crew-key"')).toBe(true);
186 expect(home.body).toMatch(/<a href="\/asks#asked">(?:1 person is|\d+ people are) stopped until you answer<\/a>/);
187 expect(home.body.includes("carol asks for a model key")).toBe(false);
188 const asks = await get(world, world.viewers.admin, "/asks");
189 const asked = asks.body.slice(asks.body.indexOf('id="asked"'));
190 expect(asked.includes("carol asks for a model key: the crew cannot start without one")).toBe(true);
191 expect(asked.includes('href="/settings/crew#crew-key"')).toBe(true);
192 expect(asked.includes('name="back" value="/asks"')).toBe(true);
187193 // A member cannot answer what is the admins'.
188194 await get(world, world.viewers.member, "/asks/admin/later", form({ username: "carol", want: "crew_key", subject: "", back: "/" }));
189195 expect(stateOf()).toBe("asked");
test/home-flow.test.ts +25 −19
@@ -286,7 +286,6 @@ describe("before the first reading, a page never reads on the thread", () => {
286286 const html = await first.text();
287287 expect(html).toContain("data-reading");
288288 expect(html).toContain("Reading what the forge is doing");
289 expect(html).toContain("Reading today's figures");
290289 expect(html).toContain("Reading the hosted forges");
291290 for (const lane of LANES) expect(html).toContain(`id="lane-${lane}"`);
292291 expect(html).not.toContain("A cost ledger per delivery");
@@ -341,14 +340,15 @@ describe("the home is the root", () => {
341340 expect(c.headers.get("location")).toBe("/");
342341 });
343342
344 test("it carries the box that tells the crew with Notes and Talk, one line that needs the owner with the real count, and no second pipeline", async () => {
343 test("it carries the box that tells the crew with Notes and Talk under the lanes, no line at all on a healthy forge, and no second pipeline", async () => {
345344 const html = await (await get("/", owner)).text();
346345 expect(html).toContain('id="tell-box"');
347346 expect(html).toContain('href="/notes"');
348347 expect(html).toContain('href="/talk"');
349348 for (const old of ["Being built", "Just shipped", "Later gate", "Since you were here", 'id="live-moving"', 'id="now-line"', 'id="needs-you"'])
350349 expect(html).not.toContain(old);
351 expect(html.match(/hf-need|hf-calm/g)?.length).toBeLessThanOrEqual(2);
350 expect(html).not.toMatch(/class="hf-need"|hf-calm|Nothing needs you/);
351 expect(html.indexOf('id="tell-box"')).toBeGreaterThan(html.indexOf('class="hf-lanes"'));
352352 });
353353 });
354354
@@ -359,28 +359,34 @@ describe("a proof that did not pass is told in words, with its own record, and r
359359 };
360360 const RATE = "a stranger's journey failed: the forge could not be named: it sent the person somewhere else (/?start=rate&name=probe-0a9a10a2#start-f)";
361361
362 test("a stranger turned away by the sign-up limit is a notice: the release is serving, no query string, one line", async () => {
362 test("a stranger turned away by the sign-up limit is not the forge being broken: the release is serving, so the home says nothing of it", async () => {
363363 await write({ failure: RATE, failures: 2 });
364364 const html = await (await get("/", owner)).text();
365 const need = html.match(/<p class="hf-need"[\s\S]*?<\/p>/)?.[0] ?? "";
366 expect(need).toContain('data-tone="notice"');
367 expect(need).toContain("is serving");
368 expect(need).toContain("sign-up limit");
369 expect(need).toContain('href="/releases#proof"');
370 expect(need).not.toContain("start=rate");
371 expect(need).not.toContain("probe-");
372 expect(need).not.toContain('data-tone="danger"');
373 expect(html.match(/class="hf-need"/g)?.length).toBe(1);
374 // a person who cannot administer the forge is not told of it
375 expect(await (await get("/", bob)).text()).not.toContain("sign-up limit");
365 expect(html).not.toContain('class="hf-need"');
366 expect(html).not.toContain("sign-up limit");
367 expect(html).not.toContain("start=rate");
368 expect(await (await get("/asks", owner)).text()).not.toContain('id="forge-broken"');
376369 });
377370
378 test("a public address that did not answer as the release is red, and says it is not serving", async () => {
371 test("a public address that did not answer as the release is the forge broken: one line in the header with a count, and /asks lists it", async () => {
379372 await write({ failure: "https://f/a.css expected 200 (status 500)" });
380 const need = (await (await get("/", owner)).text()).match(/<p class="hf-need"[\s\S]*?<\/p>/)?.[0] ?? "";
381 expect(need).toContain('data-tone="alarm"');
373 const html = await (await get("/", owner)).text();
374 const need = html.match(/<p class="hf-need"[\s\S]*?<\/p>/)?.[0] ?? "";
375 expect(need).toContain('<a href="/asks#forge-broken">1 problem with the forge</a>');
382376 expect(need).toContain("is not serving as it should");
383 expect(need).toContain('data-dot="danger"'.replace("data-dot", "data-tone"));
377 expect(need).toContain('data-tone="danger"');
378 expect(html.match(/class="hf-need"/g)?.length).toBe(1);
379 // The line is in the page's own header, above the lanes; nothing else is.
380 const head = html.indexOf('<header class="hf-head">');
381 expect(html.indexOf('class="hf-need"')).toBeGreaterThan(head);
382 expect(html.indexOf('class="hf-need"')).toBeLessThan(html.indexOf("</header>", head));
383 const asks = await (await get("/asks", owner)).text();
384 const listed = asks.slice(asks.indexOf('id="forge-broken"'));
385 expect(listed).toContain("<h2>Problems with the forge</h2>");
386 expect(listed).toMatch(/<a href="\/releases#proof">[^<]*is not serving as it should/);
387 // a person who cannot administer the forge is not told of it, on either page
388 expect(await (await get("/", bob)).text()).not.toContain('class="hf-need"');
389 expect(await (await get("/asks", bob)).text()).not.toContain('id="forge-broken"');
384390 });
385391
386392 test("the releases page opens on the proof's record: where it stopped, what happened, when it tries again, and a way to try now", async () => {
test/home-kpi-row.test.ts +4 −3
@@ -246,10 +246,11 @@ describe("home waiting line", () => {
246246 expect(body).toMatch(/<p class="small muted break stack stack-tight"><span>3 waiting on you, oldest 2 days<\/span><a href="\/review">Review them<\/a><\/p>/);
247247 }, 30_000);
248248
249 test("the home says it once, as the one line that needs the owner: the real count, the oldest in days, linking to /review", async () => {
249 test("the home does not say it: what waits on a person is on /review and in the header's count, never above the lanes", async () => {
250250 const body = await homeWith([30, 40, 50], undefined, "/");
251 expect(body).toMatch(/<p class="hf-need"[^>]*role="status">[\s\S]*?<a href="\/review">3 waiting on you, oldest 2 days<\/a>/);
252 expect(body).not.toContain(" h</a>");
251 expect(body).toMatch(/class="hf-lanes"/);
252 expect(body).not.toContain("waiting on you");
253 expect(body).not.toContain('class="hf-need"');
253254 expect(body).not.toContain("Review them");
254255 }, 30_000);
255256
test/home-no-shift.test.ts +3 −1
@@ -145,7 +145,9 @@ describe("the signed-in home", () => {
145145
146146 test("each reading renderer, called directly, reserves", () => {
147147 const q = parseTable(new URLSearchParams());
148 const states = [readingStrip(true), readingStrip(false), readingTable(q), readingForges(), ...LANES.map((k) => readingLane(k, null))];
148 // Only an admin has a strip, so only an admin's is reserved for.
149 expect(readingStrip(false)).toBeNull();
150 const states = [readingStrip(true), readingTable(q), readingForges(), ...LANES.map((k) => readingLane(k, null))];
149151 for (const state of states) {
150152 expect(String(state)).toContain("data-reading");
151153 expect(unreserved(String(state), rules)).toEqual([]);
test/home-quiet.test.ts +1 −1
@@ -69,7 +69,7 @@ test("a forge whose crew has no model key says so on /settings/crew, and / stays
6969 const home = await (await fetch(`${servers.url}/`, { headers: { cookie } })).text();
7070 expect(home).not.toContain(NO_KEY_LINE);
7171 expect(home).not.toContain("/settings/crew#crew-key");
72 expect(home).toContain("Nothing needs you right now.");
72 expect(home).not.toContain('class="hf-need"');
7373 expect({ offending: noticesAbove(home) }).toEqual({ offending: [] });
7474 const crew = await (await fetch(`${servers.url}/settings/crew`, { headers: { cookie } })).text();
7575 expect(crew).toContain('id="crew-key"');
test/no-alarm-banner.test.ts +7 −4
@@ -159,9 +159,11 @@ const said = (html: string): string =>
159159 const ALARMS: readonly { readonly alarm: string; readonly says: string; readonly pages: readonly string[] }[] = [
160160 { alarm: "disk full", says: "disk has 0.0% free", pages: ["/", "/alice/forge/next", "/alice/forge", "/system"] },
161161 { alarm: "disk full, as the board needs it", says: "Disk is nearly full", pages: ["/board"] },
162 { alarm: "backup overdue", says: "the bucket refused", pages: ["/", "/board"] },
163 // The home (the lanes, since 2026-11-13) says the two most pressing in one needs line and counts
164 // the rest; every sentence in full is on /boards.
162 { alarm: "backup overdue", says: "the bucket refused", pages: ["/asks", "/board"] },
163 // The home (the lanes first, since 2026-11-15) counts what is broken about the forge in one
164 // quiet line, with the first of them beside the count; each sentence in full is on /asks, and
165 // every alarm's on /boards.
166 { alarm: "what is broken, as home counts it", says: "2 problems with the forge", pages: ["/"] },
165167 { alarm: "bug past its clock", says: "Bug past its clock: alice/forge#1", pages: ["/boards"] },
166168 { alarm: "bug past its clock, as home counts it", says: "1 past their clock", pages: ["/"] },
167169 { alarm: "main red", says: "Main has been red for", pages: ["/", "/boards"] },
@@ -174,7 +176,8 @@ const PAGES = ["/", "/alice/forge/next", "/alice/forge", "/board", "/boards", "/
174176 test("each alarm is raised, said on its page, and no page draws a banner for any of them", async () => {
175177 const w = await open(0);
176178 const html = new Map<string, string>();
177 for (const path of PAGES) {
179 // /asks is read for its words alone: its own cards are not this file's to judge.
180 for (const path of [...PAGES, "/asks"]) {
178181 const page = await read(w, path);
179182 expect(page).toContain("<main");
180183 html.set(path, page);
test/stuck-pile-doors.test.ts +123 −3
@@ -1,12 +1,16 @@
11 /**
2 * The doors of the stuck pile (#12611): the form on the home, the MCP `forge` tool and the
3 * terminal's needs screen each take one choice over all of a stuck repository's pulls, and each
4 * refuses who may not and plans before it acts.
2 * The doors of a repository standing still (#12611): its row on `/asks`, the MCP `forge` tool and
3 * the terminal's needs screen each take one choice about it, turning the app off among them, and
4 * each refuses who may not and plans before it acts. The home draws none of it: its lanes come
5 * first, on every width.
56 */
67 import { afterAll, beforeAll, beforeEach, expect, test } from "bun:test";
78 import { snappyFixture, type SnappyFixture } from "../bench/snappy.ts";
89 import { needsStack } from "../src/actions/needs.ts";
10 import { OFF_SAYS } from "../src/crew/stuck_pile.ts";
11 import { getRepoById } from "../src/core/repos.ts";
912 import { forgetStuckRepos } from "../src/flow/stuck_pile.ts";
13 import { homeFlowCss } from "../src/web/pages/home_flow_style.ts";
1014 import { tool as forgeTool } from "../src/http/mcp/tools/forge.ts";
1115 import { needsScreen } from "../src/tui/screens/needs.ts";
1216 import type { Ctx as TuiCtx, Screen } from "../src/tui/app/app.ts";
@@ -29,6 +33,7 @@ afterAll(() => f.close());
2933 beforeEach(() => {
3034 forgetStuckRepos(f.app.db);
3135 f.app.db.run("DELETE FROM issue WHERE kind = 'pull'");
36 f.app.db.run("UPDATE repo SET archived_at = NULL");
3237 for (let i = 0; i < 3; i++) {
3338 n++;
3439 const at = new Date(Date.now() - 10 * DAY).toISOString();
@@ -69,6 +74,86 @@ test("POST /stuck: a writer closes them with a reason, and is sent back to the p
6974 expect(open()).toBe(0);
7075 });
7176
77 const page = async (at: string, cookie = f.ownerCookie): Promise<string> => (await fetch(`${f.base}${at}`, { headers: { cookie } })).text();
78 /** One of the seeded pulls approved `days` ago: the row the week sweep leaves to a person. */
79 const approve = (days: number): void =>
80 void f.app.db.run("INSERT OR REPLACE INTO review (id, issue_id, author_id, state, created_at) VALUES ('spr', ?1, ?2, 'approved', ?3)", [`sp${n}`, f.owner.id, new Date(Date.now() - days * DAY).toISOString()]);
81
82 test("the home: the lanes are the first thing under the header, on a phone as on a desk, and nothing standing still is on it", async () => {
83 approve(9);
84 const html = await page("/");
85 const head = html.indexOf('<header class="hf-head">');
86 const lanes = html.indexOf('class="hf-lanes"');
87 expect(head).toBeGreaterThan(-1);
88 expect(lanes).toBeGreaterThan(head);
89 // Between the header's end and the lanes there is no element at all.
90 expect(html.slice(html.indexOf("</header>", head) + "</header>".length, html.lastIndexOf("<", lanes)).trim()).toBe("");
91 // The header itself holds no notice on a healthy forge: the title, the view switch, the filter.
92 expect(html.slice(head, lanes)).not.toMatch(/hf-need|role="(?:status|alert)"/);
93 for (const after of ['class="hf-tell"', 'id="hf-strip"']) expect(html.indexOf(after)).toBeGreaterThan(lanes);
94 // A phone (390 px) reads the same order: the stylesheet moves nothing above the lanes.
95 expect(homeFlowCss).not.toMatch(/[\s;{]order\s*:|flex-direction:\s*\w+-reverse/);
96 expect(html).not.toMatch(/data-lane="pile"|has not landed|nobody has touched|sat approved|Standing still|Turn this app off/);
97 expect(html).not.toContain(`${path.slice(1)} is stuck`);
98 expect(html).not.toContain(`action="${path}/stuck"`);
99 });
100
101 test("/asks lists it under Standing still: the calm sentence, its choices as buttons, what turning off does, and the approved pull", async () => {
102 approve(9);
103 const html = await page("/asks");
104 const still = html.slice(html.indexOf('id="standing"'));
105 expect(still).toContain("<h2>Standing still</h2>");
106 expect(still).toContain(`${path.slice(1)}: 3 pulls nobody has touched since `);
107 expect(still).toContain("Nothing new can start there until they move.");
108 expect(still).toContain(`action="${path}/stuck"`);
109 expect(still).toContain('name="next" value="/asks"');
110 for (const [value, label] of [["recheck", "Re-check its pulls"], ["builders", "Hand its pulls to builders"], ["close", "Close its stale pulls"], ["off", "Turn this app off"]])
111 expect(still).toMatch(new RegExp(`<button[^>]*name="choice"[^>]*value="${value}"[^>]*>[\\s\\S]*?${label}`));
112 expect(still).toContain(OFF_SAYS);
113 expect(still).toMatch(new RegExp(`href="${path}/pulls/${n}"[^>]*>[^<]*was approved 9 days ago and has not landed`));
114 expect(still).not.toMatch(/is stuck/);
115 // Someone who cannot write there is shown none of it.
116 expect(await page("/asks", f.peerCookie)).not.toContain('id="standing"');
117 });
118
119 test("Turn this app off: the row's button archives the repository, its row is gone from every door, and nothing counts it", async () => {
120 const off = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "off", next: "/asks" });
121 expect(off.status).toBe(303);
122 expect(off.headers.get("location")).toBe(`/asks?off=${repoId}#standing`);
123 expect(getRepoById(f.app.db, repoId)!.archivedAt).not.toBeNull();
124 expect(open()).toBe(3);
125 forgetStuckRepos(f.app.db);
126 expect(await page("/asks")).not.toContain(`action="${path}/stuck"`);
127 // Where its row was, the page says it is off and offers the way back in one button.
128 const there = await page(`/asks?off=${repoId}`);
129 const row = there.slice(there.indexOf(`data-standing-off="${repoId}"`) - 200).slice(0, 900);
130 expect(row).toContain(`action="${path}/settings/archive"`);
131 expect(row).toContain('name="archived" value="0"');
132 expect(row).toContain(`${path.slice(1)} is off.`);
133 expect(row).toContain("Turn it back on");
134 // Someone who does not administer it is offered nothing.
135 expect(await page(`/asks?off=${repoId}`, f.peerCookie)).not.toContain("data-standing-off");
136 expect(needsStack({ app: f.app }, f.owner).filter((x) => x.id.startsWith("stuck:"))).toEqual([]);
137 // Off already, there is nothing left to choose about it.
138 const again = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "close", next: "/asks" });
139 expect(again.status).toBe(303);
140 expect(open()).toBe(3);
141 // The button: one press and the app is on again, its row back with its choices.
142 const on = await fetch(`${f.base}${path}/settings/archive`, {
143 method: "POST",
144 redirect: "manual",
145 headers: { "content-type": "application/x-www-form-urlencoded", origin: f.base, cookie: f.ownerCookie },
146 body: new URLSearchParams({ archived: "0", to: "/asks" }),
147 });
148 expect(on.status).toBe(303);
149 expect(on.headers.get("location")).toBe("/asks");
150 expect(getRepoById(f.app.db, repoId)!.archivedAt).toBeNull();
151 forgetStuckRepos(f.app.db);
152 const back = await page(`/asks?off=${repoId}`);
153 expect(back).toContain(`action="${path}/stuck"`);
154 expect(back).not.toContain("data-standing-off");
155 });
156
72157 test("POST /stuck: the home is the default way back, and an address elsewhere is not followed", async () => {
73158 const res = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "recheck", next: "https://evil.example/" });
74159 expect(res.status).toBe(303);
@@ -97,6 +182,26 @@ test("MCP forge: a choice is a plan unless dryRun is false; a bad choice and a n
97182 expect(open()).toBe(0);
98183 });
99184
185 test("MCP forge: off is planned first, and done only with an admin token, as `archive` is", async () => {
186 const ctxWith = (scope: "rw" | "admin"): HttpCtx => ({
187 app: f.app,
188 request: new Request("http://localhost/mcp"),
189 url: new URL("http://localhost/mcp"),
190 params: {},
191 auth: { user: f.owner, scope, via: "token" },
192 theme: undefined,
193 });
194 const run = (scope: "rw" | "admin", args: Record<string, unknown>) => forgeTool.run(ctxWith(scope), f.owner, args) as Promise<{ ok: boolean; value?: unknown }>;
195 expect(await run("rw", { apply: `stuck:${repoId}`, choice: "off" })).toMatchObject({ ok: true, value: { choice: "off", dryRun: true } });
196 expect((await run("rw", { apply: `stuck:${repoId}`, choice: "off", dryRun: false })).ok).toBe(false);
197 expect(getRepoById(f.app.db, repoId)!.archivedAt).toBeNull();
198 expect(await run("admin", { apply: `stuck:${repoId}`, choice: "off", dryRun: false })).toMatchObject({
199 ok: true,
200 value: { choice: "off", dryRun: false, undo: `archive {repo:"${path.slice(1)}", archived:false, dryRun:false}` },
201 });
202 expect(getRepoById(f.app.db, repoId)!.archivedAt).not.toBeNull();
203 });
204
100205 /** The terminal: screens pushed are kept, a key is a key. */
101206 function terminal() {
102207 const toasts: string[] = [];
@@ -136,6 +241,21 @@ test("the terminal: r and h plan first and act only on a yes; Esc leaves everyth
136241 expect(t.toasts.join(" ")).toContain("left alone");
137242 });
138243
244 test("the terminal: o says what turning off does, and turns the app off only on a yes", async () => {
245 const t = terminal();
246 for (let i = 0; i < t.at; i++) await t.press("j");
247 await t.press("o");
248 expect(t.stack).toHaveLength(1);
249 expect(getRepoById(f.app.db, repoId)!.archivedAt).toBeNull();
250 await t.press("enter", t.stack[0]!);
251 expect(getRepoById(f.app.db, repoId)!.archivedAt).not.toBeNull();
252 expect(t.toasts.at(-1)).toContain("is off");
253 expect(t.toasts.at(-1)).toContain("Press u to turn it back on.");
254 await t.press("u");
255 expect(getRepoById(f.app.db, repoId)!.archivedAt).toBeNull();
256 expect(t.toasts.at(-1)).toContain("is back on.");
257 });
258
139259 test("the terminal: c asks for a reason, plans, and closes every pull on a yes", async () => {
140260 const t = terminal();
141261 for (let i = 0; i < t.at; i++) await t.press("j");
test/stuck-pile.test.ts +53 −14
@@ -1,7 +1,7 @@
11 /**
2 * A repository stuck behind its own pulls (#12611): found, raised once in the needs stack for
3 * whoever writes there, shown as a lane of its own on the home, and moved by its three choices;
4 * and a re-check says where it stands in the line.
2 * A repository standing still behind its own pulls (#12611): found, raised once in the needs
3 * stack for whoever writes there in calm words, never one that is turned off, and moved by its
4 * choices; and a re-check says where it stands in the line.
55 */
66 import type { CheckSummary } from "../src/core/runs.ts";
77 import { afterAll, beforeAll, beforeEach, expect, test } from "bun:test";
@@ -17,9 +17,10 @@ import { getPull } from "../src/core/pulls.ts";
1717 import { placeWords, queuePlace } from "../src/checks/place.ts";
1818 import { getRun } from "../src/core/runs.ts";
1919 import { createUser, getUserByName, type User } from "../src/core/users.ts";
20 import { pilePlan, takePileChoice } from "../src/crew/stuck_pile.ts";
21 import { forgetStuckRepos, PILE_MIN, readStuckRepos } from "../src/flow/stuck_pile.ts";
22 import { pileRegion } from "../src/web/pages/home_flow.ts";
20 import { assignIssue } from "../src/actions/issues.ts";
21 import { getIssue } from "../src/core/issues.ts";
22 import { OFF_SAYS, pilePlan, pileWords, takePileChoice, turnBackOn, type PileDone } from "../src/crew/stuck_pile.ts";
23 import { forgetStuckRepos, PILE_MIN, pileSentence, readStuckRepos } from "../src/flow/stuck_pile.ts";
2324
2425 const DAY = 86_400_000;
2526 const now = new Date("2026-11-14T12:00:00Z");
@@ -50,6 +51,7 @@ beforeEach(() => {
5051 forgetStuckRepos(app.db);
5152 app.db.run("DELETE FROM run");
5253 app.db.run("DELETE FROM issue");
54 app.db.run("UPDATE repo SET archived_at = NULL");
5355 });
5456
5557 /** An open pull whose check on its head is `check`, last touched `idle` days ago. */
@@ -92,19 +94,56 @@ test("the needs stack raises it once, by name, for a writer and not for anyone e
9294 for (let i = 0; i < 4; i++) pull({ check: "failed", idle: 10 });
9395 const rows = needsStack({ app }, alice).filter((r) => r.id.startsWith("stuck:"));
9496 expect(rows).toHaveLength(1);
95 expect(rows[0]!.sentence).toContain("alice/scratch is stuck: 4 open pulls");
96 expect(rows[0]!.choices).toEqual(["Re-check all on today's main", "Hand all to builders", "Close all with a reason"]);
97 expect(rows[0]!.sentence).not.toContain("stuck");
98 expect(rows[0]!.sentence).toContain("alice/scratch: 4 pulls nobody has touched since");
99 expect(rows[0]!.choices).toEqual(["Re-check its pulls", "Hand its pulls to builders", "Close its stale pulls", "Turn this app off"]);
97100 expect(rows[0]!.recommended.safe).toBe(false);
98101 expect(needsStack({ app }, bob).filter((r) => r.id.startsWith("stuck:"))).toEqual([]);
99102 });
100103
101 test("the home shows the pile as one lane of its own with an age on each pull", () => {
104 test("the sentence says what is true and calm: how many, since what day, and what it holds up", () => {
105 const held = "Nothing new can start there until they move.";
106 const s = { ref: "trevato/scratchpad", open: 38, red: 0, untouched: 38, touchedAt: "2026-11-02T09:00:00.000Z" };
107 expect(pileSentence(s)).toBe(`trevato/scratchpad: 38 pulls nobody has touched since 2 Nov. ${held}`);
108 expect(pileSentence({ ...s, red: 5 })).toBe(`trevato/scratchpad: 38 pulls nobody has touched since 2 Nov, 5 with a failing check. ${held}`);
109 expect(pileSentence({ ...s, red: 30, untouched: 8 })).toBe(`trevato/scratchpad: 38 pulls, 30 with a failing check, the rest untouched for 3 days or more. ${held}`);
110 for (let i = 0; i < 3; i++) pull({ idle: 12 + i });
111 expect(pileSentence(readStuckRepos(app.db, now)[0]!)).toBe(`alice/scratch: 3 pulls nobody has touched since 2 Nov. ${held}`);
112 });
113
114 test("a repository that is turned off is never counted, and turning it off is the archive: planned first, an admin's, undone by waking", async () => {
102115 for (let i = 0; i < 3; i++) pull({ check: "failed", idle: 10 });
103 const html = String(pileRegion(app.db, alice, now.getTime()));
104 expect(html).toContain('data-lane="pile"');
105 expect(html).toContain("10 d");
106 expect(html).toContain('action="/alice/scratch/stuck"');
107 expect(pileRegion(app.db, bob, now.getTime())).toBeNull();
116 expect(await takePileChoice(app, bob, "r1", "off")).toEqual({ error: "not found" });
117 const plan = await takePileChoice(app, alice, "r1", "off", { dryRun: true });
118 expect(plan).toEqual({ choice: "off", dryRun: true, acted: [], left: [], ref: "alice/scratch" });
119 await crewPull("failed");
120 const bot = getUserByName(app.db, "bot")!;
121 const ask = (): ReturnType<typeof getIssue> => getIssue(app.db, "r1", 901);
122 app.db.run("INSERT INTO issue (id, repo_id, number, kind, title, author_id, state) VALUES ('is2', 'r1', 901, 'issue', 'an ask', ?1, 'open')", [alice.id]);
123 const give = () => assignIssue(app, alice, getRepoById(app.db, "r1")!, ask()!, bot);
124 expect(pilePlan(plan as PileDone)).toEqual(["Turn alice/scratch off.", OFF_SAYS]);
125 expect(getRepoById(app.db, "r1")!.archivedAt).toBeNull();
126 const done = await takePileChoice(app, alice, "r1", "off");
127 expect(pileWords(done as PileDone)).toContain("alice/scratch is off");
128 // The answer carries the exact call that turns it back on, and off the crew starts nothing.
129 expect((done as PileDone).undo).toBe('archive {repo:"alice/scratch", archived:false, dryRun:false}');
130 expect(give()).toMatchObject({ ok: false, error: "archived" });
131 expect(getRepoById(app.db, "r1")!.archivedAt).not.toBeNull();
132 // Its pulls are as they were, and it is not standing still any more: it is off.
133 expect(app.db.query("SELECT COUNT(*) AS n FROM issue WHERE kind = 'pull' AND state = 'open'").get()).toEqual({ n: 4 });
134 expect(readStuckRepos(app.db, now)).toEqual([]);
135 forgetStuckRepos(app.db);
136 expect(needsStack({ app }, alice).filter((r) => r.id.startsWith("stuck:"))).toEqual([]);
137 // Turned back on, by its admin alone, it is as it was: on, counted again, and the crew may be
138 // given work there.
139 expect(await turnBackOn(app, bob, "r1")).toEqual({ error: "only an admin of that repository turns it back on" });
140 expect(getRepoById(app.db, "r1")!.archivedAt).not.toBeNull();
141 expect(await turnBackOn(app, alice, "r1")).toEqual({ ref: "alice/scratch" });
142 expect(getRepoById(app.db, "r1")!.archivedAt).toBeNull();
143 expect(readStuckRepos(app.db, now)).toHaveLength(1);
144 forgetStuckRepos(app.db);
145 expect(needsStack({ app }, alice).filter((r) => r.id.startsWith("stuck:"))).toHaveLength(1);
146 expect(give().ok).toBe(true);
108147 });
109148
110149 test("closing all closes every pull with the reason and sets its issue ready again", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs