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

A tell's page says what became of it: queued, picked up by whom, and the pull it produced #13471

Merged opened this

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

Merged

scout/forge:scout/13447-a-tell-s-page-says-what-became-of-it-que → main 4 commits fork 5 threads · 5 unresolved

  • Merged. scout/13447-a-tell-s-page-says-what-became-of-it-que was merged into main as 3cfb22a.

Review

Sign in to review this change.
8 files changed +407 −19
docs/design/attention-budget.json +5 −5
@@ -49,16 +49,16 @@
4949 },
5050 "issue": {
5151 "390": {
52 "words": 76,
53 "blocks": 19,
52 "words": 83,
53 "blocks": 20,
5454 "colours": 2
5555 },
5656 "1280": {
57 "words": 76,
58 "blocks": 19,
57 "words": 83,
58 "blocks": 20,
5959 "colours": 2
6060 },
61 "note": "76 words: the composer offers \"Ask as a question\" (four words) on an issue, the one control that marks a comment as a standing question (#13176)."
61 "note": "83 words: the tell status line (seven words, #13447); before it 76: the composer offers \"Ask as a question\" (four words) on an issue, the one control that marks a comment as a standing question (#13176)."
6262 },
6363 "issues list": {
6464 "390": {
docs/features/README.md +1
@@ -96,6 +96,7 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
9696 - [A run's state is worked out from what it did](run-state.md)
9797 - [A team is told once that a pull waits on its review](team-waits.md)
9898 - [A tell from a preview's toolbar carries its pull](toolbar-tell.md)
99 - [A tell's page says what became of it](tell-status.md)
99100 - [Tell the crew from the terminal's screen: key M](tell-from-here.md)
100101 - [A write the restart cut short, in a conversation](talk-resume-writes.md)
101102 - [Actions that answer at once](act-now.md)
docs/features/tell-status.md added +14
@@ -0,0 +1,14 @@
1 # A tell's page says what became of it
2
3 The head of a tell's page (and the terminal's issue screen, in its summary row) carries one line:
4
5 - `Waiting: nobody has picked it up yet`, or `Waiting: queued for the crew`
6 - `Picked up by <crew member>` while a run is going, or `…; no pull came of it (<state>)`
7 - `…pull #N is open` and `Landed in pull #N`, with the pull linked on the page
8
9 A tell with several agent runs shows the latest and `· N runs`.
10
11 - **Where it comes from.** `tellStatus` (`src/runs/tell_status.ts`) reads the `run` rows of the issue and
12 the pull that closes it or that the latest run's branch opened. No table of its own.
13 - **Who sees it.** Those who may read the app's runs (`mayReadRuns`); a private app's tells show it to nobody else.
14 - Tests: `test/tell-status.test.ts`.
src/runs/tell_status.ts added +94
@@ -0,0 +1,94 @@
1 /**
2 * Where a tell went, in one line (#13447): waiting, picked up by a named
3 * crew member, or landed with its pull. Read from the run and pull rows that
4 * already exist — no table of its own. A tell that spawned several runs
5 * shows the latest and a count.
6 */
7
8 import type { Database } from "bun:sqlite";
9 import type { Issue } from "../core/issues.ts";
10 import { getPull, pullForBranch, type Pull } from "../core/pulls.ts";
11 import { listRuns, type Run } from "../core/runs.ts";
12 import { getUsersByIds, type User } from "../core/users.ts";
13
14 /** How many runs a reader loads for a tell; more is shown as `N+ runs`. */
15 export const TELL_RUNS_SHOWN = 10;
16
17 export interface TellStatus {
18 /** The line before the pull number (all of it when there is no pull). */
19 readonly before: string;
20 /** The pull it produced, when there is one. */
21 readonly pull: number | null;
22 /** The line after the pull number. */
23 readonly after: string;
24 /** The run count suffix (` · 2 runs`), or "". */
25 readonly count: string;
26 /** The line as plain text, for where a link cannot go. */
27 readonly plain: string;
28 }
29
30 /**
31 * The status of one tell from its agent runs (newest first, at most
32 * `TELL_RUNS_SHOWN`) and the pull that closes it. With no `closingPull` the
33 * newest run's branch is looked up.
34 */
35 export function tellStatus(
36 db: Database,
37 repoId: string,
38 issue: Issue,
39 runs: readonly Run[],
40 actors: ReadonlyMap<string, Pick<User, "username">>,
41 closingPull?: Pull,
42 ): TellStatus {
43 const latest = runs[0];
44 const pull =
45 closingPull ?? (latest && latest.branch !== "" ? pullForBranch(db, repoId, latest.branch) : undefined);
46 const who = (latest?.actorId != null && actors.get(latest.actorId)?.username) || "the crew";
47 let before: string;
48 let after = "";
49 if (pull !== undefined) {
50 if (pull.mergedAt !== null) before = "Landed in pull ";
51 else if (pull.state === "closed") {
52 before = "Pull ";
53 after = " was closed";
54 } else {
55 before = `${latest ? `Picked up by ${who}; ` : ""}pull `;
56 after = " is open";
57 }
58 } else if (latest === undefined) {
59 before = issue.state === "closed" ? "Closed without the crew" : "Waiting: nobody has picked it up yet";
60 } else if (latest.state === "queued") before = "Waiting: queued for the crew";
61 else if (latest.state === "running") before = `Picked up by ${who}`;
62 else before = `Picked up by ${who}; no pull came of it (${latest.state})`;
63 const n = runs.length >= TELL_RUNS_SHOWN ? `${TELL_RUNS_SHOWN}+` : String(runs.length);
64 const count = runs.length > 1 ? ` · ${n} runs` : "";
65 const num = pull === undefined ? "" : `#${pull.number}`;
66 return { before, pull: pull?.number ?? null, after, count, plain: `${before}${num}${after}${count}` };
67 }
68
69 /** `tellStatus` with its own reads, for the terminal. */
70 export function readTellStatus(db: Database, repoId: string, issue: Issue, closingPull?: Pull): TellStatus {
71 const runs = listRuns(db, repoId, { kind: "agent", issueId: issue.id, limit: TELL_RUNS_SHOWN });
72 const ids = runs.slice(0, 1).flatMap((r) => (r.actorId === null ? [] : [r.actorId]));
73 return tellStatus(db, repoId, issue, runs, getUsersByIds(db, ids), closingPull);
74 }
75
76 /**
77 * The pull whose merge closed a closed tell, from the `issue.closed` event the merge left (the web
78 * page reads the same record).
79 */
80 export function landedPull(db: Database, repoId: string, issue: Issue): Pull | undefined {
81 if (issue.state !== "closed") return undefined;
82 const row = db
83 .query<{ pull: unknown }, [string, number]>(
84 `SELECT json_extract(payload, '$.pull') AS pull
85 FROM event INDEXED BY event_repo_kind_number_at
86 WHERE repo_id = ?1 AND kind = 'issue.closed'
87 AND json_extract(payload, '$.by') = 'merge'
88 AND json_extract(payload, '$.number') = ?2
89 ORDER BY seq DESC LIMIT 1`,
90 )
91 .get(repoId, issue.number);
92 const n = Number(row?.pull);
93 return Number.isInteger(n) ? getPull(db, repoId, n) : undefined;
94 }
src/tui/screens/issue.ts +14 −2
@@ -35,6 +35,8 @@ import { THREAD_SAYS } from "../../actions/thread_words.ts";
3535 import { ISSUE_TEAMS_SAY, nameTeams } from "../../actions/issue_teams.ts";
3636 import { teamsOfIssue, TEAMS_MAX } from "../../core/issue_teams.ts";
3737 import { listTeams } from "../../core/teams.ts";
38 import { landedPull, readTellStatus } from "../../runs/tell_status.ts";
39 import { openPullsClosing } from "../../core/pulls.ts";
3840 import { costLine, issueCostFor, type IssueCost } from "../../core/issue_cost.ts";
3941 import { listRepoRuns, mayReadRuns } from "../../actions/runs.ts";
4042 import { readPlan } from "../../actions/run_plan.ts";
@@ -174,6 +176,7 @@ export function issueScreen(
174176 let cost: IssueCost | null = null;
175177 /** The cost-ledger line (#12114); "" when none or hidden from this viewer. */
176178 let ledgerLine = "";
179 let statusText = "";
177180 let shown: ReturnType<typeof headline>;
178181 /** Which issues this one waits for and holds up; a line when any. */
179182 let waits: Waits = { blockedBy: [], blocks: [] };
@@ -229,6 +232,15 @@ export function issueScreen(
229232 : issueCostFor(f.db, repo, issueRow, f.user);
230233 ledgerLine =
231234 repo === undefined || issueRow === undefined ? "" : costLineFor(f.db, repo, f.user, issueRow, "issue");
235 statusText =
236 repo === undefined || issueRow === undefined || !mayReadRuns(f.app, f.user, repo)
237 ? ""

Closed tells get no status here, while the page shows 'Landed in pull #N'. Both doors must say the same; the page's closing-pull lookup (shippedBy) should apply here too.

238 : readTellStatus(
239 f.db,
240 repo.id,
241 issueRow,
242 issueRow.state === "closed" ? landedPull(f.db, repo.id, issueRow) : openPullsClosing(f.db, repo.id).get(issueRow.number),
243 ).plain;
232244 crew.set(runs !== undefined && runs.ok ? runs.value : []);
233245 plan =
234246 repo === undefined || issueRow === undefined ? undefined : readPlan(f.app, repo, f.user, issueRow);
@@ -631,7 +643,7 @@ export function issueScreen(
631643 const planH = planRows.length === 0 ? 0 : Math.min(planRows.length, CREW_ROWS + 2) + 2;
632644 const waitsLine = waitsParts(waits);
633645 const headH = waitsLine.length === 0 ? 3 : 4;
634 const costH = cost === null && ledgerLine === "" ? 0 : 1;
646 const costH = cost === null && ledgerLine === "" && statusText === "" ? 0 : 1;
635647 const [strip, head, waitRow, crewRow, costRow, planRow, body, box] = split(area, "v", [
636648 len(whereRows(src)),
637649 len(headH),
@@ -733,7 +745,7 @@ export function issueScreen(
733745 }
734746
735747 if (costH > 0 && costRow!.h > 0)
736 s.text(costRow!.x, costRow!.y, truncate([cost === null ? "" : costLine(cost), ledgerLine].filter((p) => p !== "").join(" · "), costRow!.w), style(c.fg, c.bg), costRow!.x + costRow!.w);
748 s.text(costRow!.x, costRow!.y, truncate([statusText, cost === null ? "" : costLine(cost), ledgerLine].filter((p) => p !== "").join(" · "), costRow!.w), style(c.fg, c.bg), costRow!.x + costRow!.w);
737749
738750 if (planH > 0 && plan !== undefined) {
739751 const inner = card(s, planRow!, c, { title: planTitle(plan, shown) });
src/web/studio/tell.ts +34 −11
@@ -14,6 +14,7 @@ import { notePhase, takeSessionTime } from "../../core/route_timing.ts";
1414 import { cardPath } from "../og/path.ts";
1515 import { mayEditIssue } from "../../actions/issues.ts";
1616 import { marksByName } from "../../core/marks.ts";
17 import { TELL_RUNS_SHOWN, tellStatus } from "../../runs/tell_status.ts";
1718 import { threadNote } from "../../crew/direct.ts";
1819 import { alreadyDone } from "../../core/done_on_main.ts";
1920 import { appsRuntime } from "../../apps/runtime.ts";
@@ -334,20 +335,13 @@ async function tellRuns(
334335 wordCtx: WordCtx,
335336 repo: Repo,
336337 issue: Issue,
338 runs: readonly Run[],
339 actors: ReadonlyMap<string, { username: string }>,
337340 ): Promise<Html | null> {
338341 if (!runsOpenTo(wordCtx, repo)) return null;
339 const runs = listRuns(wordCtx.db, repo.id, {
340 kind: "agent",
341 issueId: issue.id,
342 limit: 10,
343 });
344342 const cost = issueCostFor(wordCtx.db, repo, issue, wordCtx.viewer);
345343 if (runs.length === 0 && cost === null) return null;
346344 const base = repoBase(repo);
347 const actors = getUsersByIds(
348 wordCtx.db,
349 runs.map((r) => r.actorId).filter((id): id is string => id !== null),
350 );
351345 const rows = await Promise.all(
352346 runs.map(async (r) => {
353347 const who =
@@ -488,12 +482,40 @@ async function studioTell(
488482 </form>`,
489483 { extra: "mt", tone: "success" },
490484 );
485 // One read of the runs and who ran them, shared by the runs card and the status line.
486 const mayRead = runsOpenTo(wordCtx, repo);
487 const runList = mayRead
488 ? listRuns(db, repo.id, { kind: "agent", issueId: issue.id, limit: TELL_RUNS_SHOWN })
489 : [];
490 const actors = getUsersByIds(
491 db,
492 runList.map((r) => r.actorId).filter((id): id is string => id !== null),
493 );
491494 const [wordInfo, runsCard, closingCard] = await Promise.all([
492495 direction ? undefined : tellWord(wordCtx, repo, issue, closingPull),
493 tellRuns(wordCtx, repo, issue),
496 tellRuns(wordCtx, repo, issue, runList, actors),
494497 closingPull ? tellClosingPull(ctx, wordCtx, repo, closingPull) : undefined,
495498 ]);
496499
500 // Where the thought went, from the runs and pulls already stored.
outdated

Gate (runsOpenTo) has no test that a non-reader sees nothing. Add one for the private-app case.

501 const status =
502 direction || !mayRead
503 ? undefined
504 : tellStatus(
505 db,
506 repo.id,
507 issue,
508 runList,
509 actors,
510 issue.state === "closed" ? shippedBy(wordCtx, repo, issue) : closingPull,
511 );
512 const statusLine =
513 status === undefined
514 ? null
outdated

Hand-built link by splitting the text on '#N' (twice). Fragile; have tellStatus return text parts (before, pull, after) and render them directly. The run-count suffix is also built in both places (plain and here).

515 : html`<p class="small" data-tell-status>${status.before}${
516 status.pull === null ? null : html`<a href="${changeHref(base, status.pull)}">#${status.pull}</a>`
517 }${status.after}${status.count}</p>`;
518
497519 const marks = marksByName(db, [issue.authorName, issue.assigneeName ?? ""]);
498520 const head = html`<div class="page-head">
499521 <h1>${issue.title} <span class="num">#${issue.number}</span></h1>
@@ -545,7 +567,8 @@ async function studioTell(
545567 >`
546568 : null}
547569 </div>
outdated

Stray </div>: the head is closed on the line above, so this closes a parent that is not yours. Balance the tags.

548 </div>`;
570 </div>
571 ${statusLine}`;
549572
550573 const threadStart = performance.now();
551574 const talk = conversation(ctx, repo, issue, {
test/pages-budget.test.ts +1 −1
@@ -55,7 +55,7 @@ const HEAVIER: Record<string, { statements?: number; git?: number }> = {
5555 "/:owner/:name/pulls/:number": { statements: 114 }, // +1: the desk hold on the pull, one read of the notes that link it (#12536); +1: whether a repository is the forge's own copy, one read of the source setting for the tell box (#12037); +1: the paused sentence, one read of a queued paused run on the pull (#12010); +1: the header Talk count (#10327); +1: the landing line (#10860); +1: whether a reviewer is seated, read only when Require review is off and the pull would otherwise wait on one; the page loads no crew besides (#11666)
5656 "/api/v1/asks": { statements: 61 }, // +1: the stopped apps someone asked for, one read of the viewer's archived repositories (#12277)
5757 "/board": { statements: 72 }, // +1: the forge-copy read for the tell box (#12037); +1: the vitals read the database's growth (#12025); +6: the money line (#510) — one settings read, then the month's and the 30 days' meter, storage and ledger reads; constant in the number of apps
58 "/settings/capacity": { statements: 71 },
58 "/settings/capacity": { statements: 70 },
5959 };
6060
6161 /** Patterns with no fixture today: lower this as fixtures are added, never raise it silently. */
test/tell-status.test.ts added +244
@@ -0,0 +1,244 @@
1 /**
2 * A tell's page says what became of it (#13447): waiting, picked up by a
3 * named crew member, or landed with a pull link — from the run and pull rows,
4 * on the web page and in the terminal's issue screen.
5 */
6
7 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
8 import { mkdtemp, rm } from "node:fs/promises";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import { openIssue } from "../src/actions/issues.ts";
12 import { openPull } from "../src/actions/pulls.ts";
13 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
14 import { createApp as createAppRecord } from "../src/core/apps.ts";
15 import { createApp, type App } from "../src/app.ts";
16 import type { Issue } from "../src/core/issues.ts";
17 import { getRepoById, type Repo } from "../src/core/repos.ts";
18 import { createRun } from "../src/core/runs.ts";
19 import { createSession } from "../src/core/sessions.ts";
20 import { createUser, type User } from "../src/core/users.ts";
21 import { serve, type Servers } from "../src/http/server.ts";
22 import { readTellStatus } from "../src/runs/tell_status.ts";
23 import { createForgeApp } from "../src/tui/forge.ts";
24 import { issueScreen } from "../src/tui/screens/issue.ts";
25 import { local } from "../src/tui/screens/where.ts";
26 import { headlessTerminal } from "../src/tui/term/terminal.ts";
27 import { quietLogs } from "./helpers/globals.ts";
28 import { settleApp } from "./helpers/tui.ts";
29
30 quietLogs();
31
32 describe("what became of a tell", () => {
33 let dataDir = "";
34 let app: App;
35 let servers: Servers;
36 let alice: User;
37 let repo: Repo;
38 const cookie = () => `forge_session=${createSession(app.db, alice.id).token}`;
39 const tell = (title: string): Issue => {
40 const o = openIssue(app, alice, repo, { title });
41 if (!o.ok) throw new Error(o.error);
42 return o.value;
43 };
44 const run = (issue: Issue, state: string, branch = "") => {
45 const r = createRun(app.db, { repoId: repo.id, kind: "agent", issueId: issue.id, branch, actorId: alice.id });
46 app.db.query("UPDATE run SET state = ?1, actor_id = ?2 WHERE id = ?3").run(state, alice.id, r.id);
47 };
48 const line = async (issue: Issue, as: User = alice, name = "garden") => {
49 const html = await (
50 await fetch(`${servers.url}/alice/${name}/issues/${issue.number}`, {
51 headers: { cookie: `forge_session=${createSession(app.db, as.id).token}` },
52 })
53 ).text();
54 return /<p class="small" data-tell-status>([\s\S]*?)<\/p>/.exec(html)?.[1]?.replace(/<[^>]+>/g, "") ?? "";
55 };
56
57 beforeAll(async () => {
58 dataDir = await mkdtemp(join(tmpdir(), "forge-tell-status-"));
59 app = createApp({ dataDir, port: 0 });
60 servers = await serve(app);
61 const made = await createUser(app.db, {
62 origin: "seed",
63 trusted: true,
64 username: "alice",
65 email: "[email protected]",
66 password: "a-good-passphrase",
67 adminIfFirst: true,
68 });
69 if (!made.ok) throw new Error(made.error);
70 alice = made.value;
71 const r = await createRepo(app, alice, { name: "garden", visibility: "private" });
72 if (!r.ok) throw new Error(String(r.error));
73 const seeded = await commitToBranch(app, alice, r.value, {
74 message: "seed",
75 files: [{ path: "README.md", content: "# garden\n" }],
76 });
77 if (!seeded.ok) throw new Error(JSON.stringify(seeded.error));
78 repo = getRepoById(app.db, r.value.id)!;
79 }, 30_000);
80
81 afterAll(async () => {
82 await servers.stop();
83 app.close();
84 await rm(dataDir, { recursive: true, force: true });
85 });
86
87 test("a tell nobody has picked up is waiting", async () => {
88 const issue = tell("Water the beds");
89 expect(readTellStatus(app.db, repo.id, issue).plain).toBe("Waiting: nobody has picked it up yet");
90 expect(await line(issue)).toBe("Waiting: nobody has picked it up yet");
91 });
92
93 test("a running run names who picked it up, and several runs are counted", async () => {
94 const issue = tell("Prune the roses");
95 run(issue, "failed");
96 run(issue, "running");
97 expect(await line(issue)).toBe("Picked up by alice · 2 runs");
98 });
99
100 test("a pull the run produced is linked, and merged reads landed", async () => {
101 const issue = tell("Fence the plot");
102 const c = await commitToBranch(app, alice, repo, {
103 branch: "fence",
104 base: "main",
105 message: "fence",
106 files: [{ path: "fence.md", content: "x\n" }],
107 });
108 if (!c.ok) throw new Error(JSON.stringify(c.error));
109 const p = await openPull(app, alice, repo, {
110 title: "Fence",
111 body: `Closes #${issue.number}`,
112 baseBranch: "main",
113 headBranch: "fence",
114 });
115 if (!p.ok) throw new Error(String(p.error));
116 run(issue, "ok", "fence");
117 expect(await line(issue)).toBe(`Picked up by alice; pull #${p.value.number} is open`);
118 const html = await (
119 await fetch(`${servers.url}/alice/garden/issues/${issue.number}`, { headers: { cookie: cookie() } })
120 ).text();
121 expect(html).toContain(`>#${p.value.number}</a>`);
122 app.db.query("UPDATE pull SET merged_at = ?2 WHERE issue_id = ?1").run(p.value.id, new Date().toISOString());
123 expect(readTellStatus(app.db, repo.id, issue).plain).toBe(`Landed in pull #${p.value.number}`);
124 });
125
126 const screen = async (who: User, r: Repo, issue: Issue): Promise<string> => {
127 const terminal = headlessTerminal(140, 40);
128 const { app: tui, session } = createForgeApp(
129 app,
130 { sshUsername: "t", remoteAddress: "127.0.0.1", user: who },
131 { terminal, exitHooks: false },
132 );
133 tui.start();
134 await settleApp(tui);
135 tui.push(issueScreen(session, tui.ctx, local(session, r), issue.number));
136 await settleApp(tui);
137 const text = tui.screen.toText();
138 tui.stop();
139 return text;
140 };
141
142 /** A pull on its own branch that closes `issue`. */
143 const pullFor = async (issue: Issue, branch: string) => {
144 const c = await commitToBranch(app, alice, repo, {
145 branch,
146 base: "main",
147 message: branch,
148 files: [{ path: `${branch}.md`, content: "x\n" }],
149 });
150 if (!c.ok) throw new Error(JSON.stringify(c.error));
151 const p = await openPull(app, alice, repo, {
152 title: branch,
153 body: `Closes #${issue.number}`,
154 baseBranch: "main",
155 headBranch: branch,
156 });
157 if (!p.ok) throw new Error(String(p.error));
158 return p.value;
159 };
160
161 test("the terminal's issue screen says the same line", async () => {
162 const issue = tell("Mulch");
163 run(issue, "running");
164 expect(await screen(alice, repo, issue)).toContain("Picked up by alice");
165 });
166
167 test("a closed pull is said so, on the page and in the terminal", async () => {
168 const issue = tell("Trellis");
169 const p = await pullFor(issue, "trellis");
170 run(issue, "ok", "trellis");
171 app.db.query("UPDATE issue SET state = 'closed' WHERE id = ?1").run(p.id);
172 expect(await line(issue)).toBe(`Pull #${p.number} was closed`);
173 expect(await screen(alice, repo, issue)).toContain(`Pull #${p.number} was closed`);
174 });
175
176 test("a landed tell, closed by the merge, says so on the page and in the terminal", async () => {
177 const issue = tell("Gate");
178 const p = await pullFor(issue, "gate");
179 app.db.query("UPDATE pull SET merged_at = ?2 WHERE issue_id = ?1").run(p.id, new Date().toISOString());
180 app.db.query("UPDATE issue SET state = 'closed' WHERE id = ?1").run(issue.id);
181 app.bus.append({
182 kind: "issue.closed",
183 repoId: repo.id,
184 actorId: alice.id,
185 payload: { number: issue.number, by: "merge", pull: p.number },
186 });
187 expect(await line(issue)).toBe(`Landed in pull #${p.number}`);
188 expect(await screen(alice, repo, issue)).toContain(`Landed in pull #${p.number}`);
189 });
190
191 test("a tell closed by hand with no run says it was closed without the crew", async () => {
192 const issue = tell("Never mind");
193 app.db.query("UPDATE issue SET state = 'closed' WHERE id = ?1").run(issue.id);
194 expect(await line(issue)).toBe("Closed without the crew");
195 expect(await screen(alice, repo, issue)).toContain("Closed without the crew");
196 });
197
198 test("a reader who may not enter a private app sees no status line, on the page or in the terminal", async () => {
199 const made = await createUser(app.db, {
200 origin: "seed",
201 trusted: true,
202 username: "bob",
203 email: "[email protected]",
204 password: "a-good-passphrase",
205 });
206 if (!made.ok) throw new Error(made.error);
207 const bob = made.value;
208 const r = await createRepo(app, alice, { name: "vault", visibility: "public" });
209 if (!r.ok) throw new Error(String(r.error));
210 const seeded = await commitToBranch(app, alice, r.value, {
211 message: "seed",
212 files: [{ path: "README.md", content: "# vault\n" }],
213 });
214 if (!seeded.ok) throw new Error(JSON.stringify(seeded.error));
215 createAppRecord(app.db, { repoId: r.value.id, slug: "vault", access: "private" });
216 const vault = getRepoById(app.db, r.value.id)!;
217 const o = openIssue(app, alice, vault, { title: "Seal it" });
218 if (!o.ok) throw new Error(o.error);
219 const issue = o.value;
220 // The owner sees it; the reader who may only read the repository does not.
221 expect(await line(issue, alice, "vault")).toBe("Waiting: nobody has picked it up yet");
222 expect(await screen(alice, vault, issue)).toContain("Waiting: nobody has picked it up yet");
223 const page = await (
224 await fetch(`${servers.url}/alice/vault/issues/${issue.number}`, {
225 headers: { cookie: `forge_session=${createSession(app.db, bob.id).token}` },
226 })
227 ).text();
228 expect(page).toContain("Seal it");
229 expect(page).not.toContain("data-tell-status");
230 expect(await screen(bob, vault, issue)).not.toContain("Waiting: nobody");
231 // A guest with no session sees none either.
232 const guest = await (await fetch(`${servers.url}/alice/vault/issues/${issue.number}`)).text();
233 expect(guest).not.toContain("data-tell-status");
234 });
235
236 test("the markup around the line is balanced", async () => {
237 const issue = tell("Balance");
238 const html = await (
239 await fetch(`${servers.url}/alice/garden/issues/${issue.number}`, { headers: { cookie: cookie() } })
240 ).text();
241 const head = /<div class="page-head">[\s\S]*?data-tell-status>/.exec(html)![0];
242 expect((head.match(/<div\b/g) ?? []).length).toBe((head.match(/<\/div>/g) ?? []).length);
243 });
244 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs