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

Say where a pull stands in one pane: one reader, three doors #17187

opened this

Merged 41h 35m ago, live in production

slice2 → main 0 commits 5 threads · 5 unresolved

  • Merged. slice2 was merged into main as 32c8a8a.

Review

Sign in to review this change.
30 files changed +789 −184
docs/design/areas/pull.md +1 −1
@@ -4,7 +4,7 @@ Every forge pull's preview carries desk and phone looks of this page as the owne
44
55 A pull is one change waiting on a person: read it, see its check, ship it or say what is off (#8773).
66
7 At rest: the state is a dot (`.dot`, `role=img`, one `aria-label`, no `title`), with the word written beside it once the pull is settled. The check is one muted line. The decision is a plain block holding the page's one primary action (Ship); Comment steps down while it is there. The path line carries "Next: …" in the same paragraph. The where strip is left to the repository's home.
7 At rest, under the title on both tabs, the pane (`src/web/studio/pane.ts`, `.pane`, `.pane-says`, `.pane-evidence`, `.pane-verbs`, `.pane-form`): one sentence of where it stands with its tone's `.dot` (`src/flow/pull_pane.ts`, the same words the terminal's pull screen and the peek print), one muted line of what shows it (the conflicting files, the run's last word), and at most three verbs, each a small `.btn` with its key in a `<kbd>` from the keymap. A verb posts through the act's own route (`.pane-form` is `display: contents`, so the buttons sit in one row) or links to its control. It replaces the state dot and word, the path line, the waits-for line and the verdict line: one way to say one thing. The check is one muted line. The decision is a plain block holding the page's one primary action (Ship); Comment steps down while it is there. The where strip is left to the repository's home.
88
99 Rare actions (Hold, Take it back) sit in a `<details id="more" class="mt mb">`, the same disclosure Hold always used. Their palette rows link to `?more=1#hold` / `?more=1#take-back`: the server renders the details open for `?more`, so the target is visible with no script. Every other action is a palette row too (`pullActions`, "This pull request"). No new class.
1010
docs/features/pull-pane.md added +20
@@ -0,0 +1,20 @@
1 ---
2 topic: Ship and undo
3 row: The pull pane: where a pull stands in one sentence, with its keys
4 ---
5 # The pull pane
6
7 A pull says where it stands in one sentence, with what shows it and at most three verbs, each a key from the forge's one keymap (`src/web/keymap.ts`).
8
9 - **One reader:** `src/flow/pull_pane.ts` (`pullPane`, `paneOf`) reads the facts the flow already trusts: who acts next (`nextOfPull`, which carries a hold), the head's check and its place in the queue, the crew's unfinished run on the pull, and whether production has served since a merge.
10 - **Three doors, one sentence:** the pull page (both tabs, under the title, `src/web/studio/pane.ts`), the terminal's pull screen, and the peek card that a link to a pull shows on hover. Each prints the same sentence.
11 - **States:** draft, held, conflict, building, checking, red, changes asked, a person decides, waits for a review, ready, merged, closed. `test/pull-pane.test.ts` holds each one's sentence, verbs and evidence.
12 - **Verbs** go through the doors the acts already have:
13 - a run's stop and queue again post to the run's routes;
14 - update and close post to the pull's routes;
15 - merge goes to the merge box;
16 - a review verdict goes to the review form. On the Files tab, `a` and `b` are links to the form's own choices: with the script the click or the key picks the choice and puts the caret in the box, and with none the link takes the reader there.
17 - A verb the viewer may not use is not drawn.
18 - **Replaces:** the state dot and word, the path line ("Check · Review · Land · Live"), the waits-for line and the verdict line on the pull page; and, on the terminal, the "step:" and "next:" parts of the pull's line. `verdictOf` still answers the merge box's question.
19
20 Next: the pane's keys in place (lanes, `#hash` following focus, `v` on lists), on the shared focus layer (`src/web/focus/`, #17173).
src/flow/next_actor.ts +8 −2
@@ -19,6 +19,12 @@ export type Actor = "builder" | "reviewer" | "queue" | "person";
1919 export interface Next {
2020 readonly who: Actor;
2121 readonly why: string;
22 /** Set when a hold is the reason (the pull pane says it as its own state). */
23 readonly held?: true;
24 /**
25 * Set when a reviewer's asked-for changes on this head are the reason (the pane's own state too).
26 */
27 readonly changes?: true;
2228 }
2329
2430 export interface NextInput {
@@ -50,7 +56,7 @@ const WAITING = {
5056
5157 export function nextActor(i: NextInput): Next {
5258 if (i.held !== null)
53 return { who: "person", why: `${i.held.by} holds it: ${i.held.why}` };
59 return { who: "person", why: `${i.held.by} holds it: ${i.held.why}`, held: true };
5460 if (i.conflicted) return { who: "builder", why: "it conflicts with its base" };
5561 if (i.changesRequested > 0 && i.firstChange === true && i.check !== "failed") {
5662 if (i.wall != null && i.wall.length > 0) return { who: "person", why: wallAsk(i.wall) };
@@ -58,7 +64,7 @@ export function nextActor(i: NextInput): Next {
5864 return { who: "queue", why: WAITING[i.check] };
5965 }
6066 if (i.changesRequested > 0)
61 return { who: "builder", why: i.askedBy == null ? "changes were asked on this head" : `changes were asked on this head: ${i.askedBy}` };
67 return { who: "builder", why: i.askedBy == null ? "changes were asked on this head" : `changes were asked on this head: ${i.askedBy}`, changes: true };
6268 if (i.check === "failed") return { who: "builder", why: "its check is red" };
6369 if (i.wall != null && i.wall.length > 0) return { who: "person", why: wallAsk(i.wall) };
6470 if (i.approvals > 0) {
src/flow/path.ts +1 −1
@@ -87,7 +87,7 @@ const CHECK_WORDS: Record<Exclude<RunState, "ok">, string> = {
8787 };
8888
8989 /** Whether production for `repo` has deployed since `at`. */
90 function deployedSince(db: Database, repoId: string, at: string): boolean {
90 export function deployedSince(db: Database, repoId: string, at: string): boolean {
9191 return (
9292 db
9393 .query<{ n: number }, [string, string]>(
src/flow/pull_pane.ts added +196
@@ -0,0 +1,196 @@
1 /**
2 * A pull in one sentence, its next acts and what shows it (the owner's single pane): one reader,
3 * and the pull page, the terminal's pull screen and the peek all print what it says, so the three
4 * doors never disagree about where a pull stands.
5 *
6 * `paneOf` is plain data in, plain data out; `pullPane` reads the facts for one pull from the
7 * readers the flow already trusts (`nextOfPull`, which carries the hold, `checkSummary`,
8 * `queuePlace`, `stepOfPull`'s deploy question) and adds nothing of its own. The sentence replaces
9 * the state pill and the path and waits-for lines it was drawn from: one way to say one thing.
10 *
11 * The verbs are at most three, named by the keymap's ids (src/web/keymap.ts VERBS), never by a key,
12 * so a door draws each with the key and word the map gives it.
13 */
14
15 import type { Database } from "bun:sqlite";
16 import { getAppByRepo } from "../core/apps.ts";
17 import { DRAFT_LINE, isTalkDraft, TALK_DRAFT_LINE, type Pull } from "../core/pulls.ts";
18 import type { Repo } from "../core/repos.ts";
19 import { activeRunFor, checkSummary, type CheckSummary, type RunState } from "../core/runs.ts";
20 import { queuePlace, type Place } from "../checks/place.ts";
21 import { nextOfPull, type Next } from "./next_actor.ts";
22 import { deployedSince } from "./path.ts";
23 import { span } from "./pipeline.ts";
24
25 export type PaneState =
26 | "draft"
27 | "held"
28 | "conflict"
29 | "building"
30 | "checking"
31 | "red"
32 | "changes"
33 | "decide"
34 | "waits"
35 | "ready"
36 | "merged"
37 | "closed";
38
39 /** The keymap's verb ids a pane may offer (each is a key of VERBS; keymap.test holds that). */
40 export type PaneVerb = "merge" | "close" | "approve" | "sendBack" | "update" | "requeue" | "stop" | "watch" | "wheel";
41
42 export interface Pane {
43 readonly state: PaneState;
44 /** How the state reads at a glance: the page's dot. */
45 readonly tone: "success" | "attn" | "danger" | "merged" | undefined;
46 /** One plain sentence, ours, with a person's name or words only where the facts carry them. */
47 readonly sentence: string;
48 /** At most three, the act that moves it first. */
49 readonly verbs: readonly PaneVerb[];
50 /** What shows the sentence is true: a few short lines (files, a run's last word). */
51 readonly evidence: readonly string[];
52 }
53
54 export interface PaneFacts {
55 readonly now: Date;
56 readonly state: "open" | "closed";
57 readonly mergedAt: string | null;
58 readonly closedAt: string | null;
59 readonly parked: boolean;
60 /** Merged only: production deploys from this base, and has since the merge. */
61 readonly deploys: boolean;
62 readonly liveSince: boolean;
63 readonly baseBranch: string;
64 /** A draft's line (`DRAFT_LINE` or a Talk preview's); null when it is not one. */
65 readonly draft: string | null;
66 /** What holds it, in the next actor's words (`nextActor`); null when nothing does. */
67 readonly held: string | null;
68 /** Files that conflict with the base, as the caller read them (none read: empty). */
69 readonly conflicts: readonly string[];
70 /** The crew's unfinished run on this pull. */
71 readonly building: { readonly state: RunState; readonly startedAt: string | null; readonly createdAt: string; readonly summary: string } | null;
72 readonly check: {
73 readonly state: RunState | "none";
74 readonly startedAt: string | null;
75 readonly createdAt: string | null;
76 readonly finishedAt: string | null;
77 readonly summary: string;
78 readonly place: Place | undefined;
79 };
80 /** Who acts next (`nextOfPull`); null once it is not open. */
81 readonly next: Next | null;
82 }
83
84 const MAX_FILES = 3;
85 const cap = (s: string): string => `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
86 const files = (n: number): string => `${n} file${n === 1 ? "" : "s"}`;
87 const ago = (now: Date, at: string | null): string =>
88 at === null ? "" : now.getTime() - Date.parse(at) < 60_000 ? "just now" : `${span(now.getTime() - Date.parse(at))} ago`;
89 const since = (now: Date, at: string | null): string => (at === null ? "" : span(now.getTime() - Date.parse(at)));
90 const placeWords = (p: Place | undefined): string => (p === undefined ? "" : `, place ${p.place} of ${p.of}`);
91
92 /** The pane, from the facts. */
93 export function paneOf(f: PaneFacts): Pane {
94 if (f.mergedAt !== null) {
95 const where = !f.deploys ? "" : f.liveSince ? ", live in production" : ", goes live with the next release";
96 return { state: "merged", tone: "merged", sentence: `Merged ${ago(f.now, f.mergedAt)}${where}`, verbs: [], evidence: [] };
97 }
98 if (f.state === "closed")
99 return { state: "closed", tone: undefined, sentence: `${f.parked ? "Parked" : "Closed"} ${ago(f.now, f.closedAt)}`.trim(), verbs: [], evidence: [] };
100 if (f.draft !== null) return { state: "draft", tone: "attn", sentence: f.draft.replace(/\.$/, ""), verbs: [], evidence: [] };
101 if (f.held !== null) return { state: "held", tone: "attn", sentence: f.held.replace(/\.$/, ""), verbs: [], evidence: [] };
102 if (f.conflicts.length > 0) {
103 const more = f.conflicts.length > MAX_FILES ? [`and ${f.conflicts.length - MAX_FILES} more`] : [];
104 return {
105 state: "conflict",
106 tone: "danger",
107 sentence: `Conflicts with ${f.baseBranch} in ${files(f.conflicts.length)}`,
108 verbs: ["update"],
109 evidence: [...f.conflicts.slice(0, MAX_FILES), ...more],
110 };
111 }
112 const b = f.building;

Branching on n.why.startsWith("changes were asked") couples the state to wording. Carry a flag on Next, as held does, and branch on that.

113 if (b !== null && (b.state === "running" || b.state === "queued")) {
114 const words = b.state === "running" ? `The crew is building it, ${since(f.now, b.startedAt ?? b.createdAt)} so far` : "The crew's run on it is queued";
115 return { state: "building", tone: "attn", sentence: words, verbs: ["wheel", "watch", "stop"], evidence: b.summary === "" ? [] : [b.summary] };
116 }
117 const c = f.check;
118 if (c.state === "running")
119 return { state: "checking", tone: "attn", sentence: `Its check is running, ${since(f.now, c.startedAt ?? c.createdAt)} so far${placeWords(c.place)}`, verbs: ["watch", "stop"], evidence: [] };
120 if (c.state === "queued")
121 return { state: "checking", tone: "attn", sentence: `Its check is queued${placeWords(c.place)}`, verbs: ["watch", "stop"], evidence: [] };
122 const n = f.next;
123 if (n !== null && n.changes === true && c.state !== "failed")
124 return { state: "changes", tone: "attn", sentence: cap(n.why.replace(/^changes were asked on this head: /, "")), verbs: [], evidence: [] };
125 if (c.state === "failed")
126 return {
127 state: "red",
128 tone: "danger",
129 sentence: `Its check is red, ${ago(f.now, c.finishedAt ?? c.createdAt)}`,
130 verbs: ["requeue", "watch", "sendBack"],
131 evidence: c.summary === "" ? [] : [c.summary],
132 };
133 if (n === null) return { state: "waits", tone: undefined, sentence: "Waiting", verbs: [], evidence: [] };
134 const green = c.state === "ok" ? "Green" : c.state === "cancelled" ? "Its check was cancelled" : "No check yet";
135 if (n.who === "person") return { state: "decide", tone: "attn", sentence: cap(n.why), verbs: [], evidence: [] };
136 if (n.who === "queue")
137 return {
138 state: "ready",
139 tone: c.state === "ok" ? "success" : "attn",
140 // "green, reviews are off: it lands" says it already; "approved and green" gains what it
141 // means.
142 sentence: c.state === "ok" && !n.why.endsWith("it lands") ? `${cap(n.why)}, ready to merge` : cap(n.why),
143 verbs: c.state === "ok" ? ["merge", "close"] : [],
144 evidence: [],
145 };
146 const waited = c.state === "ok" ? `, ${since(f.now, c.finishedAt ?? c.createdAt)}` : "";
147 return { state: "waits", tone: "attn", sentence: `${green}, waits for a review (${n.why})${waited}`, verbs: ["approve", "sendBack"], evidence: [] };
148 }
149
150 /**
151 * The pane of `pull`. `live` is its head and conflicting files as the caller read them (a list or
152 * the peek, which open no repository, pass the stored head and none); `known` and `next` are the
153 * head's check and next actor when the caller already read them, so one render reads each once.
154 */
155 export function pullPane(
156 db: Database,
157 repo: Pick<Repo, "id" | "requireReview" | "defaultBranch">,
158 pull: Pull,
159 live: { readonly headOid: string; readonly conflicts: readonly string[] },
160 now: Date = new Date(),
161 known?: CheckSummary,
162 next?: Next | null,
163 ): Pane {
164 const open = pull.state === "open" && pull.mergedAt === null;
165 const deploys = pull.mergedAt !== null && pull.baseBranch === repo.defaultBranch && getAppByRepo(db, repo.id) !== undefined;
166 const draft = !open || pull.draftRun === null ? null : isTalkDraft(pull) ? TALK_DRAFT_LINE : DRAFT_LINE;
167 const check = open ? (known ?? checkSummary(db, pull.id, live.headOid)) : { state: "none" as const, run: null };
168 const who = !open ? null : next !== undefined ? next : nextOfPull(db, pull, { headOid: live.headOid, conflicts: live.conflicts.length }, repo, check);
169 const held = who?.held === true ? who.why : null;
170 const building = open && held === null && draft === null && live.conflicts.length === 0 ? (activeRunFor(db, "agent", pull.id) ?? null) : null;
171 const run = check.run;
172 const place = run !== null && (check.state === "queued" || check.state === "running") ? queuePlace(db, run) : undefined;
173 return paneOf({
174 now,
175 state: pull.state === "closed" ? "closed" : "open",
176 mergedAt: pull.mergedAt,
177 closedAt: pull.closedAt,
178 parked: pull.closeReason === "parked",
179 deploys,
180 liveSince: deploys && pull.mergedAt !== null && deployedSince(db, repo.id, pull.mergedAt),
181 baseBranch: pull.baseBranch,
182 draft,
183 held,
184 conflicts: open ? live.conflicts : [],
185 building: building === null ? null : { state: building.state, startedAt: building.startedAt, createdAt: building.createdAt, summary: building.summary },
186 check: {
187 state: check.state,
188 startedAt: run?.startedAt ?? null,
189 createdAt: run?.createdAt ?? null,
190 finishedAt: run?.finishedAt ?? null,
191 summary: run?.summary ?? "",
192 place,
193 },
194 next: who,
195 });
196 }
src/tui/screens/pull.ts +9 −10
@@ -86,7 +86,7 @@ import { oneLine } from "../../checks/words.ts";
8686 import { resolveOid } from "../../git/merge.ts";
8787 import { nextOfPull, type Next } from "../../flow/next_actor.ts";
8888 import { landingLine } from "../../flow/landing_line.ts";
89 import { stepLine, stepOfPull, type PathStep } from "../../flow/path.ts";
89 import { pullPane, type Pane } from "../../flow/pull_pane.ts";
9090 import { fromKeptFork } from "../../core/landing_kind.ts";
9191 import { DRAFT_LINE, getPull, isDraft, isTalkDraft, pullDir, TALK_DRAFT_LINE, variantSiblings, type MergePullError, type Pull } from "../../core/pulls.ts";
9292 import { voteVariant } from "../../actions/variants.ts";
@@ -288,8 +288,8 @@ export function pullScreen(
288288 let threads: Thread[] = [];
289289 /** Who acts next, for a local open pull; the page says the same line. */
290290 let next: Next | null = null;
291 /** Which of check, review, land, live the pull is at; the page's step line. */
292 let step: PathStep | null = null;
291 /** Where it stands in one sentence: the page's pane (`flow/pull_pane.ts`). */
292 let pane: Pane | null = null;
293293 /**
294294 * Where an approved open pull stands in the landing queue; the page's line under its path
295295 * (#10860).
@@ -480,17 +480,16 @@ export function pullScreen(
480480 headOid: row.headOid || (facts?.headOid ?? ""),
481481 conflicts: facts?.conflicts.length ?? 0,
482482 }, settings);
483 step =
483 pane =
484484 row === undefined || settings === undefined
485485 ? null
486 : stepOfPull(
486 : pullPane(
487487 f.db,
488488 settings,
489489 row,
490 {
491 headOid: row.headOid || (facts?.headOid ?? ""),
492 conflicts: facts?.conflicts.length ?? 0,
493 },
490 { headOid: row.headOid || (facts?.headOid ?? ""), conflicts: facts?.conflicts ?? [] },
491 new Date(),
492 row.state === "open" && row.mergedAt === null ? check : undefined,
494493 next,
495494 );
496495 landing =
@@ -1393,7 +1392,7 @@ export function pullScreen(
13931392 x1,
13941393 head!.y + 1,
13951394 truncate(
1396 ` ${facts?.mergedAt != null ? "merged" : issue.state} · opened by ${who(issue.authorName, issue.originAuthor)} ${ago(issue.createdAt)}${outsideOf(issue)}${guestWaiting() ? ` · ${isContribHead(facts?.headBranch ?? "") ? OUTSIDE_NOTE : repo !== undefined && crewFilters(repo) ? GUEST_NOTE_FILTERED : GUEST_NOTE}` : ""}${assignedText(issueRow, ctx.icons)}${facts?.proposal ? ` · ${proposedByText(facts.proposal)}` : ""}${facts?.proposal?.attestation ? ` · ${attestationLine(facts.proposal.child, facts.proposal.attestation, facts.proposal.headTree)}` : ""}${hold === undefined ? "" : ` · held by ${hold.heldByName}: ${hold.why}`}${reviewFailed ? " · review failed to start" : ""}${step === null ? "" : ` · step: ${stepLine(step)}`}${landing === null ? "" : ` · ${landing}`}${next === null ? "" : ` · next: ${next.who}, ${next.why}`}${ledgerLine === "" ? "" : ` · ${ledgerLine}`}`,
1395 ` ${pane === null ? (facts?.mergedAt != null ? "merged" : issue.state) : pane.sentence} · opened by ${who(issue.authorName, issue.originAuthor)} ${ago(issue.createdAt)}${outsideOf(issue)}${guestWaiting() ? ` · ${isContribHead(facts?.headBranch ?? "") ? OUTSIDE_NOTE : repo !== undefined && crewFilters(repo) ? GUEST_NOTE_FILTERED : GUEST_NOTE}` : ""}${assignedText(issueRow, ctx.icons)}${facts?.proposal ? ` · ${proposedByText(facts.proposal)}` : ""}${facts?.proposal?.attestation ? ` · ${attestationLine(facts.proposal.child, facts.proposal.attestation, facts.proposal.headTree)}` : ""}${hold === undefined || pane !== null ? "" : ` · held by ${hold.heldByName}: ${hold.why}`}${reviewFailed ? " · review failed to start" : ""}${landing === null ? "" : ` · ${landing}`}${ledgerLine === "" ? "" : ` · ${ledgerLine}`}`,
13971396 Math.max(0, edge - x1),
13981397 ),
13991398 style(c.mutedFg, c.bg),
src/web/pages/conflicts.ts +2 −2
@@ -186,7 +186,7 @@ export async function conflictsPage(ctx: Ctx): Promise<Response> {
186186 crumbs: crumbsFor(repo),
187187 palette: repoPalette(ctx, repo),
188188 body: html`${repoHeader(ctx, repo, "pulls", { compact: true, ownTitle: true })}
189 ${changeHead(ctx, repo, pull, null, proposal)}${changeTabs(repo, pull, "files")}
189 ${changeHead(ctx, repo, pull, null, proposal, "files")}${changeTabs(repo, pull, "files")}
190190 <p class="mt">${unknown && pull.state === "open"
191191 ? "No conflict in that file."
192192 : "This pull has no conflicts."}
@@ -239,7 +239,7 @@ export async function conflictsPage(ctx: Ctx): Promise<Response> {
239239 });
240240
241241 const body = html`${repoHeader(ctx, repo, "pulls", { compact: true, ownTitle: true })}
242 ${changeHead(ctx, repo, pull, null, proposal)}${changeTabs(repo, pull, "files")}
242 ${changeHead(ctx, repo, pull, null, proposal, "files")}${changeTabs(repo, pull, "files")}
243243 <p class="muted small mt">
244244 <a href="${back}">← Files</a> · <span class="mono">${file}</span> ·
245245 <strong id="rs-count">${done} of ${total} resolved</strong>
src/web/pages/pull-verdict.ts +4 −15
@@ -1,7 +1,7 @@
11 /**
2 * What a pull's page opens on: one verdict line (can it land, and if not what
3 * holds it, with the one action that moves it) and, directly under it, the
4 * change itself. Reviews, checks and history come after.
2 * Can a pull land, and if not what holds it (`verdictOf`), for the merge box,
3 * the terminal and the land-as-is offer; the page says where it stands in the
4 * pane (`studio/pane.ts`). And the change itself, once (`changeSummary`).
55 *
66 * `verdictOf` is plain data in, plain data out; it asks the questions
77 * `mergeBox` and `mergePull` ask, in the same order, so the line and the
@@ -10,7 +10,7 @@
1010 import { changedSentences, DRAFT_LINE, TALK_DRAFT_LINE } from "../../core/pulls.ts";
1111 import type { Diff } from "../../git/diff.ts";
1212 import { html, when, type Html } from "../html.ts";
13 import { btn, dot, type Tone } from "../ui.ts";
13 import type { Tone } from "../ui.ts";
1414
1515 export interface VerdictInput {
1616 readonly merged: boolean;
@@ -92,17 +92,6 @@ export function verdictOf(v: VerdictInput, thread: string, page = ""): Verdict {
9292 };
9393 }
9494
95 /** The verdict as the first line of the page: the dot, the words, the action. */
96 export function verdictLine(verdict: Verdict, show: { readonly action?: boolean } = {}): Html {
97 return html`<div class="bar mt" data-verdict role="status">
98 ${dot(verdict.tone)}
99 ${verdict.kind === "draft"
100 ? html`<dl class="row-facts"><div><dt>Draft</dt><dd>${verdict.words.startsWith("Draft: ") ? verdict.words.slice("Draft: ".length) : verdict.words}</dd></div></dl>`
101 : html`<strong>${verdict.words}</strong>`}
102 ${when(show.action === false ? null : verdict.action, (a) => btn(a.label, { href: a.href, size: "sm", ...(verdict.tone === "success" ? { variant: "primary" as const } : {}) }))}
103 </div>`;
104 }
105
10695 /**
10796 * The change itself, once: the first sentences of the description (`changedSentences`; the verdict
10897 * line above already says what was verified), a link to the notes, and the total. The file list is
src/web/pages/pull.ts +5 −4
@@ -8,6 +8,7 @@
88 * it needs.
99 */
1010
11 import { paneJs } from "../studio/pane.ts";
1112 import { pullProposalAt } from "../../core/proposal_token.ts";
1213 import { keyOf, oldKeys } from "../keymap.ts";
1314 import { returnTo, withReturn } from "../return_to.ts";
@@ -38,7 +39,7 @@ import { RED_ALONE_WAIT, redAloneAt, redMark, type RedMark } from "../../checks/
3839 import { tierLine, type TierState } from "../../checks/tiers.ts";
3940 import { fromKeptFork } from "../../core/landing_kind.ts";
4041 import { combinedCard } from "./pull-combined.ts";
41 import { verdictLine, verdictOf, type VerdictInput } from "./pull-verdict.ts";
42 import { verdictOf, type VerdictInput } from "./pull-verdict.ts";
4243 import { landAsIs, shipsOn } from "../studio/land_as_is.ts";
4344 import { getAppByRepo } from "../../core/apps.ts";
4445 import { labelsFor, listLabels } from "../../core/issues.ts";
@@ -977,6 +978,7 @@ function reviewCard(ctx: Ctx, repo: Repo, pull: Pull, action: string): Html {
977978 (option, i) =>
978979 html`<label class="check" ${hintAttr(option.key)}>
979980 <input
981 id="review-${option.value}"
980982 type="radio"
981983 name="state"
982984 value="${option.value}"
@@ -1233,9 +1235,8 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> {
12331235 compact: true,
12341236 ownTitle: true,
12351237 })}
1236 ${changeHead(ctx, repo, pull, { headOid: status.headOid, conflicts: status.conflicts.length }, await pullProposalAt(ctx.app.db, pull.id, dir, status.headOid))}
1238 ${changeHead(ctx, repo, pull, { headOid: status.headOid, conflicts: status.conflicts }, await pullProposalAt(ctx.app.db, pull.id, dir, status.headOid), "files")}
12371239 ${changeTabs(repo, pull, "files")}
1238 ${verdictLine(verdict)}
12391240 ${shipsOn(verdict, ctx.app, repo, pull, ctx.auth.user) && mayMerge && check.state === "ok" && !stale
12401241 ? landAsIs(ctx, repo, pull)
12411242 : null}
@@ -1313,7 +1314,7 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> {
13131314 ],
13141315 body,
13151316 styleCss: labelCss([...allLabels, ...applied]),
1316 scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${diffTapJs}`,
1317 scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${diffTapJs}\n${paneJs}`,
13171318 });
13181319 const { diff: diffMs, git, checks, reviews } = spent;
13191320 notePhase(ctx.request, "diff", diffMs, diffHit);
src/web/pages/pulls.ts −6
@@ -34,12 +34,6 @@ import { flashTo, page } from "../layout.ts";
3434 import { btn, empty, field as formField } from "../ui.ts";
3535 import { refSet } from "./refs.ts";
3636
37 /** open | closed | merged — the one place the third state is derived. */
38 export function pullState(pull: Pull): "open" | "closed" | "merged" {
39 if (pull.mergedAt !== null) return "merged";
40 return pull.state === "closed" ? "closed" : "open";
41 }
42
4337 // ---- compose ----
4438
4539 interface ComposeValues {
src/web/peek.ts +16 −26
@@ -5,12 +5,13 @@
55 * or `owner/name#12`, so a row that already shows its title gets none; in Talk's thread every link
66 * to an issue, a pull or a repository on this forge peeks.
77 *
8 * `GET /peek?href=/owner/name/issues/12` answers the card: the reference and its state in a word
9 * (Open, Merged, Closed; Draft; how its checks went), the title, who opened it and when, and the
10 * first lines of its body as plain text (Markdown, HTML and code fences taken out). Anything the
11 * viewer may not read, a signed-out visitor on a private repository included, answers the same
12 * 404, byte for byte, as a number that does not exist. Every answer is private to the viewer and
13 * varies on the cookie, so no shared cache hands one person's card to another.
8 * `GET /peek?href=/owner/name/issues/12` answers the card: the reference and its state (an issue's
9 * in a word, Open or Closed; a pull's in the sentence its page's pane says, `flow/pull_pane.ts`),
10 * the title, who opened it and when, and the first lines of its body as plain text (Markdown, HTML
11 * and code fences taken out). Anything the viewer may not read, a signed-out visitor on a private
12 * repository included, answers the same 404, byte for byte, as a number that does not exist. Every
13 * answer is private to the viewer and varies on the cookie, so no shared cache hands one person's
14 * card to another.
1415 *
1516 * The body is someone else's words: escaped plain text, never Markdown, never a link.
1617 */
@@ -18,6 +19,8 @@
1819 import type { Database } from "bun:sqlite";
1920 import type { Ctx } from "../http/context.ts";
2021 import { getIssue } from "../core/issues.ts";
22 import { getPull } from "../core/pulls.ts";
23 import { pullPane } from "../flow/pull_pane.ts";
2124 import { canRead, getRepo } from "../core/repos.ts";
2225 import { mayView } from "../core/sealed.ts";
2326 import type { User } from "../core/users.ts";
@@ -63,12 +66,8 @@ const PEEK_WORDS = {
6366 talk: "Talk about this",
6467 merged: "Merged",
6568 closed: "Closed",
66 draft: "Draft",
6769 repository: "Repository",
6870 opened: "Opened by",
69 checksOk: "checks passed",
70 checksFailed: "checks failed",
71 checksRunning: "checks running",
7271 } as const;
7372
7473 /**
@@ -112,7 +111,8 @@ export function plainLines(body: string, lines = LINES_SHOWN, chars = BODY_SHOWN
112111
113112 /**
114113 * The card for `href` as `viewer` reads it, or undefined for anything they may not read and
115 * anything that is not there, alike. At most five statements.
114 * anything that is not there, alike. An issue's card is at most five statements; a pull's reads its
115 * pane as the page does, from the stored head (no repository is opened on a hover).
116116 */
117117 export function peekCard(db: Database, viewer: User | undefined, href: string): Html | undefined {
118118 const m = PEEK.exec(href);
@@ -135,29 +135,19 @@ export function peekCard(db: Database, viewer: User | undefined, href: string):
135135 const issue = getIssue(db, repo.id, Number(number));
136136 // `/issues/N` names a pull as well (the page answers both); `/pulls/N` names only a pull.
137137 if (issue === undefined || !mayView(db, repo, issue, viewer) || (kind === "pulls" && issue.kind !== "pull")) return undefined;
138 const pull =
139 issue.kind === "pull"
140 ? db
141 .query<
142 { merged_at: string | null; draft_run: string | null; check: string | null },
143 [string]
144 >("SELECT merged_at, draft_run, (SELECT state FROM run WHERE issue_id = ?1 AND kind = 'check' ORDER BY id DESC LIMIT 1) AS \"check\" FROM pull WHERE issue_id = ?1")
145 .get(issue.id)
146 : null;
147 const state = pull?.merged_at
138 const pull = issue.kind === "pull" ? getPull(db, repo.id, issue.number) : undefined;
139 const state = pull?.mergedAt
148140 ? (["merge", PEEK_WORDS.merged] as const)
149141 : issue.state === "open"
150142 ? ([issue.kind === "pull" ? "pull" : "issue", PEEK_WORDS.open] as const)
151143 : (["issueClosed", PEEK_WORDS.closed] as const);
152 const check = pull?.check ?? null;
153 const checks =
154 check === null ? null : check === "ok" ? PEEK_WORDS.checksOk : check === "failed" ? PEEK_WORDS.checksFailed : PEEK_WORDS.checksRunning;
155 const draft = pull !== null && pull !== undefined && pull.draft_run !== null && issue.state === "open";
144 // A pull says where it stands in its pane's sentence, the words its page and the terminal use.
145 const says = pull === undefined ? state[1] : pullPane(db, repo, pull, { headOid: pull.headOid, conflicts: [] }).sentence;
156146 const body = plainLines(issue.body);

The card now runs the whole pane (next actor, check summary, queue place, deploy lookup, active run) for each hover. Check that it stays well under 50 ms on a pull with many runs, and add a test for that.

157147 const path = `/${full}/${issue.kind === "pull" ? "pulls" : "issues"}/${issue.number}`;
158148 return html`<p class="peek-kind small muted">
159149 ${icon(state[0])} ${full}#${String(issue.number)} ·
160 ${state[1]}${draft ? ` · ${PEEK_WORDS.draft}` : null}${checks === null ? null : ` · ${checks}`}
150 ${says}
161151 </p>
162152 <p class="peek-title">${issue.title}</p>
163153 <p class="small muted">${PEEK_WORDS.opened} ${issue.authorName} ${time(issue.createdAt)}</p>
src/web/studio/change.ts +45 −47
@@ -18,7 +18,6 @@ import { keptRead } from "../head-reads.ts";
1818 import { pullProposalAt, type PullProposalAt } from "../../core/proposal_token.ts";
1919 import { attestationLine } from "../../core/attestation.ts";
2020 import { offerStatusLinkFor } from "../../core/outsider_status.ts";
21 import { getIssueById } from "../../core/issues.ts";
2221 import { mayEditIssue } from "../../actions/issues.ts";
2322 import { outsideLabelFrom } from "../outside.ts";
2423 import { accountsByName, marksByName, marksOf, type Mark } from "../../core/marks.ts";
@@ -40,7 +39,7 @@ import {
4039 import { canAdmin, canWrite, type Repo } from "../../core/repos.ts";
4140 import { listReviews, type Review } from "../../core/reviews.ts";
4241 import { wallOf, wallPlain, wallSentence, type Wall } from "../../contract/policy.ts";
43 import { checkSummary } from "../../core/runs.ts";
42 import { activeRunFor, checkSummary } from "../../core/runs.ts";
4443 import { commitLog } from "../../git/read.ts";
4544 import { mayReadRunLog } from "../../actions/runs.ts";
4645 import { readRunLogTail } from "../../runs/log.ts";
@@ -67,7 +66,6 @@ import {
6766 crumbs,
6867 confirmAction,
6968 copyField,
70 badge,
7169 icon,
7270 originTag,
7371 seg,
@@ -83,12 +81,11 @@ import { filmstrip, filmstripJs } from "../pages/filmstrip.ts";
8381 import { lookCard } from "../pages/looks.ts";
8482 import { approveHereCard, keptChange, pullChecksLineFor, reachLine, teamsCard, markReadyForm, verdictFacts } from "../pages/pull.ts";
8583 import { landAsIs, shipsOn } from "./land_as_is.ts";
86 import { changeSummary, verdictLine, verdictOf } from "../pages/pull-verdict.ts";
84 import { changeSummary, verdictOf } from "../pages/pull-verdict.ts";
8785 import { guestWalls, strangerCard } from "../pages/pull-guest.ts";
8886 import { combinedCard } from "../pages/pull-combined.ts";
8987 import { teamVerdicts } from "../../core/issue_teams.ts";
9088 import { liveRegionsJs } from "../client.ts";
91 import { pullState } from "../pages/pulls.ts";
9289 import { workSpent } from "../pages/runs.ts";
9390 import {
9491 composer,
@@ -105,12 +102,13 @@ import { previewVision } from "../../crew/vision.ts";
105102 import { visionPreviewCard } from "./direction.ts";
106103 import { holdCard } from "./hold.ts";
107104 import { pullMayRun } from "../../core/pull_trust.ts";
108 import { pullWaitsFor } from "../../flow/waits_for.ts";
109105 import { landingLine } from "../../flow/landing_line.ts";
110106 import { nextOfPull } from "../../flow/next_actor.ts";
111 import { STEP_MEANS, STEPS, stepOfPull, stepWord, type PathStep } from "../../flow/path.ts";
107 import { pullPane } from "../../flow/pull_pane.ts";
108 import { canVerdict } from "../../core/verdict.ts";
109 import { paneView, type PaneDoors } from "./pane.ts";
112110 import { changeHref } from "./nouns.ts";
113 import { pullWord, servingHistory, stateDot, wordDot, type WordCtx } from "./words.ts";
111 import { pullWord, servingHistory, wordDot, type WordCtx } from "./words.ts";
114112 import { getHold } from "../../core/holds.ts";
115113 import { backToWave } from "../../story/waves.ts";
116114 import { offerPullCard } from "../pages/offer-upstream.ts";
@@ -252,35 +250,58 @@ function statusLinkLine(ctx: Ctx, repo: Repo, pull: Pull): Html | "" {
252250 return html`<div class="small" data-status-link>${copyField("status-link", url, "Status link for the person who offered this", "Copy status link")}</div>`;
253251 }
254252
255 /** A change's head, the same on both of its tabs: the title, its state,
256 * who opened it and in answer to whom, where it came from, and what the
257 * crew spent on it. */
253 /**
254 * Where each of the pane's verbs acts for this viewer on this tab (`pane.ts`): only the acts they
255 * may take, each through the door it already has.
256 */
257 function paneDoors(ctx: Ctx, repo: Repo, pull: Pull, tab: "change" | "files", checkRun: string | null): PaneDoors {
258 const user = ctx.auth.user;
259 if (user === undefined) return {};
260 const base = repoBase(repo);
261 const thread = `${base}/pulls/${pull.number}`;
262 const writer = canWrite(ctx.app.db, repo, user) && user.kind !== "agent";
263 const judge = pull.authorId !== user.id && canVerdict(ctx.app.db, repo, user);
264 const crew = activeRunFor(ctx.app.db, "agent", pull.id);
265 const run = crew?.id ?? checkRun;
266 const files = tab === "files";
267 return {
268 ...(run === null ? {} : { watch: { href: `${base}/runs/${run}` } }),
269 ...(crew === undefined ? {} : { wheel: { href: `${base}/runs/${crew.id}#run-steer` } }),
270 ...(writer && run !== null ? { stop: { post: `${base}/runs/${run}/cancel` }, requeue: { post: `${base}/runs/${run}/requeue` } } : {}),
271 ...(writer ? { update: { post: `${thread}/update` }, close: { post: `${thread}/state`, field: ["state", "closed"] as const }, merge: { href: files ? "#merge" : `${thread}/files#merge` } } : {}),
272 ...(judge
273 ? files
274 ? { approve: { pick: "review-approved" }, sendBack: { pick: "review-changes_requested" } }
275 : { approve: { href: `${thread}/files#review-body` }, sendBack: { href: `${thread}/files#review-body` } }
276 : {}),
277 };
278 }
279
280 /** A change's head, the same on both of its tabs: the title, where it stands
281 * (the pane), who opened it and in answer to whom, where it came from, and
282 * what the crew spent on it. */
258283 export function changeHead(
259284 ctx: Ctx,
260285 repo: Repo,
261286 pull: Pull,
262 live: { readonly headOid: string; readonly conflicts: number } | null,
287 live: { readonly headOid: string; readonly conflicts: readonly string[] } | null,
263288 // The child's proposal, if one opened this pull, read by the caller with `pullProposalAt`
264289 // (async: it reads the head's tree when the child attested one, #13645).
265290 proposal: PullProposalAt | undefined,
291 tab: "change" | "files" = "change",
266292 ): Html {
267 // The head's check, read once for the next actor, the path step and the waits-for line (#15913).
293 // The head's check, read once for the next actor and the pane (#15913).
268294 const check = live === null || pull.state !== "open" || pull.mergedAt !== null ? undefined : checkSummary(ctx.app.db, pull.id, live.headOid);
269 const next = live === null ? null : nextOfPull(ctx.app.db, pull, live, repo, check);
270 const step =
271 live === null && pull.mergedAt === null
272 ? null
273 : stepOfPull(ctx.app.db, repo, pull, live ?? { headOid: pull.headOid, conflicts: 0 }, next, check);
295 const next = live === null ? null : nextOfPull(ctx.app.db, pull, { headOid: live.headOid, conflicts: live.conflicts.length }, repo, check);

When live is null on an open pull there is no pane at all, so the page loses the state it used to show (dot and word). Fall back to the stored head, as the peek does, so the pane is always present (principle 1: one sentence says what the page is for).

296 // Where the live head is not read (the resolve page), the stored one stands for it, as on the
297 // peek.
298 const pane = pullPane(ctx.app.db, repo, pull, live ?? { headOid: pull.headOid, conflicts: [] }, new Date(), check, next);
274299 const who = toldBy(ctx.app.db, pull);
275300 const accounts = accountsByName(ctx.app.db, [pull.authorName, who ?? ""], repo.id);
276301 const marks = marksOf(accounts);
277302 return html`<div class="page-head">
278303 <h1>${pull.title} <a class="num self" href="${changeHref(repoBase(repo), pull.number)}" title="This pull's address">#${pull.number}</a></h1>
279304 <div class="page-head-sub bar muted small">
280 ${stateDot(
281 pullState(pull),
282 getIssueById(ctx.app.db, pull.id)?.closeReason === "parked",
283 )}
284305 <span
285306 >${pull.originAuthor
286307 ? originTag(pull.originAuthor, originGlyph(repo))
@@ -310,15 +331,12 @@ export function changeHead(
310331 >`,
311332 )}
312333 </div>
313 ${statusLinkLine(ctx, repo, pull)}${when(step, (st) => pathLine(st, next === null ? undefined : `${next.who}, ${next.why}`))}${when(
334 ${when(pane, (p) => paneView(p, paneDoors(ctx, repo, pull, tab, check?.run?.id ?? null)))}${statusLinkLine(ctx, repo, pull)}${when(
314335 pull.mergedAt === null ? pausedSentence(ctx.app.db, { issueId: pull.id }) : undefined,
315336 (says) => html`<p class="muted small" data-paused role="status">${says}.</p>`,
316337 )}${when(
317338 live === null ? null : landingLine(ctx.app.db, pull, repo.id),
318339 (eta) => html`<p class="muted small" data-landing-eta>${eta.says}</p>`,
319 )}${when(
320 live === null ? null : pullWaitsFor(ctx.app.db, repo, pull, live, undefined, check, next ?? undefined),
321 (w) => html`<p class="small" data-waits-for="${w.cause}" role="status">${w.line}</p>`,
322340 )}${
323341 // The desk is the crew's: a guest sees no note, not even a hold on a public pull.
324342 ctx.auth.user === undefined
@@ -328,25 +346,6 @@ export function changeHead(
328346 </div>`;
329347 }
330348
331 /**
332 * Where the pull is on the one path (#7703): the four words, the current one
333 * marked, and why it waits there. The words link to /pipeline, which says
334 * what each one means and holds the finer steps.
335 */
336 export function pathLine(p: PathStep, next?: string): Html {
337 const at = STEPS.indexOf(p.step);
338 const words = STEPS.map((s, i) => {
339 const label = stepWord(s);
340 if (i === at)
341 return html`<strong aria-current="step" title="${STEP_MEANS[s]}">${label}</strong>${p.done ? html` ${badge("done", { tone: "success" })}` : null}`;
342 return html`<span>${label}</span>`;
343 });
344 return html`<p class="muted small" data-path="${p.step}">
345 <a href="/pipeline">${words.map((w, i) => html`${i > 0 ? " · " : ""}${w}`)}</a>
346 — ${p.why}${next === undefined ? "" : html`<span class="next-actor"> Next: ${next}.</span>`}
347 </p>`;
348 }
349
350349 /** The change's two steps: the change itself, and its Files one tab
351350 * deeper — never a mode, the same address family either way. */
352351 export function changeTabs(
@@ -743,7 +742,7 @@ async function changeConversation(
743742 ownTitle: true,
744743 quiet: true,
745744 })}
746 ${changeHead(ctx, repo, pull, status === undefined ? null : { headOid, conflicts: status.conflicts.length }, proposal)}
745 ${changeHead(ctx, repo, pull, status === undefined ? null : { headOid, conflicts: status.conflicts }, proposal)}
747746 ${changeTabs(repo, pull, "change")}`,
748747 crumbs: crumbsFor(repo),
749748 palette: [
@@ -880,7 +879,6 @@ async function changeConversation(
880879 const wave = backToWave(ctx.url.searchParams.get("from"));
881880 const body = html`${pageHead.top}
882881 ${when(wave, (w) => crumbs([{ label: `Wave ${w.version}`, href: w.href }, { label: "This pull" }]))}
883 ${verdictLine(verdict, { action: false })}
884882 <div class="split" data-pull>
885883 <div>
886884 ${changeSummary(pull.body, totals, files, "#conversation")}
src/web/studio/pane.ts added +58
@@ -0,0 +1,58 @@
1 /**
2 * The pull's pane on the page (src/flow/pull_pane.ts): the state sentence with its dot, what shows
3 * it, and at most three verbs, each a key from the map. It sits under the title on both of the
4 * pull's tabs and replaces the state pill and the path and waits-for lines: the sentence says it
5 * once.
6 *
7 * Every verb is an act that already has a door of its own, reached from here with its key: a run's
8 * stop and queue again post to the run's routes, update and close to the pull's, merge and the
9 * review verdicts go to the merge box and the review form (on the Files tab, the review verbs are
10 * links to the form's own choices, and their click or key picks one: `paneJs`). A verb the viewer
11 * may not use is not drawn. With no script, each is a plain link or form.
12 */
13 import type { Pane, PaneVerb } from "../../flow/pull_pane.ts";
14 import { html, type Html } from "../html.ts";
15 import { KEYMAP } from "../keymap.ts";
16 import { dot } from "../ui.ts";
17
18 /** Where each verb acts for this pull and viewer; a verb with no door here is not drawn. */
19 export type PaneDoors = Partial<Record<PaneVerb, { readonly href: string } | { readonly post: string; readonly field?: readonly [string, string] } | { readonly pick: string }>>;
20
21 function verbView(id: PaneVerb, door: NonNullable<PaneDoors[PaneVerb]>): Html {
22 const { key, label } = KEYMAP[id];
23 const inner = html`<kbd>${key}</kbd> ${label}`;
24 const attrs = html`class="btn" data-size="sm" data-shortcut="${key}" aria-keyshortcuts="${key}"`;

Keyboard: a <label for> styled as .btn is not focusable and not a button to a screen reader, so Approve and Request changes on the Files tab cannot be reached without a mouse. Use an anchor to the radio (works with JavaScript off) or a real button. Also data-shortcut and aria-keyshortcuts on a label announce a key that nothing in the element handles.

25 if ("href" in door) return html`<a ${attrs} href="${door.href}">${inner}</a>`;
26 if ("pick" in door) return html`<a ${attrs} href="#${door.pick}" data-pick="${door.pick}">${inner}</a>`;
27 return html`<form method="post" action="${door.post}" class="pane-form">${door.field === undefined ? null : html`<input type="hidden" name="${door.field[0]}" value="${door.field[1]}" />`}<button type="submit" ${attrs}>${inner}</button></form>`;
28 }
29
30 /**
31 * A verdict verb on the Files tab is a link to the review form's own radio (`#review-approved`):
32 * with no script it takes the reader there; with it, the click (or the verb's key, which the shell
33 * clicks) picks the radio and puts the caret in the form's box, where the words go next.
34 */
35 export const paneJs = /* js */ `
36 document.addEventListener("click", (e) => {
37 const a = e.target instanceof Element ? e.target.closest("a[data-pick]") : null;
38 const radio = a && document.getElementById(a.getAttribute("data-pick"));
39 if (!radio) return;
40 e.preventDefault();
41 radio.checked = true;
42 const box = radio.form && radio.form.querySelector("textarea");
43 (box || radio).focus();
44 });
45 `;
46
47 /** The pane: one status line, the evidence under it, the verbs it has doors for. */
48 export function paneView(pane: Pane, doors: PaneDoors): Html {
49 const verbs = pane.verbs.flatMap((v) => {
50 const door = doors[v];
51 return door === undefined ? [] : [verbView(v, door)];
52 });
53 return html`<section class="pane mt" data-pane="${pane.state}" aria-label="Where it stands">
54 <p class="pane-says" role="status">${dot(pane.tone)} <strong>${pane.sentence}</strong></p>
55 ${pane.evidence.length === 0 ? null : html`<p class="pane-evidence small muted">${pane.evidence.join(" · ")}</p>`}
56 ${verbs.length === 0 ? null : html`<div class="pane-verbs bar">${verbs}</div>`}
57 </section>`;
58 }
src/web/studio/words.ts −10
@@ -638,16 +638,6 @@ export function wordDot(word: Word, note?: string): Html {
638638 return html`<span class="dot" data-tone="${tone}" data-word="${word}" role="img" aria-label="${said}"></span>`;
639639 }
640640
641 /** A pull's own state at rest: the dot, its word for a screen reader. */
642 export function stateDot(state: "open" | "closed" | "merged", parked = false): Html {
643 const said = state === "closed" && parked ? "parked" : state;
644 const tone = state === "open" ? "success" : state === "merged" ? "merged" : "none";
645 // Open is the quiet state; a settled one is written out beside its dot.
646 return html`<span class="dot" data-state="${state}" data-tone="${tone}" role="img" aria-label="${said}"></span>${
647 state === "open" ? null : html`<span class="word-text">${said === "merged" ? "Merged" : said === "parked" ? "Parked" : "Closed"}</span>`
648 }`;
649 }
650
651641 // ---- what a subscription has left, and what a change costs ----
652642
653643 /** One figure as a person reads it, and whether the forge worked it out
src/web/style/components.ts +6
@@ -1062,6 +1062,12 @@ a[data-palette] { display: none; }
10621062 }
10631063 .page-head h1 { min-width: 0; overflow-wrap: anywhere; }
10641064 .page-head > .page-head-sub { flex-basis: 100%; margin-top: -4px; }
1065 /* The pull pane (studio/pane.ts): where it stands, what shows it, the verbs that move it. */
1066 .pane { flex-basis: 100%; }
1067 .pane-says { margin: 0; }
1068 .pane-evidence { margin: 4px 0 0; }
1069 .pane-verbs { margin-top: 8px; flex-wrap: wrap; }
1070 .pane-form { display: contents; }
10651071
10661072 /* ---- breadcrumbs ---- */
10671073 .crumbs {
test/crew-draft.test.ts +4 −2
@@ -403,7 +403,9 @@ describe("an app's first build pushes early, as a draft", () => {
403403 return (await res.text()).replace(/\s+/g, " ");
404404 };
405405 const seen = await page(alice);
406 expect(seen).toContain(`<dt>Draft</dt><dd>${DRAFT_LINE.slice("Draft: ".length)}</dd>`);
406 // The pane says it (studio/pane.ts).
407 expect(seen).toContain(`data-pane="draft"`);
408 expect(seen).toContain(`<strong>${DRAFT_LINE.replace(/\.$/, "")}</strong>`);
407409 expect(seen).not.toContain("Merge pull request");
408410 expect(seen).toContain(`action="/${repo.ownerName}/${repo.name}/pulls/${pull.number}/ready"`);
409411 const made = await createUser(app.db, { username: "wren", email: "[email protected]", origin: "seed", trusted: true, password: "a-good-passphrase" });
@@ -416,7 +418,7 @@ describe("an app's first build pushes early, as a draft", () => {
416418 expect((await press(alice)).status).toBe(303);
417419 expect(isDraft(getPull(app.db, repo.id, pull.number)!)).toBe(false);
418420 expect(await waitFor(() => checksOf(pull).length > 0)).toBe(true);
419 expect(await page(alice)).not.toContain("<dt>Draft</dt>");
421 expect(await page(alice)).not.toContain(`data-pane="draft"`);
420422 }, 30_000);
421423
422424 test("the API marks it ready for its admin, once; a token of someone else is refused", async () => {
test/next_actor.test.ts +7 −3
@@ -1,5 +1,5 @@
11 import { describe, expect, test } from "bun:test";
2 import { nextActor, nextAsking, type NextInput } from "../src/flow/next_actor.ts";
2 import { nextActor, nextAsking, type Actor, type Next, type NextInput } from "../src/flow/next_actor.ts";
33
44 const base: NextInput = {
55 held: null,
@@ -10,7 +10,7 @@ const base: NextInput = {
1010 pushedSince: 0,
1111 };
1212
13 const cases: [string, Partial<NextInput>, string, string][] = [
13 const cases: [string, Partial<NextInput>, Actor, string][] = [
1414 ["held", { held: { by: "sam", why: "wait for legal" }, approvals: 1, check: "ok" }, "person", "sam holds it: wait for legal"],
1515 ["conflicted", { conflicted: true, approvals: 1, check: "ok" }, "builder", "it conflicts with its base"],
1616 ["changes asked", { changesRequested: 1, check: "ok" }, "builder", "changes were asked on this head"],
@@ -35,7 +35,11 @@ const cases: [string, Partial<NextInput>, string, string][] = [
3535
3636 describe("nextActor", () => {
3737 for (const [name, input, who, why] of cases)
38 test(name, () => expect(nextActor({ ...base, ...input })).toEqual({ who: who as never, why }));
38 // A hold says so as a flag too (the pull pane reads it as its own state, flow/pull_pane.ts).
39 test(name, () => {
40 const want: Next = name === "held" ? { who, why, held: true } : why.startsWith("changes were asked") ? { who, why, changes: true } : { who, why };
41 expect(nextActor({ ...base, ...input })).toEqual(want);
42 });
3943 });
4044
4145 describe("nextAsking (#11666)", () => {
test/parked-close.test.ts +4 −5
@@ -181,11 +181,10 @@ describe("a parked pull", () => {
181181 setIssueState(app, alice, repo, plain, "closed");
182182
183183 const page = await get(`/alice/shop/pulls/${parked.number}`);
184 expect(page).toMatch(/data-state="closed"[\s\S]*?"word-text">Parked</);
185 expect(page).not.toMatch(/"word-text">Closed</);
186 expect(await get(`/alice/shop/pulls/${plain.number}`)).toMatch(
187 /"word-text">Closed</,
188 );
184 // The pane says it (studio/pane.ts): parked, or closed.
185 expect(page).toMatch(/data-pane="closed"[\s\S]*?<strong>Parked /);
186 expect(page).not.toMatch(/<strong>Closed /);
187 expect(await get(`/alice/shop/pulls/${plain.number}`)).toMatch(/<strong>Closed /);
189188
190189 const list = await get("/alice/shop/pulls?word=stopped");
191190 expect(list).toContain("parked by the crew");
test/peek.test.ts +14 −8
@@ -157,7 +157,7 @@ test("a stranger, a signed-out visitor, a missing number and a missing repositor
157157 expect((await peek("/alice/vault/issues/1", alice)).status).toBe(200);
158158 });
159159
160 test("each state a card carries: merged, closed, draft, checks in words; a sealed issue is not found to whoever may not see it", async () => {
160 test("each state a card carries: a pull in its pane's sentence (merged, red, draft), an issue in a word; a sealed issue is not found to whoever may not see it", async () => {
161161 const repo = getRepo(app.db, "alice", "harbor")!;
162162 const made = (title: string, more: { kind?: "pull"; sealed?: boolean } = {}) => {
163163 const i = createIssue(app.db, { repoId: repo.id, authorId: alice.id, title, body: "b", ...more });
@@ -169,22 +169,22 @@ test("each state a card carries: merged, closed, draft, checks in words; a seale
169169 app.db.run("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at, draft_run) VALUES (?1, 'main', ?2, '', 'h', ?3, ?4)", [p.id, `b${String(p.number)}`, merged, draft]);
170170 return p;
171171 };
172 const checked = (p: { id: string }, state: string) => app.db.run("UPDATE run SET state = ?1 WHERE id = ?2", [state, createRun(app.db, { repoId: repo.id, kind: "check", issueId: p.id }).id]);
172 const checked = (p: { id: string }, state: string) => app.db.run("UPDATE run SET state = ?1 WHERE id = ?2", [state, createRun(app.db, { repoId: repo.id, kind: "check", issueId: p.id, commitOid: "h" }).id]);
173173 const text = async (href: string, u: User = alice) => (await (await peek(href, u)).text()).replace(/\s+/g, " ");
174174
175175 const merged = pullOf("Ship WebP", new Date().toISOString());
176176 checked(merged, "ok");
177177 const card = await text(`/alice/harbor/pulls/${String(merged.number)}`);
178 expect(card).toContain(`alice/harbor#${String(merged.number)} · Merged · checks passed`);
178 expect(card).toContain(`alice/harbor#${String(merged.number)} · Merged just now`);
179179 expect(card).toMatch(new RegExp(`href="/alice/harbor/pulls/${String(merged.number)}">Open</a\\s*>`));
180180 // A pull named as an issue, as `#N` in a comment links it, is the pull's card.
181 expect(await text(`/alice/harbor/issues/${String(merged.number)}`)).toContain("· Merged");
181 expect(await text(`/alice/harbor/issues/${String(merged.number)}`)).toContain("· Merged just now");
182182 const red = pullOf("Try AVIF", null);
183183 checked(red, "failed");
184 expect(await text(`/alice/harbor/pulls/${String(red.number)}`)).toContain("· Open · checks failed");
184 expect(await text(`/alice/harbor/pulls/${String(red.number)}`)).toContain("· Its check is red, just now");
185185 const going = pullOf("Try JPEG XL", null, "run-1");
186186 checked(going, "running");
187 expect(await text(`/alice/harbor/pulls/${String(going.number)}`)).toContain("· Open · Draft · checks running");
187 expect(await text(`/alice/harbor/pulls/${String(going.number)}`)).toContain("· Draft: its build is still running");
188188 const done = made("Old banner");
189189 setIssueState(app.db, done.id, "closed");
190190 expect(await text(`/alice/harbor/issues/${String(done.number)}`)).toContain(`alice/harbor#${String(done.number)} · Closed`);
@@ -193,7 +193,13 @@ test("each state a card carries: merged, closed, draft, checks in words; a seale
193193 expect((await peek(`/alice/harbor/issues/${String(sealed.number)}`, alice)).status).toBe(200);
194194 });
195195
196 test("a card is at most five statements, whatever it shows or refuses", async () => {
196 // An issue's card reads the issue and its repository: five. A pull's card says where the pull
197 // stands in its pane's sentence, the same reader the page and the terminal use, so it reads the
198 // pane's facts too: the next actor (its reviews, hold and wall), the head's check and its queue
199 // place, and the crew's unfinished run, seven more, each one statement whatever the pull's history
200 // (pull-pane.test.ts holds that the count does not grow with its runs). Twelve is that sum,
201 // measured.
202 test("a card is at most five statements, whatever it shows or refuses; a pull's, which reads its pane as the page does, at most twelve", async () => {
197203 const repo = getRepo(app.db, "alice", "harbor")!;
198204 const p = createIssue(app.db, { repoId: repo.id, authorId: alice.id, title: "Counted", body: "b", kind: "pull" });
199205 if (!p.ok) throw new Error("pull");
@@ -206,7 +212,7 @@ test("a card is at most five statements, whatever it shows or refuses", async ()
206212 [undefined, "/alice/harbor/issues/1"],
207213 ] as const) {
208214 const n = await once(app.db, () => void peekCard(app.db, who, href));
209 expect(n, `${href} as ${who?.username ?? "nobody"}`).toBeLessThanOrEqual(5);
215 expect(n, `${href} as ${who?.username ?? "nobody"}`).toBeLessThanOrEqual(href.includes("/pulls/") ? 12 : 5);
210216 }
211217 });
212218
test/pipeline-path.test.ts +7 −9
@@ -129,20 +129,18 @@ test("/pipeline names the four steps in order, each with its finer parts one cli
129129 expect(body).toContain('href="/boards"');
130130 });
131131
132 test("an open pull says it is at review and why, on both tabs, linked to /pipeline", async () => {
132 test("an open pull's pane says it waits for a review and why, on both tabs (studio/pane.ts)", async () => {
133133 for (const tab of ["", "/files"]) {
134134 const body = await read(`/alice/open/pulls/${numbers["open"]}${tab}`);
135 expect(body).toContain('data-path="review"');
136 expect(body).toMatch(/<strong aria-current="step"[^>]*>Review<\/strong>/);
137 expect(body).toContain("— No review yet.");
138 expect(body).toContain('<a href="/pipeline">');
135 expect(body).toContain('data-pane="waits"');
136 expect(body).toContain("waits for a review (no review yet)");
139137 }
140138 });
141139
142 test("a merged pull in a repository with no app says its path ends at land", async () => {
140 test("a merged pull in a repository with no app says only that it merged: nothing deploys from it", async () => {
143141 const body = await read(`/alice/merged/pulls/${numbers["merged"]}`);
144 expect(body).toContain('data-path="land"');
145 expect(body).toContain("nothing deploys from this branch");
142 expect(body).toContain('data-pane="merged"');
143 expect(body).toMatch(/<strong>Merged [^<,]*<\/strong>/);
146144 });
147145
148146 test("the MCP pull answers the same step", async () => {
@@ -206,7 +204,7 @@ test("a merged pull into an app is landed until production has served a deploy s
206204 // One serving after the merge makes it live.
207205 deploy("d-after", "2999-01-01T00:00:00.000Z", "2999-01-01T00:01:00.000Z");
208206 expect(stepOfPull(app.db, repo, pull, live)).toEqual({ step: "live", why: "Landed and live in production.", done: true });
209 expect(await read(`/alice/shipped/pulls/${opened.value.number}`)).toContain('data-path="live"');
207 expect(await read(`/alice/shipped/pulls/${opened.value.number}`)).toContain(", live in production");
210208 });
211209
212210 test("/pipeline links the full-suite report's issues, and that link answers", async () => {
test/pull-next-line.test.ts +3 −3
@@ -81,12 +81,12 @@ afterAll(async () => {
8181 test("an open pull with no review names the reviewer on the change tab and on Files", async () => {
8282 for (const tab of ["", "/files"] as const) {
8383 const body = await read("open", tab);
84 expect(body).toContain("Next: reviewer, no review yet.");
85 expect(body).toContain('class="next-actor');
84 // The pane names who acts next in its sentence (studio/pane.ts).
85 expect(body).toContain("waits for a review (no review yet)");
8686 }
8787 });
8888
8989 test("a merged pull draws no next line", async () => {
9090 for (const tab of ["", "/files"] as const)
91 expect(await read("merged", tab)).not.toContain("next-actor");
91 expect(await read("merged", tab)).not.toContain("waits for a review");
9292 });
test/pull-next-tui.test.ts +6 −6
@@ -88,10 +88,10 @@ async function screenSaying(repo: Awaited<ReturnType<typeof openTopic>>, wanted:
8888 }
8989 }
9090
91 test("the terminal's pull screen says who acts next, as the page does", async () => {
92 const text = await screenSaying(await openTopic("lib", true), "next: reviewer, no review yet");
93 // The page's step line, too: this pull is at review.
94 if (!text.includes("step: Review — ")) throw new Error(text);
91 test("the terminal's pull screen says where it stands and who acts next in the pane's sentence, as the page does", async () => {
92 const text = await screenSaying(await openTopic("lib", true), "No check yet, waits for a review (no review yet)");
93 // One way to say it: no second step or next line beside the sentence.
94 if (text.includes("step: ") || text.includes("next: ")) throw new Error(text);
9595 });
9696
9797 test("with reviews off, a green pull's screen says it lands by itself, as the page does (#11666)", async () => {
@@ -99,8 +99,8 @@ test("with reviews off, a green pull's screen says it lands by itself, as the pa
9999 const run = createRun(app.db, { repoId: topic.repo.id, kind: "check", issueId: topic.pull.id, commitOid: topic.pull.headOid });
100100 claimRun(app.db, run.id);
101101 finishRun(app.db, run.id, { state: "ok", summary: "green" });
102 const text = await screenSaying(topic, "next: queue, green, reviews are off: it lands");
103 if (text.includes("next: reviewer")) throw new Error(text);
102 const text = await screenSaying(topic, "Green, reviews are off: it lands");
103 if (text.includes("waits for a review")) throw new Error(text);
104104 });
105105
106106 test("the terminal's pull screen says when an approval was given for a base that has moved", async () => {
test/pull-pane-keys.test.ts added +116
@@ -0,0 +1,116 @@
1 /**
2 * On a pull's Files tab the pane's verdicts are links to the review form's own radios (pane.ts
3 * paneJs): pressed in a browser, `a` picks Approve and `b` Request changes, each putting the caret
4 * in the form's box; each is a focusable link a screen reader announces, not a label.
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { openPull } from "../src/actions/pulls.ts";
11 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
12 import { createApp, type App } from "../src/app.ts";
13 import { createSession } from "../src/core/sessions.ts";
14 import { createUser, type User } from "../src/core/users.ts";
15 import { serve, type Servers } from "../src/http/server.ts";
16 import { findChromium } from "../src/looks/capture.ts";
17 import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts";
18 import { quietLogs } from "./helpers/globals.ts";
19
20 quietLogs();
21 const found = findChromium();
22 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
23 const skip = chromium === undefined && (process.env["FORGE_CHECK"] ?? "") === "";
24 if (skip) console.log("SKIPPING: no chromium that starts on this machine, so the pane's verdicts are not pressed");
25
26 let dir: string;
27 let app: App;
28 let servers: Servers;
29 let alice: User;
30 let number = 0;
31 beforeAll(async () => {
32 dir = await mkdtemp(join(tmpdir(), "forge-pull-pane-keys-"));
33 app = createApp({ dataDir: dir, port: 0 });
34 servers = await serve(app);
35 const made = await createUser(app.db, {
36 origin: "seed",
37 trusted: true,
38 username: "alice",
39 email: "[email protected]",
40 password: "a-good-passphrase",
41 adminIfFirst: true,
42 });
43 if (!made.ok) throw new Error(made.error);
44 alice = made.value;
45 const bob = await createUser(app.db, {
46 origin: "seed",
47 trusted: true,
48 username: "bob",
49 email: "[email protected]",
50 password: "a-good-passphrase",
51 });
52 if (!bob.ok) throw new Error(bob.error);
53 const r = await createRepo(app, alice, { name: "harbor", visibility: "public" });
54 if (!r.ok) throw new Error("repo");
55 const base = await commitToBranch(app, alice, r.value, { message: "Start", files: [{ path: "README.md", content: "# harbor\n" }] });
56 if (!base.ok) throw new Error("base");
57 const branch = await commitToBranch(app, alice, r.value, {
58 branch: "topic",
59 base: "main",
60 message: "x",
61 files: [{ path: "x.ts", content: "export const x = 1;\n" }],
62 });
63 if (!branch.ok) throw new Error("branch");
64 const opened = await openPull(app, alice, r.value, { title: "A change", baseBranch: "main", headBranch: "topic" });
65 if (!opened.ok) throw new Error(String(opened.error));
66 number = opened.value.number;
67 // Bob's pull, so alice may pass every verdict on it.
68 app.db.query("UPDATE issue SET author_id = ?1 WHERE kind = 'pull'").run(bob.value.id);
69 // Reviews asked for, so the pull waits for one and the pane offers the verdicts.
70 app.db.query("UPDATE repo SET require_review = 1 WHERE id = ?1").run(r.value.id);
71 }, 30_000);
72 afterAll(async () => {
73 servers.stop();
74 app.close();
75 await rm(dir, { recursive: true, force: true });
76 });
77
78 test.skipIf(skip)(
79 "a and b on Files pick the verdict and put the caret in the box; each verb is a focusable link",
80 async () => {
81 if (chromium === undefined)
82 throw new Error(
83 "no Chromium starts in this check, so the verdicts are not pressed: the check's image must carry one (FORGE_CHROMIUM)",
84 );
85 const out = JSON.parse(
86 await evaluateLoaded(
87 chromium,
88 `${servers.url}/alice/harbor/pulls/${String(number)}/files`,
89 { width: 1280, height: 900 },
90 [{ name: "forge_session", value: createSession(app.db, alice.id).token }],
91 `(async () => {
92 const pane = document.querySelector("[data-pane]");
93 const verbs = [...pane.querySelectorAll("[data-pick]")].map((v) => ({ tag: v.tagName, href: v.getAttribute("href"), tab: v.tabIndex }));
94 const press = async (k) => {
95 document.activeElement?.blur();
96 document.dispatchEvent(new KeyboardEvent("keydown", { key: k, bubbles: true, cancelable: true }));
97 await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
98 return { picked: document.querySelector('input[name="state"]:checked')?.value ?? null, caret: document.activeElement?.tagName, path: location.pathname };
99 };
100 return JSON.stringify({ verbs, a: await press("a"), b: await press("b") });
101 })()`,
102 ),
103 ) as {
104 verbs: { tag: string; href: string; tab: number }[];
105 a: { picked: string; caret: string; path: string };
106 b: { picked: string; caret: string };
107 };
108 expect(out.verbs).toEqual([
109 { tag: "A", href: "#review-approved", tab: 0 },
110 { tag: "A", href: "#review-changes_requested", tab: 0 },
111 ]);
112 expect(out.a).toEqual({ picked: "approved", caret: "TEXTAREA", path: `/alice/harbor/pulls/${String(number)}/files` });
113 expect(out.b).toMatchObject({ picked: "changes_requested", caret: "TEXTAREA" });
114 },
115 30_000,
116 );
test/pull-pane.test.ts added +209
@@ -0,0 +1,209 @@
1 /**
2 * The pull pane (src/flow/pull_pane.ts): each state's sentence, verbs and evidence from plain
3 * facts; every verb a key of the map; and one pull read through the reader says the same sentence
4 * on the page, the terminal's pull screen and the peek.
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { createApp, type App } from "../src/app.ts";
11 import { createRepo } from "../src/actions/repos.ts";
12 import { createIssue } from "../src/core/issues.ts";
13 import { createUser } from "../src/core/users.ts";
14 import { promote } from "./helpers/members.ts";
15 import { getPull } from "../src/core/pulls.ts";
16 import { getRepo } from "../src/core/repos.ts";
17 import { createRun } from "../src/core/runs.ts";
18 import { paneOf, pullPane, type PaneFacts, type PaneVerb } from "../src/flow/pull_pane.ts";
19 import { peekCard } from "../src/web/peek.ts";
20 import { paneView } from "../src/web/studio/pane.ts";
21 import { VERBS } from "../src/web/keymap.ts";
22 import { quietLogs } from "./helpers/globals.ts";
23 import { once } from "./helpers/statements.ts";
24
25 quietLogs();
26 const NOW = new Date("2026-12-01T12:00:00Z");
27 const min = (n: number) => new Date(NOW.getTime() - n * 60_000).toISOString();
28 const base: PaneFacts = {
29 now: NOW,
30 state: "open",
31 mergedAt: null,
32 closedAt: null,
33 parked: false,
34 deploys: false,
35 liveSince: false,
36 baseBranch: "main",
37 draft: null,
38 held: null,
39 conflicts: [],
40 building: null,
41 check: { state: "none", startedAt: null, createdAt: null, finishedAt: null, summary: "", place: undefined },
42 next: { who: "reviewer", why: "no review yet" },
43 };
44 const check = (state: PaneFacts["check"]["state"], more: Partial<PaneFacts["check"]> = {}): PaneFacts["check"] => ({
45 ...base.check,
46 state,
47 createdAt: min(9),
48 ...more,
49 });
50
51 test("each state says one sentence, offers at most three verbs from the map, and shows its evidence", () => {
52 const cases: [string, PaneFacts, string, PaneVerb[], string[]][] = [
53 ["merged, live", { ...base, mergedAt: min(4), deploys: true, liveSince: true }, "Merged 4m ago, live in production", [], []],
54 ["merged, next release", { ...base, mergedAt: min(4), deploys: true }, "Merged 4m ago, goes live with the next release", [], []],
55 ["merged where nothing deploys", { ...base, mergedAt: min(0.5) }, "Merged just now", [], []],
56 ["closed", { ...base, state: "closed", closedAt: min(120) }, "Closed 2h ago", [], []],
57 ["parked", { ...base, state: "closed", closedAt: min(3), parked: true }, "Parked 3m ago", [], []],
58 ["draft", { ...base, draft: "Draft: its build is still running." }, "Draft: its build is still running", [], []],
59 ["held", { ...base, held: "alice holds it: waiting on the vendor" }, "alice holds it: waiting on the vendor", [], []],
60 [
61 "conflict",
62 { ...base, conflicts: ["a.ts", "b.ts", "c.ts", "d.ts"] },
63 "Conflicts with main in 4 files",
64 ["update"],
65 ["a.ts", "b.ts", "c.ts", "and 1 more"],
66 ],
67 [
68 "building",
69 { ...base, building: { state: "running", startedAt: min(4), createdAt: min(5), summary: "writing the tests" } },
70 "The crew is building it, 4m so far",
71 ["wheel", "watch", "stop"],
72 ["writing the tests"],
73 ],
74 [
75 "checking",
76 { ...base, check: check("running", { startedAt: min(2), place: { place: 2, of: 5 } }) },
77 "Its check is running, 2m so far, place 2 of 5",
78 ["watch", "stop"],
79 [],
80 ],
81 [
82 "queued",
83 { ...base, check: check("queued", { place: { place: 3, of: 4 } }) },
84 "Its check is queued, place 3 of 4",
85 ["watch", "stop"],
86 [],
87 ],
88 [
89 "red",
90 {
91 ...base,
92 check: check("failed", { finishedAt: min(6), summary: "2 tests failed" }),
93 next: { who: "builder", why: "its check is red" },
94 },
95 "Its check is red, 6m ago",
96 ["requeue", "watch", "sendBack"],
97 ["2 tests failed"],
98 ],
99 [
100 "changes asked",
101 {
102 ...base,
103 check: check("ok"),
104 next: { who: "builder", why: "changes were asked on this head: juniper asked for changes (review 12)", changes: true },
105 },
106 "Juniper asked for changes (review 12)",
107 [],
108 [],
109 ],
110 [
111 "waits for a review",
112 { ...base, check: check("ok", { finishedAt: min(6) }) },
113 "Green, waits for a review (no review yet), 6m",
114 ["approve", "sendBack"],
115 [],
116 ],
117 ["no check yet", { ...base }, "No check yet, waits for a review (no review yet)", ["approve", "sendBack"], []],
118 [
119 "ready",
120 { ...base, check: check("ok"), next: { who: "queue", why: "approved and green" } },
121 "Approved and green, ready to merge",
122 ["merge", "close"],
123 [],
124 ],
125 ["lands by itself", { ...base, check: check("ok"), next: { who: "queue", why: "green, reviews are off: it lands" } }, "Green, reviews are off: it lands", ["merge", "close"], []],
126 [
127 "a person decides",
128 { ...base, check: check("ok"), next: { who: "person", why: "the access wall holds it: a new host" } },
129 "The access wall holds it: a new host",
130 [],
131 [],
132 ],
133 ];
134 for (const [name, facts, sentence, verbs, evidence] of cases) {
135 const p = paneOf(facts);
136 expect({ name, sentence: p.sentence, verbs: [...p.verbs], evidence: [...p.evidence] }).toEqual({ name, sentence, verbs, evidence });
137 expect(p.verbs.length).toBeLessThanOrEqual(3);
138 for (const v of p.verbs) expect(Object.keys(VERBS)).toContain(v);
139 expect(p.sentence).not.toMatch(/[—.]$/);
140 }
141 });
142
143 test("the page draws each verb with its key from the map through its own door, and only those it has a door for", () => {
144 const pane = paneOf({ ...base, check: check("ok", { finishedAt: min(1) }) });
145 const label = paneView(pane, { approve: { pick: "review-approved" }, sendBack: { href: "/a/b/pulls/1/files#review-body" } }).text;
146 // On Files a verdict is a link to the form's own radio: focusable, a link to a screen reader, and
147 // with the script its click (or key) picks the radio (paneJs).
148 expect(label).toContain('<a class="btn" data-size="sm" data-shortcut="a" aria-keyshortcuts="a" href="#review-approved" data-pick="review-approved"><kbd>a</kbd> Approve</a>');
149 expect(label).toContain('<a class="btn" data-size="sm" data-shortcut="b" aria-keyshortcuts="b" href="/a/b/pulls/1/files#review-body"><kbd>b</kbd> Send back</a>');
150 const red = paneOf({ ...base, check: check("failed", { summary: "red" }) });
151 const posted = paneView(red, { requeue: { post: "/a/b/runs/r1/requeue" } }).text;
152 expect(posted).toContain('<form method="post" action="/a/b/runs/r1/requeue" class="pane-form"><button type="submit" class="btn" data-size="sm" data-shortcut="r"');
153 expect(posted).not.toContain('data-shortcut="w"');
154 expect(paneView(red, {}).text).not.toContain("pane-verbs");
155 });
156
157 test("the changes state is the next actor's flag, not its wording: a reworded reason keeps it, the words alone do not make it", () => {
158 const ok = { ...base, check: check("ok") };
159 expect(paneOf({ ...ok, next: { who: "builder", why: "a reviewer wants another pass", changes: true } }).state).toBe("changes");
160 expect(paneOf({ ...ok, next: { who: "builder", why: "changes were asked on this head" } }).state).not.toBe("changes");
161 });
162
163 let dir: string;
164 let app: App;
165 beforeAll(async () => {
166 dir = await mkdtemp(join(tmpdir(), "forge-pull-pane-"));
167 app = createApp({ dataDir: dir, port: 0 });
168 }, 30_000);
169 afterAll(async () => {
170 app.close();
171 await rm(dir, { recursive: true, force: true });
172 });
173
174 test("one pull, read by the reader, says the same sentence on the page's pane and the peek", async () => {
175 const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
176 if (!u.ok) throw new Error(u.error);
177 promote(app.db, u.value);
178 const r = await createRepo(app, u.value, { name: "harbor", visibility: "public" });
179 if (!r.ok) throw new Error("repo");
180 const repo = getRepo(app.db, "alice", "harbor")!;
181 const i = createIssue(app.db, { repoId: repo.id, authorId: u.value.id, title: "Try AVIF", body: "b", kind: "pull" });
182 if (!i.ok) throw new Error("pull");
183 app.db.run("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid) VALUES (?1, 'main', 'avif', '', 'h')", [
184 i.value.id,
185 ]);
186 app.db.run("UPDATE run SET state = 'failed', finished_at = ?2 WHERE id = ?1", [
187 createRun(app.db, { repoId: repo.id, kind: "check", issueId: i.value.id, commitOid: "h" }).id,
188 new Date().toISOString(),
189 ]);
190 const pull = getPull(app.db, repo.id, i.value.number)!;
191 const pane = pullPane(app.db, repo, pull, { headOid: pull.headOid, conflicts: [] });
192 expect(pane.state).toBe("red");
193 const card = peekCard(app.db, u.value, `/alice/harbor/pulls/${String(pull.number)}`)!.text.replace(/\s+/g, " ");
194 expect(card).toContain(`alice/harbor#${String(pull.number)} · ${pane.sentence}`);
195 });
196
197 test("the peek's pull card costs the same statements with one run or three hundred: the pane reads a fixed set of facts, never one per run", async () => {
198 const repo = getRepo(app.db, "alice", "harbor")!;
199 const alice = (await import("../src/core/users.ts")).getUserByName(app.db, "alice")!;
200 const i = createIssue(app.db, { repoId: repo.id, authorId: alice.id, title: "Many runs", body: "b", kind: "pull" });
201 if (!i.ok) throw new Error("pull");
202 app.db.run("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid) VALUES (?1, 'main', 'many', '', 'h')", [i.value.id]);
203 const href = `/alice/harbor/pulls/${String(i.value.number)}`;
204 createRun(app.db, { repoId: repo.id, kind: "check", issueId: i.value.id, commitOid: "h" });
205 const few = await once(app.db, () => void peekCard(app.db, alice, href));
206 for (let n = 0; n < 300; n++) createRun(app.db, { repoId: repo.id, kind: n % 2 === 0 ? "check" : "agent", issueId: i.value.id, commitOid: "h" });
207 const many = await once(app.db, () => void peekCard(app.db, alice, href));
208 expect(many).toBe(few);
209 });
test/pull-step-surfaces.test.ts +2 −2
@@ -93,9 +93,9 @@ test("the feed's post for a pull says its step, linked to /pipeline", async () =
9393 expect(await get("/feed")).toContain(expected());
9494 });
9595
96 test("the repository's pulls list leaves the step to the pull (#10415)", async () => {
96 test("the repository's pulls list leaves where it stands to the pull's pane (#10415)", async () => {
9797 expect(await get("/alice/site/pulls")).not.toContain(expected());
98 expect(await get(`/alice/site/pulls/${pull.number}`)).toContain('data-path="review"');
98 expect(await get(`/alice/site/pulls/${pull.number}`)).toContain('data-pane="');
9999 });
100100
101101 const openMore = async (r: Repo, by: User, name: string): Promise<Pull> => {
test/pull-verdict.test.ts +23 −17
@@ -1,6 +1,7 @@
11 /**
2 * A pull's page opens on its verdict (can it land, what holds it) and then the
3 * change itself; reviews and checks come after.
2 * A pull's page opens on its pane (where it stands, in one sentence, with what moves it;
3 * studio/pane.ts) and then the change itself; reviews and checks come after. `verdictOf` still
4 * answers the merge box's question in the merge box's order.
45 */
56 import { afterAll, beforeAll, expect, test } from "bun:test";
67 import { mkdir, mkdtemp, rm } from "node:fs/promises";
@@ -93,22 +94,23 @@ const at = (body: string, needle: string): number => {
9394 return i;
9495 };
9596
97 // Reviews are off for a person's own repository, so a pull with no check yet waits only on one.
9698 for (const [name, words] of [
97 ["ready", "Ready to land"],
98 ["held", "Waiting for the check"],
99 ["conflicted", "Conflicts with main"],
99 ["ready", "No check yet"],
100 ["held", "No check yet"],
101 ["conflicted", "Conflicts with main in 1 file"],
100102 ] as const) {
101 test(`${name}: the files tab opens on the verdict, before the merge box`, async () => {
103 test(`${name}: the files tab opens on the pane, before the merge box`, async () => {
102104 const body = await pageOf(name);
103 const verdict = at(body, "data-verdict");
105 const verdict = at(body, "data-pane=");
104106 expect(body.indexOf(words, verdict)).toBeGreaterThan(verdict);
105107 expect(verdict).toBeLessThan(at(body, 'id="merge"'));
106 expect(body.split("data-verdict").length).toBe(2);
108 expect(body.split("data-pane=").length).toBe(2);
107109 });
108110
109 test(`${name}: the pull's own page opens on the verdict, then the change, before the check`, async () => {
111 test(`${name}: the pull's own page opens on the pane, then the change, before the check`, async () => {
110112 const body = await pageOf(name, "");
111 const verdict = at(body, "data-verdict");
113 const verdict = at(body, "data-pane=");
112114 expect(body.indexOf(words, verdict)).toBeGreaterThan(verdict);
113115 const change = at(body, "data-change");
114116 expect(change).toBeGreaterThan(verdict);
@@ -119,13 +121,17 @@ for (const [name, words] of [
119121 });
120122 }
121123
122 test("ready offers Go to merge beside the verdict on Files; conflicted offers Resolve", async () => {
123 expect(await pageOf("ready")).toMatch(/data-verdict[\s\S]*?<a[^>]*href="#merge"[^>]*>[\s\S]*?Go to merge/);
124 // The pull's own page has its own Ship button below; the line carries no second action.
125 const own = await pageOf("ready", "");
126 const line = own.slice(own.indexOf("data-verdict"), own.indexOf("data-change"));
127 expect(line).not.toContain("<a");
128 expect(await pageOf("conflicted")).toMatch(/data-verdict[\s\S]*?href="\/alice\/conflicted\/pulls\/\d+\/resolve"/);
124 test("a conflicted pull's pane offers Update on its key and names the file; one with nothing to press yet offers nothing", async () => {
125 for (const tab of ["", "/files"]) {
126 const body = await pageOf("conflicted", tab);
127 const pane = body.slice(body.indexOf("data-pane="), body.indexOf("</section>", body.indexOf("data-pane=")));
128 expect(pane).toMatch(/<form method="post" action="\/alice\/conflicted\/pulls\/\d+\/update"[^>]*><button type="submit" class="btn" data-size="sm" data-shortcut="u"/);
129 expect(pane).toMatch(/class="pane-evidence[^"]*">forge\.json</);
130 // The pane's key is the page's only one: pressing u updates, nothing else answers it.
131 expect(body.split('data-shortcut="u"').length - 1).toBe(1);
132 }
133 const ready = await pageOf("ready", "");
134 expect(ready.slice(ready.indexOf("data-pane="), ready.indexOf("</section>", ready.indexOf("data-pane=")))).not.toContain("data-shortcut");
129135 });
130136
131137 const base: VerdictInput = {
test/reviewer-lands.test.ts +15
@@ -109,6 +109,21 @@ describe("a team reviewer reviews and a writer lands", () => {
109109 expect(body).not.toContain(reviewWords.forbidden);
110110 });
111111
112 test("each verdict's radio has the id the pane's a and b label (studio/pane.ts), and the pane offers a team reviewer no merge or close", async () => {
113 const body = await page("dee");
114 expect(body).toMatch(/<input\s+id="review-approved"\s+type="radio"/);
115 expect(body).toMatch(/<input\s+id="review-changes_requested"\s+type="radio"/);
116 const pane = body.slice(body.indexOf("data-pane="), body.indexOf("</section>", body.indexOf("data-pane=")));
117 expect(pane).not.toContain('data-shortcut="m"');
118 expect(pane).not.toContain('data-shortcut="x"');
119 });
120
121 test("the pane offers nothing to a plain reader: no verdict is theirs to pass", async () => {
122 const body = await page("cas");
123 const pane = body.slice(body.indexOf("data-pane="), body.indexOf("</section>", body.indexOf("data-pane=")));
124 expect(pane).not.toContain("data-shortcut");
125 });
126
112127 test("a plain reader sees only Comment, and not the reviewer's line", async () => {
113128 const body = await page("cas");
114129 expect(body).not.toContain('value="approved"');
test/talk-lane.test.ts +2 −1
@@ -302,7 +302,8 @@ describe("the lane is visible", () => {
302302 const cookie = `forge_session=${createSession(app.db, alice.id).token}`;
303303 const seen = async (path: string) => (await (await fetch(`${servers.url}/${name}/pulls/${pull.number}${path}`, { headers: { cookie } })).text()).replace(/\s+/g, " ");
304304 // The verdict line, and the merge box beside the files, with the way back to the conversation.
305 expect(await seen("")).toContain(`<dt>Draft</dt><dd>${TALK_DRAFT_LINE}</dd>`);
305 // The pane says it (studio/pane.ts): what a Talk draft is, in its own sentence.
306 expect(await seen("")).toContain(`<strong>${TALK_DRAFT_LINE.replace(/\.$/, "")}</strong>`);
306307 const files = await seen("/files");
307308 expect(files).toContain(TALK_DRAFT_LINE);
308309 expect(files).not.toContain("Nothing to merge until its build ends.");
test/tui-pull-hold.test.ts +3 −2
@@ -84,13 +84,14 @@ test("h holds with a reason, the header says held, h again releases; an agent ha
8484 await h.press(...Array(WHY_MAX + 1).fill("backspace"));
8585 await h.press(..."wait for docs", "enter");
8686 expect(getHold(app.db, pullId)?.why).toBe("wait for docs");
87 expect(h.text()).toContain("held by alice: wait for docs");
87 // The pane's sentence (flow/pull_pane.ts) leads the line.
88 expect(h.text()).toContain("alice holds it: wait for docs");
8889
8990 await h.press("h");
9091 expect(h.text()).toContain("Let #");
9192 await h.press("enter");
9293 expect(getHold(app.db, pullId)).toBeUndefined();
93 expect(h.text()).not.toContain("held by alice");
94 expect(h.text()).not.toContain("alice holds it");
9495 } finally {
9596 h.tui.stop();
9697 }
test/web-ui.test.ts +3 −2
@@ -267,7 +267,8 @@ describe("web ui", () => {
267267 redirect: "manual",
268268 });
269269 let page = await (await fetch(at)).text();
270 expect(page).toContain('data-state="closed"');
270 // The pane says where it stands (studio/pane.ts).
271 expect(page).toContain('data-pane="closed"');
271272 expect(await (await fetch(`${at}/files`)).text()).toContain(
272273 "Closed without merging.",
273274 );
@@ -282,7 +283,7 @@ describe("web ui", () => {
282283 redirect: "manual",
283284 });
284285 page = await (await fetch(at)).text();
285 expect(page).toContain('data-state="open"');
286 expect(page).toMatch(/data-pane="(?!closed|merged)/);
286287 expect(await (await fetch(`${at}/files`)).text()).toContain(
287288 "Ready to merge",
288289 );

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

Keyboard shortcuts

Docs