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

A line sent from /talk that becomes work answers with a receipt: the issue number as a link #13956

Merged opened this

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

Merged

scout/forge:scout/13942-a-line-sent-from-talk-that-becomes-work → main 8 commits fork 7 threads · 7 unresolved

  • Merged. scout/13942-a-line-sent-from-talk-that-becomes-work was merged into main as 5ac4f27.

Review

Sign in to review this change.
9 files changed +331 −2
docs/features/README.md +1
@@ -160,6 +160,7 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md).
160160 - [Talk to the forge's agent](talk.md)
161161 - [Stopping a Talk answer](talk-stop.md)
162162 - [Talk answers link the issue and pull numbers they cite](talk-links.md)
163 - [A line said in Talk that became work answers with a receipt](talk-filed.md)
163164 - [Tell the crew from a share, with a look before it files](share-tell.md)
164165 - [The crew line on Home](crew-line.md)
165166 - [The crew list](crew-list.md)
docs/features/talk-filed.md added +10
@@ -0,0 +1,10 @@
1 # What a line said in Talk became
2
3 When a line said in `/talk` makes the crew file an issue, the answer is followed by a receipt: **Filed #N** linking to the issue, with its title.
4
5 - A filed issue is a fact however the turn ended: a turn that filed and then failed, or was stopped, still shows its **Filed #N**, so the work is not filed twice.
6 - A turn that answered, whose line read as an ask for work ("tell the crew…", "file an issue for…") and filed nothing, is followed by a plain **Nothing was filed from this line.** It only says what is known; a turn that failed or was stopped says nothing about it.
7 - A plain question gets no receipt.
8 - Each turn files only its own receipts; an earlier turn's are not shown again.
9 - A turn cut by a forge restart and resumed keeps what it filed before the cut: its receipt is shown under the resumed answer, even when that answer then fails. A cut turn that is not resumed (it was already resumed once) shows no receipt; the issue is still on its repository's list.
10 - In the terminal, `ssh ... talk` shows the same line as a step in the thread: `Filed #N <title>` with the issue's path under it.
src/core/conversation_writes.ts +21
@@ -97,3 +97,24 @@ export function unended(db: Database, via: string): string[] {
9797 .all(via)
9898 .map((r) => r.tool);
9999 }
100
101 /**
102 * What this turn's finished `tell` calls answered, oldest first; an answer that is not the tell's
103 * shape is skipped.
104 */
105 export function toldIn(db: Database, via: string): { issue: number; page: string }[] {
106 const out: { issue: number; page: string }[] = [];
107 for (const row of db
108 .query<{ result: string }, [string]>("SELECT result FROM conversation_write WHERE via = ?1 AND tool = 'tell' AND result IS NOT NULL ORDER BY id")
109 .all(via)) {
110 try {
111 const data = JSON.parse(row.result) as Record<string, unknown> | null;
112 const issue = data?.["issue"];
113 const page = data?.["page"];
114 if (typeof issue === "number" && Number.isInteger(issue) && issue > 0 && typeof page === "string") out.push({ issue, page });
115 } catch {
116 // A result cut at RESULT_MAX is not JSON: it is not a receipt.
117 }
118 }
119 return out;
120 }
src/core/talk_steps.ts +24
@@ -46,8 +46,32 @@ export function parseCall(text: string): { tool: string; args: Record<string, un
4646 /** Lines in a string: what a write added. */
4747 const lines = (s: string): number => (s === "" ? 0 : s.split("\n").length - (s.endsWith("\n") ? 1 : 0));
4848
49 /**
50 * A receipt turn of where a line went (#13942) as a step: "Filed #N title" with its path, or the
51 * word that nothing was.
52 */
53 function filedStep(text: string): Step | undefined {
54 if (!text.startsWith("{")) return undefined;
55 let data: Record<string, unknown> | null;
56 try {
57 data = JSON.parse(text) as Record<string, unknown> | null;
58 } catch {
59 return undefined;
60 }
61 if (data === null || typeof data !== "object") return undefined;
62 if (data["filed"] === false && typeof data["says"] === "string") return { label: cut(data["says"]), details: [] };
63 const r = data["receipt"] as Record<string, unknown> | null | undefined;
64 if (data["filed"] !== true || r === null || typeof r !== "object") return undefined;
65 const { verb, object, href } = r;
66 if (typeof verb !== "string" || typeof object !== "string" || typeof href !== "string" || !/^\/[^/]/.test(href)) return undefined;
67 const title = typeof data["title"] === "string" ? data["title"] : "";
68 return { label: cut(`${verb} ${object}${title === "" ? "" : ` ${title}`}`), details: [href] };
69 }
70
4971 /** The step a call stands for. */
5072 export function stepOf(text: string): Step | undefined {
73 const filed = filedStep(text);
74 if (filed !== undefined) return filed;
5175 const call = parseCall(text);
5276 if (call === undefined) return undefined;
5377 const { tool, args } = call;
src/crew/conversation.ts +6
@@ -26,6 +26,7 @@ import { getRepoById } from "../core/repos.ts";
2626 import { appendTurn, getConversation, lastExchange, listTurns, openConversation, removeTurn, restoreTurns, setAsideFrom, setClaudeSession, type Conversation } from "../core/conversations.ts";
2727 import { attach, deliver, fileOwnedBy, NOTHING, release, type ConversationFile, type Delivery } from "../core/conversation_files.ts";
2828 import { carryWrites, forgetWrites, unended } from "../core/conversation_writes.ts";
29 import { filedTurns } from "./filed.ts";
2930 import { cancelHeld, WORDS_MAX } from "../core/fence.ts";
3031 import { thinkingOf } from "../core/talk_work.ts";
3132 import { contextOf } from "../core/conversation_cost.ts";
@@ -633,6 +634,8 @@ function begin(
633634 // A write held after the stop was asked is cancelled too.
634635 cancelHeld(app.db, via);
635636 put("agent", STOPPED_LINE);
637 // A tell that finished before the stop still filed its issue: say so (#13942).
638 for (const text of filedTurns(app.db, via, prompt, false)) put("tool", text);
636639 app.db
637640 .query("UPDATE conversation_run SET state = 'stopped', stopped = 1, tokens_in = ?2, tokens_out = ?3, cost_usd = ?4, finished_at = ?5, context_tokens = ?6, context_window = ?7 WHERE id = ?1")
638641 .run(runId, outcome?.tokensIn ?? 0, outcome?.tokensOut ?? 0, cost, new Date().toISOString(), outcome?.contextTokens ?? 0, outcome?.contextWindow ?? 0);
@@ -653,6 +656,9 @@ function begin(
653656 } else if (!outcome.ok) couldNot(failureLine(outcome.reason), (said) => said === outcome!.result);
654657 else if (answer.trim() !== "" && answer !== lastText) put("agent", answer);
outdated

Only on outcome.ok: a turn that filed and then failed or was stopped shows no receipt. Emit the Filed receipts on every outcome; keep 'Nothing was filed' to the ok case. Test it.

655658 else if (answer.trim() === "" && lastText === "") couldNot(failureLine("error"), () => false);
outdated

This wiring is untested: no test fails if this line is removed. Also the terminal door gets no receipt.

659 // Where the line went (#13942): each issue a tell opened, on every outcome; the plain word
660 // that none was only when the turn answered.
661 for (const text of filedTurns(app.db, via, prompt, outcome?.ok === true)) put("tool", text);
656662 app.db
657663 .query(
658664 "UPDATE conversation_run SET state = ?2, tokens_in = ?3, tokens_out = ?4, cost_usd = ?5, finished_at = ?6, context_tokens = ?7, context_window = ?8 WHERE id = ?1",
src/crew/filed.ts added +55
@@ -0,0 +1,55 @@
1 /**
2 * Where a line said in /talk went (#13942): when the turn's agent told the
3 * crew, a receipt turn names each issue it opened — "Filed #N" linking to it —
4 * whatever the turn did next; and when a turn that answered had words that
5 * matched an ask for work and nothing was filed, a plain turn says only that.
6 * Plain data in, the JSON of one `tool` turn out.
7 */
8
9 import type { Database } from "bun:sqlite";
10 import { toldIn } from "../core/conversation_writes.ts";
11 import { getIssue } from "../core/issues.ts";
12 import { getRepo } from "../core/repos.ts";
13 import { UNDOABLE } from "./conversation_confirm.ts";
14
outdated

'did not become an issue' states more than the phrase match knows. Soften to what is known: 'Nothing was filed from this line.'

15 /** What a line that asked for work and filed none says. */
16 export const FILED_NOTHING = "Nothing was filed from this line.";
17
18 /** The words ask for work: the same asks that let the agent tell the crew. */
outdated

Rebuilding a global RegExp on every call to avoid lastIndex state: use a non-global test on the source or reset lastIndex, and say why.

19 export const asksForWork = (words: string): boolean => {
20 const lower = words.toLowerCase();
21 return (UNDOABLE["tell"]?.ask ?? []).some((re) => {
22 // The asks are shared global patterns and `test` on one moves its lastIndex: start it at 0,
23 // and leave it at 0 for the next reader.
24 re.lastIndex = 0;
25 const hit = re.test(lower);
26 re.lastIndex = 0;
27 return hit;
outdated

toldIn(db, via) is per conversation, not per turn: a later turn re-emits earlier receipts unless writes are cleared. Scope to this turn and test two turns in one conversation.

28 });
29 };
30
31 /** The issue's path and number from the page a tell answered; undefined for any other shape. */
32 const PAGE = /^\/([^/\s]+)\/([^/\s]+)\/issues\/(\d+)$/;
33
34 /**
35 * The turns to store when a turn ends, each as the JSON of a `tool` turn. A
36 * finished tell is a fact however the turn ended, so its receipt comes on every
37 * outcome; `answered` (the turn ended ok) alone lets the "nothing was filed"
38 * line through, since a failed or stopped turn may simply not have got there.
39 */
40 export function filedTurns(db: Database, via: string, words: string, answered: boolean): string[] {
41 const told = toldIn(db, via);
42 if (told.length === 0) return answered && asksForWork(words) ? [JSON.stringify({ filed: false, done: true, says: FILED_NOTHING })] : [];
43 return told.flatMap(({ issue, page }) => {
44 let path: string;
45 try {
46 path = new URL(page).pathname;
47 } catch {
48 return [];
49 }
50 const m = PAGE.exec(path);
51 const repo = m === null ? undefined : getRepo(db, m[1]!, m[2]!);
52 const title = repo === undefined ? "" : (getIssue(db, repo.id, issue)?.title ?? "");
53 return [JSON.stringify({ filed: true, done: true, ...(title === "" ? {} : { title }), receipt: { verb: "Filed", object: `#${issue}`, href: path } })];
54 });
55 }
src/web/pages/talk.ts +7 −2
@@ -128,9 +128,9 @@ const undoneIn = (turns: readonly Turn[]): Set<string> =>
128128 );
129129
130130 /** A receipt as a line: what changed, its page, and the one tap to undo it when it can be. */
131 function receiptCard(id: string, turnId: string, receipt: Receipt, at: string, set: string, undone: boolean): Html {
131 function receiptCard(id: string, turnId: string, receipt: Receipt, at: string, set: string, undone: boolean, title = ""): Html {
132132 return html`<li class="talk-turn talk-tool${set}" id="${id}">
133 <p><strong>${receipt.verb}</strong> <a href="${receipt.href}">${receipt.object}</a> <span class="talk-when">${time(at)}</span></p>
133 <p><strong>${receipt.verb}</strong> <a href="${receipt.href}">${receipt.object}</a>${title === "" ? null : html` <span class="muted">${title}</span>`} <span class="talk-when">${time(at)}</span></p>
134134 ${receipt.undo === undefined || !INVERSES.has(receipt.undo.tool)
135135 ? null
136136 : undone
@@ -261,6 +261,11 @@ export function turnHtml(turn: Turn, waiting: ReadonlySet<string>, cost?: Spend,
261261 const receipt = data?.["done"] === true ? readReceipt(data["receipt"]) : undefined;
262262 if (data !== undefined && receipt !== undefined && ("confirm" in data || "undid" in data))
263263 return receiptCard(id, turn.id, receipt, turn.createdAt, set, undone.has(turn.id));
264 // Where a line went (#13942): the issue it opened, linked, or the plain word that none was.
265 if (data?.["filed"] === true && receipt !== undefined && /^\/[^/]/.test(receipt.href))

Page-only: the same receipt must show in src/tui/ (both doors) with a docs/features/ how-to.

266 return receiptCard(id, turn.id, receipt, turn.createdAt, set, false, typeof data["title"] === "string" ? data["title"] : "");
267 if (data?.["filed"] === false && typeof data["says"] === "string")
268 return html`<li class="talk-turn talk-tool${set}" id="${id}"><p class="muted">${data["says"]} <span class="talk-when">${time(turn.createdAt)}</span></p></li>`;
264269 if (data !== undefined && "undid" in data)
265270 return toolCard(id, data["done"] === true ? `Undone: ${String(data["tool"])}.` : `Undo did not go through: ${String(data["message"] ?? data["error"] ?? "")}`, String(data["tool"] ?? "undo"), turn.createdAt, set);
266271 if (data !== undefined && "confirm" in data) {
test/talk-receipt-turn.test.ts added +172
@@ -0,0 +1,172 @@
1 /**
2 * Where a line said in /talk went (#13942), through the real turn: a stand-in `claude` holds while
3 * the test records the agent's tell, the turn ends, and the receipt is stored; the next turn in the
4 * same conversation does not file it again. The terminal reads the same turn as a step.
5 */
6
7 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
8 import { chmodSync, writeFileSync } from "node:fs";
9 import { mkdtemp, rm } from "node:fs/promises";
10 import { tmpdir } from "node:os";
11 import { join } from "node:path";
12 import { createRepo } from "../src/actions/repos.ts";
13 import { createApp, type App } from "../src/app.ts";
14 import { completeWrite, recordWrite } from "../src/core/conversation_writes.ts";
15 import { listTurns, openConversation, type Turn } from "../src/core/conversations.ts";
16 import { createIssue } from "../src/core/issues.ts";
17 import { stepOf } from "../src/core/talk_steps.ts";
18 import { createUser, type User } from "../src/core/users.ts";
19 import { say, STOPPED_LINE, stopTurn, type ConversationOptions } from "../src/crew/conversation.ts";
20 import { asksForWork, FILED_NOTHING } from "../src/crew/filed.ts";
21 import { turnHtml } from "../src/web/pages/talk.ts";
22
23 let dir: string;
24 let app: App;
25 let alice: User;
26 let repoId: string;
27
28 const options = (binary: string): ConversationOptions => ({ binary, localUrl: "http://127.0.0.1:9", budgetUsd: 1, timeoutMs: 30_000, signal: new AbortController().signal });
29
30 const SUCCESS = (name: string): string =>
31 `{"type":"result","subtype":"success","is_error":false,"result":"Done.","total_cost_usd":0.1,"num_turns":1,"session_id":"s-${name}","terminal_reason":"completed","usage":{"input_tokens":1,"output_tokens":1}}`;
32 const FAILURE = (name: string): string =>
33 `{"type":"result","subtype":"error_during_execution","is_error":true,"result":"","total_cost_usd":0.1,"num_turns":1,"session_id":"s-${name}","usage":{"input_tokens":1,"output_tokens":1}}`;
34
35 /** A stand-in `claude` that answers, or fails, once the gate file exists. */
36 function stub(name: string, result = SUCCESS(name)): string {
37 const path = join(dir, name);
38 writeFileSync(
39 path,
40 `#!/bin/sh
41 if [ "$1" = "--version" ]; then echo "2.1.0 (fake)"; exit 0; fi
42 IFS= read -r first
43 echo '{"type":"system","subtype":"init","session_id":"s-${name}","model":"fake"}'
44 while [ ! -f "${dir}/${name}.gate" ]; do sleep 0.05; done
45 echo '{"type":"assistant","session_id":"s-${name}","message":{"id":"m","content":[{"type":"text","text":"Done."}],"usage":{"input_tokens":1,"output_tokens":1}}}'
46 echo '${result}'
47 `,
48 );
49 chmodSync(path, 0o755);
50 return path;
51 }
52
53 /** One turn: `during` runs while the agent holds, then the turn is let go and awaited. */
54 async function turn(name: string, words: string, during: (via: string) => void, result?: string): Promise<string[]> {
55 return (await turns(name, words, during, result)).filter((t) => t.role === "tool").map((t) => t.text);
56 }
57
58 /** The same, answering every turn the conversation now holds. */
59 async function turns(name: string, words: string, during: (via: string) => void, result?: string): Promise<Turn[]> {
60 const c = openConversation(app.db, alice.id);
61 const said = say(app, options(stub(name, result)), alice.id, words);
62 if (!said.ok) throw new Error("say");
63 during(`conversation:${c.id}`);
64 writeFileSync(join(dir, `${name}.gate`), "");
65 await said.value.done;
66 const r = listTurns(app.db, alice.id, c.id);
67 return r.ok ? r.value : [];
68 }
69
70 beforeAll(async () => {
71 dir = await mkdtemp(join(tmpdir(), "forge-receipt-turn-"));
72 app = createApp({ dataDir: dir, port: 0 });
73 const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
74 if (!u.ok) throw new Error(u.error);
75 alice = u.value;
76 const made = await createRepo(app, alice, { name: "rt", visibility: "public" });
77 if (!made.ok) throw new Error(String(made.error));
78 repoId = made.value.id;
79 }, 30_000);
80 afterAll(async () => {
81 app.db.close();
82 await rm(dir, { recursive: true, force: true });
83 });
84
85 describe("a turn that tells the crew", () => {
86 test("stores Filed #N once, and the next turn in the conversation does not file it again", async () => {
87 const made = createIssue(app.db, { repoId, authorId: alice.id, title: "fix the typo", body: "b" });
88 if (!made.ok) throw new Error(made.error);
89 const n = made.value.number;
90 const first = await turn("one", "tell the crew to fix the typo", (via) =>
91 completeWrite(app.db, recordWrite(app.db, via, "tell", { text: "fix the typo" }), JSON.stringify({ says: "ok", issue: n, page: `http://x/alice/rt/issues/${n}` })),
92 );
93 expect(first).toHaveLength(1);
94 expect(JSON.parse(first[0]!)).toMatchObject({ filed: true, title: "fix the typo", receipt: { verb: "Filed", object: `#${n}`, href: `/alice/rt/issues/${n}` } });
95 // The terminal draws it as a step, not as JSON.
96 expect(stepOf(first[0]!)).toEqual({ label: `Filed #${n} fix the typo`, details: [`/alice/rt/issues/${n}`] });
97 // A later turn that did nothing says nothing: the earlier receipt is not filed again.
98 const second = await turn("two", "what is waiting for me?", () => {});
99 expect(second).toEqual(first);
100 });
101
102 test("a line that asked for work and filed none says so, in the terminal too", async () => {
103 const out = await turn("three", "please file an issue for the crash", () => {});
104 const says = out.filter((t) => t.includes(FILED_NOTHING));
105 expect(says).toHaveLength(1);
106 expect(stepOf(says[0]!)).toEqual({ label: FILED_NOTHING, details: [] });
107 });
108
109 test("the stored receipt renders as a link to the issue on the page", async () => {
110 const made = createIssue(app.db, { repoId, authorId: alice.id, title: "<i>rendered</i>", body: "b" });
111 if (!made.ok) throw new Error(made.error);
112 const n = made.value.number;
113 const all = await turns("four", "tell the crew to render it", (via) =>
114 completeWrite(app.db, recordWrite(app.db, via, "tell", { text: "render it" }), JSON.stringify({ says: "ok", issue: n, page: `http://x/alice/rt/issues/${n}` })),
115 );
116 const stored = all.filter((t) => t.role === "tool").at(-1)!;
117 const page = turnHtml(stored, new Set()).text;
118 expect(page).toContain(`<a href="/alice/rt/issues/${n}">#${n}</a>`);
119 expect(page).toContain("&lt;i&gt;rendered&lt;/i&gt;");
120 });
121
122 test("a turn that filed and then failed still shows Filed #N, and claims nothing when it filed none", async () => {
123 const made = createIssue(app.db, { repoId, authorId: alice.id, title: "filed then failed", body: "b" });
124 if (!made.ok) throw new Error(made.error);
125 const n = made.value.number;
126 const before = (await turn("five-pre", "what is waiting for me?", () => {})).length;
127 const out = await turn(
128 "five",
129 "tell the crew to fix the footer",
130 (via) => completeWrite(app.db, recordWrite(app.db, via, "tell", { text: "fix the footer" }), JSON.stringify({ says: "ok", issue: n, page: `http://x/alice/rt/issues/${n}` })),
131 FAILURE("five"),
132 );
133 const fresh = out.slice(before);
134 expect(fresh).toHaveLength(1);
135 expect(JSON.parse(fresh[0]!)).toMatchObject({ filed: true, receipt: { object: `#${n}` } });
136 // A failed turn that filed nothing does not say "nothing was filed": it may not have got there.
137 const after = await turn("six", "please file an issue for the crash", () => {}, FAILURE("six"));
138 expect(after.slice(out.length)).toEqual([]);
139 });
140
141 test("a turn that filed and then was stopped still shows Filed #N, and claims nothing when it filed none", async () => {
142 const made = createIssue(app.db, { repoId, authorId: alice.id, title: "filed then stopped", body: "b" });
143 if (!made.ok) throw new Error(made.error);
144 const n = made.value.number;
145 const before = await turns("seven-pre", "what is waiting for me?", () => {});
146 const all = await turns("seven", "tell the crew to fix the header", (via) => {
147 completeWrite(app.db, recordWrite(app.db, via, "tell", { text: "fix the header" }), JSON.stringify({ says: "ok", issue: n, page: `http://x/alice/rt/issues/${n}` }));
148 expect(stopTurn(app, alice.id)).toBe(true);
149 });
150 const fresh = all.slice(before.length);
151 expect(fresh.some((t) => t.text === STOPPED_LINE)).toBe(true);
152 const receipts = fresh.filter((t) => t.role === "tool");
153 expect(receipts).toHaveLength(1);
154 expect(JSON.parse(receipts[0]!.text)).toMatchObject({ filed: true, receipt: { object: `#${n}` } });
155 // Stopped before it filed anything: no "nothing was filed", it may not have got there.
156 const later = await turns("eight", "please file an issue for the crash", () => {
157 expect(stopTurn(app, alice.id)).toBe(true);
158 });
159 expect(later.slice(all.length).filter((t) => t.role === "tool")).toEqual([]);
160 });
161
162 test("the ask match gives the same answer when asked twice", () => {
163 expect(asksForWork("tell the crew to fix it")).toBe(true);
164 expect(asksForWork("tell the crew to fix it")).toBe(true);
165 expect(asksForWork("what is waiting for me?")).toBe(false);
166 });
167
168 test("a receipt turn that is not the shape is not a step", () => {
169 expect(stepOf(JSON.stringify({ filed: true, receipt: { verb: "Filed", object: "#1", href: "//evil.example" } }))).toBeUndefined();
170 expect(stepOf("{not json")).toBeUndefined();
171 });
172 });
test/talk-receipt.test.ts +35
@@ -11,6 +11,8 @@ import { createRepo } from "../src/actions/repos.ts";
1111 import { createApp, type App } from "../src/app.ts";
1212 import { createSession } from "../src/core/sessions.ts";
1313 import { appendTurn, openConversation, undoneBy } from "../src/core/conversations.ts";
14 import { completeWrite, recordWrite } from "../src/core/conversation_writes.ts";
15 import { filedTurns, FILED_NOTHING } from "../src/crew/filed.ts";
1416 import { hold } from "../src/core/fence.ts";
1517 import { createIssue, getIssue } from "../src/core/issues.ts";
1618 import { createUser, type User } from "../src/core/users.ts";
@@ -145,3 +147,36 @@ describe("an undo", () => {
145147 expect(getIssue(app.db, repoId, n)?.state).toBe("open");
146148 });
147149 });
150
151 describe("a line that becomes work", () => {

Tests build the turns by hand through filedTurns; they do not send a tell through a turn, so box 3 is not met.

152 const sayTurns = (words: string, title: string, args: Record<string, unknown>): void => {
153 const c = openConversation(app.db, alice.id);
154 const via = `conversation:${c.id}`;
155 if (title !== "") {
156 const n = makeIssue(title);
157 completeWrite(app.db, recordWrite(app.db, via, "tell", args), JSON.stringify({ says: "ok", issue: n, page: `${servers.url}/alice/${name}/issues/${n}` }));
158 }
159 for (const text of filedTurns(app.db, via, words, true)) appendTurn(app.db, alice.id, c.id, { role: "tool", text });
160 };
161
162 test("after a tell the reply shows Filed #N linking to it, the title escaped", async () => {
163 sayTurns("tell the crew to fix it", "<b>fix</b> it", { text: "fix it" });
164 const page = await (await get("/talk")).text();
165 const n = app.db.query<{ n: number }, []>("SELECT MAX(number) AS n FROM issue").get()!.n;
166 expect(page).toContain("Filed");
167 expect(page).toContain(`<a href="/alice/${name}/issues/${n}">#${n}</a>`);
168 expect(page).toContain("&lt;b&gt;fix&lt;/b&gt; it");
169 expect(page).not.toContain("<b>fix</b>");
170 });
171
172 test("a line that asked for work and filed nothing says so; a plain question says nothing", async () => {
173 const via = "conversation:quiet";
174 expect(filedTurns(app.db, via, "what is waiting for me?", true)).toEqual([]);
175 expect(filedTurns(app.db, via, "please file an issue for the crash", true)).toHaveLength(1);
176 // A turn that failed or was stopped may not have got there: it claims nothing.
177 expect(filedTurns(app.db, via, "please file an issue for the crash", false)).toEqual([]);
178 const c = openConversation(app.db, alice.id);
179 for (const text of filedTurns(app.db, "conversation:quiet", "please file an issue for the crash", true)) appendTurn(app.db, alice.id, c.id, { role: "tool", text });
180 expect(await (await get("/talk")).text()).toContain(FILED_NOTHING);
181 });
182 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs