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

A tell can be taken back within a minute from the page it was sent on #14116

Merged opened this

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

Merged

torque/forge:torque/14081-a-tell-can-be-taken-back-within-a-minute → main 7 commits fork 2 threads · 2 unresolved

  • Merged. torque/14081-a-tell-can-be-taken-back-within-a-minute was merged into main as e7b06d6.

Review

Sign in to review this change.
10 files changed +395 −1
docs/features/README.md +1
@@ -107,6 +107,7 @@ Read with the guide page [Your first app in five minutes](../guide-first-app.md)
107107
108108 Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
109109
110 - [Take a tell back within a minute, while unread](tell-undo.md)
110111 - [Dictate into the tell box](speak.md)
111112 - [Send a tell with Ctrl or Cmd+Enter](composer-send-key.md)
112113 - [A bug closes with a reason](bug-close.md)
docs/features/tell-undo.md added +13
@@ -0,0 +1,13 @@
1 # Take a tell back
2
3 A tell you sent can be taken back for 60 seconds, as long as nobody has read it. Nobody has read it when no agent run has begun on it and no one has commented. A run still waiting in the queue is cancelled with it.
4
5 ## On the page
6
7 After you tell the crew from an app's toolbar, the receipt page shows **Undo**. Press it. The issue closes as dropped and the receipt says "Taken back. Nothing was started." If the minute has passed or the crew has read it, the answer is "Too late", and the tell stands.
8
9 ## In the terminal
10
11 Open the palette and choose **Take a tell back**. The screen lists your tells that can still be taken back, across every app. Move with `j` and `k`, press `u` to take the one under the cursor back. The page and the terminal use the same rule and write the same receipt (an `issue.tell_undone` event), so a web page open on the app updates at once.
12
13 Only the person who sent the tell can take it back.
src/actions/tell_undo.ts added +89
@@ -0,0 +1,89 @@
1 /**

Both doors: this action has no src/tui/ screen and no docs/features/tell-undo.md. Add both; the No door: excuse does not meet the bar.

2 * Taking a tell back: for 60 seconds after it was sent, the person who said
3 * it may withdraw it while nobody has read it. Unread means no agent run has
4 * started on it and nobody has commented; a run still queued is cancelled
5 * with it. The withdrawal closes the issue as dropped and writes a receipt
6 * (the `issue.tell_undone` event), so nothing vanishes without a trace.
7 */
8
9 import type { App } from "../app.ts";
10 import { countComments, getIssue, type Issue } from "../core/issues.ts";
11 import { getRepoById, type Repo } from "../core/repos.ts";
12 import { cancelRun } from "../core/runs.ts";
13 import type { User } from "../core/users.ts";
14 import { err, ok, type Result } from "../kernel/result.ts";
15 import { assignIssue, setIssueState } from "./issues.ts";
16
17 /** How long after sending a tell may be taken back, in milliseconds. */
18 export const TELL_UNDO_MS = 60_000;
19
20 /** What the receipt says once a tell is withdrawn. */
21 export const TAKEN_BACK_WORDS = "Taken back. Nothing was started.";
22
23 /** Why a tell cannot be taken back: the minute passed, or someone has read it. */
24 export const TOO_LATE_WORDS = "Too late to take that back: it was sent over a minute ago or the crew has read it.";
25
26 export type UndoError = "not_found" | "unauthorized" | "forbidden" | "too_late";
27
28 /** Whether an issue is still inside its undo minute and unread (no run begun, no comment). */
29 export function tellUndoable(app: App, repo: Repo, issue: Issue, now = Date.now()): boolean {
30 if (issue.kind !== "issue" || issue.state !== "open") return false;
31 const age = now - Date.parse(issue.createdAt);
32 if (!(age >= 0 && age < TELL_UNDO_MS)) return false;
33 if (countComments(app.db, issue.id) > 0) return false;
34 // One existence query, not a page of runs: a tell with many runs is still judged on all of them.
35 const begun = app.db
36 .query<{ n: number }, [string]>(
37 "SELECT 1 AS n FROM run WHERE issue_id = ?1 AND kind = 'agent' AND state NOT IN ('queued','cancelled') LIMIT 1",
38 )
39 .get(issue.id);
40 return begun === null;
41 }
42
43 /**
44 * The signed-in person's tells that can still be taken back, newest first, across every repository.
45 */
46 export function undoableTells(app: App, user: User, now = Date.now()): { repo: Repo; issue: Issue }[] {
47 const since = new Date(now - TELL_UNDO_MS).toISOString();
48 const rows = app.db
49 .query<{ repo_id: string; number: number }, [string, string]>(
50 "SELECT repo_id, number FROM issue WHERE author_id = ?1 AND kind = 'issue' AND state = 'open' AND created_at > ?2 ORDER BY created_at DESC LIMIT 20",
51 )
52 .all(user.id, since);
53 const out: { repo: Repo; issue: Issue }[] = [];
54 for (const row of rows) {
55 const repo = getRepoById(app.db, row.repo_id);
56 const issue = repo === undefined ? undefined : getIssue(app.db, repo.id, row.number);
57 if (repo !== undefined && issue !== undefined && tellUndoable(app, repo, issue, now)) out.push({ repo, issue });
58 }
59 return out;
60 }
61
62 /** Withdraw the tell `number`: its author only, within the minute, while unread. */
63 export function undoTell(
64 app: App,
65 actor: User | undefined,
66 repo: Repo,
67 number: number,
68 now = Date.now(),
69 ): Result<Issue, UndoError> {
70 if (actor === undefined) return err("unauthorized");
71 const issue = getIssue(app.db, repo.id, number);
72 if (issue === undefined) return err("not_found");
73 if (issue.authorId !== actor.id) return err("forbidden");
74 if (!tellUndoable(app, repo, issue, now)) return err("too_late");
75 const queued = app.db
76 .query<{ id: string }, [string]>("SELECT id FROM run WHERE issue_id = ?1 AND kind = 'agent' AND state = 'queued'")
77 .all(issue.id);
78 for (const r of queued) cancelRun(app.db, r.id, "the tell was taken back");
79 assignIssue(app, actor, repo, issue, null);
80 const closed = setIssueState(app, actor, repo, issue, "closed", { reason: "dropped" });
81 if (!closed.ok) return err("too_late");
82 app.bus.append({
83 kind: "issue.tell_undone",
84 repoId: repo.id,
85 actorId: actor.id,
86 payload: { number: issue.number },
87 });
88 return ok(closed.value);
89 }
src/core/event_audience.ts +1
@@ -66,6 +66,7 @@ const READER_KINDS: ReadonlySet<string> = new Set([
6666 "issue.ranked",
6767 "week.retro",
6868 "issue.closed",
69 "issue.tell_undone",
6970 "issue.gate_reviewed",
7071 "issue.snoozed",
7172 "issue.snooze_ended",
src/http/server.ts +2
@@ -315,6 +315,7 @@ import {
315315 releaseSubmit,
316316 composerSubmit,
317317 tellSubmit,
318 tellUndoSubmit,
318319 } from "../web/studio/actions.ts";
319320 import { shareTellPage } from "../web/studio/share_tell.ts";
320321 import { forgeReady } from "../web/pages/forge-ready.ts";
@@ -1410,6 +1411,7 @@ export function buildRouter(): Router<Handler> {
14101411 // change — take it back.
14111412 router.add("GET", "/:owner/:name/tell", tellHerePage);
14121413 router.add("POST", "/:owner/:name/tell", tellSubmit);
1414 router.add("POST", "/:owner/:name/tell/undo", tellUndoSubmit);
14131415 // The home's composer without a script: a tell to the app it names (#599).
14141416 router.add("POST", "/tell", composerSubmit);
14151417 // Where the phone share sheet lands: the shared words in a form, filed only on Send.
src/tui/screens/entries.ts +2
@@ -72,6 +72,7 @@ import { entry as maintenanceWeek } from "./maintenanceweek.ts";
7272 import { entry as offsite } from "./offsite.ts";
7373 import { entry as waiting } from "./waiting.ts";
7474 import { entry as waitingForMe } from "./waiting_for_me.ts";
75 import { entry as tellUndo } from "./tell_undo.ts";
7576 import { entry as slowPagesEntry } from "./slowpages.ts";
7677 import { entry as maintenance } from "./maintenance.ts";
7778 import { entry as maintainRuns } from "./maintainruns.ts";
@@ -148,6 +149,7 @@ export const ENTRIES: readonly PaletteEntry[] = [
148149 offsite,
149150 waiting,
150151 waitingForMe,
152 tellUndo,
151153 slowPagesEntry,
152154 telemetry,
153155 resilience,
src/tui/screens/tell_undo.ts added +59
@@ -0,0 +1,59 @@
1 /**
2 * Taking a tell back, in the terminal: the signed-in person's tells that are
3 * still inside their minute and unread, from the same `undoableTells` and
4 * `undoTell` the page's Undo uses, so the gates and the receipt are the same.
5 * `u` takes back the one under the cursor. The write is an event on the bus
6 * (`issue.closed`, `issue.tell_undone`), so an open web page redraws.
7 */
8
9 import { TAKEN_BACK_WORDS, TOO_LATE_WORDS, undoableTells, undoTell } from "../../actions/tell_undo.ts";
10 import type { Ctx, Screen } from "../app/app.ts";
11 import { binding } from "../app/keys.ts";
12 import type { Session } from "../session.ts";
13 import { style } from "../term/style.ts";
14 import { truncate } from "../term/width.ts";
15 import { fill, len, split } from "../ui/layout.ts";
16 import { ListState, drawList, live, type ListRow } from "./common.ts";
17 import type { PaletteEntry } from "./entries.ts";
18
19 const mayTell = (session: Session): boolean => session.user !== undefined && session.user.kind !== "agent";
20
21 export function tellUndoScreen(f: Session, ctx: Ctx): Screen {
22 const state = new ListState();
23 const rowsNow = () => (f.user === undefined ? [] : undoableTells(f.app, f.user));
24 return {
25 title: "Take a tell back",
26 keys: [binding(["j", "k"], "move cursor"), binding(["u"], "take it back")],
27 async load(signal) {
28 live(f, signal, { where: (e) => e.kind === "issue.opened" || e.kind === "issue.closed" || e.kind === "issue.tell_undone" }, () => ctx.invalidate());
29 },
30 render(area, s) {
31 const c = ctx.theme.c;
32 const all = rowsNow();
33 const [head, list] = split(area, "v", [len(1), fill(1)]);
34 s.text(head!.x, head!.y, truncate(all.length === 0 ? "No tell of yours can be taken back." : "u takes back the tell under the cursor.", head!.w), style(c.mutedFg, c.bg), head!.x + head!.w);
35 const lines: ListRow[] = all.map((r) => ({ title: `${r.repo.ownerName}/${r.repo.name}#${String(r.issue.number)} ${r.issue.title}` }));
36 drawList(s, list!, c, state, lines);
37 },
38 key(e) {
39 const all = rowsNow();
40 if (state.key(e, all.length)) return true;
41 if (e.ctrl || e.alt || e.key !== "u") return false;
42 const at = all[state.index];
43 if (at === undefined) return true;
44 const done = undoTell(f.app, f.user, at.repo, at.issue.number);
45 ctx.toast(done.ok ? TAKEN_BACK_WORDS : done.error === "too_late" ? TOO_LATE_WORDS : "That tell cannot be taken back.", done.ok ? undefined : "danger");
46 ctx.invalidate();
47 return true;
48 },
49 };
50 }
51
52 export const entry: PaletteEntry = {
53 id: "tell-undo",
54 title: "Take a tell back",
55 hint: "a tell you sent in the last minute, while nobody has read it",
56 after: ["waiting-for-me"],
57 offered: mayTell,
58 run: (session, ctx) => ctx.push(tellUndoScreen(session, ctx)),
59 };
src/web/studio/actions.ts +35 −1
@@ -16,6 +16,7 @@ import { holdPull, releasePull } from "../../actions/holds.ts";
1616 import { addComment } from "../../actions/issues.ts";
1717 import { parseFrom } from "../../actions/tell_from.ts";
1818 import { SENT_WORDS, tell, toldWords, TOO_LONG_WORDS } from "../../actions/tell.ts";
19 import { TAKEN_BACK_WORDS, TOO_LATE_WORDS, tellUndoable, undoTell } from "../../actions/tell_undo.ts";
1920 import { contextNote, parseContext } from "../../actions/tell_context.ts";
2021 import { refusalWords } from "../../actions/tell_answer.ts";
2122 import { NOT_TOLD_FROM_WORDS, SAY_SOMETHING_WORDS } from "../../actions/tell_words.ts";
@@ -198,7 +199,40 @@ async function tellFromPage(ctx: Ctx, repo: Repo, form: Form): Promise<Response>
198199 crumbs: crumbsFor(repo),
199200 body: html`${pageHead("Issue opened")}
200201 <p>${toldWords(told.value)}</p>
201 <p><a href="${issue}" data-receipt>See issue #${String(told.value.issue.number)}</a></p>`,
202 <p><a href="${issue}" data-receipt>See issue #${String(told.value.issue.number)}</a></p>
203 ${
204 tellUndoable(ctx.app, repo, told.value.issue)
205 ? html`<form method="post" action="${repoBase(repo)}/tell/undo" data-undo>
206 <input type="hidden" name="number" value="${String(told.value.issue.number)}" />
207 <button type="submit">Undo</button>
208 </form>`
outdated

Principle 1 and 8: this hint explains the button a second time and goes false once the minute passes while the page stays open. Drop it or say it in one plain sentence.

209 : ""
210 }`,
211 });
212 }
213
214 /** POST /:owner/:name/tell/undo { number } — take a tell back within its minute, if unread. */
215 export async function tellUndoSubmit(ctx: Ctx): Promise<Response> {
216 const repo = loadRepo(ctx);
217 if (!repo) return notFoundPage(ctx);
218 if (!ctx.auth.user) return signInFirst(ctx);
219 const form = await readForm(ctx, "rw");
220 if (form instanceof Response) return form;
221 const raw = field(form, "number");
222 const number = /^\d{1,9}$/.test(raw) ? Number(raw) : -1;
223 const back = repoBase(repo);
224 const undone = undoTell(ctx.app, ctx.auth.user, repo, number);
225 if (!undone.ok)
226 return flashTo(ctx, back, {
227 tone: "danger",
228 message: undone.error === "too_late" ? TOO_LATE_WORDS : "That tell cannot be taken back.",
229 });
230 return page({
231 ctx,
232 title: `Taken back · ${repo.name}`,
233 crumbs: crumbsFor(repo),
234 body: html`${pageHead("Taken back")}
235 <p data-receipt>${TAKEN_BACK_WORDS} Issue #${String(undone.value.number)} is closed as dropped.</p>`,
202236 });
203237 }
204238
test/palette-roster.test.ts +2
@@ -132,6 +132,7 @@ test("a site-admin person is offered the whole roster", () => {
132132 ["refused-asks", "Refused first asks", "the last 20 first asks turned away"],
133133 ["disks", "Disks", "machines' disk readings: 30-day write rate and projected rated-TBW date"],
134134 ["telemetry", "Telemetry", "which agents may read flow and system; enter flips the grant"],
135 ["tell-undo", "Take a tell back", "a tell you sent in the last minute, while nobody has read it"],
135136 ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"],
136137 ["stalls", "Main-thread stalls", "the last hour's stall ms by route"],
137138 ["footing", "What the forge stands on", "each piece on another machine, in the order it would break the forge"],
@@ -411,6 +412,7 @@ test("a member person is offered the signed-in roster without the admin entries"
411412 ["bugs", "Bugs", "open bugs and the bug clock"],
412413 ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"],
413414 ["waiting-for-me", "Waiting for me", "issues and pulls that wait for you"],
415 ["tell-undo", "Take a tell back", "a tell you sent in the last minute, while nobody has read it"],
414416 ["audit", "Who can do what", "each app's doors from its contract.json: yes, own or no"],
415417 ["archived", "Archived repositories", "put away, not gone: open one or restore it"],
416418 ["apps-crew", "What the crew is doing", "one plain sentence per app: who is on what"],
test/tell-undo.test.ts added +191
@@ -0,0 +1,191 @@
1 /**
2 * A tell can be taken back for 60 seconds, while unread: the author's Undo
3 * closes it and writes a receipt; after the minute, once the crew has begun
4 * on it or commented, or for anyone else, it cannot, and the link is gone.
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 { createApp, type App } from "../src/app.ts";
12 import { newApp } from "../src/actions/apps.ts";
13 import { addComment } from "../src/actions/issues.ts";
14 import { tell } from "../src/actions/tell.ts";
15 import { TAKEN_BACK_WORDS, TELL_UNDO_MS, tellUndoable, undoableTells, undoTell } from "../src/actions/tell_undo.ts";
16 import { getIssue, listIssues } from "../src/core/issues.ts";
17 import type { Repo } from "../src/core/repos.ts";
18 import { cancelRun, claimRun, createRun } from "../src/core/runs.ts";
19 import { createSession } from "../src/core/sessions.ts";
20 import { createToken } from "../src/core/tokens.ts";
21 import { createUser, type User } from "../src/core/users.ts";
22 import { serve, type Servers } from "../src/http/server.ts";
23 import { tellUndoScreen } from "../src/tui/screens/tell_undo.ts";
24 import type { Ctx } from "../src/tui/app/app.ts";
25 import type { KeyEvent } from "../src/tui/term/input.ts";
26 import type { Session } from "../src/tui/session.ts";
27 import { quietLogs } from "./helpers/globals.ts";
28 import { proveAll } from "./helpers/verified.ts";
29
30 quietLogs();
31
32 const press = (key: string): KeyEvent => ({ type: "key", key, ctrl: false, alt: false, shift: false });
33
34 describe("taking a tell back", () => {
35 let dataDir: string;
36 let app: App;
37 let servers: Servers;
38 let alice: User;
39 let bob: User;
40 let repo: Repo;
41 let auth: Record<string, string>;
42
43 beforeAll(async () => {
44 dataDir = await mkdtemp(join(tmpdir(), "forge-tellundo-"));
45 app = createApp({ dataDir, port: 0, host: "forge.test" });
46 servers = await serve(app);
47 const mk = async (username: string, first = false) => {
48 const u = await createUser(app.db, {
49 origin: "seed",
50 trusted: true,
51 username,
52 email: `${username}@forge.local`,
53 password: "a-good-passphrase",
54 adminIfFirst: first,
55 });
56 if (!u.ok) throw new Error(u.error);
57 return u.value;
58 };
59 alice = await mk("alice", true);
60 bob = await mk("bob");
61 proveAll(app);
62 const made = await newApp(app, alice, { name: "notes", description: "x", visibility: "public" });
63 if (!made.ok) throw new Error(String(made.error));
64 repo = made.value.repo;
65 auth = { authorization: `Bearer ${createToken(app.db, alice.id, "t", "rw").token}` };
66 }, 120_000);
67
68 afterAll(async () => {
69 servers.stop();
70 app.close();
71 await rm(dataDir, { recursive: true, force: true });
72 });
73
74 const say = async (text: string) => {
75 const t = await tell(app, alice, repo, text);
76 if (!t.ok) throw new Error(t.error);
77 return t.value.issue;
78 };
79
80 test("within the minute an unread tell is taken back and a receipt is written", async () => {
81 const issue = await say("Make it purple");
82 const soon = Date.parse(issue.createdAt) + 30_000;
83 expect(tellUndoable(app, repo, issue, soon)).toBe(true);
84 const undone = undoTell(app, alice, repo, issue.number, soon);
85 expect(undone.ok).toBe(true);
86 const after = getIssue(app.db, repo.id, issue.number)!;
87 expect(after.state).toBe("closed");
88 expect(after.closeReason).toBe("dropped");
89 const receipt = app.db
90 .query<{ n: number }, [string]>("SELECT COUNT(*) AS n FROM event WHERE repo_id = ?1 AND kind = 'issue.tell_undone'")
91 .get(repo.id);
92 expect(receipt?.n).toBe(1);
93 // Taken back once: a second try finds nothing open to take back.
94 expect(undoTell(app, alice, repo, issue.number, soon)).toEqual({ ok: false, error: "too_late" });
95 });
96
97 test("after the minute the tell stands", async () => {
98 const issue = await say("Make it green");
99 const late = Date.parse(issue.createdAt) + TELL_UNDO_MS + 1;
100 expect(tellUndoable(app, repo, issue, late)).toBe(false);
101 expect(undoTell(app, alice, repo, issue.number, late)).toEqual({ ok: false, error: "too_late" });
102 expect(getIssue(app.db, repo.id, issue.number)!.state).toBe("open");
103 });
104
105 test("once read, by a run begun or a comment, it cannot be taken back", async () => {
106 const begun = await say("Make it blue");
107 const run = createRun(app.db, { repoId: repo.id, kind: "agent", issueId: begun.id, branch: "b", reason: "assigned" });
108 claimRun(app.db, run.id);
109 const soon = Date.parse(begun.createdAt) + 10_000;
110 expect(tellUndoable(app, repo, begun, soon)).toBe(false);
111 expect(undoTell(app, alice, repo, begun.number, soon).ok).toBe(false);
112
113 const talked = await say("Make it red");
114 addComment(app, bob, repo, talked, "what do you mean?");
115 expect(tellUndoable(app, repo, talked, Date.parse(talked.createdAt) + 10_000)).toBe(false);
116 });
117
118 test("only the author may take it back", async () => {
119 const issue = await say("Make it grey");
120 const soon = Date.parse(issue.createdAt) + 5_000;
121 expect(undoTell(app, bob, repo, issue.number, soon)).toEqual({ ok: false, error: "forbidden" });
122 expect(undoTell(app, undefined, repo, issue.number, soon)).toEqual({ ok: false, error: "unauthorized" });
123 });
124
125 test("the receipt page offers Undo, and Undo takes the tell back", async () => {
126 const post = (path: string, fields: Record<string, string>) =>
127 fetch(`${servers.url}/alice/notes${path}`, { method: "POST", headers: auth, body: new URLSearchParams(fields), redirect: "manual" });
128 const sent = await post("/tell", { text: "Make it gold", page: "https://notes.apps.test/a" });
129 const body = await sent.text();
130 expect(body).toContain("data-undo");
131 expect(body).toContain("/alice/notes/tell/undo");
132 const issue = listIssues(app.db, repo.id, {}).find((i) => i.title.startsWith("Make it gold"))!;
133 const undone = await post("/tell/undo", { number: String(issue.number) });
134 expect(await undone.text()).toContain("Taken back");
135 expect(getIssue(app.db, repo.id, issue.number)!.state).toBe("closed");
136 });
137
138 test("a run begun is read however many runs the tell has", async () => {
139 const issue = await say("Make it teal");
140 for (let i = 0; i < 25; i++)
141 cancelRun(app.db, createRun(app.db, { repoId: repo.id, kind: "agent", issueId: issue.id, branch: "b", reason: "assigned" }).id, "x");
142 const last = createRun(app.db, { repoId: repo.id, kind: "agent", issueId: issue.id, branch: "b", reason: "assigned" });
143 claimRun(app.db, last.id);
144 expect(tellUndoable(app, repo, issue, Date.parse(issue.createdAt) + 1_000)).toBe(false);
145 });
146
147 test("the receipt page of a read tell renders no Undo", async () => {
148 const post = (path: string, fields: Record<string, string>) =>
149 fetch(`${servers.url}/alice/notes${path}`, { method: "POST", headers: auth, body: new URLSearchParams(fields), redirect: "manual" });
150 const sent = await post("/tell", { text: "Make it pink", page: "https://notes.apps.test/a" });
151 expect(await sent.text()).toContain("data-undo");
152 const issue = listIssues(app.db, repo.id, {}).find((i) => i.title.startsWith("Make it pink"))!;
153 addComment(app, bob, repo, issue, "on it");
154 const again = await post("/tell/undo", { number: String(issue.number) });
155 expect(await again.text()).not.toContain("data-undo");
156 expect(getIssue(app.db, repo.id, issue.number)!.state).toBe("open");
157 });
158
159 test("a cross-origin POST to /tell/undo is refused and takes nothing back", async () => {
160 const issue = await say("Make it brown");
161 const cookie = `forge_session=${createSession(app.db, alice.id).token}`;
162 const res = await fetch(`${servers.url}/alice/notes/tell/undo`, {
163 method: "POST",
164 headers: { cookie, origin: "https://evil.example" },
165 body: new URLSearchParams({ number: String(issue.number) }),
166 redirect: "manual",
167 });
168 expect(res.status).toBe(403);
169 expect(getIssue(app.db, repo.id, issue.number)!.state).toBe("open");
170 });
171
172 test("the terminal lists a person's open tells and takes one back, with the same gates", async () => {
173 const issue = await say("Make it navy");
174 const mine = undoableTells(app, alice).map((r) => r.issue.number);
175 expect(mine).toContain(issue.number);
176 expect(undoableTells(app, bob)).toEqual([]);
177 const toasts: string[] = [];
178 const heard: string[] = [];
179 const off = app.bus.subscribe((e) => heard.push(e.kind));
180 const session = { user: alice, db: app.db, app } as unknown as Session;
181 const ctx = { toast: (t: string) => toasts.push(t), invalidate() {}, push() {}, theme: {} } as unknown as Ctx;
182 const screen = tellUndoScreen(session, ctx);
183 const at = undoableTells(app, alice).findIndex((r) => r.issue.number === issue.number);
184 for (let i = 0; i < at; i++) screen.key?.(press("j"));
185 expect(screen.key?.(press("u"))).toBe(true);
186 off();
187 expect(toasts).toEqual([TAKEN_BACK_WORDS]);
188 expect(heard).toContain("issue.tell_undone");
189 expect(getIssue(app.db, repo.id, issue.number)!.state).toBe("closed");
190 });
191 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs