Public: anyone can read this; the crew can change it.
Say where a pull stands in one pane: one reader, three doors #17187
Merged 41h 35m ago, live in production
slice2 → main 0 commits 5 threads · 5 unresolved
30 files
changed +789
−184
- docs/design/areas/pull.md
- docs/features/pull-pane.md
- src/flow/next_actor.ts
- src/flow/path.ts
- src/flow/pull_pane.ts
- src/tui/screens/pull.ts
- src/web/pages/conflicts.ts
- src/web/pages/pull-verdict.ts
- src/web/pages/pull.ts
- src/web/pages/pulls.ts
- src/web/peek.ts
- src/web/studio/change.ts
- src/web/studio/pane.ts
- src/web/studio/words.ts
- src/web/style/components.ts
- test/crew-draft.test.ts
- test/next_actor.test.ts
- test/parked-close.test.ts
- test/peek.test.ts
- test/pipeline-path.test.ts
- test/pull-next-line.test.ts
- test/pull-next-tui.test.ts
- test/pull-pane-keys.test.ts
- test/pull-pane.test.ts
- test/pull-step-surfaces.test.ts
- test/pull-verdict.test.ts
- test/reviewer-lands.test.ts
- test/talk-lane.test.ts
- test/tui-pull-hold.test.ts
- test/web-ui.test.ts
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 | ||
| 4 | 4 | |
| 5 | 5 | A pull is one change waiting on a person: read it, see its check, ship it or say what is off (#8773). |
| 6 | 6 | |
| 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. | |
| 8 | 8 | |
| 9 | 9 | 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. |
| 10 | 10 |
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"; | ||
| 19 | 19 | export interface Next { |
| 20 | 20 | readonly who: Actor; |
| 21 | 21 | 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; | |
| 22 | 28 | } |
| 23 | 29 | |
| 24 | 30 | export interface NextInput { |
| @@ -50,7 +56,7 @@ const WAITING = { | ||
| 50 | 56 | |
| 51 | 57 | export function nextActor(i: NextInput): Next { |
| 52 | 58 | 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 }; | |
| 54 | 60 | if (i.conflicted) return { who: "builder", why: "it conflicts with its base" }; |
| 55 | 61 | if (i.changesRequested > 0 && i.firstChange === true && i.check !== "failed") { |
| 56 | 62 | 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 { | ||
| 58 | 64 | return { who: "queue", why: WAITING[i.check] }; |
| 59 | 65 | } |
| 60 | 66 | 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 }; | |
| 62 | 68 | if (i.check === "failed") return { who: "builder", why: "its check is red" }; |
| 63 | 69 | if (i.wall != null && i.wall.length > 0) return { who: "person", why: wallAsk(i.wall) }; |
| 64 | 70 | if (i.approvals > 0) { |
src/flow/path.ts +1 −1
| @@ -87,7 +87,7 @@ const CHECK_WORDS: Record<Exclude<RunState, "ok">, string> = { | ||
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | /** 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 { | |
| 91 | 91 | return ( |
| 92 | 92 | db |
| 93 | 93 | .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; | |
| 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"; | ||
| 86 | 86 | import { resolveOid } from "../../git/merge.ts"; |
| 87 | 87 | import { nextOfPull, type Next } from "../../flow/next_actor.ts"; |
| 88 | 88 | 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"; | |
| 90 | 90 | import { fromKeptFork } from "../../core/landing_kind.ts"; |
| 91 | 91 | import { DRAFT_LINE, getPull, isDraft, isTalkDraft, pullDir, TALK_DRAFT_LINE, variantSiblings, type MergePullError, type Pull } from "../../core/pulls.ts"; |
| 92 | 92 | import { voteVariant } from "../../actions/variants.ts"; |
| @@ -288,8 +288,8 @@ export function pullScreen( | ||
| 288 | 288 | let threads: Thread[] = []; |
| 289 | 289 | /** Who acts next, for a local open pull; the page says the same line. */ |
| 290 | 290 | 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; | |
| 293 | 293 | /** |
| 294 | 294 | * Where an approved open pull stands in the landing queue; the page's line under its path |
| 295 | 295 | * (#10860). |
| @@ -480,17 +480,16 @@ export function pullScreen( | ||
| 480 | 480 | headOid: row.headOid || (facts?.headOid ?? ""), |
| 481 | 481 | conflicts: facts?.conflicts.length ?? 0, |
| 482 | 482 | }, settings); |
| 483 | step = | |
| 483 | pane = | |
| 484 | 484 | row === undefined || settings === undefined |
| 485 | 485 | ? null |
| 486 | : stepOfPull( | |
| 486 | : pullPane( | |
| 487 | 487 | f.db, |
| 488 | 488 | settings, |
| 489 | 489 | 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, | |
| 494 | 493 | next, |
| 495 | 494 | ); |
| 496 | 495 | landing = |
| @@ -1393,7 +1392,7 @@ export function pullScreen( | ||
| 1393 | 1392 | x1, |
| 1394 | 1393 | head!.y + 1, |
| 1395 | 1394 | 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}`}`, | |
| 1397 | 1396 | Math.max(0, edge - x1), |
| 1398 | 1397 | ), |
| 1399 | 1398 | style(c.mutedFg, c.bg), |
src/web/pages/conflicts.ts +2 −2
| @@ -186,7 +186,7 @@ export async function conflictsPage(ctx: Ctx): Promise<Response> { | ||
| 186 | 186 | crumbs: crumbsFor(repo), |
| 187 | 187 | palette: repoPalette(ctx, repo), |
| 188 | 188 | 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")} | |
| 190 | 190 | <p class="mt">${unknown && pull.state === "open" |
| 191 | 191 | ? "No conflict in that file." |
| 192 | 192 | : "This pull has no conflicts."} |
| @@ -239,7 +239,7 @@ export async function conflictsPage(ctx: Ctx): Promise<Response> { | ||
| 239 | 239 | }); |
| 240 | 240 | |
| 241 | 241 | 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")} | |
| 243 | 243 | <p class="muted small mt"> |
| 244 | 244 | <a href="${back}">← Files</a> · <span class="mono">${file}</span> · |
| 245 | 245 | <strong id="rs-count">${done} of ${total} resolved</strong> |
src/web/pages/pull-verdict.ts +4 −15
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /** |
| 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`). | |
| 5 | 5 | * |
| 6 | 6 | * `verdictOf` is plain data in, plain data out; it asks the questions |
| 7 | 7 | * `mergeBox` and `mergePull` ask, in the same order, so the line and the |
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | import { changedSentences, DRAFT_LINE, TALK_DRAFT_LINE } from "../../core/pulls.ts"; |
| 11 | 11 | import type { Diff } from "../../git/diff.ts"; |
| 12 | 12 | import { html, when, type Html } from "../html.ts"; |
| 13 | import { btn, dot, type Tone } from "../ui.ts"; | |
| 13 | import type { Tone } from "../ui.ts"; | |
| 14 | 14 | |
| 15 | 15 | export interface VerdictInput { |
| 16 | 16 | readonly merged: boolean; |
| @@ -92,17 +92,6 @@ export function verdictOf(v: VerdictInput, thread: string, page = ""): Verdict { | ||
| 92 | 92 | }; |
| 93 | 93 | } |
| 94 | 94 | |
| 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 | ||
| 106 | 95 | /** |
| 107 | 96 | * The change itself, once: the first sentences of the description (`changedSentences`; the verdict |
| 108 | 97 | * 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 @@ | ||
| 8 | 8 | * it needs. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { paneJs } from "../studio/pane.ts"; | |
| 11 | 12 | import { pullProposalAt } from "../../core/proposal_token.ts"; |
| 12 | 13 | import { keyOf, oldKeys } from "../keymap.ts"; |
| 13 | 14 | import { returnTo, withReturn } from "../return_to.ts"; |
| @@ -38,7 +39,7 @@ import { RED_ALONE_WAIT, redAloneAt, redMark, type RedMark } from "../../checks/ | ||
| 38 | 39 | import { tierLine, type TierState } from "../../checks/tiers.ts"; |
| 39 | 40 | import { fromKeptFork } from "../../core/landing_kind.ts"; |
| 40 | 41 | 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"; | |
| 42 | 43 | import { landAsIs, shipsOn } from "../studio/land_as_is.ts"; |
| 43 | 44 | import { getAppByRepo } from "../../core/apps.ts"; |
| 44 | 45 | import { labelsFor, listLabels } from "../../core/issues.ts"; |
| @@ -977,6 +978,7 @@ function reviewCard(ctx: Ctx, repo: Repo, pull: Pull, action: string): Html { | ||
| 977 | 978 | (option, i) => |
| 978 | 979 | html`<label class="check" ${hintAttr(option.key)}> |
| 979 | 980 | <input |
| 981 | id="review-${option.value}" | |
| 980 | 982 | type="radio" |
| 981 | 983 | name="state" |
| 982 | 984 | value="${option.value}" |
| @@ -1233,9 +1235,8 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> { | ||
| 1233 | 1235 | compact: true, |
| 1234 | 1236 | ownTitle: true, |
| 1235 | 1237 | })} |
| 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")} | |
| 1237 | 1239 | ${changeTabs(repo, pull, "files")} |
| 1238 | ${verdictLine(verdict)} | |
| 1239 | 1240 | ${shipsOn(verdict, ctx.app, repo, pull, ctx.auth.user) && mayMerge && check.state === "ok" && !stale |
| 1240 | 1241 | ? landAsIs(ctx, repo, pull) |
| 1241 | 1242 | : null} |
| @@ -1313,7 +1314,7 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> { | ||
| 1313 | 1314 | ], |
| 1314 | 1315 | body, |
| 1315 | 1316 | styleCss: labelCss([...allLabels, ...applied]), |
| 1316 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${diffTapJs}`, | |
| 1317 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${diffTapJs}\n${paneJs}`, | |
| 1317 | 1318 | }); |
| 1318 | 1319 | const { diff: diffMs, git, checks, reviews } = spent; |
| 1319 | 1320 | notePhase(ctx.request, "diff", diffMs, diffHit); |
src/web/pages/pulls.ts −6
| @@ -34,12 +34,6 @@ import { flashTo, page } from "../layout.ts"; | ||
| 34 | 34 | import { btn, empty, field as formField } from "../ui.ts"; |
| 35 | 35 | import { refSet } from "./refs.ts"; |
| 36 | 36 | |
| 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 | ||
| 43 | 37 | // ---- compose ---- |
| 44 | 38 | |
| 45 | 39 | interface ComposeValues { |
src/web/peek.ts +16 −26
| @@ -5,12 +5,13 @@ | ||
| 5 | 5 | * or `owner/name#12`, so a row that already shows its title gets none; in Talk's thread every link |
| 6 | 6 | * to an issue, a pull or a repository on this forge peeks. |
| 7 | 7 | * |
| 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. | |
| 14 | 15 | * |
| 15 | 16 | * The body is someone else's words: escaped plain text, never Markdown, never a link. |
| 16 | 17 | */ |
| @@ -18,6 +19,8 @@ | ||
| 18 | 19 | import type { Database } from "bun:sqlite"; |
| 19 | 20 | import type { Ctx } from "../http/context.ts"; |
| 20 | 21 | import { getIssue } from "../core/issues.ts"; |
| 22 | import { getPull } from "../core/pulls.ts"; | |
| 23 | import { pullPane } from "../flow/pull_pane.ts"; | |
| 21 | 24 | import { canRead, getRepo } from "../core/repos.ts"; |
| 22 | 25 | import { mayView } from "../core/sealed.ts"; |
| 23 | 26 | import type { User } from "../core/users.ts"; |
| @@ -63,12 +66,8 @@ const PEEK_WORDS = { | ||
| 63 | 66 | talk: "Talk about this", |
| 64 | 67 | merged: "Merged", |
| 65 | 68 | closed: "Closed", |
| 66 | draft: "Draft", | |
| 67 | 69 | repository: "Repository", |
| 68 | 70 | opened: "Opened by", |
| 69 | checksOk: "checks passed", | |
| 70 | checksFailed: "checks failed", | |
| 71 | checksRunning: "checks running", | |
| 72 | 71 | } as const; |
| 73 | 72 | |
| 74 | 73 | /** |
| @@ -112,7 +111,8 @@ export function plainLines(body: string, lines = LINES_SHOWN, chars = BODY_SHOWN | ||
| 112 | 111 | |
| 113 | 112 | /** |
| 114 | 113 | * 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). | |
| 116 | 116 | */ |
| 117 | 117 | export function peekCard(db: Database, viewer: User | undefined, href: string): Html | undefined { |
| 118 | 118 | const m = PEEK.exec(href); |
| @@ -135,29 +135,19 @@ export function peekCard(db: Database, viewer: User | undefined, href: string): | ||
| 135 | 135 | const issue = getIssue(db, repo.id, Number(number)); |
| 136 | 136 | // `/issues/N` names a pull as well (the page answers both); `/pulls/N` names only a pull. |
| 137 | 137 | 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 | |
| 148 | 140 | ? (["merge", PEEK_WORDS.merged] as const) |
| 149 | 141 | : issue.state === "open" |
| 150 | 142 | ? ([issue.kind === "pull" ? "pull" : "issue", PEEK_WORDS.open] as const) |
| 151 | 143 | : (["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; | |
| 156 | 146 | const body = plainLines(issue.body); |
| 157 | 147 | const path = `/${full}/${issue.kind === "pull" ? "pulls" : "issues"}/${issue.number}`; |
| 158 | 148 | return html`<p class="peek-kind small muted"> |
| 159 | 149 | ${icon(state[0])} ${full}#${String(issue.number)} · |
| 160 | ${state[1]}${draft ? ` · ${PEEK_WORDS.draft}` : null}${checks === null ? null : ` · ${checks}`} | |
| 150 | ${says} | |
| 161 | 151 | </p> |
| 162 | 152 | <p class="peek-title">${issue.title}</p> |
| 163 | 153 | <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"; | ||
| 18 | 18 | import { pullProposalAt, type PullProposalAt } from "../../core/proposal_token.ts"; |
| 19 | 19 | import { attestationLine } from "../../core/attestation.ts"; |
| 20 | 20 | import { offerStatusLinkFor } from "../../core/outsider_status.ts"; |
| 21 | import { getIssueById } from "../../core/issues.ts"; | |
| 22 | 21 | import { mayEditIssue } from "../../actions/issues.ts"; |
| 23 | 22 | import { outsideLabelFrom } from "../outside.ts"; |
| 24 | 23 | import { accountsByName, marksByName, marksOf, type Mark } from "../../core/marks.ts"; |
| @@ -40,7 +39,7 @@ import { | ||
| 40 | 39 | import { canAdmin, canWrite, type Repo } from "../../core/repos.ts"; |
| 41 | 40 | import { listReviews, type Review } from "../../core/reviews.ts"; |
| 42 | 41 | 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"; | |
| 44 | 43 | import { commitLog } from "../../git/read.ts"; |
| 45 | 44 | import { mayReadRunLog } from "../../actions/runs.ts"; |
| 46 | 45 | import { readRunLogTail } from "../../runs/log.ts"; |
| @@ -67,7 +66,6 @@ import { | ||
| 67 | 66 | crumbs, |
| 68 | 67 | confirmAction, |
| 69 | 68 | copyField, |
| 70 | badge, | |
| 71 | 69 | icon, |
| 72 | 70 | originTag, |
| 73 | 71 | seg, |
| @@ -83,12 +81,11 @@ import { filmstrip, filmstripJs } from "../pages/filmstrip.ts"; | ||
| 83 | 81 | import { lookCard } from "../pages/looks.ts"; |
| 84 | 82 | import { approveHereCard, keptChange, pullChecksLineFor, reachLine, teamsCard, markReadyForm, verdictFacts } from "../pages/pull.ts"; |
| 85 | 83 | 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"; | |
| 87 | 85 | import { guestWalls, strangerCard } from "../pages/pull-guest.ts"; |
| 88 | 86 | import { combinedCard } from "../pages/pull-combined.ts"; |
| 89 | 87 | import { teamVerdicts } from "../../core/issue_teams.ts"; |
| 90 | 88 | import { liveRegionsJs } from "../client.ts"; |
| 91 | import { pullState } from "../pages/pulls.ts"; | |
| 92 | 89 | import { workSpent } from "../pages/runs.ts"; |
| 93 | 90 | import { |
| 94 | 91 | composer, |
| @@ -105,12 +102,13 @@ import { previewVision } from "../../crew/vision.ts"; | ||
| 105 | 102 | import { visionPreviewCard } from "./direction.ts"; |
| 106 | 103 | import { holdCard } from "./hold.ts"; |
| 107 | 104 | import { pullMayRun } from "../../core/pull_trust.ts"; |
| 108 | import { pullWaitsFor } from "../../flow/waits_for.ts"; | |
| 109 | 105 | import { landingLine } from "../../flow/landing_line.ts"; |
| 110 | 106 | 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"; | |
| 112 | 110 | 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"; | |
| 114 | 112 | import { getHold } from "../../core/holds.ts"; |
| 115 | 113 | import { backToWave } from "../../story/waves.ts"; |
| 116 | 114 | import { offerPullCard } from "../pages/offer-upstream.ts"; |
| @@ -252,35 +250,58 @@ function statusLinkLine(ctx: Ctx, repo: Repo, pull: Pull): Html | "" { | ||
| 252 | 250 | return html`<div class="small" data-status-link>${copyField("status-link", url, "Status link for the person who offered this", "Copy status link")}</div>`; |
| 253 | 251 | } |
| 254 | 252 | |
| 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}-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. */ | |
| 258 | 283 | export function changeHead( |
| 259 | 284 | ctx: Ctx, |
| 260 | 285 | repo: Repo, |
| 261 | 286 | pull: Pull, |
| 262 | live: { readonly headOid: string; readonly conflicts: number } | null, | |
| 287 | live: { readonly headOid: string; readonly conflicts: readonly string[] } | null, | |
| 263 | 288 | // The child's proposal, if one opened this pull, read by the caller with `pullProposalAt` |
| 264 | 289 | // (async: it reads the head's tree when the child attested one, #13645). |
| 265 | 290 | proposal: PullProposalAt | undefined, |
| 291 | tab: "change" | "files" = "change", | |
| 266 | 292 | ): 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). | |
| 268 | 294 | 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); | |
| 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); | |
| 274 | 299 | const who = toldBy(ctx.app.db, pull); |
| 275 | 300 | const accounts = accountsByName(ctx.app.db, [pull.authorName, who ?? ""], repo.id); |
| 276 | 301 | const marks = marksOf(accounts); |
| 277 | 302 | return html`<div class="page-head"> |
| 278 | 303 | <h1>${pull.title} <a class="num self" href="${changeHref(repoBase(repo), pull.number)}" title="This pull's address">#${pull.number}</a></h1> |
| 279 | 304 | <div class="page-head-sub bar muted small"> |
| 280 | ${stateDot( | |
| 281 | pullState(pull), | |
| 282 | getIssueById(ctx.app.db, pull.id)?.closeReason === "parked", | |
| 283 | )} | |
| 284 | 305 | <span |
| 285 | 306 | >${pull.originAuthor |
| 286 | 307 | ? originTag(pull.originAuthor, originGlyph(repo)) |
| @@ -310,15 +331,12 @@ export function changeHead( | ||
| 310 | 331 | >`, |
| 311 | 332 | )} |
| 312 | 333 | </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( | |
| 314 | 335 | pull.mergedAt === null ? pausedSentence(ctx.app.db, { issueId: pull.id }) : undefined, |
| 315 | 336 | (says) => html`<p class="muted small" data-paused role="status">${says}.</p>`, |
| 316 | 337 | )}${when( |
| 317 | 338 | live === null ? null : landingLine(ctx.app.db, pull, repo.id), |
| 318 | 339 | (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>`, | |
| 322 | 340 | )}${ |
| 323 | 341 | // The desk is the crew's: a guest sees no note, not even a hold on a public pull. |
| 324 | 342 | ctx.auth.user === undefined |
| @@ -328,25 +346,6 @@ export function changeHead( | ||
| 328 | 346 | </div>`; |
| 329 | 347 | } |
| 330 | 348 | |
| 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 | ||
| 350 | 349 | /** The change's two steps: the change itself, and its Files one tab |
| 351 | 350 | * deeper — never a mode, the same address family either way. */ |
| 352 | 351 | export function changeTabs( |
| @@ -743,7 +742,7 @@ async function changeConversation( | ||
| 743 | 742 | ownTitle: true, |
| 744 | 743 | quiet: true, |
| 745 | 744 | })} |
| 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)} | |
| 747 | 746 | ${changeTabs(repo, pull, "change")}`, |
| 748 | 747 | crumbs: crumbsFor(repo), |
| 749 | 748 | palette: [ |
| @@ -880,7 +879,6 @@ async function changeConversation( | ||
| 880 | 879 | const wave = backToWave(ctx.url.searchParams.get("from")); |
| 881 | 880 | const body = html`${pageHead.top} |
| 882 | 881 | ${when(wave, (w) => crumbs([{ label: `Wave ${w.version}`, href: w.href }, { label: "This pull" }]))} |
| 883 | ${verdictLine(verdict, { action: false })} | |
| 884 | 882 | <div class="split" data-pull> |
| 885 | 883 | <div> |
| 886 | 884 | ${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 |
||
| 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 { | ||
| 638 | 638 | return html`<span class="dot" data-tone="${tone}" data-word="${word}" role="img" aria-label="${said}"></span>`; |
| 639 | 639 | } |
| 640 | 640 | |
| 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 | ||
| 651 | 641 | // ---- what a subscription has left, and what a change costs ---- |
| 652 | 642 | |
| 653 | 643 | /** 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; } | ||
| 1062 | 1062 | } |
| 1063 | 1063 | .page-head h1 { min-width: 0; overflow-wrap: anywhere; } |
| 1064 | 1064 | .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; } | |
| 1065 | 1071 | |
| 1066 | 1072 | /* ---- breadcrumbs ---- */ |
| 1067 | 1073 | .crumbs { |
test/crew-draft.test.ts +4 −2
| @@ -403,7 +403,9 @@ describe("an app's first build pushes early, as a draft", () => { | ||
| 403 | 403 | return (await res.text()).replace(/\s+/g, " "); |
| 404 | 404 | }; |
| 405 | 405 | 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>`); | |
| 407 | 409 | expect(seen).not.toContain("Merge pull request"); |
| 408 | 410 | expect(seen).toContain(`action="/${repo.ownerName}/${repo.name}/pulls/${pull.number}/ready"`); |
| 409 | 411 | 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", () => { | ||
| 416 | 418 | expect((await press(alice)).status).toBe(303); |
| 417 | 419 | expect(isDraft(getPull(app.db, repo.id, pull.number)!)).toBe(false); |
| 418 | 420 | 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"`); | |
| 420 | 422 | }, 30_000); |
| 421 | 423 | |
| 422 | 424 | 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 @@ | ||
| 1 | 1 | 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"; | |
| 3 | 3 | |
| 4 | 4 | const base: NextInput = { |
| 5 | 5 | held: null, |
| @@ -10,7 +10,7 @@ const base: NextInput = { | ||
| 10 | 10 | pushedSince: 0, |
| 11 | 11 | }; |
| 12 | 12 | |
| 13 | const cases: [string, Partial<NextInput>, string, string][] = [ | |
| 13 | const cases: [string, Partial<NextInput>, Actor, string][] = [ | |
| 14 | 14 | ["held", { held: { by: "sam", why: "wait for legal" }, approvals: 1, check: "ok" }, "person", "sam holds it: wait for legal"], |
| 15 | 15 | ["conflicted", { conflicted: true, approvals: 1, check: "ok" }, "builder", "it conflicts with its base"], |
| 16 | 16 | ["changes asked", { changesRequested: 1, check: "ok" }, "builder", "changes were asked on this head"], |
| @@ -35,7 +35,11 @@ const cases: [string, Partial<NextInput>, string, string][] = [ | ||
| 35 | 35 | |
| 36 | 36 | describe("nextActor", () => { |
| 37 | 37 | 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 | }); | |
| 39 | 43 | }); |
| 40 | 44 | |
| 41 | 45 | describe("nextAsking (#11666)", () => { |
test/parked-close.test.ts +4 −5
| @@ -181,11 +181,10 @@ describe("a parked pull", () => { | ||
| 181 | 181 | setIssueState(app, alice, repo, plain, "closed"); |
| 182 | 182 | |
| 183 | 183 | 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 /); | |
| 189 | 188 | |
| 190 | 189 | const list = await get("/alice/shop/pulls?word=stopped"); |
| 191 | 190 | 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 | ||
| 157 | 157 | expect((await peek("/alice/vault/issues/1", alice)).status).toBe(200); |
| 158 | 158 | }); |
| 159 | 159 | |
| 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 () => { | |
| 161 | 161 | const repo = getRepo(app.db, "alice", "harbor")!; |
| 162 | 162 | const made = (title: string, more: { kind?: "pull"; sealed?: boolean } = {}) => { |
| 163 | 163 | 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 | ||
| 169 | 169 | 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]); |
| 170 | 170 | return p; |
| 171 | 171 | }; |
| 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]); | |
| 173 | 173 | const text = async (href: string, u: User = alice) => (await (await peek(href, u)).text()).replace(/\s+/g, " "); |
| 174 | 174 | |
| 175 | 175 | const merged = pullOf("Ship WebP", new Date().toISOString()); |
| 176 | 176 | checked(merged, "ok"); |
| 177 | 177 | 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`); | |
| 179 | 179 | expect(card).toMatch(new RegExp(`href="/alice/harbor/pulls/${String(merged.number)}">Open</a\\s*>`)); |
| 180 | 180 | // 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"); | |
| 182 | 182 | const red = pullOf("Try AVIF", null); |
| 183 | 183 | 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"); | |
| 185 | 185 | const going = pullOf("Try JPEG XL", null, "run-1"); |
| 186 | 186 | 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"); | |
| 188 | 188 | const done = made("Old banner"); |
| 189 | 189 | setIssueState(app.db, done.id, "closed"); |
| 190 | 190 | 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 | ||
| 193 | 193 | expect((await peek(`/alice/harbor/issues/${String(sealed.number)}`, alice)).status).toBe(200); |
| 194 | 194 | }); |
| 195 | 195 | |
| 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 () => { | |
| 197 | 203 | const repo = getRepo(app.db, "alice", "harbor")!; |
| 198 | 204 | const p = createIssue(app.db, { repoId: repo.id, authorId: alice.id, title: "Counted", body: "b", kind: "pull" }); |
| 199 | 205 | 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 () | ||
| 206 | 212 | [undefined, "/alice/harbor/issues/1"], |
| 207 | 213 | ] as const) { |
| 208 | 214 | 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); | |
| 210 | 216 | } |
| 211 | 217 | }); |
| 212 | 218 |
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 | ||
| 129 | 129 | expect(body).toContain('href="/boards"'); |
| 130 | 130 | }); |
| 131 | 131 | |
| 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 () => { | |
| 133 | 133 | for (const tab of ["", "/files"]) { |
| 134 | 134 | 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)"); | |
| 139 | 137 | } |
| 140 | 138 | }); |
| 141 | 139 | |
| 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 () => { | |
| 143 | 141 | 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>/); | |
| 146 | 144 | }); |
| 147 | 145 | |
| 148 | 146 | 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 | ||
| 206 | 204 | // One serving after the merge makes it live. |
| 207 | 205 | deploy("d-after", "2999-01-01T00:00:00.000Z", "2999-01-01T00:01:00.000Z"); |
| 208 | 206 | 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"); | |
| 210 | 208 | }); |
| 211 | 209 | |
| 212 | 210 | 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 () => { | ||
| 81 | 81 | test("an open pull with no review names the reviewer on the change tab and on Files", async () => { |
| 82 | 82 | for (const tab of ["", "/files"] as const) { |
| 83 | 83 | 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)"); | |
| 86 | 86 | } |
| 87 | 87 | }); |
| 88 | 88 | |
| 89 | 89 | test("a merged pull draws no next line", async () => { |
| 90 | 90 | 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"); | |
| 92 | 92 | }); |
test/pull-next-tui.test.ts +6 −6
| @@ -88,10 +88,10 @@ async function screenSaying(repo: Awaited<ReturnType<typeof openTopic>>, wanted: | ||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 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); | |
| 95 | 95 | }); |
| 96 | 96 | |
| 97 | 97 | 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 | ||
| 99 | 99 | const run = createRun(app.db, { repoId: topic.repo.id, kind: "check", issueId: topic.pull.id, commitOid: topic.pull.headOid }); |
| 100 | 100 | claimRun(app.db, run.id); |
| 101 | 101 | 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); | |
| 104 | 104 | }); |
| 105 | 105 | |
| 106 | 106 | 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 () = | ||
| 93 | 93 | expect(await get("/feed")).toContain(expected()); |
| 94 | 94 | }); |
| 95 | 95 | |
| 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 () => { | |
| 97 | 97 | 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="'); | |
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | 101 | const openMore = async (r: Repo, by: User, name: string): Promise<Pull> => { |
test/pull-verdict.test.ts +23 −17
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | /** |
| 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. | |
| 4 | 5 | */ |
| 5 | 6 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 6 | 7 | import { mkdir, mkdtemp, rm } from "node:fs/promises"; |
| @@ -93,22 +94,23 @@ const at = (body: string, needle: string): number => { | ||
| 93 | 94 | return i; |
| 94 | 95 | }; |
| 95 | 96 | |
| 97 | // Reviews are off for a person's own repository, so a pull with no check yet waits only on one. | |
| 96 | 98 | 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"], | |
| 100 | 102 | ] 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 () => { | |
| 102 | 104 | const body = await pageOf(name); |
| 103 | const verdict = at(body, "data-verdict"); | |
| 105 | const verdict = at(body, "data-pane="); | |
| 104 | 106 | expect(body.indexOf(words, verdict)).toBeGreaterThan(verdict); |
| 105 | 107 | 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); | |
| 107 | 109 | }); |
| 108 | 110 | |
| 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 () => { | |
| 110 | 112 | const body = await pageOf(name, ""); |
| 111 | const verdict = at(body, "data-verdict"); | |
| 113 | const verdict = at(body, "data-pane="); | |
| 112 | 114 | expect(body.indexOf(words, verdict)).toBeGreaterThan(verdict); |
| 113 | 115 | const change = at(body, "data-change"); |
| 114 | 116 | expect(change).toBeGreaterThan(verdict); |
| @@ -119,13 +121,17 @@ for (const [name, words] of [ | ||
| 119 | 121 | }); |
| 120 | 122 | } |
| 121 | 123 | |
| 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"); | |
| 129 | 135 | }); |
| 130 | 136 | |
| 131 | 137 | const base: VerdictInput = { |
test/reviewer-lands.test.ts +15
| @@ -109,6 +109,21 @@ describe("a team reviewer reviews and a writer lands", () => { | ||
| 109 | 109 | expect(body).not.toContain(reviewWords.forbidden); |
| 110 | 110 | }); |
| 111 | 111 | |
| 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 | ||
| 112 | 127 | test("a plain reader sees only Comment, and not the reviewer's line", async () => { |
| 113 | 128 | const body = await page("cas"); |
| 114 | 129 | expect(body).not.toContain('value="approved"'); |
test/talk-lane.test.ts +2 −1
| @@ -302,7 +302,8 @@ describe("the lane is visible", () => { | ||
| 302 | 302 | const cookie = `forge_session=${createSession(app.db, alice.id).token}`; |
| 303 | 303 | const seen = async (path: string) => (await (await fetch(`${servers.url}/${name}/pulls/${pull.number}${path}`, { headers: { cookie } })).text()).replace(/\s+/g, " "); |
| 304 | 304 | // 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>`); | |
| 306 | 307 | const files = await seen("/files"); |
| 307 | 308 | expect(files).toContain(TALK_DRAFT_LINE); |
| 308 | 309 | 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 | ||
| 84 | 84 | await h.press(...Array(WHY_MAX + 1).fill("backspace")); |
| 85 | 85 | await h.press(..."wait for docs", "enter"); |
| 86 | 86 | 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"); | |
| 88 | 89 | |
| 89 | 90 | await h.press("h"); |
| 90 | 91 | expect(h.text()).toContain("Let #"); |
| 91 | 92 | await h.press("enter"); |
| 92 | 93 | expect(getHold(app.db, pullId)).toBeUndefined(); |
| 93 | expect(h.text()).not.toContain("held by alice"); | |
| 94 | expect(h.text()).not.toContain("alice holds it"); | |
| 94 | 95 | } finally { |
| 95 | 96 | h.tui.stop(); |
| 96 | 97 | } |
test/web-ui.test.ts +3 −2
| @@ -267,7 +267,8 @@ describe("web ui", () => { | ||
| 267 | 267 | redirect: "manual", |
| 268 | 268 | }); |
| 269 | 269 | 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"'); | |
| 271 | 272 | expect(await (await fetch(`${at}/files`)).text()).toContain( |
| 272 | 273 | "Closed without merging.", |
| 273 | 274 | ); |
| @@ -282,7 +283,7 @@ describe("web ui", () => { | ||
| 282 | 283 | redirect: "manual", |
| 283 | 284 | }); |
| 284 | 285 | page = await (await fetch(at)).text(); |
| 285 | expect(page).toContain('data-state="open"'); | |
| 286 | expect(page).toMatch(/data-pane="(?!closed|merged)/); | |
| 286 | 287 | expect(await (await fetch(`${at}/files`)).text()).toContain( |
| 287 | 288 | "Ready to merge", |
| 288 | 289 | ); |
new above
offline
Branching on
n.why.startsWith("changes were asked")couples the state to wording. Carry a flag onNext, ashelddoes, and branch on that.