Public: anyone can read this; the crew can change it.
Talk calls the Do it card a confirm, and fixes the designer's six: the list in its column, one last line, Display as a dialog, tables that scroll, Pause in its own strip, a useful empty pane #16299
Check · Review · Land · Live done — Landed and live in production.
talk/look-7-six-rename → main 0 commits
14 files
changed +241
−140
docs/design/areas/talk.md +5 −3
| @@ -8,7 +8,6 @@ | ||
| 8 | 8 | - `.talk-person` — the person's words: right-aligned, a quiet bubble (`--muted` surface, 18px radius), pre-wrapped; the time under it. |
| 9 | 9 | - `.talk-agent` — the agent's reply, markdown, full width, no bubble; its time, cost and actions show only under the last block of a reply. |
| 10 | 10 | - `.talk-tool` — what the agent did, one muted small line. |
| 11 | - `.talk-confirm` — a held action: the sentence, then Do it and Not now at 44px high. | |
| 12 | 11 | - `.talk-compose` — the composer, sticky to the bottom of the viewport above the keyboard (padded for the phone's safe area), faded into the page above it; on an empty conversation it sits under the greeting instead. |
| 13 | 12 | - `.talk-status` — one polite line (sending, answering, an error); it always takes its line, so nothing shifts. |
| 14 | 13 | - `.talk-more` — the "Earlier" link above the log. |
| @@ -127,7 +126,10 @@ Prior art: Claude and ChatGPT (one centred column, the person's words in a quiet | ||
| 127 | 126 | - `.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 | 127 | - `.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 | 128 | - `.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. |
| 130 | - `.talk-asks`, `.talk-asks-count`, `.talk-ask-list`: the dock directly above the composer holding what waits on the person (held actions): always in view, never in the thread; several read as a count and a stack, the first open, never taller than a third of the screen. | |
| 131 | - `.talk-ask`, `.talk-ask-does`, `.talk-ask-left`, `.talk-ask-acts`: one ask: the engine's sentence of what will happen, the time left only under two minutes, Do it and a quiet Not now. Answered, it collapses out of the dock. | |
| 129 | - `.talk-confirms`, `.talk-confirms-count`, `.talk-confirm-list`: the dock directly above the composer holding what waits on the person (confirms): always in view, never in the thread; several read as a count and a stack, the first open, never taller than a third of the screen. | |
| 130 | - `.talk-confirm`, `.talk-confirm-does`, `.talk-confirm-left`, `.talk-confirm-acts`: one confirm: the engine's sentence of what will happen, the time left only under two minutes, Do it and a quiet Not now. Answered, it collapses out of the dock. | |
| 132 | 131 | - `.talk-code`, `.talk-code-changed`, `.talk-code-files`, `.talk-code-tree`, `.talk-code-file`, `.talk-code-n`, `.talk-code-add`, `.talk-code-del`: the pane's Code tab: the files this conversation changed (with what each added and removed) above the repository's own explorer tree at the conversation's branch; a file opens in the pane from the blob page's fragment, with the way back to the files. |
| 133 | 132 | - `.talk-diff`, `.talk-diff-head`, `.talk-diff-versions`, `.talk-diff-pull`: the pane's Diff tab: which change (all, or one version), the totals, the pull as a quiet link with its checks in words, then the forge's own diff, each file folded open inline. |
| 133 | - `.talk-display-sheet`: Display as its own small dialog from the conversation menu, every choice in view; without the script it stays a disclosure in the menu. | |
| 134 | - `.talk-links`: what a reply opened or changed, folded behind its count ("3 files") on the reply's one last line, each file by its path in its repository. | |
| 135 | - `.talk-stage-files`: before a first version, the pane says what will appear and when, and shows the files the app starts from. |
docs/design/size-budget.json +2 −2
| @@ -68,8 +68,8 @@ | ||
| 68 | 68 | "css": 48384 |
| 69 | 69 | }, |
| 70 | 70 | "/talk": { |
| 71 | "js": 37632, | |
| 72 | "css": 53760 | |
| 71 | "js": 37888, | |
| 72 | "css": 54528 | |
| 73 | 73 | }, |
| 74 | 74 | "/:owner/:name/pulls/:number": { |
| 75 | 75 | "js": 32000, |
docs/features/talk.md +5 −5
| @@ -136,7 +136,7 @@ A reply is drawn by the README renderer and then, for Talk alone, by `linkTalk` | ||
| 136 | 136 | |
| 137 | 137 | 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. |
| 138 | 138 | |
| 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 16,900 B, the script under 42,300 B, and a page with a code reply under 49,500 B (its own page: one question and a code reply; the widgets' rules ride every page, so a chart drawn in a live reply is styled at once). | |
| 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 18,000 B, the script under 43,500 B, and a page with a code reply under 50,000 B (its own page: one question and a code reply; the widgets' rules ride every page, so a chart drawn in a live reply is styled at once). | |
| 140 | 140 | |
| 141 | 141 | ## Following |
| 142 | 142 | |
| @@ -207,15 +207,15 @@ A receipt is one calm line in the thread: a check, what was done and its link, t | ||
| 207 | 207 | |
| 208 | 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`. |
| 209 | 209 | |
| 210 | ## Asks wait above the composer (#15734) | |
| 210 | ## Confirms wait above the composer (#15734) | |
| 211 | 211 | |
| 212 | A held action (one that asks before it acts) is never drawn in the scrolled thread, where a long reply could push it off screen. It waits in a dock directly above the composer, always in view: the engine's one sentence of what will happen and to what, **Do it**, and a quiet **Not now**, with the time left only when under two minutes. Several read as "2 waiting" and a stack, the first open and the rest one line each; the stack never grows past a third of the screen and scrolls inside itself beyond that. The dock is part of the composer, so the thread's end stays clear of it and following holds; its buttons come before the box in the Tab order, Enter on Do it answers, and Escape is never Not now. A new ask is said once, politely. | |
| 212 | A confirm (an action held for the person's yes) is never drawn in the scrolled thread, where a long reply could push it off screen. It waits in a dock directly above the composer, always in view: the engine's one sentence of what will happen and to what, **Do it**, and a quiet **Not now**, with the time left only when under two minutes. Several read as "2 waiting" and a stack, the first open and the rest one line each; the stack never grows past a third of the screen and scrolls inside itself beyond that. The dock is part of the composer, so the thread's end stays clear of it and following holds; its buttons come before the box in the Tab order, Enter on Do it answers, and Escape is never Not now. A new confirm is said once, politely. | |
| 213 | 213 | |
| 214 | Its buttons belong to the composer's form and post to the confirm's own address (`formaction`), so the dock works without the script. Answered, the ask collapses out of the dock (instantly where motion is reduced) and its outcome arrives in the thread where it happened: the receipt for Do it, or "Not now: nothing was done." Only an ask that ran out says so in the thread, with Ask again. | |
| 214 | Its buttons belong to the composer's form and post to the confirm's own address (`formaction`), so the dock works without the script. Answered, the confirm collapses out of the dock (instantly where motion is reduced) and its outcome arrives in the thread where it happened: the receipt for Do it, or "Not now: nothing was done." Only a confirm that ran out says so in the thread, with Ask again. | |
| 215 | 215 | |
| 216 | 216 | **Things done fold:** a run of receipts and steps in one reply reads as one line with a check, "2 things done, 3 steps", opening to the list; one receipt alone stays as itself. Proof: `test/talk-page.test.ts`, `test/talk-live.test.ts`. |
| 217 | 217 | |
| 218 | **In the terminal** an ask still waiting is never in the scrolled thread either: it waits at the foot of the conversation with its sentence, and `a` opens Confirms, where `y` does it and `n` says not now. | |
| 218 | **In the terminal** a confirm still waiting is never in the scrolled thread either: it waits at the foot of the conversation with its sentence, and `a` opens Confirms, where `y` does it and `n` says not now. | |
| 219 | 219 | |
| 220 | 220 | ## The pane's Code and Diff (#15734) |
| 221 | 221 |
src/tui/screens/talk_chats.ts +1 −1
| @@ -52,7 +52,7 @@ import { fresh, mayAct, pressCard, PRESS_REFUSED } from "../../actions/talk_act. | ||
| 52 | 52 | |
| 53 | 53 | const BAD_TITLE = `A title is up to ${TITLE_MAX} characters, on one line.`; |
| 54 | 54 | |
| 55 | const WHO: Readonly<Record<string, string>> = { person: "You", agent: "Forge", tool: "Tool", confirm: "Asks" }; | |
| 55 | const WHO: Readonly<Record<string, string>> = { person: "You", agent: "Forge", tool: "Tool", confirm: "Confirm" }; | |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * The person's conversation as the Markdown the page's /talk/:id/download serves; none when it is |
src/web/pages/talk.ts +28 −20
| @@ -131,13 +131,13 @@ const parse = (text: string): Record<string, unknown> | undefined => { | ||
| 131 | 131 | * own address (`formaction`), so the dock needs no form of its own and works without the script. |
| 132 | 132 | * A result shown once is answered in Settings → Confirms, which draws it there. |
| 133 | 133 | */ |
| 134 | export function askItem(id: string, tool: string, does: string, expiresAt: string, shown = ""): Html { | |
| 134 | export function confirmItem(id: string, tool: string, does: string, expiresAt: string, shown = ""): Html { | |
| 135 | 135 | const once = ASKING[tool]?.once !== undefined; |
| 136 | return html`<div class="talk-ask" id="ask-${id}" data-ask="${id}" data-expires="${expiresAt}"> | |
| 137 | <p class="talk-ask-does">${does}</p> | |
| 136 | return html`<div class="talk-confirm" id="confirm-${id}" data-confirm-id="${id}" data-expires="${expiresAt}"> | |
| 137 | <p class="talk-confirm-does">${does}</p> | |
| 138 | 138 | ${shown === "" ? null : html`<details><summary>Everything it will send</summary><pre>${shown}</pre></details>`} |
| 139 | <p class="talk-ask-left small muted">${WAITS}</p> | |
| 140 | <div class="talk-ask-acts"> | |
| 139 | <p class="talk-confirm-left small muted">${WAITS}</p> | |
| 140 | <div class="talk-confirm-acts"> | |
| 141 | 141 | <button type="submit" class="btn" data-variant="primary" formaction="${once ? `/settings/confirms/${id}` : `${HERE}/confirm/${id}`}" formnovalidate name="answer" value="yes"${once ? null : raw(" data-answer")}>${icon("check")} Do it</button> |
| 142 | 142 | <button type="submit" class="btn" data-variant="ghost" formaction="${HERE}/confirm/${id}" formnovalidate name="answer" value="no" data-answer>Not now</button> |
| 143 | 143 | </div> |
| @@ -148,20 +148,20 @@ export function askItem(id: string, tool: string, does: string, expiresAt: strin | ||
| 148 | 148 | * What waits on the person in this conversation, docked directly above the composer: always in |
| 149 | 149 | * view, never in the thread. One shows whole; several are a count and a stack, the first open. |
| 150 | 150 | */ |
| 151 | function asksDock(asks: Html[]): Html { | |
| 152 | return html`<div class="talk-asks" data-asks role="region" aria-label="Waiting for your answer"${asks.length === 0 ? raw(" hidden") : null}${asks.length > 1 ? raw(" data-many") : null}> | |
| 153 | <p class="talk-asks-count small muted" data-asks-count>${asks.length > 1 ? `${asks.length} waiting` : ""}</p> | |
| 154 | <div class="talk-ask-list">${asks}</div> | |
| 151 | function confirmsDock(held: Html[]): Html { | |
| 152 | return html`<div class="talk-confirms" data-confirms role="region" aria-label="Waiting for your answer"${held.length === 0 ? raw(" hidden") : null}${held.length > 1 ? raw(" data-many") : null}> | |
| 153 | <p class="talk-confirms-count small muted" data-confirms-count>${held.length > 1 ? `${held.length} waiting` : ""}</p> | |
| 154 | <div class="talk-confirm-list">${held}</div> | |
| 155 | 155 | </div>`; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | /** The asks still waiting among these turns, in order, drawn for the dock. */ | |
| 159 | const asksOf = (turns: readonly Turn[], waiting: readonly Waiting[]): Html[] => | |
| 158 | /** The confirms still waiting among these turns, in order, drawn for the dock. */ | |
| 159 | const confirmsOf = (turns: readonly Turn[], waiting: readonly Waiting[]): Html[] => | |
| 160 | 160 | turns.flatMap((t) => { |
| 161 | 161 | if (t.role !== "confirm" || t.replaced) return []; |
| 162 | 162 | const d = parse(t.text); |
| 163 | 163 | const w = waiting.find((x) => x.id === String(d?.["confirm"] ?? "")); |
| 164 | return w === undefined ? [] : [askItem(w.id, w.tool, typeof d?.["does"] === "string" ? d["does"] : w.does, w.expiresAt, typeof d?.["shown"] === "string" ? d["shown"] : "")]; | |
| 164 | return w === undefined ? [] : [confirmItem(w.id, w.tool, typeof d?.["does"] === "string" ? d["does"] : w.does, w.expiresAt, typeof d?.["shown"] === "string" ? d["shown"] : "")]; | |
| 165 | 165 | }); |
| 166 | 166 | |
| 167 | 167 | /** The turns a page holds that say they undid another: those receipts have no Undo left. */ |
| @@ -291,7 +291,14 @@ export function foldSteps(open: boolean, turns: readonly Html[]): Html[] { | ||
| 291 | 291 | |
| 292 | 292 | /** The quiet steps line and the links to what the turn opened or changed, under its reply. */ |
| 293 | 293 | const workHtml = (work: Work): Html => |
| 294 | html`<p class="talk-steps small muted">${work.steps.charAt(0).toUpperCase() + work.steps.slice(1)}</p>${work.links.length === 0 ? null : html`<p class="talk-links small">${work.links.map((l) => html`<a href="${l.href}">${l.label}</a>`)}</p>`}`; | |
| 294 | html`<p class="talk-steps small muted">${work.steps.charAt(0).toUpperCase() + work.steps.slice(1)}</p>${work.links.length === 0 ? null : linksFold(work.links)}`; | |
| 295 | ||
| 296 | /** What a turn opened or changed, folded behind its count; a file named by its path in its repository. */ | |
| 297 | const linksFold = (links: Work["links"]): Html => { | |
| 298 | const files = links.every((l) => l.href.includes("/blob/")); | |
| 299 | const n = links.length; | |
| 300 | return html`<details class="talk-links small"><summary>${n} ${files ? (n === 1 ? "file" : "files") : n === 1 ? "link" : "links"}</summary><p>${links.map((l) => html`<a href="${l.href}" title="${l.label}">${l.href.includes("/blob/") ? l.label.replace(/^[^/\s]+\/[^/\s]+\//, "") : l.label}</a>`)}</p></details>`; | |
| 301 | }; | |
| 295 | 302 | |
| 296 | 303 | /** Ask again as a form, so it works without the script; the script only enhances it. */ |
| 297 | 304 | const againForm = (base: string, how: "regenerate" | "retry", label: string, words: string, turn?: string): Html => |
| @@ -373,7 +380,7 @@ export function turnHtml(turn: Turn, waiting: ReadonlySet<string>, cost?: Spend, | ||
| 373 | 380 | </li>`; |
| 374 | 381 | const data = parse(turn.text); |
| 375 | 382 | const thought = thinkingOf(turn); |
| 376 | // An ask waits in the dock, not here; once answered, the thread keeps its outcome (the receipt, | |
| 383 | // A confirm waits in the dock, not here; once answered, the thread keeps its outcome (the receipt, | |
| 377 | 384 | // or Not now) in the place it happened. Only one that ran out says so here, with the way on. |
| 378 | 385 | if (turn.role === "confirm") { |
| 379 | 386 | const confirm = String(data?.["confirm"] ?? ""); |
| @@ -542,7 +549,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string | | ||
| 542 | 549 | const turns = listed.ok ? listed.value : []; |
| 543 | 550 | const waitingList = waitingConfirms(ctx, user); |
| 544 | 551 | const waiting = new Set(waitingList.map((w) => w.id)); |
| 545 | const asks = asksOf(turns, waitingList); | |
| 552 | const pendingConfirms = confirmsOf(turns, waitingList); | |
| 546 | 553 | const expired = ranOutOf(ctx, user.id, turns); |
| 547 | 554 | const undone = undoneIn(turns); |
| 548 | 555 | const sent = filesOfTurns(ctx.app.db, user.id, turns.filter((t) => t.role === "person").map((t) => t.id)); |
| @@ -581,12 +588,13 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string | | ||
| 581 | 588 | const builtRepo = buildRow === undefined ? undefined : getRepoById(ctx.app.db, buildRow.repoId); |
| 582 | 589 | const v = Number(ctx.url.searchParams.get("v") ?? ""); |
| 583 | 590 | const wait = panel === null ? undefined : pending ? "Starting the preview…" : undefined; |
| 584 | const idle = panel === null ? undefined : running ? "Making the first version…" : "Your app appears here as soon as the first change is made."; | |
| 591 | const idle = panel === null ? undefined : running ? "Making the first version. The preview shows here once it is built, and each version after it reloads in place." : "Your app shows here once its first version is made: say what to change and the crew makes it. Below are the files it starts from."; | |
| 585 | 592 | const pane = await talkPane(ctx, user, builtRepo === undefined ? cited : `${builtRepo.ownerName}/${builtRepo.name}`, works, view, undefined, { |
| 586 | 593 | ...(buildRow === undefined ? {} : { build: buildRow }), |
| 587 | 594 | ...(Number.isInteger(v) && v > 0 ? { version: v } : {}), |
| 588 | 595 | ...(wait === undefined ? {} : { wait }), |
| 589 | 596 | ...(idle === undefined ? {} : { idle }), |
| 597 | busy: pending || running, | |
| 590 | 598 | }); |
| 591 | 599 | // A tab asks for the pane alone, so it swaps in place without the page. |
| 592 | 600 | if (ctx.url.searchParams.get("fragment") === "pane") return fragment(pane.html, { request: ctx.request }); |
| @@ -621,8 +629,8 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string | | ||
| 621 | 629 | ${about} |
| 622 | 630 | ${editing === undefined && about !== null ? html`<input type="hidden" name="about" value="${ctx.url.searchParams.get("about")}" />` : null} |
| 623 | 631 | ${chosen === undefined ? null : html`<input type="hidden" name="template" value="${chosen}" />`} |
| 624 | ${asksDock(asks)} | |
| 625 | <p class="sr-only" role="status" data-asks-said></p> | |
| 632 | ${confirmsDock(pendingConfirms)} | |
| 633 | <p class="sr-only" role="status" data-confirms-said></p> | |
| 626 | 634 | <div class="talk-box"> |
| 627 | 635 | <div class="talk-chips" data-chips role="group" aria-label="Attached files"></div> |
| 628 | 636 | <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> |
| @@ -945,8 +953,8 @@ export function talkStream(ctx: Ctx): Response { | ||
| 945 | 953 | const look = talkLook(app.db, user, fresh.filter((t) => t.role === "agent").map((t) => t.text), appLook(app, user)); |
| 946 | 954 | for (const turn of fresh) { |
| 947 | 955 | // A frame lands in a page whose sprite is its own: its icons are drawn inline (`inlineIcons`). |
| 948 | const ask = asksOf([turn], waitingList)[0]; | |
| 949 | 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), ...(ask === undefined ? {} : { ask: inlineIcons(ask.text) }) }, turn.id); | |
| 956 | const held = confirmsOf([turn], waitingList)[0]; | |
| 957 | 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), ...(held === undefined ? {} : { held: inlineIcons(held.text) }) }, turn.id); | |
| 950 | 958 | cursor = turn.id; |
| 951 | 959 | } |
| 952 | 960 | // The page is told at once what the block holds after these turns, empty once it is |
src/web/pages/talk_client.ts +80 −56
| @@ -87,12 +87,18 @@ body:has(.talk-page) .foot { display: none; } | ||
| 87 | 87 | .talk-tabs { flex: none; } |
| 88 | 88 | [data-split] .talk-head > form { display: none; } |
| 89 | 89 | .talk-tabs a { min-height: 2.75rem; display: inline-flex; align-items: center; } |
| 90 | .talk-chats { display: grid; gap: 8px; } | |
| 90 | .talk-body table { display: block; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; background: linear-gradient(to right, var(--bg) 30%, transparent) left / 24px 100% no-repeat local, linear-gradient(to left, var(--bg) 30%, transparent) right / 24px 100% no-repeat local, linear-gradient(to right, var(--border-strong), transparent) left / 8px 100% no-repeat scroll, linear-gradient(to left, var(--border-strong), transparent) right / 8px 100% no-repeat scroll; } | |
| 91 | .talk-body :is(td, th) { overflow-wrap: normal; word-break: normal; } | |
| 92 | .talk-body td code { white-space: nowrap; } | |
| 93 | .talk-display-sheet .dialog-body { display: grid; gap: 12px; } | |
| 94 | .talk-chats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; } | |
| 91 | 95 | .talk-new { width: 100%; justify-content: flex-start; min-height: 2.75rem; } |
| 92 | 96 | .talk-find .input { width: 100%; font-size: 16px; } |
| 93 | 97 | .talk-chats .list { margin: 0; } |
| 94 | 98 | .talk-chats .row { min-height: 2.75rem; border-radius: var(--radius-sm); } |
| 95 | .talk-chats :is(.row-meta, .row-title) { overflow-wrap: anywhere; } | |
| 99 | .talk-chats .row-main { min-width: 0; } | |
| 100 | .talk-chats .row-title { overflow: hidden; text-overflow: ellipsis; } | |
| 101 | .talk-chats .row-meta { overflow-wrap: anywhere; } | |
| 96 | 102 | .talk-chats .row-meta { font-variant-numeric: tabular-nums; } |
| 97 | 103 | .talk-archived { padding: 8px; } |
| 98 | 104 | @media (min-width: 56.25rem) { |
| @@ -113,6 +119,7 @@ body:has(.talk-page) .foot { display: none; } | ||
| 113 | 119 | [data-split] .talk-work { display: block; position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; padding-block: 12px; padding-inline: 16px 0; border-inline-start: 1px solid var(--border); } |
| 114 | 120 | } |
| 115 | 121 | .talk-work { min-width: 0; } |
| 122 | .talk:has(form[data-answering]) .talk-log { padding-bottom: calc(2.75rem + 24px); } | |
| 116 | 123 | .talk-log { list-style: none; margin: 0; padding: 8px 0 4px; display: grid; gap: 16px; align-content: end; flex: 1; min-width: 0; font-size: 15px; line-height: 1.65; } |
| 117 | 124 | .talk-turn { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; } |
| 118 | 125 | .talk-turn p { margin: 0 0 8px; } |
| @@ -141,18 +148,23 @@ body:has(.talk-page) .foot { display: none; } | ||
| 141 | 148 | @media (prefers-reduced-motion: no-preference) { |
| 142 | 149 | .talk:not([data-motion=reduced]) :is(.talk-log > [data-in], .talk-fold-list > [data-in], .talk-jump:not([hidden])) { animation: talk-in var(--dur-3) var(--ease); } |
| 143 | 150 | .talk:not([data-motion=reduced]) .talk-live [data-in] { animation: talk-fade var(--dur-3) var(--ease); } |
| 144 | .talk:not([data-motion=reduced]) .talk-ask[data-in] { animation: talk-in var(--dur-3) var(--ease); } | |
| 145 | .talk:not([data-motion=reduced]) .talk-asks { transition: height var(--dur-3) var(--ease), padding var(--dur-3) var(--ease); } | |
| 146 | .talk:not([data-motion=reduced]) .talk-ask[data-out] { transition: opacity var(--dur-2) var(--ease); } | |
| 151 | .talk:not([data-motion=reduced]) .talk-confirm[data-in] { animation: talk-in var(--dur-3) var(--ease); } | |
| 152 | .talk:not([data-motion=reduced]) .talk-confirms { transition: height var(--dur-3) var(--ease), padding var(--dur-3) var(--ease); } | |
| 153 | .talk:not([data-motion=reduced]) .talk-confirm[data-out] { transition: opacity var(--dur-2) var(--ease); } | |
| 147 | 154 | .talk-versions [data-in] { animation: talk-in var(--dur-3) var(--ease); } |
| 148 | 155 | } |
| 149 | 156 | .talk[data-motion=reduced] :is(*, ::before, ::after) { animation: none !important; transition: none !important; } |
| 150 | 157 | .talk-person > .talk-body { min-width: 0; max-width: min(calc(100% - 4.5rem), 36rem); padding: 8px 16px; border-radius: 18px; background: var(--muted); white-space: pre-wrap; } |
| 151 | 158 | .talk-agent > .talk-body, .talk-person > .talk-body + .talk-files, .talk-agent > .talk-steps { flex: 1 0 100%; } |
| 152 | .talk-agent > .talk-links { order: 1; margin: 0; margin-inline-end: 8px; font-size: 12.5px; } | |
| 159 | .talk-agent > .talk-links { order: 2; margin: 0; font-size: 12.5px; color: var(--muted-fg); } | |
| 160 | .talk-links > summary { cursor: pointer; min-height: 2rem; display: inline-flex; align-items: center; } | |
| 161 | .talk-links[open] { flex-basis: 100%; } | |
| 162 | .talk-links > p { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; } | |
| 163 | .talk-agent > .talk-body { margin-bottom: 16px; } | |
| 164 | .talk-agent { column-gap: 12px; } | |
| 153 | 165 | .talk-links a { color: var(--muted-fg); } |
| 154 | .talk-agent > .talk-cost { order: 1; margin: 0; margin-inline-end: 8px; font-size: 12.5px; } | |
| 155 | .talk-agent > .talk-acts { order: 2; } | |
| 166 | .talk-agent > .talk-cost { order: 1; margin: 0; font-size: 12.5px; } | |
| 167 | .talk-agent > .talk-acts { order: 3; } | |
| 156 | 168 | .talk-agent > .talk-body { max-width: 100%; } |
| 157 | 169 | .talk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; font-size: 12.5px; } |
| 158 | 170 | .talk-turn > :is(.talk-meta, .talk-links, .talk-cost) { margin-block: 0; } |
| @@ -176,26 +188,24 @@ body:has(.talk-page) .foot { display: none; } | ||
| 176 | 188 | .talk-fold > details > summary:hover { color: var(--fg); } |
| 177 | 189 | .talk-fold-list { list-style: none; margin: 0; margin-inline-start: 8px; padding: 0; padding-inline-start: 12px; border-inline-start: 2px solid var(--border); display: grid; gap: 2px; } |
| 178 | 190 | .talk-steps { margin: 4px 0 0; } |
| 179 | .talk-live .talk-steps:last-child, .talk-status:not(:empty), .talk-stage-note { background: linear-gradient(90deg, var(--muted-fg) 40%, var(--fg) 50%, var(--muted-fg) 60%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: talk-shine 2s linear infinite; } | |
| 191 | .talk-live .talk-steps:last-child, .talk-status:not(:empty), .talk-stage[data-busy] .talk-stage-note { background: linear-gradient(90deg, var(--muted-fg) 40%, var(--fg) 50%, var(--muted-fg) 60%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: talk-shine 2s linear infinite; } | |
| 180 | 192 | @keyframes talk-shine { from { background-position: 100% 0; } to { background-position: 0 0; } } |
| 181 | @media (prefers-reduced-motion: reduce) { .talk-live .talk-steps:last-child, .talk-status:not(:empty), .talk-stage-note { animation: none; color: var(--muted-fg); background: none; } } | |
| 182 | .talk-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 2px 0 0; font-size: 13px; } | |
| 183 | .talk-confirm { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); } | |
| 184 | .talk-asks { display: grid; align-content: start; gap: 4px; padding-bottom: 8px; overflow: hidden; } | |
| 185 | .talk-asks[data-out] { padding-bottom: 0; } | |
| 186 | .talk-asks[hidden], .talk-asks-count:empty { display: none; } | |
| 187 | .talk-asks-count { margin: 0; padding-inline: 4px; } | |
| 188 | .talk-ask-list { display: grid; gap: 4px; } | |
| 189 | .talk-asks[data-many] .talk-ask-list { max-height: 33dvh; overflow-y: auto; overscroll-behavior: contain; } | |
| 190 | .talk-ask { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); } | |
| 191 | .talk-ask-does, .talk-ask-left { margin: 0; } | |
| 192 | .talk-ask-does { font-size: 15px; } | |
| 193 | .talk-ask-acts { display: flex; flex-wrap: wrap; gap: 8px; } | |
| 194 | .talk-ask-acts .btn { min-height: 2.75rem; } | |
| 195 | .talk-ask[data-out] { opacity: 0; } | |
| 196 | .talk-asks[data-many] .talk-ask:not(:first-child) { padding-block: 8px; } | |
| 197 | .talk-asks[data-many] .talk-ask:not(:first-child) .talk-ask-does { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; color: var(--muted-fg); } | |
| 198 | .talk-asks[data-many] .talk-ask:not(:first-child) :is(.talk-ask-acts, .talk-ask-left) { display: none; } | |
| 193 | @media (prefers-reduced-motion: reduce) { .talk-live .talk-steps:last-child, .talk-status:not(:empty), .talk-stage[data-busy] .talk-stage-note { animation: none; color: var(--muted-fg); background: none; } } | |
| 194 | .talk-confirms { display: grid; align-content: start; gap: 4px; padding-bottom: 8px; overflow: hidden; } | |
| 195 | .talk-confirms[data-out] { padding-bottom: 0; } | |
| 196 | .talk-confirms[hidden], .talk-confirms-count:empty { display: none; } | |
| 197 | .talk-confirms-count { margin: 0; padding-inline: 4px; } | |
| 198 | .talk-confirm-list { display: grid; gap: 4px; } | |
| 199 | .talk-confirms[data-many] .talk-confirm-list { max-height: 33dvh; overflow-y: auto; overscroll-behavior: contain; } | |
| 200 | .talk-confirm { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); } | |
| 201 | .talk-confirm-does, .talk-confirm-left { margin: 0; } | |
| 202 | .talk-confirm-does { font-size: 15px; } | |
| 203 | .talk-confirm-acts { display: flex; flex-wrap: wrap; gap: 8px; } | |
| 204 | .talk-confirm-acts .btn { min-height: 2.75rem; } | |
| 205 | .talk-confirm[data-out] { opacity: 0; } | |
| 206 | .talk-confirms[data-many] .talk-confirm:not(:first-child) { padding-block: 8px; } | |
| 207 | .talk-confirms[data-many] .talk-confirm:not(:first-child) .talk-confirm-does { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; color: var(--muted-fg); } | |
| 208 | .talk-confirms[data-many] .talk-confirm:not(:first-child) :is(.talk-confirm-acts, .talk-confirm-left) { display: none; } | |
| 199 | 209 | .talk-fold[data-dones] summary > .ico { margin-inline-end: 8px; vertical-align: -3px; color: var(--muted-fg); } |
| 200 | 210 | .talk:has(.talk-hello) .talk-log { flex: 0; margin-top: auto; } |
| 201 | 211 | .talk:has(.talk-hello) .talk-compose { position: static; margin-bottom: auto; padding-bottom: 32px; } |
| @@ -228,7 +238,7 @@ body:has(.talk-page) .foot { display: none; } | ||
| 228 | 238 | [data-answering] .talk-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } |
| 229 | 239 | .talk-error { margin: 6px 4px 0; color: var(--danger); } |
| 230 | 240 | .talk-error[hidden] { display: none; } |
| 231 | .talk-jump { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); min-height: 2.75rem; border-radius: 999px; box-shadow: var(--shadow-2); gap: 6px; } | |
| 241 | .talk-jump { position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); min-height: 2.75rem; border-radius: 999px; box-shadow: var(--shadow-2); gap: 6px; } | |
| 232 | 242 | .talk-jump[data-follow="pause"] .ico + .ico, .talk-jump:not([data-follow="pause"]) .ico:first-child, .talk-jump:not([data-new]) .talk-dot { display: none; } |
| 233 | 243 | .talk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); } |
| 234 | 244 | .talk-code { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; } |
| @@ -470,7 +480,7 @@ if (root) { | ||
| 470 | 480 | grown = h; |
| 471 | 481 | draw(); |
| 472 | 482 | }); |
| 473 | for (const el of [root, log, form, ...root.children]) sizes.observe(el); | |
| 483 | for (const el of [root, log, form, ...root.children]) sizes.observe(el, { box: "border-box" }); | |
| 474 | 484 | document.addEventListener("scroll", (e) => { |
| 475 | 485 | const s = sc(); |
| 476 | 486 | if (e.target !== s && !(e.target === document && s === page)) return; |
| @@ -633,8 +643,8 @@ if (root) { | ||
| 633 | 643 | answering = on; |
| 634 | 644 | form.toggleAttribute("data-answering", on); |
| 635 | 645 | paint(); |
| 636 | // The composer just changed (Steer and Stop, a row that wraps): a follower stays at the end | |
| 637 | // now, in this task, rather than for a frame until the size observer catches up. | |
| 646 | // The composer and the thread's end strip just changed: a follower stays at the end now, in | |
| 647 | // this task, rather than for a frame until the size observer catches up. | |
| 638 | 648 | if (stuck) toEnd(); |
| 639 | 649 | draw(); |
| 640 | 650 | }; |
| @@ -675,7 +685,7 @@ if (root) { | ||
| 675 | 685 | source.addEventListener("turn", (e) => { |
| 676 | 686 | const turn = JSON.parse(e.data); |
| 677 | 687 | last = turn.id; |
| 678 | if (turn.ask) addAsk(turn.ask); | |
| 688 | if (turn.held) addConfirm(turn.held); | |
| 679 | 689 | if (!document.getElementById("t-" + turn.id)) { |
| 680 | 690 | place(turn.html); |
| 681 | 691 | decorate(log); |
| @@ -729,37 +739,37 @@ if (root) { | ||
| 729 | 739 | if (r && !e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); talkTo(r.dataset.reply, r.dataset.replyTo); } |
| 730 | 740 | if (e.target.closest && e.target.closest("[data-to-off]")) talkTo("", ""); |
| 731 | 741 | }); |
| 732 | // The dock: what waits on the person, above the composer. An answered ask collapses out of it | |
| 742 | // The dock: what waits on the person, above the composer. An answered confirm collapses out of it | |
| 733 | 743 | // (instantly where motion is reduced) and its outcome arrives in the thread as a turn. |
| 734 | const dock = form.querySelector("[data-asks]"), asks = dock.querySelector(".talk-ask-list"), said = form.querySelector("[data-asks-said]"); | |
| 744 | const dock = form.querySelector("[data-confirms]"), pending = dock.querySelector(".talk-confirm-list"), said = form.querySelector("[data-confirms-said]"); | |
| 735 | 745 | const tell = (words) => { said.textContent = words; }; |
| 736 | 746 | // The stream is read again only to bring the answer's outcome: its end says nothing. |
| 737 | 747 | let hush = false; |
| 738 | const countAsks = () => { | |
| 739 | const n = asks.children.length; | |
| 748 | const countConfirms = () => { | |
| 749 | const n = pending.children.length; | |
| 740 | 750 | dock.hidden = !n; |
| 741 | 751 | dock.toggleAttribute("data-many", n > 1); |
| 742 | dock.querySelector("[data-asks-count]").textContent = n > 1 ? n + " waiting" : ""; | |
| 743 | for (const a of asks.children) timeLeft(a); | |
| 752 | dock.querySelector("[data-confirms-count]").textContent = n > 1 ? n + " waiting" : ""; | |
| 753 | for (const a of pending.children) timeLeft(a); | |
| 744 | 754 | }; |
| 745 | 755 | // The time left is said once it is under two minutes, by one timeout per confirm set for that |
| 746 | 756 | // moment and for its end: never a clock that ticks. |
| 747 | 757 | const timeLeft = (a) => { |
| 748 | 758 | if (a.dataset.timed) return; |
| 749 | 759 | a.dataset.timed = "1"; |
| 750 | const end = Date.parse(a.dataset.expires), p = a.querySelector(".talk-ask-left"); | |
| 760 | const end = Date.parse(a.dataset.expires), p = a.querySelector(".talk-confirm-left"); | |
| 751 | 761 | const tell = (words, over) => { if (!a.isConnected) return; p.hidden = false; p.textContent = words; if (over) a.querySelectorAll("button").forEach((b) => { b.disabled = true; }); }; |
| 752 | 762 | setTimeout(() => tell("Less than 2 minutes left.", false), Math.max(0, end - 120000 - Date.now())); |
| 753 | 763 | setTimeout(() => tell("This ran out: nothing was done.", true), Math.max(0, end - Date.now())); |
| 754 | 764 | }; |
| 755 | // The dock moves once, from the height it had to the one it has now (the next ask opened, or | |
| 765 | // The dock moves once, from the height it had to the one it has now (the next confirm opened, or | |
| 756 | 766 | // none left), so the thread above glides with it and never jumps. Reduced motion: at once. |
| 757 | const dropAsk = (a) => { | |
| 758 | const from = dock.offsetHeight, last = asks.children.length === 1; | |
| 759 | if (last) { a.setAttribute("data-out", ""); dock.setAttribute("data-out", ""); } else { a.remove(); countAsks(); } | |
| 767 | const dropConfirm = (a) => { | |
| 768 | const from = dock.offsetHeight, last = pending.children.length === 1; | |
| 769 | if (last) { a.setAttribute("data-out", ""); dock.setAttribute("data-out", ""); } else { a.remove(); countConfirms(); } | |
| 760 | 770 | const to = last ? 0 : dock.offsetHeight; |
| 761 | 771 | let over = false; |
| 762 | const done = () => { if (over) return; over = true; dock.style.height = ""; dock.removeAttribute("data-out"); if (last) { a.remove(); countAsks(); } }; | |
| 772 | const done = () => { if (over) return; over = true; dock.style.height = ""; dock.removeAttribute("data-out"); if (last) { a.remove(); countConfirms(); } }; | |
| 763 | 773 | dock.style.height = from + "px"; |
| 764 | 774 | const glide = (parseFloat(window.getComputedStyle(dock).transitionDuration) || 0) * 1000; |
| 765 | 775 | if (!glide || from === to) return done(); |
| @@ -769,20 +779,20 @@ if (root) { | ||
| 769 | 779 | const end = (e) => { if (e.target === dock && e.propertyName === "height") { dock.removeEventListener("transitionend", end); done(); } }; |
| 770 | 780 | dock.addEventListener("transitionend", end); |
| 771 | 781 | }; |
| 772 | const addAsk = (markup) => { | |
| 782 | const addConfirm = (markup) => { | |
| 773 | 783 | const t = document.createElement("template"); |
| 774 | 784 | t.innerHTML = markup.trim(); |
| 775 | 785 | const a = t.content.firstElementChild; |
| 776 | if (!a || asks.querySelector('[data-ask="' + a.dataset.ask + '"]')) return; | |
| 786 | if (!a || pending.querySelector('[data-confirm-id="' + a.dataset.confirmId + '"]')) return; | |
| 777 | 787 | a.setAttribute("data-in", ""); |
| 778 | asks.append(a); | |
| 779 | countAsks(); | |
| 780 | tell("Waiting for your answer: " + a.querySelector(".talk-ask-does").textContent); | |
| 788 | pending.append(a); | |
| 789 | countConfirms(); | |
| 790 | tell("Waiting for your answer: " + a.querySelector(".talk-confirm-does").textContent); | |
| 781 | 791 | }; |
| 782 | const answerAsk = async (b) => { | |
| 783 | const a = b.closest(".talk-ask"), yes = b.value === "yes", buttons = a.querySelectorAll("button"); | |
| 784 | // Said without a visible line, so answering moves nothing; a refusal is said on the ask itself. | |
| 785 | const refused = (why) => { const p = a.querySelector(".talk-ask-left"); p.hidden = false; p.textContent = why; tell(why); buttons.forEach((x) => { x.disabled = false; }); }; | |
| 792 | const answerConfirm = async (b) => { | |
| 793 | const a = b.closest(".talk-confirm"), yes = b.value === "yes", buttons = a.querySelectorAll("button"); | |
| 794 | // Said without a visible line, so answering moves nothing; a refusal is said on the confirm itself. | |
| 795 | const refused = (why) => { const p = a.querySelector(".talk-confirm-left"); p.hidden = false; p.textContent = why; tell(why); buttons.forEach((x) => { x.disabled = false; }); }; | |
| 786 | 796 | buttons.forEach((x) => { x.disabled = true; }); |
| 787 | 797 | try { |
| 788 | 798 | const res = await fetch(b.getAttribute("formaction"), { method: "POST", headers: { accept: "application/json" }, body: new URLSearchParams({ answer: b.value }) }); |
| @@ -790,14 +800,14 @@ if (root) { | ||
| 790 | 800 | if (res.status === 410) { window.location.reload(); return; } |
| 791 | 801 | if (!res.ok) return refused(out.message || "Nothing was done."); |
| 792 | 802 | tell(yes ? "Done." : "Not now: nothing was done."); |
| 793 | dropAsk(a); | |
| 803 | dropConfirm(a); | |
| 794 | 804 | hush = !paged; |
| 795 | 805 | follow(); |
| 796 | 806 | } catch (_) { |
| 797 | 807 | refused("That was not sent: no connection."); |
| 798 | 808 | } |
| 799 | 809 | }; |
| 800 | countAsks(); | |
| 810 | countConfirms(); | |
| 801 | 811 | const picker = form.querySelector("[data-files]"); |
| 802 | 812 | const attach = form.querySelector("[data-attach]"); |
| 803 | 813 | if (attach) { attach.hidden = false; attach.addEventListener("click", () => picker.click()); } |
| @@ -845,7 +855,7 @@ ${dictateJs} | ||
| 845 | 855 | }); |
| 846 | 856 | const send = async (e) => { |
| 847 | 857 | const by = e.submitter; |
| 848 | if (by && by.hasAttribute("formaction")) { if (by.hasAttribute("data-answer")) { e.preventDefault(); answerAsk(by); } return; } | |
| 858 | if (by && by.hasAttribute("formaction")) { if (by.hasAttribute("data-answer")) { e.preventDefault(); answerConfirm(by); } return; } | |
| 849 | 859 | if (form.hasAttribute("data-build")) { clearTimeout(draftTimer); draft.save(""); return; } |
| 850 | 860 | e.preventDefault(); |
| 851 | 861 | hush = false; |
| @@ -1054,6 +1064,20 @@ ${dictateJs} | ||
| 1054 | 1064 | f.addEventListener("load", () => clearTimeout(late), { once: true }); |
| 1055 | 1065 | }; |
| 1056 | 1066 | document.querySelectorAll("[data-frame]").forEach(watchFrame); |
| 1067 | // Display opens as its own small dialog, every choice in view; the menu closes behind it. | |
| 1068 | document.addEventListener("click", (e) => { | |
| 1069 | const s = e.target.closest && e.target.closest(".talk-display > summary"); | |
| 1070 | if (!s || !window.forgeOverlay) return; | |
| 1071 | e.preventDefault(); | |
| 1072 | const box = s.parentElement, f = box.querySelector("form"), menu = s.closest("details[open]:not(.talk-display)"), opener = menu ? menu.querySelector("summary") : s; | |
| 1073 | if (menu) menu.open = false; | |
| 1074 | const d = Object.assign(document.createElement("dialog"), { className: "dialog talk-display-sheet", innerHTML: '<div class="dialog-head"><h2 id="talk-display-title">Display</h2></div><div class="dialog-body"></div><div class="dialog-foot"><form method="dialog"><button class="btn" type="submit">Close</button></form></div>' }); | |
| 1075 | d.setAttribute("aria-labelledby", "talk-display-title"); | |
| 1076 | d.querySelector(".dialog-body").append(f); | |
| 1077 | document.body.append(d); | |
| 1078 | d.addEventListener("close", () => { box.append(f); d.remove(); }); | |
| 1079 | window.forgeOverlay.open(d, { opener, name: "display" }); | |
| 1080 | }); | |
| 1057 | 1081 | codePane(); |
| 1058 | 1082 | } |
| 1059 | 1083 | `; |
src/web/pages/talk_preview.ts +6 −2
| @@ -39,6 +39,8 @@ export interface PaneAsk { | ||
| 39 | 39 | readonly version?: number; |
| 40 | 40 | readonly wait?: string; |
| 41 | 41 | readonly idle?: string; |
| 42 | /** Something is under way (a preview starting, a first version being made): its words shimmer. */ | |
| 43 | readonly busy?: boolean; | |
| 42 | 44 | } |
| 43 | 45 | |
| 44 | 46 | export async function talkPane(ctx: Ctx, user: User, name: string | undefined, works: ReadonlyMap<string, Work>, view: View = "preview", apps?: Apps, ask: PaneAsk = {}): Promise<Pane> { |
| @@ -60,7 +62,7 @@ export async function talkPane(ctx: Ctx, user: User, name: string | undefined, w | ||
| 60 | 62 | : view === "diff" |
| 61 | 63 | ? await diffView(ctx.app, work, ask.version) |
| 62 | 64 | : url === undefined || ask.wait !== undefined |
| 63 | ? html`<div class="talk-stage talk-stage-wait" data-stage><p class="talk-stage-note small" data-stage-note>${ask.wait ?? ask.idle ?? "Nothing is running yet: the app appears here once it is built."}</p></div>` | |
| 65 | ? html`<div class="talk-stage talk-stage-wait" data-stage${ask.busy === true ? raw(" data-busy") : null}><p class="talk-stage-note" data-stage-note>${ask.wait ?? ask.idle ?? "Nothing is running yet: the app appears here once it is built."}</p></div>${ask.build === undefined ? null : html`<h2 class="talk-stage-files small muted">The files it starts from</h2>${await codeView(ctx.app, work)}`}` | |
| 64 | 66 | : html`<div class="talk-stage" data-stage><iframe class="talk-frame" data-frame src="${url}" title="Live preview of ${name}" referrerpolicy="no-referrer" sandbox="allow-scripts allow-same-origin allow-forms allow-popups"></iframe><p class="talk-stage-note small" data-stage-note hidden>Updating the preview…</p></div>`; |
| 65 | 67 | // The address bar of what runs: which environment, where it lives, reload and open on its own. |
| 66 | 68 | const where = url === undefined ? null : html`<span class="talk-addr small" title="${url}"><span class="muted">${pull === undefined ? "Production" : `Pull #${String(pull)}`}</span> ${new URL(url).host}</span>`; |
| @@ -90,7 +92,9 @@ export const paneCss = /* css */ ` | ||
| 90 | 92 | .talk-frame { display: block; width: 100%; height: calc(100dvh - 14rem); min-height: 24rem; border: 0; transition: opacity var(--dur-3) var(--ease); } |
| 91 | 93 | .talk-stage[data-busy] .talk-frame { opacity: .35; } |
| 92 | 94 | .talk-stage-note { position: absolute; inset: auto 0 45% 0; margin: 0; padding: 0 24px; text-align: center; } |
| 93 | .talk-stage-wait { height: calc(100dvh - 14rem); min-height: 24rem; } | |
| 95 | .talk-stage-wait { padding: 16px; } | |
| 96 | .talk-stage-wait .talk-stage-note { position: static; padding: 0; text-align: start; } | |
| 97 | .talk-stage-files { margin: 16px 0 8px; font-size: 12.5px; font-weight: 600; } | |
| 94 | 98 | .talk-stage-note[hidden] { display: none; } |
| 95 | 99 | @media (max-width: 30rem) { .talk-addr { display: none; } } |
| 96 | 100 | @media (prefers-reduced-motion: reduce) { .talk-frame { transition: none; } } |
src/web/talk_build.ts +7 −7
| @@ -63,6 +63,11 @@ export function buildPanel(state: BuildState, base: string, chosen: number | und | ||
| 63 | 63 | <div class="talk-build-head"> |
| 64 | 64 | <strong class="talk-build-name">${state.repoName}</strong> |
| 65 | 65 | ${state.published ? badge("Published", { tone: "success" }) : env === undefined ? html`<span class="small muted">${newest === undefined ? "No version yet" : "Preview on its way"}</span>` : envStateBadge(env)} |
| 66 | ${state.versions.length === 0 | |
| 67 | ? null | |
| 68 | : html`<nav class="talk-versions" aria-label="Versions">${state.versions.map( | |
| 69 | (v) => html`<a class="btn" data-size="sm" href="${base}?v=${v.number}"${v.number === shown ? html` aria-current="true"` : null} title="${v.subject}">v${v.number}</a>`, | |
| 70 | )}</nav>`} | |
| 66 | 71 | <span class="spacer"></span> |
| 67 | 72 | ${state.published |
| 68 | 73 | ? state.productionUrl === null |
| @@ -72,11 +77,6 @@ export function buildPanel(state: BuildState, base: string, chosen: number | und | ||
| 72 | 77 | ? null |
| 73 | 78 | : html`<form method="post" action="${base}/build/publish">${btn("Publish", { variant: "primary", icon: "rocket", label: "Publish: merge to main and deploy production" })}</form>`} |
| 74 | 79 | </div> |
| 75 | ${state.versions.length === 0 | |
| 76 | ? null | |
| 77 | : html`<nav class="talk-versions" aria-label="Versions">${state.versions.map( | |
| 78 | (v) => html`<a class="btn" data-size="sm" href="${base}?v=${v.number}"${v.number === shown ? html` aria-current="true"` : null} title="${v.subject}">v${v.number}</a>`, | |
| 79 | )}</nav>`} | |
| 80 | 80 | ${chosen === undefined || diff === undefined |
| 81 | 81 | ? null |
| 82 | 82 | : html`<div class="talk-build-chosen"><p><strong>v${chosen}</strong> ${state.versions.find((v) => v.number === chosen)?.subject ?? ""} <span class="small muted">${time(state.versions.find((v) => v.number === chosen)?.date ?? "")}</span></p> |
| @@ -152,8 +152,8 @@ export async function talkPublish(ctx: Ctx): Promise<Response> { | ||
| 152 | 152 | /** Styles for the box and the panel; added to Talk's own only on a page that draws one. Spacing is the 4px scale. */ |
| 153 | 153 | export const buildCss = /* css */ ` |
| 154 | 154 | .talk-build { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; } |
| 155 | .talk-build-head { display: flex; align-items: center; gap: 8px; min-width: 0; } | |
| 156 | .talk-build-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } | |
| 155 | .talk-build-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; } | |
| 156 | .talk-build-name { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } | |
| 157 | 157 | .talk-versions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; } |
| 158 | 158 | .talk-versions .btn { min-height: 2.75rem; min-width: 2.75rem; justify-content: center; border-radius: 999px; font-variant-numeric: tabular-nums; } |
| 159 | 159 | .talk-versions [aria-current] { background: var(--fg); color: var(--bg); border-color: var(--fg); } |
src/web/talk_code.ts +1
| @@ -197,6 +197,7 @@ export const codePaneCss = ` | ||
| 197 | 197 | .talk-code-files p { display: flex; align-items: center; gap: 8px; min-width: 0; } |
| 198 | 198 | .talk-code-files a, .talk-code-tree a { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 2.75rem; flex: 1; } |
| 199 | 199 | .talk-code-n { flex: none; font-size: 12.5px; font-variant-numeric: tabular-nums; } |
| 200 | .talk-code-tree .ex-dir > summary { color: var(--muted-fg); } | |
| 200 | 201 | .talk-code-tree .ex-file[data-changed]::after { content: "changed"; margin-inline-start: auto; font-size: 11.5px; color: var(--muted-fg); } |
| 201 | 202 | .talk-code-file { display: grid; gap: 8px; min-width: 0; } |
| 202 | 203 | .talk-code-file[hidden], .talk-code[data-open] > :is(.talk-code-changed, .talk-code-tree) { display: none; } |
test/conversation-holds.test.ts +2 −2
| @@ -21,7 +21,7 @@ import { mintViaToken } from "../src/core/via_token.ts"; | ||
| 21 | 21 | import { ASKING, UNDOABLE } from "../src/crew/conversation_confirm.ts"; |
| 22 | 22 | import { ASKED_WRITES_MAX } from "../src/http/mcp/shared.ts"; |
| 23 | 23 | import { serve, type Servers } from "../src/http/server.ts"; |
| 24 | import { ASK_AGAIN, askItem, turnHtml, WAITS } from "../src/web/pages/talk.ts"; | |
| 24 | import { ASK_AGAIN, confirmItem, turnHtml, WAITS } from "../src/web/pages/talk.ts"; | |
| 25 | 25 | import { promote } from "./helpers/members.ts"; |
| 26 | 26 | |
| 27 | 27 | let dataDir: string; |
| @@ -155,7 +155,7 @@ describe("what nobody asked for stays held, with buttons", () => { | ||
| 155 | 155 | for (const t of turns) { |
| 156 | 156 | expect(turnHtml(t, waiting).text).toBe(""); |
| 157 | 157 | const c = listed.find((x) => x.id === JSON.parse(t.text).confirm)!; |
| 158 | const docked = askItem(c.id, c.tool, c.does, c.expiresAt).text; | |
| 158 | const docked = confirmItem(c.id, c.tool, c.does, c.expiresAt).text; | |
| 159 | 159 | expect(docked).toContain(`/talk/confirm/${c.id}`); |
| 160 | 160 | expect(docked).toContain("Do it"); |
| 161 | 161 | expect(docked).toContain("Not now"); |
test/talk-live.test.ts +2 −2
| @@ -838,8 +838,8 @@ describe("a turn stored by another door", () => { | ||
| 838 | 838 | const confirm = await s.until((f) => f.event === "turn" && f.data["role"] === "confirm"); |
| 839 | 839 | // The ask goes to the dock above the composer, whole; the thread draws no copy of it. |
| 840 | 840 | expect(String(confirm.data["html"])).toBe(""); |
| 841 | expect(String(confirm.data["ask"])).toContain("Do it"); | |
| 842 | expect(String(confirm.data["ask"])).toContain("Not now"); | |
| 841 | expect(String(confirm.data["held"])).toContain("Do it"); | |
| 842 | expect(String(confirm.data["held"])).toContain("Not now"); | |
| 843 | 843 | s.close(); |
| 844 | 844 | await s.ended; |
| 845 | 845 | } finally { |
test/talk-page.test.ts +81 −39
| @@ -290,6 +290,35 @@ describe("the page", () => { | ||
| 290 | 290 | expect(out).not.toMatch(/<details open/); |
| 291 | 291 | }); |
| 292 | 292 | |
| 293 | test("a reply ends in one line: what it opened folds behind its count, each file by its path in its repository", async () => { | |
| 294 | const { turnHtml } = await import("../src/web/pages/talk.ts"); | |
| 295 | const work = { steps: "read 3 files", links: ["a.ts", "src/b.ts", "README.md"].map((p) => ({ href: `/erin/site/blob/main/${p}`, label: `erin/site/${p}` })) }; | |
| 296 | const out = turnHtml({ id: "9", role: "agent", text: "Done.", createdAt: "2026-01-01T00:00:00Z" } as any, new Set(), undefined, undefined, work as any).text; | |
| 297 | expect(out).toContain('<details class="talk-links small"><summary>3 files</summary>'); | |
| 298 | expect(out).toContain('href="/erin/site/blob/main/src/b.ts" title="erin/site/src/b.ts">src/b.ts</a>'); | |
| 299 | // One file is "1 file"; anything that is not a file is counted as links, named as it was. | |
| 300 | const one = turnHtml({ id: "10", role: "agent", text: "Done.", createdAt: "2026-01-01T00:00:00Z" } as any, new Set(), undefined, undefined, { steps: "read a file", links: [{ href: "/erin/site/blob/main/a.ts", label: "erin/site/a.ts" }] } as any).text; | |
| 301 | expect(one).toContain("<summary>1 file</summary>"); | |
| 302 | const mixed = turnHtml({ id: "11", role: "agent", text: "Done.", createdAt: "2026-01-01T00:00:00Z" } as any, new Set(), undefined, undefined, { steps: "opened #12", links: [{ href: "/erin/site/issues/12", label: "#12" }, { href: "/erin/site/blob/main/a.ts", label: "erin/site/a.ts" }] } as any).text; | |
| 303 | expect(mixed).toContain("<summary>2 links</summary>"); | |
| 304 | expect(mixed).toContain('href="/erin/site/issues/12" title="#12">#12</a>'); | |
| 305 | const { talkCss } = await import("../src/web/pages/talk_client.ts"); | |
| 306 | expect(talkCss).toContain(".talk-agent > .talk-body { margin-bottom: 16px; }"); | |
| 307 | }); | |
| 308 | ||
| 309 | test("the stylesheet keeps the list inside its column, a table inside its box, and the pause control clear of the thread", async () => { | |
| 310 | const { talkCss } = await import("../src/web/pages/talk_client.ts"); | |
| 311 | // The list's one column may shrink below its longest title, which ends in an ellipsis. | |
| 312 | expect(talkCss).toContain(".talk-chats { display: grid; grid-template-columns: minmax(0, 1fr);"); | |
| 313 | expect(talkCss).toContain(".talk-chats .row-title { overflow: hidden; text-overflow: ellipsis; }"); | |
| 314 | // A table scrolls inside its own box and never breaks a word or a code value. | |
| 315 | expect(talkCss).toMatch(/\.talk-body table \{ display: block; max-width: 100%; overflow-x: auto;/); | |
| 316 | expect(talkCss).toContain(".talk-body td code { white-space: nowrap; }"); | |
| 317 | // While a reply is written the thread keeps a strip at its end for the control, 12 px clear. | |
| 318 | expect(talkCss).toContain(".talk:has(form[data-answering]) .talk-log { padding-bottom: calc(2.75rem + 24px); }"); | |
| 319 | expect(talkCss).toContain("bottom: calc(100% + 12px);"); | |
| 320 | }); | |
| 321 | ||
| 293 | 322 | test("the server folds a run of things done into one line, \"2 things done\", and leaves one alone as itself", async () => { |
| 294 | 323 | const { foldSteps, turnHtml } = await import("../src/web/pages/talk.ts"); |
| 295 | 324 | const filed = (id: string, n: number) => turnHtml({ id, role: "tool", text: JSON.stringify({ done: true, filed: true, receipt: { verb: "Filed", object: `#${n}`, href: `/a/b/issues/${n}` } }), createdAt: "2026-01-01T00:00:00Z" } as any, new Set()); |
| @@ -371,7 +400,7 @@ describe("the page", () => { | ||
| 371 | 400 | const { talkCss, talkJs } = await import("../src/web/pages/talk_client.ts"); |
| 372 | 401 | const page = await (await get("/talk", alice)).text(); |
| 373 | 402 | expect(page).not.toMatch(/tabindex="-1"/); |
| 374 | expect(talkCss).toMatch(/\.talk-ask-acts \.btn \{[^}]*min-height: 2\.75rem/); | |
| 403 | expect(talkCss).toMatch(/\.talk-confirm-acts \.btn \{[^}]*min-height: 2\.75rem/); | |
| 375 | 404 | expect(talkCss).not.toContain("outline: none"); |
| 376 | 405 | expect(talkCss).not.toContain("outline: 0"); |
| 377 | 406 | expect(talkJs).not.toContain('tabindex", "-1"'); |
| @@ -406,7 +435,7 @@ describe("the page", () => { | ||
| 406 | 435 | // form sent to the confirm's own address, and the thread holds no copy of it. |
| 407 | 436 | const composer = doc1.querySelector("form.talk-compose"); |
| 408 | 437 | expect(composer?.getAttribute("method")).toBe("post"); |
| 409 | const buttons = [...composer!.querySelectorAll(`[data-asks] button[formaction="/talk/confirm/${id}"]`)]; | |
| 438 | const buttons = [...composer!.querySelectorAll(`[data-confirms] button[formaction="/talk/confirm/${id}"]`)]; | |
| 410 | 439 | expect(buttons.map((b) => [b.getAttribute("type"), b.getAttribute("name"), b.getAttribute("value"), b.hasAttribute("formnovalidate")])).toEqual([ |
| 411 | 440 | ["submit", "answer", "yes", true], |
| 412 | 441 | ["submit", "answer", "no", true], |
| @@ -416,8 +445,8 @@ describe("the page", () => { | ||
| 416 | 445 | |
| 417 | 446 | test("the page's own bytes are held: stylesheet and script stay small", async () => { |
| 418 | 447 | const { talkCss, talkJs } = await import("../src/web/pages/talk_client.ts"); |
| 419 | expect(Buffer.byteLength(talkCss)).toBeLessThan(16_900); | |
| 420 | expect(Buffer.byteLength(talkJs)).toBeLessThan(42_300); | |
| 448 | expect(Buffer.byteLength(talkCss)).toBeLessThan(18_000); | |
| 449 | expect(Buffer.byteLength(talkJs)).toBeLessThan(43_500); | |
| 421 | 450 | // A page of its own, so what other tests said to alice never counts: one question and a code reply. |
| 422 | 451 | const sizer = await createUser(app.db, { origin: "seed", trusted: true, username: "sizer", email: "[email protected]", password: "a-good-passphrase" }); |
| 423 | 452 | if (!sizer.ok) throw new Error(sizer.error); |
| @@ -426,8 +455,9 @@ describe("the page", () => { | ||
| 426 | 455 | const size = (await (await get("/talk", sizer.value)).arrayBuffer()).byteLength; |
| 427 | 456 | // Raised from 47,000 by the widgets' rules and no more (widgetCss, 2,495 B raw): they ride every |
| 428 | 457 | // Talk page, because a chart can arrive in a live reply, and a page drawn without them would |
| 429 | // show it unstyled until a reload. 48,328 measured. | |
| 430 | expect(size).toBeLessThan(49_500); | |
| 458 | // show it unstyled until a reload. 48,328 measured. Then to 50,000 by the reply's one last line | |
| 459 | // and the pane's first-version words: 49,466 measured. | |
| 460 | expect(size).toBeLessThan(50_000); | |
| 431 | 461 | }); |
| 432 | 462 | |
| 433 | 463 | describe("the script, driven against a DOM", () => { |
| @@ -521,7 +551,7 @@ describe("the page", () => { | ||
| 521 | 551 | const doc = window.document as any; |
| 522 | 552 | 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> |
| 523 | 553 | <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> |
| 524 | <form class="talk-compose"><div data-asks hidden><p data-asks-count></p><div class="talk-ask-list"></div></div><p data-asks-said></p><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>`; | |
| 554 | <form class="talk-compose"><div data-confirms hidden><p data-confirms-count></p><div class="talk-confirm-list"></div></div><p data-confirms-said></p><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>`; | |
| 525 | 555 | const how = { value: "started" }; |
| 526 | 556 | const cancel = { status: 200 }; |
| 527 | 557 | const answer = { status: 200 }; |
| @@ -556,10 +586,10 @@ describe("the page", () => { | ||
| 556 | 586 | new Function("document", "window", "EventSource", "fetch", "localStorage", "navigator", "setTimeout", "clearTimeout", talkJs)(doc, window, ES, fetchStub, local, nav, timers.setTimeout, timers.clearTimeout); |
| 557 | 587 | const box = doc.querySelector("textarea"); |
| 558 | 588 | const key = (init: object) => box.dispatchEvent(new window.KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true, ...init })); |
| 559 | const emitAsk = (id: string, ask: string) => sources.at(-1)!.on["turn"]!({ data: JSON.stringify({ id, html: "", ask }) }); | |
| 589 | const emitConfirm = (id: string, held: string) => sources.at(-1)!.on["turn"]!({ data: JSON.stringify({ id, html: "", held }) }); | |
| 560 | 590 | const emit = (id: string, html: string) => sources.at(-1)!.on["turn"]!({ data: JSON.stringify({ id, html }) }); |
| 561 | 591 | const grow = () => { for (const f of grows) f(); }; |
| 562 | return { how, cancel, answer, emitAsk, 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") }; | |
| 592 | return { how, cancel, answer, emitConfirm, 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") }; | |
| 563 | 593 | }; |
| 564 | 594 | /** An element that scrolls `height` px in a `client` px view; each programmatic move is kept. */ |
| 565 | 595 | const scrollable = (el: any, height: number, client: number) => { |
| @@ -1030,40 +1060,40 @@ describe("the page", () => { | ||
| 1030 | 1060 | expect(t.sent.at(-1)).toBe("back to the forge"); |
| 1031 | 1061 | }); |
| 1032 | 1062 | |
| 1033 | test("an ask the stream brings docks above the composer, said once; Do it posts the yes, and the ask leaves the dock", async () => { | |
| 1063 | test("a confirm the stream brings docks above the composer, said once; Do it posts the yes, and the confirm leaves the dock", async () => { | |
| 1034 | 1064 | const t = await boot(); |
| 1035 | const dock = t.doc.querySelector("[data-asks]"); | |
| 1065 | const dock = t.doc.querySelector("[data-confirms]"); | |
| 1036 | 1066 | expect(dock.hidden).toBe(true); |
| 1037 | const { askItem } = await import("../src/web/pages/talk.ts"); | |
| 1038 | const ask = (id: string, does: string) => askItem(id, "archive", does, new Date(Date.now() + 600_000).toISOString()).text; | |
| 1039 | t.emitAsk("5", ask("h1", "Archive alice/site.")); | |
| 1040 | t.emitAsk("5", ask("h1", "Archive alice/site.")); | |
| 1041 | const said = t.doc.querySelector("[data-asks-said]"); | |
| 1042 | expect([dock.hidden, dock.querySelectorAll(".talk-ask").length, said.textContent]).toEqual([false, 1, "Waiting for your answer: Archive alice/site."]); | |
| 1067 | const { confirmItem } = await import("../src/web/pages/talk.ts"); | |
| 1068 | const ask = (id: string, does: string) => confirmItem(id, "archive", does, new Date(Date.now() + 600_000).toISOString()).text; | |
| 1069 | t.emitConfirm("5", ask("h1", "Archive alice/site.")); | |
| 1070 | t.emitConfirm("5", ask("h1", "Archive alice/site.")); | |
| 1071 | const said = t.doc.querySelector("[data-confirms-said]"); | |
| 1072 | expect([dock.hidden, dock.querySelectorAll(".talk-confirm").length, said.textContent]).toEqual([false, 1, "Waiting for your answer: Archive alice/site."]); | |
| 1043 | 1073 | expect(t.doc.querySelector(".talk-log").textContent).not.toContain("Archive alice/site."); |
| 1044 | t.emitAsk("6", ask("h2", "Close alice/site#4.")); | |
| 1045 | expect([dock.hasAttribute("data-many"), dock.querySelector("[data-asks-count]").textContent]).toEqual([true, "2 waiting"]); | |
| 1074 | t.emitConfirm("6", ask("h2", "Close alice/site#4.")); | |
| 1075 | expect([dock.hasAttribute("data-many"), dock.querySelector("[data-confirms-count]").textContent]).toEqual([true, "2 waiting"]); | |
| 1046 | 1076 | // Before the composer in the order, so Tab reaches the ask first. |
| 1047 | 1077 | const order = [...t.doc.querySelectorAll("form.talk-compose button, form.talk-compose textarea")]; |
| 1048 | 1078 | expect(order.indexOf(dock.querySelector("[data-answer]"))).toBeLessThan(order.indexOf(t.box)); |
| 1049 | t.doc.querySelector("form.talk-compose").requestSubmit(dock.querySelector('#ask-h1 button[value="yes"]')); | |
| 1079 | t.doc.querySelector("form.talk-compose").requestSubmit(dock.querySelector('#confirm-h1 button[value="yes"]')); | |
| 1050 | 1080 | await tick(); |
| 1051 | 1081 | expect(t.sent).toEqual(["answer:/talk/confirm/h1:answer=yes"]); |
| 1052 | expect([dock.querySelectorAll(".talk-ask").length, dock.querySelector("[data-asks-count]").textContent, said.textContent, t.status.textContent]).toEqual([1, "", "Done.", ""]); | |
| 1053 | t.doc.querySelector("form.talk-compose").requestSubmit(dock.querySelector('#ask-h2 button[value="no"]')); | |
| 1082 | expect([dock.querySelectorAll(".talk-confirm").length, dock.querySelector("[data-confirms-count]").textContent, said.textContent, t.status.textContent]).toEqual([1, "", "Done.", ""]); | |
| 1083 | t.doc.querySelector("form.talk-compose").requestSubmit(dock.querySelector('#confirm-h2 button[value="no"]')); | |
| 1054 | 1084 | await tick(); |
| 1055 | 1085 | expect(t.sent.at(-1)).toBe("answer:/talk/confirm/h2:answer=no"); |
| 1056 | 1086 | expect([dock.hidden, said.textContent]).toEqual([true, "Not now: nothing was done."]); |
| 1057 | 1087 | }); |
| 1058 | 1088 | |
| 1059 | test("an ask says its time left under two minutes and, run out, takes its buttons away; nothing ticks", async () => { | |
| 1089 | test("a confirm says its time left under two minutes and, run out, takes its buttons away; nothing ticks", async () => { | |
| 1060 | 1090 | const due: (() => void)[] = []; |
| 1061 | 1091 | const timers = { setTimeout: ((f: () => void) => due.push(f)) as unknown as typeof setTimeout, clearTimeout: (() => {}) as unknown as typeof clearTimeout }; |
| 1062 | 1092 | const t = await boot("u1", {}, "c1", timers); |
| 1063 | const { askItem } = await import("../src/web/pages/talk.ts"); | |
| 1064 | t.emitAsk("5", askItem("h1", "archive", "Archive alice/site.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1065 | const left = t.doc.querySelector("#ask-h1 .talk-ask-left"); | |
| 1066 | const buttons = [...t.doc.querySelectorAll("#ask-h1 button")]; | |
| 1093 | const { confirmItem } = await import("../src/web/pages/talk.ts"); | |
| 1094 | t.emitConfirm("5", confirmItem("h1", "archive", "Archive alice/site.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1095 | const left = t.doc.querySelector("#confirm-h1 .talk-confirm-left"); | |
| 1096 | const buttons = [...t.doc.querySelectorAll("#confirm-h1 button")]; | |
| 1067 | 1097 | // Two timeouts set, one for each moment: never an interval. |
| 1068 | 1098 | expect(due.length).toBe(2); |
| 1069 | 1099 | due.shift()!(); |
| @@ -1074,16 +1104,16 @@ describe("the page", () => { | ||
| 1074 | 1104 | |
| 1075 | 1105 | test("an answer hushes only the stream it opens: the next reply is still announced", async () => { |
| 1076 | 1106 | const t = await boot(); |
| 1077 | const { askItem } = await import("../src/web/pages/talk.ts"); | |
| 1078 | t.emitAsk("5", askItem("h1", "archive", "Archive alice/site.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1079 | t.doc.querySelector("form.talk-compose").requestSubmit(t.doc.querySelector('#ask-h1 button[value="yes"]')); | |
| 1107 | const { confirmItem } = await import("../src/web/pages/talk.ts"); | |
| 1108 | t.emitConfirm("5", confirmItem("h1", "archive", "Archive alice/site.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1109 | t.doc.querySelector("form.talk-compose").requestSubmit(t.doc.querySelector('#confirm-h1 button[value="yes"]')); | |
| 1080 | 1110 | await tick(); |
| 1081 | 1111 | // The answer's own stream ends unannounced. |
| 1082 | 1112 | t.sources.at(-1)!.on["done"]!({ data: "{}" }); |
| 1083 | 1113 | expect(t.status.textContent).not.toBe("The forge replied."); |
| 1084 | 1114 | // A send that follows is announced when its reply ends, even had the answer's stream never ended. |
| 1085 | t.emitAsk("6", askItem("h2", "archive", "Archive alice/two.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1086 | t.doc.querySelector("form.talk-compose").requestSubmit(t.doc.querySelector('#ask-h2 button[value="yes"]')); | |
| 1115 | t.emitConfirm("6", confirmItem("h2", "archive", "Archive alice/two.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1116 | t.doc.querySelector("form.talk-compose").requestSubmit(t.doc.querySelector('#confirm-h2 button[value="yes"]')); | |
| 1087 | 1117 | await tick(); |
| 1088 | 1118 | t.box.value = "and then?"; |
| 1089 | 1119 | t.key({}); |
| @@ -1092,16 +1122,16 @@ describe("the page", () => { | ||
| 1092 | 1122 | expect(t.status.textContent).toBe("The forge replied."); |
| 1093 | 1123 | }); |
| 1094 | 1124 | |
| 1095 | test("a refused answer keeps the ask, says why, and gives the buttons back", async () => { | |
| 1125 | test("a refused answer keeps the confirm, says why, and gives the buttons back", async () => { | |
| 1096 | 1126 | const t = await boot(); |
| 1097 | const { askItem } = await import("../src/web/pages/talk.ts"); | |
| 1098 | t.emitAsk("5", askItem("h1", "archive", "Archive alice/site.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1127 | const { confirmItem } = await import("../src/web/pages/talk.ts"); | |
| 1128 | t.emitConfirm("5", confirmItem("h1", "archive", "Archive alice/site.", new Date(Date.now() + 600_000).toISOString()).text); | |
| 1099 | 1129 | t.answer.status = 409; |
| 1100 | const yes = t.doc.querySelector('#ask-h1 button[value="yes"]'); | |
| 1130 | const yes = t.doc.querySelector('#confirm-h1 button[value="yes"]'); | |
| 1101 | 1131 | t.doc.querySelector("form.talk-compose").requestSubmit(yes); |
| 1102 | 1132 | await tick(); |
| 1103 | const left = t.doc.querySelector("#ask-h1 .talk-ask-left"); | |
| 1104 | expect([t.doc.querySelectorAll(".talk-ask").length, left.hidden, left.textContent, yes.disabled]).toEqual([1, false, "this confirm was already answered; it does nothing twice", false]); | |
| 1133 | const left = t.doc.querySelector("#confirm-h1 .talk-confirm-left"); | |
| 1134 | expect([t.doc.querySelectorAll(".talk-confirm").length, left.hidden, left.textContent, yes.disabled]).toEqual([1, false, "this confirm was already answered; it does nothing twice", false]); | |
| 1105 | 1135 | }); |
| 1106 | 1136 | |
| 1107 | 1137 | test("things done in a row fold into one line as they stream in; one alone stays itself", async () => { |
| @@ -1132,6 +1162,18 @@ describe("the page", () => { | ||
| 1132 | 1162 | expect([file.hasAttribute("data-changed"), file.hasAttribute("tabindex"), !!dir.querySelector("[data-stub]")]).toEqual([true, false, false]); |
| 1133 | 1163 | }); |
| 1134 | 1164 | |
| 1165 | test("Display opens as its own dialog from the menu, and its form goes back when it closes", async () => { | |
| 1166 | const t = await boot(); | |
| 1167 | const opened: unknown[] = []; | |
| 1168 | (t.window as any).forgeOverlay = { open: (d: any) => { opened.push(d); d.setAttribute("open", ""); } }; | |
| 1169 | t.doc.body.insertAdjacentHTML("beforeend", '<details class="menu" open><summary>More</summary><details class="talk-display"><summary>Display</summary><form><select name="density"></select></form></details></details>'); | |
| 1170 | t.doc.querySelector(".talk-display > summary").dispatchEvent(new t.window.MouseEvent("click", { bubbles: true, cancelable: true })); | |
| 1171 | const d = t.doc.querySelector("dialog.talk-display-sheet"); | |
| 1172 | expect([opened.length, !!d.querySelector(".dialog-body form select"), t.doc.querySelector("details.menu").open, d.getAttribute("aria-labelledby")]).toEqual([1, true, false, "talk-display-title"]); | |
| 1173 | d.dispatchEvent(new t.window.Event("close")); | |
| 1174 | expect([!!t.doc.querySelector(".talk-display > form"), !!t.doc.querySelector("dialog.talk-display-sheet")]).toEqual([true, false]); | |
| 1175 | }); | |
| 1176 | ||
| 1135 | 1177 | test("a code block in a streamed turn gets its Copy button too", async () => { |
| 1136 | 1178 | const t = await boot(); |
| 1137 | 1179 | 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>'); |
| @@ -1182,7 +1224,7 @@ describe("the page", () => { | ||
| 1182 | 1224 | test("a reply starting changes the composer, and a follower is at the end in that same moment, before any size is observed", async () => { |
| 1183 | 1225 | const t = await boot(); |
| 1184 | 1226 | expect(t.view.top).toBe(4200); |
| 1185 | // Steer and Stop appear and the composer's row wraps (wider fonts): 52 px more page. | |
| 1227 | // The action slot changes and the thread keeps its strip for the pause control: 52 px more page. | |
| 1186 | 1228 | t.view.height = 5052; |
| 1187 | 1229 | t.sources.at(-1)!.on["running"]!({ data: "{}" }); |
| 1188 | 1230 | expect(t.view.top).toBe(4252); |
test/talk-steps.test.ts +9
| @@ -134,6 +134,15 @@ describe("a repository the person can read", () => { | ||
| 134 | 134 | expect((await commitToBranch(app, user, repo, { message: "start", files: [{ path: "README.md", content: "# site\n" }, { path: "src/a.ts", content: "export const a = 1;\n" }] })).ok).toBe(true); |
| 135 | 135 | const build = startChatBuild(app.db, openConversation(app.db, user.id).id, repo.id); |
| 136 | 136 | // Before anything changed: the tree alone, from the first moment, never "no files touched yet". |
| 137 | // Before a first version the preview tab says what will appear and when, with the files it starts from. | |
| 138 | const waiting = (await talkPane(ctx, user, "erin/site", works, "preview", apps(undefined, {}), { build, idle: "Your app shows here once its first version is made." })).html.text; | |
| 139 | expect(waiting).toContain("Your app shows here once its first version is made."); | |
| 140 | expect(waiting).toContain("The files it starts from"); | |
| 141 | expect(waiting).toContain('class="explorer talk-code-tree"'); | |
| 142 | expect(waiting).not.toContain("data-busy"); | |
| 143 | // While a first version is being made, its words shimmer: only what is under way does. | |
| 144 | const making = (await talkPane(ctx, user, "erin/site", works, "preview", apps(undefined, {}), { build, idle: "Making the first version.", busy: true })).html.text; | |
| 145 | expect(making).toContain("data-stage data-busy"); | |
| 137 | 146 | const before = await talkPane(ctx, user, "erin/site", works, "code", apps(undefined, {}), { build }); |
| 138 | 147 | expect(before.html.text).toContain('class="explorer talk-code-tree"'); |
| 139 | 148 | expect(before.html.text).toContain('href="/erin/site/blob/main/README.md"'); |
test/tui-talk-chats.test.ts +12 −1
| @@ -275,7 +275,7 @@ describe("the terminal's conversations screen", () => { | ||
| 275 | 275 | const text = await drive(alice, [...open, "/", "Dock here", "\r", "\r"]); |
| 276 | 276 | expect(text).toContain("Waiting for you:"); |
| 277 | 277 | expect(text).toContain("a answers: y does it, n not now."); |
| 278 | expect(text).not.toContain("Asks ·"); | |
| 278 | expect(text).not.toContain("Confirm ·"); | |
| 279 | 279 | expect(text.indexOf("Waiting for you:")).toBeGreaterThan(text.indexOf("archive it")); |
| 280 | 280 | const confirms = await drive(alice, [...open, "/", "Dock here", "\r", "\r", "a"]); |
| 281 | 281 | expect(confirms).toContain("y does it once, as you; n says not now."); |
| @@ -298,6 +298,17 @@ describe("the terminal's conversations screen", () => { | ||
| 298 | 298 | expect(text).toContain("-export const a = 1;"); |
| 299 | 299 | }); |
| 300 | 300 | |
| 301 | test("the terminal names an answered confirm a confirm, as the page does, never an ask", async () => { | |
| 302 | const made = createConversation(app.db, alice.id); | |
| 303 | if (!made.ok) throw new Error(made.error); | |
| 304 | appendTurn(app.db, alice.id, made.value.id, { role: "person", text: "archive it" }); | |
| 305 | appendTurn(app.db, alice.id, made.value.id, { role: "confirm", text: JSON.stringify({ confirm: "gone", tool: "archive", does: "Archive it." }) }); | |
| 306 | renameConversation(app.db, alice.id, made.value.id, "Confirm here"); | |
| 307 | const text = await drive(alice, [...open, "/", "Confirm here", "\r", "\r"]); | |
| 308 | expect(text).toContain("Confirm · "); | |
| 309 | expect(text).not.toContain("Asks ·"); | |
| 310 | }); | |
| 311 | ||
| 301 | 312 | test("turns are read when the chat opens and on r, not on every draw", async () => { |
| 302 | 313 | const made = createConversation(app.db, bob.id); |
| 303 | 314 | if (!made.ok) throw new Error(made.error); |
new above
offline