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

A Talk receipt that names an issue stays alive: a line says what the crew does on it now, and Reply speaks to it #16294

Merged opened this

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

Merged

talk/look-4-receipt → main 0 commits 6 threads · 6 unresolved

  • Merged. talk/look-4-receipt was merged into main as 7afde4a.

Review

Sign in to review this change.
16 files changed +521 −66
docs/design/areas/talk.md +5
@@ -122,3 +122,8 @@ Prior art: Claude and ChatGPT (one centred column, the person's words in a quiet
122122 - `.talk-display`: Display, at the end of the conversation menu: the person's Talk preferences (spacing, motion, Enter, steps) as one plain form of selects (`core/settings.ts`).
123123 - `.talk-peek`: a peek at what a message links to on this forge (an issue, a pull, a repository), a small card placed under the link (above it near the foot of the screen) on hover, focus or a long press (`src/web/talk_peek.ts`); on touch the same card opens through the overlay host as a `.dialog` with `.talk-peek-sheet`.
124124 - `.talk-peek-card`, `.talk-peek-kind`, `.talk-peek-title`, `.talk-peek-body`, `.talk-peek-acts`: the card's kind and number with its state, its title, three lines of its body as plain text, and at most two actions (Open; Talk about this for an issue or a repository).
125 - `.talk-receipt`: a receipt, one calm line of what was done (a check, the verb, the link, the time), and under it Undo where it can be undone; a first-class part of the thread, never mistakable for a confirm or an error.
126 - `.talk-receipt-line`, `.talk-receipt-acts`: its line and its quiet row of actions (Undo; Reply on the issue).
127 - `.talk-work-line`: under a receipt that names an issue, what the crew is doing on it now (queued, working for how long, the pull it pushed and its checks, waiting for you, landed), a live region swapped from `/live/talk-work`.
128 - `.talk-to`: the line above the composer's field while its words go to an issue (Reply on a receipt): to whom, and the way back to the forge.
129 - `.talk-when`: a turn's or receipt's time, said quietly; in a receipt's line it stands apart from the title, as the time does in a reply's last row.
docs/design/size-budget.json +1 −1
@@ -68,7 +68,7 @@
6868 "css": 48384
6969 },
7070 "/talk": {
71 "js": 35328,
71 "js": 35584,
7272 "css": 53504
7373 },
7474 "/:owner/:name/pulls/:number": {
docs/features/talk.md +12 −2
@@ -136,7 +136,7 @@ A reply is drawn by the README renderer and then, for Talk alone, by `linkTalk`
136136
137137 An agent reply is Markdown, drawn on the server by the same renderer as a README: fenced code is highlighted, tables and links render, and everything else is escaped (a `<script>` in a reply shows as text). A table wider than the column scrolls inside it; the page does not. The reply sits in the column like a person's turn, with none of the README's padding or line measure.
138138
139 A reply grows in one live element while it is written (see "Live") and is then stored as one finished turn; the page only appends a turn whose id it has not drawn (a repeat is ignored). Turns already on the page are not touched, so nothing above a new reply moves, and the page follows the end only if you were already there (otherwise "Latest" appears). An unfinished fence in a stored reply is closed for drawing. The page's own bytes are held by a test (`test/talk-page.test.ts`): the stylesheet under 14,700 B, the script under 34,000 B, and a page with a code reply under 43,000 B (its own page: one question and a code reply).
139 A reply grows in one live element while it is written (see "Live") and is then stored as one finished turn; the page only appends a turn whose id it has not drawn (a repeat is ignored). Turns already on the page are not touched, so nothing above a new reply moves, and the page follows the end only if you were already there (otherwise "Latest" appears). An unfinished fence in a stored reply is closed for drawing. The page's own bytes are held by a test (`test/talk-page.test.ts`): the stylesheet under 15,500 B, the script under 35,200 B, and a page with a code reply under 45,000 B (its own page: one question and a code reply).
140140
141141 ## Following
142142
@@ -193,6 +193,16 @@ Four preferences of the person's own, at the end of the conversation menu (⋯
193193
194194 A link in a message to an issue, a pull or a repository on this forge peeks: on a pointer device a small card after a 300 ms hover (it leaves 150 ms after the pointer does, and stays while the pointer is on it), on keyboard focus, and on touch after a 500 ms long press, as a dialog through the overlay host. A tap or a click still follows the link. Escape or a press outside closes it; the link is described by the card (`aria-describedby`), and focus is never trapped by the hover card.
195195
196 The card is `GET /talk/peek?href=<rooted path>` (`src/web/talk_peek.ts`), signed in only: the kind and number with its state in a word and an icon (Open, Closed, Merged; for a pull its checks in words), the title, who it is assigned to and whether the crew works on it now ("working on it for 4 min", from the live run), the first lines of its body as escaped plain text (never Markdown, never a link), when it last changed, and at most two actions (Open, and Talk about this, which opens Talk with that subject). Read exactly as the link is: a repository the person cannot read, a sealed issue they may not see, a number that is not there, a pull asked as an issue, or any other path answers not found, and no card appears. Cached by the browser for 5 seconds. Proof: `test/talk-peek.test.ts`.
196 The card is `GET /talk/peek?href=<rooted path>` (`src/web/talk_peek.ts`), signed in only: the kind and number with its state in a word and an icon (Open, Closed, Merged; for a pull its checks in words), the title, what the crew is doing on it now, in the same sentence as a receipt's work line ("marin has been working on it for 4 min."), the first lines of its body as escaped plain text (never Markdown, never a link), when it last changed, and at most two actions (Open, and Talk about this, which opens Talk with that subject). Read exactly as the link is: a repository the person cannot read, a sealed issue they may not see, a number that is not there, a pull asked as an issue, or any other path answers not found, and no card appears. Cached by the browser for 5 seconds. Proof: `test/talk-peek.test.ts`.
197197
198198 **In the terminal** there is no hover: a conversation names the same links as `owner/repo#12` and `owner/repo`, which the terminal's issue and repository screens open.
199
200 ## Receipts that stay alive (#15734)
201
202 A receipt is one calm line in the thread: a check, what was done and its link, the time, and Undo where it can be undone (a ghost button, never a decision's weight). A receipt that names an issue (work filed, or an action on one) is alive: under it, one quiet line says what the crew is doing on it now, read when asked: queued, "scout has been working on it for 4 min", "scout pushed #12: checks running", "scout pushed #12, which is ready: waiting for you to land it", "scout landed #12", or done (`workLine` in `src/core/talk_work.ts`, which the terminal reads too). It is one of the page's live regions (`data-live="run.*,issue.*,pull.*,comment.*"` on that repository, swapped from `GET /live/talk-work?href=…&id=…`, read exactly as the issue is), so it moves as the run does with no stream of its own; the crew's line at the thread's end is one too (`/live/talk-crew`).
203
204 **Reply** on such a receipt sends the composer's next words to the issue as a comment (the issue's own comment form, `POST /<owner>/<name>/issues/<n>/comments`), where a crew member working on it hears them as its next step, the same door as MCP `say` with a repository and a number. A line above the field says to whom while it is so; its ✕ turns the composer back to the forge. Without the script Reply is a link to the issue's comment form; with it, the 303 the comment answers is read as done, and the issue page behind it is never loaded. Proof: `test/talk-receipt-live.test.ts`, `test/talk-page.test.ts`.
205
206 **Where the card opens:** below the link while it fits on the screen (over the composer at worst, never over what is being read above it), else above, and always held inside the screen under the top bar; the 300 ms and 150 ms intent delays are unchanged.
207
208 **In the terminal** a conversation keeps a receipt that names an issue in view (never folded with steps), with the same work line under it, and `c` comments on that issue through the same `addCommentThrough`.
src/core/talk_work.ts +80 −2
@@ -8,9 +8,11 @@
88 */
99
1010 import type { Database } from "bun:sqlite";
11 import { getIssue } from "./issues.ts";
11 import { getIssue, type Issue } from "./issues.ts";
1212 import { listTurns } from "./conversations.ts";
13 import { getRepo, type Repo } from "./repos.ts";
13 import { canRead, getRepo, type Repo } from "./repos.ts";
14 import { mayView } from "./sealed.ts";
15 import { getUserById, type User } from "./users.ts";
1416 import { callState } from "./talk_steps.ts";
1517
1618 /** The part of a turn the reading needs: its role and its stored text. */
@@ -200,3 +202,79 @@ export function worksOf(db: Database, userId: string, conversationId: string, pa
200202 });
201203 return works;
202204 }
205
206 /** Minutes since an ISO time, as "running for N min". */
207 const forMinutes = (at: string | null, now: number): string =>
208 at === null
209 ? ""
210 : ` for ${Math.max(1, Math.round((now - Date.parse(at)) / 60_000))} min`;
211
212 /** The words of the work line, in one place. */
213 const WORK_WORDS = { closed: "Done: it is closed.", landed: "landed", ready: "is ready: waiting for you to land it.", checksRunning: "checks running", checksFailed: "checks failed", pushed: "pushed", queued: "Queued for", working: "has been working on it", failed: "'s run did not finish.", finished: "finished.", assigned: "Assigned to", crew: "The crew" } as const;
214
215 /**
216 * What the crew is doing on an issue now, in one line, read when it is asked for: closed; a pull
217 * its run pushed (landed, ready and waiting for the person, checks running or red); the run queued,
218 * working (for how long), or ended; else who it is assigned to; "" when nobody is on it.
219 */
220 export function workLine(db: Database, issue: Issue, now: number): string {
221 if (issue.state === "closed") return WORK_WORDS.closed;
222 const named = issue.assigneeId === null ? undefined : getUserById(db, issue.assigneeId)?.username;
223 const who = named ?? WORK_WORDS.crew;
224 const run = db.query<{ state: string; started_at: string | null; branch: string }, [string]>("SELECT state, started_at, branch FROM run WHERE issue_id = ?1 AND kind = 'agent' ORDER BY id DESC LIMIT 1").get(issue.id);
225 const pull = run === null || run.branch === "" ? null : db.query<{ id: string; number: number; merged_at: string | null }, [string, string]>("SELECT i.id, i.number, p.merged_at FROM pull p JOIN issue i ON i.id = p.issue_id WHERE p.head_branch = ?1 AND i.repo_id = ?2 ORDER BY i.number DESC LIMIT 1").get(run.branch, issue.repoId);
226 if (pull !== null) {
227 if (pull.merged_at !== null) return `${who} ${WORK_WORDS.landed} #${pull.number}.`;
228 const check = db.query<{ state: string }, [string]>("SELECT state FROM run WHERE issue_id = ?1 AND kind = 'check' ORDER BY id DESC LIMIT 1").get(pull.id);
229 if (check?.state === "ok") return `${who} ${WORK_WORDS.pushed} #${pull.number}, which ${WORK_WORDS.ready}`;
230 return `${who} ${WORK_WORDS.pushed} #${pull.number}: ${check?.state === "failed" ? WORK_WORDS.checksFailed : WORK_WORDS.checksRunning}.`;
231 }
232 if (run?.state === "queued") return `${WORK_WORDS.queued} ${named ?? WORK_WORDS.crew.toLowerCase()}.`;
233 if (run?.state === "running") return `${who} ${WORK_WORDS.working}${forMinutes(run.started_at, now)}.`;
234 if (run?.state === "failed") return `${who}${WORK_WORDS.failed}`;
235 if (run?.state === "ok") return `${who} ${WORK_WORDS.finished}`;
236 return issue.assigneeId === null ? "" : `${WORK_WORDS.assigned} ${who}.`;
237 }
238
239 /** A receipt that names an issue the person may read: what it says, the issue, and its work line now. */
240 export interface LiveReceipt {
241 /** "Filed alice/site#3 Round the corners": the verb, the object and the title. */
242 readonly says: string;
243 readonly object: string;
244 readonly owner: string;
245 readonly name: string;
246 readonly number: number;
247 readonly line: string;
248 }
249
250 const RECEIPT_ISSUE = /^\/([^/]+)\/([^/]+)\/issues\/(\d+)$/;
251
252 /**
253 * Every receipt in these turns that names an issue the person may read, by turn id: the one reader
254 * of a receipt both doors draw from (the page's live line, the terminal's line and its comment).
255 */
256 export function liveReceipts(db: Database, user: User, turns: readonly { readonly id: string; readonly role: string; readonly text: string }[]): Map<string, LiveReceipt> {
257 const out = new Map<string, LiveReceipt>();
258 for (const t of turns) {
259 if (t.role !== "tool" || !t.text.includes("/issues/")) continue;
260 let d: { title?: unknown; receipt?: { verb?: unknown; object?: unknown; href?: unknown } };
261 try {
262 d = JSON.parse(t.text) as typeof d;
263 } catch {
264 continue;
265 }
266 const r = d.receipt;
267 const m = typeof r?.href === "string" ? RECEIPT_ISSUE.exec(r.href) : null;
268 if (m === null || typeof r?.verb !== "string" || typeof r.object !== "string") continue;
269 const repo = getRepo(db, m[1] ?? "", m[2] ?? "");
270 const issue = repo === undefined || !canRead(db, repo, user) ? undefined : getIssue(db, repo.id, Number(m[3]));
271 if (repo === undefined || issue === undefined || !mayView(db, repo, issue, user)) continue;
272 const title = typeof d.title === "string" && d.title !== "" ? ` ${d.title}` : "";
273 out.set(t.id, { says: `${r.verb} ${r.object}${title}`, object: r.object, owner: repo.ownerName, name: repo.name, number: issue.number, line: workLine(db, issue, Date.now()) });
274 }
275 return out;
276 }
277
278 /** The work line of each receipt, by turn id, as the page draws it. */
279 export const receiptLines = (db: Database, user: User, turns: readonly { readonly id: string; readonly role: string; readonly text: string }[]): Map<string, string> =>
280 new Map([...liveReceipts(db, user, turns)].map(([id, r]) => [id, r.line]));
src/http/marks/live.json +3 −1
@@ -16,6 +16,8 @@
1616 "/live/home/waiting": "open",
1717 "/live/home/panels": "admin",
1818 "/live/home/asked": "open",
19 "/live/home/feed": "open"
19 "/live/home/feed": "open",
20 "/live/talk-work": "open",
21 "/live/talk-crew": "open"
2022 }
2123 }
src/http/server.ts +3 −1
@@ -172,7 +172,7 @@ import {
172172 } from "../web/pages/site.ts";
173173 import { talkBuild, talkPublish, talkRestore } from "../web/talk_build.ts";
174174 import { talkAct, talkAgainSend, talkArchive, talkConfirm, talkDisplaySave, talkDownload, talkNew, talkPin, talkQueueCancel, talkRename, talkSend, talkUndo, talkStream, talkView } from "../web/pages/talk.ts";
175 import { talkPeek } from "../web/talk_peek.ts";
175 import { liveTalkCrew, liveTalkWork, talkPeek } from "../web/talk_peek.ts";
176176 import {
177177 recoverFinish,
178178 recoverOptions,
@@ -1214,6 +1214,8 @@ export function buildRouter(): Router<Handler> {
12141214 // home's shelf and its "On you" card answer for themselves, so an event
12151215 // fetches a region and not the page. Literal, above /:owner.
12161216 router.add("GET", "/live/apps", liveAppsFragment);
1217 router.add("GET", "/live/talk-work", liveTalkWork);
1218 router.add("GET", "/live/talk-crew", liveTalkCrew);
12171219 router.add("GET", "/live/on-you", liveOnYouFragment);
12181220 router.add("GET", "/live/desk", liveDeskFragment);
12191221 router.add("GET", "/live/client-apps", liveClientAppsFragment);
src/tui/screens/talk_chats.ts +42 −1
@@ -32,6 +32,10 @@ import { filesOf, repoOf, stepOf } from "../../core/talk_steps.ts";
3232 import { cardsPlaced, plainVoice } from "../../core/talk_voice.ts";
3333 import { setTalkDisplay, talkDisplay } from "../../core/settings.ts";
3434 import { talkDisplayScreen } from "./talk_display.ts";
35 import { liveReceipts, type LiveReceipt } from "../../core/talk_work.ts";
outdated

The TUI must not import from src/web/. Move workLine and workLinesOf to core and share one receipt reader with receiptOn below.

36 import { addCommentThrough } from "../../actions/issues.ts";
37 import { getIssue } from "../../core/issues.ts";
38 import { canRead, getRepo } from "../../core/repos.ts";
3539 import type { ShownCard } from "../../core/talk_voice.ts";
3640 import { workspaceOf } from "../../actions/talk_workspace.ts";
3741 import type { Ctx, Screen } from "../app/app.ts";
@@ -119,12 +123,15 @@ function chatScreen(f: Session, ctx: Ctx, chat: Conversation, hit?: string): Scr
119123 let repo: string | undefined;
120124 // The shown results the replies place, printed as their rows (docs/features/talk.md).
121125 let cards: ReadonlyMap<number, ShownCard> = new Map();
126 // The receipts that name an issue, with the crew's line on each, read with the turns.
127 let receipts: ReadonlyMap<string, LiveReceipt> = new Map();
122128 const load = (): void => {
123129 if (f.user === undefined) return;
124130 const before = around === undefined ? undefined : pageAround(f.app.db, f.user.id, chat.id, around);
125131 const listed = listTurns(f.app.db, f.user.id, chat.id, { limit: 50, ...(before === undefined ? {} : { before }) });
126132 turns = listed.ok ? listed.value : [];
127133 cards = cardsPlaced(f.app.db, f.user.id, chat.id, turns);
134 receipts = liveReceipts(f.app.db, f.user, turns);
128135 const last = before === undefined ? listed : listTurns(f.app.db, f.user.id, chat.id, { limit: 50 });
129136 recent = last.ok ? last.value : [];
130137 repo = repoOf(recent);
@@ -154,9 +161,16 @@ function chatScreen(f: Session, ctx: Ctx, chat: Conversation, hit?: string): Scr
154161 ];
155162 const refs = refTarget(f.app.db, f.user, repo);
156163 let n = 0;
157 const stepAt = (i: number) => (turns[i]?.role === "tool" ? stepOf(turns[i]!.text) : undefined);
164 const stepAt = (i: number) => (turns[i]?.role === "tool" && !receipts.has(turns[i]!.id) ? stepOf(turns[i]!.text) : undefined);
158165 return turns.flatMap((t, i) => {
159166 if (t.id === around) mark = n;
167 // A receipt that names an issue stays in view, with the crew's work line under it.
168 const receipt = receipts.get(t.id);
169 if (receipt !== undefined) {
170 const work = receipt.line;
171 n += work === "" ? 2 : 3;
172 return [[{ text: `✓ ${receipt.says}`, style: style(c.fg, c.bg) }], ...(work === "" ? [] : [[{ text: ` ${work}`, style: style(c.mutedFg, c.bg) }]]), []];
173 }
160174 const step = t.role === "tool" ? stepOf(t.text) : undefined;
161175 // Folded, a run of steps reads as one line: its one step's words, or how many.
162176 if (stepsNow() === "folded" && step !== undefined) {
@@ -189,6 +203,7 @@ function chatScreen(f: Session, ctx: Ctx, chat: Conversation, hit?: string): Scr
189203 binding(["b"], "a result's buttons"),
190204 binding(["v"], "steps open or folded"),
191205 binding(["D"], "display"),
206 binding(["c"], "comment on the receipt's issue"),
192207 binding(["d", "x"], "export as Markdown"),
193208 binding(["esc"], "back"),
194209 ],
@@ -287,6 +302,32 @@ function chatScreen(f: Session, ctx: Ctx, chat: Conversation, hit?: string): Scr
287302 ctx.push(downloadScreen(f, ctx, chat));
288303 return true;
289304 }
305 if (e.key === "c") {
306 // The newest receipt's issue: words said there reach whoever works on it, as Reply does.
307 const last = [...turns].reverse().map((t) => receipts.get(t.id)).find((r) => r !== undefined);
308 if (last === undefined) {
309 note = "No receipt here names an issue to comment on.";
310 ctx.invalidate();
311 return true;
312 }
313 ctx.push(
314 promptScreen(ctx, screen, {
315 title: "Comment",
316 label: `on ${last.object}, to whoever works on it`,
317 onSubmit: (words) => {
318 runAsync(ctx, async () => {
319 const repo = getRepo(f.app.db, last.owner, last.name);
320 const issue = repo === undefined || !canRead(f.app.db, repo, user) ? undefined : getIssue(f.app.db, repo.id, last.number);
321 const done = repo === undefined || issue === undefined ? undefined : await addCommentThrough(f.app, user, repo, issue, words);
322 note = done?.ok === true ? `Said on ${last.object}. Whoever works on it reads it next.` : `That was not said on ${last.object}.`;
323 ctx.invalidate();
324 });
325 return undefined;
326 },
327 }),
328 );
329 return true;
330 }
290331 if (e.key === "s") {
291332 ctx.push(
292333 promptScreen(ctx, screen, {
src/web/crew_now.ts −4
@@ -34,7 +34,3 @@ export function crewLine(live: readonly LiveRow[]): string {
3434 return `The crew is working${count}: ${first.who} on ${first.on ?? first.app}.`;
3535 }
3636
37 /** Always one line of fixed height, so the words arriving move nothing. */
38 export function crewLineHtml(rows: readonly LiveRow[]): Html {
39 return html`<p class="talk-crew small muted" data-crew-now>${crewLine(rows)}</p>`;
40 }
src/web/pages/talk.ts +31 −15
@@ -65,12 +65,13 @@ import { flashTo, fragment, page, redirect } from "../layout.ts";
6565 import { linkRefs, refTarget } from "../../text/talk_links.ts";
6666 import { appLook, linkTalk, talkLook, type TalkLook } from "../../text/talk_link_words.ts";
6767 import { liveCrewRows } from "../../actions/crew_now.ts";
68 import { crewLineHtml } from "../crew_now.ts";
68 import { crewLine } from "../crew_now.ts";
6969 import { agentHtml, liveHtml, voiceCss, voiceOf, type Voice } from "../talk_parts.ts";
7070 import { badge, btn, icon, iconBtn, menu, meter, row, time } from "../ui.ts";
7171 import { inlineIcons } from "../icons.ts";
7272 import { DISPLAY_NAMES, setTalkDisplay, TALK_DISPLAY, talkDisplay, type TalkDisplay } from "../../core/settings.ts";
7373 import { peekCss } from "../talk_peek.ts";
74 import { receiptLines } from "../../core/talk_work.ts";
7475 import { buildCss, chosenTemplate, panelFor, templateChips } from "../talk_build.ts";
7576 import type { User } from "../../core/users.ts";
7677 import { chatBuildOf } from "../../core/chat_build.ts";
@@ -147,14 +148,27 @@ const undoneIn = (turns: readonly Turn[]): Set<string> =>
147148 );
148149
149150 /** A receipt as a line: what changed, its page, and the one tap to undo it when it can be. */

Non-blocking: two stacked doc comments, this stale one and the one above ISSUE_PAGE. Drop this one.

150 function receiptCard(id: string, turnId: string, receipt: Receipt, at: string, set: string, undone: boolean, title = ""): Html {
151 return html`<li class="talk-turn talk-tool${set}" id="${id}">
152 <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>
153 ${receipt.undo === undefined || !INVERSES.has(receipt.undo.tool)
154 ? null
155 : undone
156 ? html`<p class="muted small">Undone.</p>`
157 : html`<form method="post" action="${HERE}/undo/${turnId}" class="bar">${btn(receipt.undo.label, { icon: "history", label: receipt.undo.label })}</form>`}
151 /** An issue a receipt names, by its page: the work on it can be followed and spoken to. */
152 const ISSUE_PAGE = /^\/([A-Za-z0-9][A-Za-z0-9_.-]{0,63})\/([A-Za-z0-9][A-Za-z0-9_.-]{0,99})\/issues\/([1-9]\d{0,8})$/;
153
154 /**
155 * A receipt: one calm line saying what was done, with its link, and Undo where it can be undone.
156 * One that names an issue is alive: a line under it says, as the run moves, what the crew is doing
157 * on it (a live region, swapped from `/live/talk-work` when a run, the issue or its pull changes),
158 * and Reply sends the composer's words to the issue, where a working crew member hears them as its
159 * next step.
160 */
161 function receiptCard(id: string, turnId: string, receipt: Receipt, at: string, set: string, undone: boolean, title = "", line = ""): Html {
162 const issue = ISSUE_PAGE.exec(receipt.href);
163 const undo = receipt.undo === undefined || !INVERSES.has(receipt.undo.tool)
164 ? null
165 : undone
166 ? html`<span class="small muted">Undone.</span>`
167 : html`<form method="post" action="${HERE}/undo/${turnId}">${btn(receipt.undo.label, { icon: "history", label: receipt.undo.label, size: "sm", variant: "ghost" })}</form>`;
168 return html`<li class="talk-turn talk-receipt${set}" id="${id}">
169 <p class="talk-receipt-line">${icon("check")}<span><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></span></p>
170 ${issue === null ? null : html`<p class="talk-work-line small muted" id="w-${turnId}" data-live="run.*,issue.*,pull.*,comment.*" data-live-repo="${issue[1]}/${issue[2]}" data-live-src="/live/talk-work?href=${encodeURIComponent(receipt.href)}&amp;id=w-${turnId}">${line}</p>`}
outdated

Principle 8 and no-JS: this Reply button does nothing without JavaScript. Make it an <a> to the issue's comment form, which the client can upgrade to the composer.

171 ${undo === null && issue === null ? null : html`<div class="talk-receipt-acts">${undo}${issue === null ? null : html`<a class="btn" data-size="sm" data-variant="ghost" href="${receipt.href}#comment-body" data-reply="${receipt.href}" data-reply-to="${receipt.object}">${icon("comment")} Reply on ${receipt.object}</a>`}</div>`}
158172 </li>`;
159173 }
160174
@@ -300,7 +314,7 @@ const linkedOf =
300314 };
301315
302316 /** One turn as the page and the stream both draw it; `waiting` is the confirms still open. */
303 export function turnHtml(turn: Turn, waiting: ReadonlySet<string>, cost?: Spend, act?: Html, work?: Work, files: readonly ConversationFile[] = [], expired: ReadonlySet<string> = new Set(), undone: ReadonlySet<string> = new Set(), refs?: (n: number) => string | undefined, voice?: Voice, look?: TalkLook): Html {
317 export function turnHtml(turn: Turn, waiting: ReadonlySet<string>, cost?: Spend, act?: Html, work?: Work, files: readonly ConversationFile[] = [], expired: ReadonlySet<string> = new Set(), undone: ReadonlySet<string> = new Set(), refs?: (n: number) => string | undefined, voice?: Voice, look?: TalkLook, lines?: ReadonlyMap<string, string>): Html {
304318 const id = `t-${turn.id}`;
305319 const set = turn.replaced ? " talk-replaced" : "";
306320 const acts = act === undefined ? null : html`<div class="talk-acts">${act}</div>`;
@@ -345,10 +359,10 @@ export function turnHtml(turn: Turn, waiting: ReadonlySet<string>, cost?: Spend,
345359 // A tool turn: the confirm's outcome as JSON, or the call the agent made as text.
346360 const receipt = data?.["done"] === true ? readReceipt(data["receipt"]) : undefined;
347361 if (data !== undefined && receipt !== undefined && ("confirm" in data || "undid" in data))
348 return receiptCard(id, turn.id, receipt, turn.createdAt, set, undone.has(turn.id));
362 return receiptCard(id, turn.id, receipt, turn.createdAt, set, undone.has(turn.id), "", lines?.get(turn.id) ?? "");
349363 // Where a line went (#13942): the issue it opened, linked, or the plain word that none was.
350364 if (data?.["filed"] === true && receipt !== undefined && /^\/[^/]/.test(receipt.href))
351 return receiptCard(id, turn.id, receipt, turn.createdAt, set, false, typeof data["title"] === "string" ? data["title"] : "");
365 return receiptCard(id, turn.id, receipt, turn.createdAt, set, false, typeof data["title"] === "string" ? data["title"] : "", lines?.get(turn.id) ?? "");
352366 if (data?.["filed"] === false && typeof data["says"] === "string")
353367 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>`;
354368 if (data !== undefined && "undid" in data)
@@ -538,6 +552,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
538552 const framed = pane.live && !pending;
539553 const about = editing === undefined ? aboutLine(ctx) : null;
540554 const display = talkDisplay(ctx.app.db, user.id);
555 const lines = receiptLines(ctx.app.db, user, turns);
541556 // The crew's line says something only while a run is live: idle is silence.
542557 const crew = liveCrewRows(ctx, user);
543558 const body = html`<div class="talk-page" data-shell data-pane="${shown}"${listing ? raw(" data-view=\"list\"") : null}${split ? raw(" data-split") : null}><h1 class="sr-only">Talk</h1>
@@ -551,10 +566,10 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
551566 <ol class="talk-log" role="log" data-last="${last}" aria-label="Conversation with the forge">
552567 ${empty
553568 ? hello(ctx, user, here, buildMode, chosen)
554 : foldSteps(display.steps === "open", timeGroups(turns, turns.map((t) => turnHtml(t, waiting, costs.get(t.id), acts.get(t.id), works.get(t.id), sent.get(t.id), expired, undone, refs, voice, look))))}
569 : foldSteps(display.steps === "open", timeGroups(turns, turns.map((t) => turnHtml(t, waiting, costs.get(t.id), acts.get(t.id), works.get(t.id), sent.get(t.id), expired, undone, refs, voice, look, lines))))}
555570 ${!paged && running ? queuedTalk(ctx.app, user, conversation.id).map(queuedHtml) : null}
556571 </ol>
557 ${crew.length === 0 ? null : crewLineHtml(crew)}
572 <p class="talk-crew small muted" id="talk-crew" data-live="run.*" data-live-src="/live/talk-crew">${crew.length === 0 ? null : crewLine(crew)}</p>
558573 <div id="end"></div>
559574 <div class="talk-keys" data-keys role="region" aria-label="Keyboard shortcuts" hidden><dl>${TALK_KEYS.map((k) => html`<dt>${k.keys}</dt><dd>${k.does}</dd>`)}</dl></div>
560575 <form class="talk-compose" id="compose" method="post" action="${buildMode ? "/talk/build" : editing === undefined ? here : `${here}/again/edit`}" ${editing === undefined ? null : html`data-edit`}${buildMode ? raw(" data-build") : null}>
@@ -564,6 +579,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
564579 ${chosen === undefined ? null : html`<input type="hidden" name="template" value="${chosen}" />`}
565580 <div class="talk-box">
566581 <div class="talk-chips" data-chips role="group" aria-label="Attached files"></div>
582 <p class="talk-to small" data-to-line hidden><span></span> <button type="button" class="btn btn-icon" data-variant="ghost" data-to-off aria-label="Talk to the forge instead" title="Talk to the forge instead">${icon("x")}</button></p>
567583 <div class="talk-tools">
568584 ${buildMode ? null : html`<button type="button" class="btn btn-icon" data-variant="ghost" data-attach hidden aria-label="Attach files" title="Attach files">${icon("paperclip")}</button><input type="file" multiple hidden data-files />`}
569585 <textarea class="talk-input" name="${buildMode ? "prompt" : "text"}" rows="1" maxlength="${WORDS_MAX}" required placeholder="${buildMode ? (chosen === undefined ? "A tip calculator for friends" : `What to make from ${chosen}`) : "Message the forge"}" aria-label="${buildMode ? "What to build" : "Talk to the forge"}" aria-keyshortcuts="/ Enter Shift+Enter" title="Enter sends, Shift+Enter adds a line" aria-describedby="talk-error">${editing === undefined ? "" : editing.text}</textarea>
@@ -882,7 +898,7 @@ export function talkStream(ctx: Ctx): Response {
882898 const look = talkLook(app.db, user, fresh.filter((t) => t.role === "agent").map((t) => t.text), appLook(app, user));
883899 for (const turn of fresh) {
884900 // A frame lands in a page whose sprite is its own: its icons are drawn inline (`inlineIcons`).
885 emit("turn", { id: turn.id, role: turn.role, html: inlineIcons(turnHtml(turn, waiting, undefined, undefined, works.get(turn.id), sent.get(turn.id), expired, undone, refs, voice, look).text) }, turn.id);
901 emit("turn", { id: turn.id, role: turn.role, html: inlineIcons(turnHtml(turn, waiting, undefined, undefined, works.get(turn.id), sent.get(turn.id), expired, undone, refs, voice, look, receiptLines(app.db, user, [turn])).text) }, turn.id);
886902 cursor = turn.id;
887903 }
888904 // The page is told at once what the block holds after these turns, empty once it is
src/web/pages/talk_client.ts +36
@@ -65,6 +65,18 @@ body:has(.talk-page) .foot { display: none; }
6565 .talk-fill meter { width: 3rem; }
6666 .talk-figures { display: grid; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
6767 .talk-figures p { margin: 0; }
68 .talk-receipt { display: grid; gap: 2px; font-size: 14px; }
outdated

Unrelated to this issue (.talk-figures). Remove it from this pull, or say what it fixes.

69 .talk-receipt-line { display: flex; gap: 8px; align-items: baseline; margin: 0; }
70 .talk-receipt-line > .ico { flex: none; align-self: center; color: var(--muted-fg); }
71 .talk-receipt-line .talk-when { margin-inline-start: 8px; font-size: 12.5px; color: var(--muted-fg); white-space: nowrap; }
outdated

Principle 5: --success is a second colour next to the one accent. Use the muted or foreground token.

72 .talk-work-line { margin: 0; padding-inline-start: 24px; }
73 .talk-work-line:empty { display: none; }
74 .talk-receipt-acts { display: flex; flex-wrap: wrap; gap: 4px; padding-inline-start: 16px; }
75 .talk-receipt-acts .btn { position: relative; }
76 .talk-to { display: flex; align-items: center; gap: 4px; margin: 0; padding: 4px 4px 0 16px; }
77 .talk-to[hidden] { display: none; }
78 .talk-to span { flex: 1; min-width: 0; }
79 .talk-crew:empty { display: none; }
6880 .talk-display form { display: grid; gap: 8px; padding: 8px 12px; }
6981 .talk-display label { display: grid; gap: 4px; }
7082 .talk-display select { font-size: 16px; }
@@ -673,6 +685,20 @@ if (root) {
673685 };
674686 };
675687 const chips = form.querySelector("[data-chips]");
688 const toLine = form.querySelector("[data-to-line]");
689 let toWho = "";
690 const talkTo = (href, who) => {
691 toWho = who;
692 if (href) form.dataset.to = href; else delete form.dataset.to;
693 toLine.hidden = !href;
694 toLine.firstElementChild.textContent = href ? "To " + who + ": it is said on the issue, to whoever works on it." : "";
695 box.focus();
696 };
697 root.addEventListener("click", (e) => {
698 const r = e.target.closest && e.target.closest("[data-reply]");
699 if (r && !e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); talkTo(r.dataset.reply, r.dataset.replyTo); }
700 if (e.target.closest && e.target.closest("[data-to-off]")) talkTo("", "");
701 });
676702 const picker = form.querySelector("[data-files]");
677703 const attach = form.querySelector("[data-attach]");
678704 if (attach) { attach.hidden = false; attach.addEventListener("click", () => picker.click()); }
@@ -722,6 +748,16 @@ ${dictateJs}
722748 if (form.hasAttribute("data-build")) { clearTimeout(draftTimer); draft.save(""); return; }
723749 e.preventDefault();
724750 const text = box.value.trim();
751 if (text && form.dataset.to) {
752 say("Sending…");
753 try {
754 const res = await fetch(form.dataset.to + "/comments", { method: "POST", body: new URLSearchParams({ body: text }), redirect: "manual" });
755 if (!res.ok && res.type !== "opaqueredirect") { fail("That was not said on " + toWho + "."); return; }
756 box.value = ""; grow(); clearTimeout(draftTimer); draft.save(""); paint();
757 say("Said on " + toWho + ". Whoever works on it reads it next.");
758 } catch (_) { fail("That was not sent: no connection."); }
759 return;
760 }
725761 if (!text) { if (attached.length) say("Add a few words about what you attached."); return; }
726762 if (editing) {
727763 if (await again("edit", new URLSearchParams({ text }))) { clearTimeout(draftTimer); draft.save(""); }
src/web/talk_peek.ts +38 −31
@@ -13,10 +13,14 @@ import type { Ctx } from "../http/context.ts";
1313 import { getIssue } from "../core/issues.ts";
1414 import { canRead, getRepo } from "../core/repos.ts";
1515 import { mayView } from "../core/sealed.ts";
16 import { getUserById } from "../core/users.ts";
1716 import { html, type Html } from "./html.ts";
1817 import { icon, time } from "./ui.ts";
1918 import { inlineIcons } from "./icons.ts";
19 import { notePhase, takeSessionTime } from "../core/route_timing.ts";
20 import { fragment } from "./layout.ts";
21 import { liveCrewRows } from "../actions/crew_now.ts";
22 import { crewLine } from "./crew_now.ts";
23 import { workLine } from "../core/talk_work.ts";
2024
2125 /** The paths a peek reads: a repository, or one of its issues or pulls. */
2226 const PEEK =
@@ -28,10 +32,7 @@ const BODY_SHOWN = 240;
2832 const PEEK_WORDS = {
2933 open: "Open",
3034 talk: "Talk about this",
31 working: "working on it",
32 queued: "queued to work on it",
3335 changed: "Changed",
34 assigned: "Assigned to",
3536 merged: "Merged",
3637 open_: "Open",
3738 closed: "Closed",
@@ -46,12 +47,6 @@ const notFound = (): Response =>
4647 headers: { "cache-control": "private, no-store" },
4748 });
4849
49 /** Minutes since an ISO time, as "running for N min". */
50 const forMinutes = (at: string | null, now: number): string =>
51 at === null
52 ? ""
53 : ` for ${Math.max(1, Math.round((now - Date.parse(at)) / 60_000))} min`;
54
5550 // GET /talk/peek?href=<a rooted path on this forge>
5651 export function talkPeek(ctx: Ctx): Response {
5752 if (ctx.auth.user === undefined)
@@ -112,14 +107,8 @@ export function talkPeek(ctx: Ctx): Response {
112107 >("SELECT state FROM run WHERE issue_id = ?1 AND kind = 'check' ORDER BY id DESC LIMIT 1")
113108 .get(issue.id)
114109 : null;
115 const run = db
116 .query<
117 { state: string; started_at: string | null },
118 [string]
119 >("SELECT state, started_at FROM run WHERE issue_id = ?1 AND kind = 'agent' AND state IN ('queued','running') ORDER BY id DESC LIMIT 1")
120 .get(issue.id);
121 const assignee =
122 issue.assigneeId === null ? undefined : getUserById(db, issue.assigneeId);
110 // Who is on it now, as the receipt's work line says it: one plain sentence.
111 const doing = issue.state === "open" && kind === "issues" ? workLine(db, issue, Date.now()) : "";
123112 const state = pull?.merged_at
124113 ? (["merge", PEEK_WORDS.merged] as const)
125114 : issue.state === "open"
@@ -143,19 +132,7 @@ export function talkPeek(ctx: Ctx): Response {
143132 · ${state[1]}${checks === null ? null : html` · ${checks}`}
144133 </p>
145134 <p class="talk-peek-title">${issue.title}</p>
146 ${assignee === undefined && run === null
147 ? null
148 : html`<p class="small muted">
149 ${assignee === undefined
150 ? null
151 : html`${PEEK_WORDS.assigned} ${assignee.username}`}${run === null
152 ? null
153 : html`${assignee === undefined ? null : " · "}<strong
154 >${run.state === "running"
155 ? `${PEEK_WORDS.working}${forMinutes(run.started_at, Date.now())}`
156 : PEEK_WORDS.queued}</strong
157 >`}
158 </p>`}
135 ${doing === "" ? null : html`<p class="small muted">${doing}</p>`}
159136 ${body === ""
160137 ? null
161138 : html`<p class="talk-peek-body small">
@@ -183,6 +160,36 @@ export function talkPeek(ctx: Ctx): Response {
183160 });
184161 }
185162
163 // GET /live/talk-work?href=/owner/name/issues/N&id=w-<turn> — a receipt's work line alone, read as
164 // the issue's own page is; the live client swaps it in place.
165 export function liveTalkWork(ctx: Ctx): Response {
166 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
167 const rendering = performance.now();
168 const answer = workFragment(ctx);
169 notePhase(ctx.request, "render", performance.now() - rendering);
170 return answer;
171 }
172
173 function workFragment(ctx: Ctx): Response {
outdated

Plain words: "Queued for The crew." reads badly, and the capital T mid-sentence is wrong. Say "Queued for the crew." and fix the tests.

174 const m = PEEK.exec(ctx.url.searchParams.get("href") ?? "");
175 const id = ctx.url.searchParams.get("id") ?? "";
176 if (ctx.auth.user === undefined || m === null || m[3] !== "issues" || !/^w-[0-9a-z]{1,40}$/.test(id)) return fragment(html``, { status: 404 });
177 const repo = getRepo(ctx.app.db, m[1] ?? "", m[2] ?? "");
178 const issue = repo === undefined || !canRead(ctx.app.db, repo, ctx.auth.user) ? undefined : getIssue(ctx.app.db, repo.id, Number(m[4]));
179 if (repo === undefined || issue === undefined || !mayView(ctx.app.db, repo, issue, ctx.auth.user)) return fragment(html``, { status: 404 });
180 return fragment(html`<p class="talk-work-line small muted" id="${id}">${workLine(ctx.app.db, issue, Date.now())}</p>`, { request: ctx.request });
181 }
182
183 // GET /live/talk-crew — the crew's one line on Talk, empty when it is idle.
184 export function liveTalkCrew(ctx: Ctx): Response {
185 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
186 const rendering = performance.now();
187 const rows = ctx.auth.user === undefined ? undefined : liveCrewRows(ctx, ctx.auth.user);
188 const answer = rows === undefined ? fragment(html``, { status: 404 }) : fragment(html`<p class="talk-crew small muted" id="talk-crew">${rows.length === 0 ? null : crewLine(rows)}</p>`, { request: ctx.request });
189 notePhase(ctx.request, "render", performance.now() - rendering);
190 return answer;
191 }
192
186193 /** The card's own styles, part of the page's sheet. Spacing is the scale. */
187194 export const peekCss = /* css */ `
188195 .talk-peek { position: absolute; width: min(22rem, calc(100vw - 32px)); padding: 12px; border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow-2); }
test/talk-crew-now.test.ts +2 −2
@@ -58,7 +58,7 @@ describe("/talk crew line", () => {
5858 });
5959
6060 test("idle when nobody works: the page says nothing, so no row is spent on it", async () => {
61 expect(line(await talk())).toBeUndefined();
61 expect(line(await talk())).toBe("");
6262 });
6363
6464 test("signed out, /talk asks for sign-in and shows no crew line", async () => {
@@ -75,7 +75,7 @@ describe("/talk crew line", () => {
7575 const sealed = createIssue(app.db, { repoId, authorId: userId, title: "the hole", sealed: true });
7676 if (!sealed.ok) throw new Error("issue");
7777 createRun(app.db, { repoId, kind: "agent", issueId: sealed.value.id, reason: "work" });
78 expect(line(await talk(bobCookie))).toBeUndefined();
78 expect(line(await talk(bobCookie))).toBe("");
7979 expect(line(await talk())).toStartWith("The crew is working (2):");
8080 });
8181
test/talk-page.test.ts +47 −5
@@ -405,15 +405,15 @@ describe("the page", () => {
405405
406406 test("the page's own bytes are held: stylesheet and script stay small", async () => {
407407 const { talkCss, talkJs } = await import("../src/web/pages/talk_client.ts");
408 expect(Buffer.byteLength(talkCss)).toBeLessThan(14_700);
409 expect(Buffer.byteLength(talkJs)).toBeLessThan(34_000);
408 expect(Buffer.byteLength(talkCss)).toBeLessThan(15_500);
409 expect(Buffer.byteLength(talkJs)).toBeLessThan(35_200);
410410 // A page of its own, so what other tests said to alice never counts: one question and a code reply.
411411 const sizer = await createUser(app.db, { origin: "seed", trusted: true, username: "sizer", email: "[email protected]", password: "a-good-passphrase" });
412412 if (!sizer.ok) throw new Error(sizer.error);
413413 say(sizer.value, "person", "how?");
414414 say(sizer.value, "agent", "```ts\nlet x = 1;\n```");
415415 const size = (await (await get("/talk", sizer.value)).arrayBuffer()).byteLength;
416 expect(size).toBeLessThan(43_000);
416 expect(size).toBeLessThan(45_000);
417417 });
418418
419419 describe("the script, driven against a DOM", () => {
@@ -507,17 +507,19 @@ describe("the page", () => {
507507 const doc = window.document as any;
508508 doc.body.innerHTML = `<div class="talk" data-talk data-user="${user}" data-c="${conv}" data-paged="0" data-running="1"><header class="talk-head"><details><summary>More</summary></details></header><div>
509509 <ol class="talk-log" role="log" data-last=""><li class="talk-turn talk-agent" id="t-1"><div class="talk-body"><pre><code>let a = 1;</code></pre></div><p class="talk-meta">Forge · now</p></li></ol><div id="end"></div></div>
510 <form class="talk-compose"><div class="talk-box"><div data-chips></div><textarea name="text" required></textarea><div class="talk-tools"><button type="button" data-attach hidden aria-label="Attach files"></button><input type="file" multiple hidden data-files /><span data-compose-hint></span><button class="btn" type="button" data-steer hidden>Steer</button><button class="btn" type="button" data-stop hidden aria-label="Stop the answer">Stop</button><button class="btn talk-send" type="submit" aria-label="Send">Send</button></div></div><p data-error hidden></p><p class="talk-status" role="status"></p><button type="button" class="btn talk-jump" data-jump hidden><span data-word></span></button></form></div>`;
510 <form class="talk-compose"><div class="talk-box"><div data-chips></div><p data-to-line hidden><span></span><button type="button" data-to-off>x</button></p><textarea name="text" required></textarea><div class="talk-tools"><button type="button" data-attach hidden aria-label="Attach files"></button><input type="file" multiple hidden data-files /><span data-compose-hint></span><button class="btn" type="button" data-steer hidden>Steer</button><button class="btn" type="button" data-stop hidden aria-label="Stop the answer">Stop</button><button class="btn talk-send" type="submit" aria-label="Send">Send</button></div></div><p data-error hidden></p><p class="talk-status" role="status"></p><button type="button" class="btn talk-jump" data-jump hidden><span data-word></span></button></form></div>`;
511511 const how = { value: "started" };
512512 const cancel = { status: 200 };
513513 const page = { html: "" };
514514 const sent: string[] = [];
515515 const urls: string[] = [];
516 const redirects: string[] = [];
516517 const copied: string[] = [];
517518 const bodies: { files?: string[] }[] = [];
518519 const fetchStub = async (u: string, init: { body: string; method?: string }) => {
519520 urls.push(u);
520521 if (u.startsWith("?pane=") || u === "/talk" || u.endsWith("?fragment=build")) return { ok: true, text: async () => page.html };
522 if (u.endsWith("/comments")) { sent.push("comment:" + u + ":" + String(init.body)); redirects.push(String((init as { redirect?: string }).redirect)); return cancel.status === 303 ? { ok: false, status: 0, type: "opaqueredirect" } : { ok: cancel.status === 200, status: cancel.status, text: async () => "" }; }
521523 if (u.endsWith("/files")) return { ok: true, json: async () => ({ id: "f1", name: "shot.png" }) };
522524 if (init.method === "DELETE") return { ok: true, json: async () => ({}) };
523525 if (u.includes("/queue/")) return { ok: cancel.status === 200, status: cancel.status, json: async () => ({}) };
@@ -538,7 +540,7 @@ describe("the page", () => {
538540 const key = (init: object) => box.dispatchEvent(new window.KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true, ...init }));
539541 const emit = (id: string, html: string) => sources.at(-1)!.on["turn"]!({ data: JSON.stringify({ id, html }) });
540542 const grow = () => { for (const f of grows) f(); };
541 return { how, cancel, page, emit, bodies, sources, urls, window, doc, box, sent, copied, store, key, view, grow, hand: () => doc.documentElement.dispatchEvent(new window.PointerEvent("pointerdown", { bubbles: true })), jump: doc.querySelector("[data-jump]"), status: doc.querySelector(".talk-status") };
543 return { how, cancel, redirects, page, emit, bodies, sources, urls, window, doc, box, sent, copied, store, key, view, grow, hand: () => doc.documentElement.dispatchEvent(new window.PointerEvent("pointerdown", { bubbles: true })), jump: doc.querySelector("[data-jump]"), status: doc.querySelector(".talk-status") };
542544 };
543545 /** An element that scrolls `height` px in a `client` px view; each programmatic move is kept. */
544546 const scrollable = (el: any, height: number, client: number) => {
@@ -969,6 +971,46 @@ describe("the page", () => {
969971 expect(t.doc.querySelectorAll("#live p")[1].hasAttribute("data-in")).toBe(false);
970972 });
971973
974 test("Reply on a receipt sends the words to its issue, where the crew member hears them, and the way back is one tap", async () => {
975 const t = await boot();
976 t.doc.querySelector(".talk-log").insertAdjacentHTML("beforeend", '<li class="talk-turn talk-receipt"><a href="/alice/x/issues/1#comment-body" data-reply="/alice/x/issues/1" data-reply-to="alice/x#1">Reply</a></li>');
977 // Without the script Reply is a link to the issue's own comment form; the script keeps the person here.
978 const reply = new t.window.MouseEvent("click", { bubbles: true, cancelable: true });
979 t.doc.querySelector("[data-reply]").dispatchEvent(reply);
980 expect(reply.defaultPrevented).toBe(true);
981 const to = t.doc.querySelector("[data-to-line]");
982 expect([to.hidden, to.querySelector("span").textContent]).toEqual([false, "To alice/x#1: it is said on the issue, to whoever works on it."]);
983 t.box.value = "make the button bigger";
984 t.key({});
985 await tick();
986 expect(t.sent).toEqual(["comment:/alice/x/issues/1/comments:body=make+the+button+bigger"]);
987 expect(t.status.textContent).toBe("Said on alice/x#1. Whoever works on it reads it next.");
988 // The comment's 303 is the answer: the issue page behind it is never downloaded.
989 expect(t.redirects).toEqual(["manual"]);
990 t.cancel.status = 303;
991 t.box.value = "as a redirect";
992 t.key({});
993 await tick();
994 expect(t.status.textContent).toBe("Said on alice/x#1. Whoever works on it reads it next.");
995 // Said, the To stays in view: the next words go to the same issue until x takes it off.
996 expect(to.hidden).toBe(false);
997 // Refused, nothing is lost: the words stay in the box, the To stays, and it says so.
998 t.cancel.status = 403;
999 t.box.value = "and the link";
1000 t.key({});
1001 await tick();
1002 expect([t.box.value, to.hidden, t.sent.at(-1)]).toEqual(["and the link", false, "comment:/alice/x/issues/1/comments:body=and+the+link"]);
1003 expect(t.doc.querySelector("[data-error]").textContent).toBe("That was not said on alice/x#1.");
1004 t.cancel.status = 200;
1005 t.box.value = "";
1006 t.doc.querySelector("[data-to-off]").click();
1007 expect(to.hidden).toBe(true);
1008 t.box.value = "back to the forge";
1009 t.key({});
1010 await tick();
1011 expect(t.sent.at(-1)).toBe("back to the forge");
1012 });
1013
9721014 test("a code block in a streamed turn gets its Copy button too", async () => {
9731015 const t = await boot();
9741016 t.emit("2", '<li class="talk-turn" id="t-2"><div class="talk-body"><pre><code>x</code></pre></div><p class="talk-meta">Forge</p></li>');
test/talk-peek.test.ts +1 −1
@@ -177,7 +177,7 @@ test("each state and line a card can carry: merged, closed, checks in words, ass
177177 const owned = made("Footer links");
178178 setAssignee(app.db, owned.id, bob.id);
179179 createRun(app.db, { repoId: repo.id, kind: "agent", issueId: owned.id, reason: "work" });
180 expect(await text(`/alice/harbor/issues/${String(owned.number)}`)).toContain("Assigned to bob · <strong >queued to work on it</strong");
180 expect(await text(`/alice/harbor/issues/${String(owned.number)}`)).toContain("Queued for bob.");
181181
182182 const sealed = made("A hole", { sealed: true });
183183 expect((await peek(`/alice/harbor/issues/${String(sealed.number)}`, bob)).status).toBe(404);
test/talk-receipt-live.test.ts added +197
@@ -0,0 +1,197 @@
1 /**
2 * A receipt that names an issue is alive (#15734): a line under it says what the crew is doing on
3 * the issue now, read as the issue itself is read, swapped in place from `/live/talk-work` by the
4 * page's live regions as the run moves; and Reply sends the composer's words to the issue, where a
5 * working crew member hears them as its next step.
6 */
7 import { afterAll, beforeAll, 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 { createRepo } from "../src/actions/repos.ts";
12 import { createApp, type App } from "../src/app.ts";
13 import { appendTurn, openConversation } from "../src/core/conversations.ts";
14 import { createIssue, type Issue, setAssignee } from "../src/core/issues.ts";
15 import { claimRun, createRun } from "../src/core/runs.ts";
16 import { createSession } from "../src/core/sessions.ts";
17 import { createUser, type User } from "../src/core/users.ts";
18 import { serve, type Servers } from "../src/http/server.ts";
19 import { workLine } from "../src/core/talk_work.ts";
20 import { quietLogs } from "./helpers/globals.ts";
21 import { promote } from "./helpers/members.ts";
22
23 quietLogs();
24
25 let dir: string;
26 let app: App;
27 let servers: Servers;
28 let alice: User;
29 let bob: User;
30 let issue: Issue;
31 let repoId: string;
32 const get = (path: string, u: User) =>
33 fetch(`${servers.url}${path}`, {
34 headers: { cookie: `forge_session=${createSession(app.db, u.id).token}` },
35 });
36
37 beforeAll(async () => {
38 dir = await mkdtemp(join(tmpdir(), "forge-talk-receipt-live-"));
39 app = createApp({ dataDir: dir, port: 0 });
40 servers = await serve(app);
41 for (const name of ["alice", "bob"]) {
42 const made = await createUser(app.db, {
43 origin: "seed",
44 trusted: true,
45 username: name,
46 email: `${name}@forge.local`,
47 password: "a-good-passphrase",
48 adminIfFirst: name === "alice",
49 });
50 if (!made.ok) throw new Error(made.error);
51 promote(app.db, made.value);
52 if (name === "alice") alice = made.value;
53 else bob = made.value;
54 }
55 const repo = await createRepo(app, alice, {
56 name: "secret",
57 visibility: "private",
58 });
59 if (!repo.ok) throw new Error("repo");
60 repoId = repo.value.id;
61 const made = createIssue(app.db, {
62 repoId,
63 authorId: alice.id,
64 title: "Round the corners",
65 body: "b",
66 });
67 if (!made.ok) throw new Error("issue");
68 issue = made.value;
69 const c = openConversation(app.db, alice.id);
70 appendTurn(app.db, alice.id, c.id, { role: "person", text: "file it" });
71 appendTurn(app.db, alice.id, c.id, {
72 role: "tool",
73 text: JSON.stringify({
74 done: true,
75 filed: true,
76 title: "Round the corners",
77 receipt: {
78 verb: "Filed",
79 object: "alice/secret#1",
80 href: "/alice/secret/issues/1",
81 },
82 }),
83 });
84 });
85 afterAll(async () => {
86 servers.stop();
87 app.close();
88 await rm(dir, { recursive: true, force: true });
89 });
90
91 test("the work line follows the run: nobody, queued, working for how long, the pull and its checks, waiting for you, landed, closed", () => {
92 expect(workLine(app.db, issue, Date.now())).toBe("");
93 const run = createRun(app.db, {
94 repoId,
95 kind: "agent",
96 issueId: issue.id,
97 reason: "work",
98 branch: "crew/round",
99 });
100 expect(workLine(app.db, issue, Date.now())).toBe("Queued for the crew.");
101 claimRun(app.db, run.id);
102 expect(workLine(app.db, issue, Date.now() + 4 * 60_000)).toBe(
103 "The crew has been working on it for 4 min.",
104 );
105 const pull = createIssue(app.db, {
106 repoId,
107 authorId: alice.id,
108 title: "Round them",
109 body: "Closes #1",
110 kind: "pull",
111 });
112 if (!pull.ok) throw new Error("pull");
113 app.db
114 .query(
115 "INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid) VALUES (?1, 'main', 'crew/round', '', '')",
116 )
117 .run(pull.value.id);
118 expect(workLine(app.db, issue, Date.now())).toBe(
119 "The crew pushed #2: checks running.",
120 );
121 const check = createRun(app.db, {
122 repoId,
123 kind: "check",
124 issueId: pull.value.id,
125 reason: "check",
126 });
127 app.db.query("UPDATE run SET state = 'ok' WHERE id = ?1").run(check.id);
128 expect(workLine(app.db, issue, Date.now())).toBe(
129 "The crew pushed #2, which is ready: waiting for you to land it.",
130 );
131 app.db
132 .query(
133 "UPDATE pull SET merged_at = '2026-01-01T00:00:00Z' WHERE issue_id = ?1",
134 )
135 .run(pull.value.id);
136 expect(workLine(app.db, issue, Date.now())).toBe("The crew landed #2.");
137 expect(workLine(app.db, { ...issue, state: "closed" }, Date.now())).toBe(
138 "Done: it is closed.",
139 );
140 });
141
142 test("the work line's other ends: checks failed, a run that did not finish, one that finished, assigned with no run", () => {
143 const other = (title: string) => {
144 const i = createIssue(app.db, { repoId, authorId: alice.id, title, body: "b" });
145 if (!i.ok) throw new Error("issue");
146 return i.value;
147 };
148 const red = other("Red one");
149 createRun(app.db, { repoId, kind: "agent", issueId: red.id, reason: "work", branch: "crew/red" });
150 const pull = createIssue(app.db, { repoId, authorId: alice.id, title: "Red pull", body: "b", kind: "pull" });
151 if (!pull.ok) throw new Error("pull");
152 app.db.query("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid) VALUES (?1, 'main', 'crew/red', '', '')").run(pull.value.id);
153 const check = createRun(app.db, { repoId, kind: "check", issueId: pull.value.id, reason: "check" });
154 app.db.query("UPDATE run SET state = 'failed' WHERE id = ?1").run(check.id);
155 expect(workLine(app.db, red, Date.now())).toBe(`The crew pushed #${String(pull.value.number)}: checks failed.`);
156 const ended = (state: string) => {
157 const i = other(`Ended ${state}`);
158 app.db.query("UPDATE run SET state = ?1 WHERE id = ?2").run(state, createRun(app.db, { repoId, kind: "agent", issueId: i.id, reason: "work" }).id);
159 return workLine(app.db, i, Date.now());
160 };
161 expect(ended("failed")).toBe("The crew's run did not finish.");
162 expect(ended("ok")).toBe("The crew finished.");
163 const owned = other("Owned");
164 setAssignee(app.db, owned.id, alice.id);
165 expect(workLine(app.db, { ...owned, assigneeId: alice.id }, Date.now())).toBe("Assigned to alice.");
166 });
167
168 test("the page draws the receipt with its live line and Reply; the line's fragment answers only who may read the issue", async () => {
169 const page = await (await get("/talk", alice)).text();
170 expect(page).toMatch(/<li class="talk-turn talk-receipt" id="t-[0-9a-z]+">/);
171 expect(page).toMatch(
172 /<p class="talk-work-line small muted" id="w-[0-9a-z]+" data-live="run\.\*,issue\.\*,pull\.\*,comment\.\*" data-live-repo="alice\/secret" data-live-src="\/live\/talk-work\?href=%2Falice%2Fsecret%2Fissues%2F1&amp;id=w-[0-9a-z]+">The crew landed #2\.<\/p>/,
173 );
174 expect(page).toContain(
175 'href="/alice/secret/issues/1#comment-body" data-reply="/alice/secret/issues/1" data-reply-to="alice/secret#1"',
176 );
177 expect(page).toContain(
178 'id="talk-crew" data-live="run.*" data-live-src="/live/talk-crew"',
179 );
180 const id = /id="(w-[0-9a-z]+)"/.exec(page)![1]!;
181 const href = `/live/talk-work?href=${encodeURIComponent("/alice/secret/issues/1")}&id=${id}`;
182 const mine = await get(href, alice);
183 expect(mine.status).toBe(200);
184 expect(await mine.text()).toContain("The crew landed #2.");
185 expect((await get(href, bob)).status).toBe(404);
186 expect(
187 (
188 await get(
189 `/live/talk-work?href=${encodeURIComponent("/alice/secret/issues/1")}&id=x"onload`,
190 alice,
191 )
192 ).status,
193 ).toBe(404);
194 expect(await (await get("/live/talk-crew", alice)).text()).toMatch(
195 /<p[^>]* class="talk-crew small muted" id="talk-crew"><\/p>/,
196 );
197 });
test/tui-talk-chats.test.ts +23
@@ -10,6 +10,7 @@ import { join } from "node:path";
1010 import { createApp, type App } from "../src/app.ts";
1111 import { appendTurn, archiveConversation, CONVERSATIONS_MAX, createConversation, listConversations, listTurns, renameConversation } from "../src/core/conversations.ts";
1212 import { createIssue } from "../src/core/issues.ts";
13 import { createRun } from "../src/core/runs.ts";
1314 import { createUser, type User } from "../src/core/users.ts";
1415 import { createRepo } from "../src/actions/repos.ts";
1516 import { STARTER_PROMPTS } from "../src/actions/talk.ts";
@@ -220,6 +221,28 @@ describe("the terminal's conversations screen", () => {
220221 expect(text).not.toContain("](/bob/site/issues/1)");
221222 });
222223
224 test("a filed receipt stays in view with what the crew is doing on it, and c says something on its issue", async () => {
225 const repo = await createRepo(app, alice, { name: "lamp", visibility: "public" });
226 if (!repo.ok) throw new Error(String(repo.error));
227 const issue = createIssue(app.db, { repoId: repo.value.id, authorId: alice.id, title: "Dim the lamp", body: "b" });
228 if (!issue.ok) throw new Error("issue");
229 createRun(app.db, { repoId: repo.value.id, kind: "agent", issueId: issue.value.id, reason: "work", branch: "crew/dim" });
230 const made = createConversation(app.db, alice.id);
231 if (!made.ok) throw new Error(made.error);
232 appendTurn(app.db, alice.id, made.value.id, { role: "person", text: "file it" });
233 for (const p of ["a.ts", "b.ts"]) appendTurn(app.db, alice.id, made.value.id, { role: "tool", text: `mcp__forge__read_file {"repo":"alice/lamp","path":"${p}"}` });
234 appendTurn(app.db, alice.id, made.value.id, { role: "tool", text: JSON.stringify({ done: true, filed: true, title: "Dim the lamp", receipt: { verb: "Filed", object: "alice/lamp#1", href: "/alice/lamp/issues/1" } }) });
235 renameConversation(app.db, alice.id, made.value.id, "Receipt here");
236 const text = await drive(alice, [...open, "/", "Receipt here", "\r", "\r"]);
237 expect(text).toContain("✓ Filed alice/lamp#1 Dim the lamp");
238 expect(text).toContain("Queued for the crew.");
239 expect(text).toContain("2 steps");
240 const said = await drive(alice, [...open, "/", "Receipt here", "\r", "\r", "c", "make it dimmer", "\r"]);
241 expect(said).toContain("Said on alice/lamp#1. Whoever works on it reads it next.");
242 const bodies = app.db.query<{ body: string }, [string]>("SELECT body FROM comment WHERE issue_id = ?1").all(issue.value.id).map((r) => r.body);
243 expect(bodies).toContain("make it dimmer");
244 });
245
223246 test("p shows what the chat works on, as the web's pane does; a repository it cannot read shows nothing of it", async () => {
224247 const made = createConversation(app.db, alice.id);
225248 if (!made.ok) throw new Error(made.error);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs