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

Building an app on Talk happens beside the chat, with a one-row composer, rtl and 44 px targets, and nothing above moves at send #16282

Merged opened this

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

Merged

talk/look-2-build-beside → main 0 commits 4 threads · 4 unresolved

  • Merged. talk/look-2-build-beside was merged into main as c0f6bd3.

Review

Sign in to review this change.
16 files changed +365 −133
docs/design/areas/talk-build.md +8 −1
@@ -2,6 +2,13 @@
22
33 - `.talk-build`: the panel beside a building conversation: repository, preview, versions, Publish.
44 - `.talk-build-box`: retired (#15734): the empty conversation's composer is the box, in build mode (`?build=1`).
5 - `.talk-build-versions`: the numbered list of versions, newest first, the chosen one in bold.
5 - `.talk-build-versions`: retired (#15734): the versions are `.talk-versions` chips.
66 - `.talk-build-starters`: retired (#15734): the templates are `.talk-suggest` chips under the greeting.
77 - `.talk-build-files`: the files a chosen version changed.
8
9 #15734: the panel heads the side pane of a building conversation, and the pane follows the work.
10
11 - `.talk-build-head`: the app's name (`.talk-build-name`, one line, ellipsized), the preview's state as an `envStateBadge`, and Publish, the pane's one primary action (Open, once published).
12 - `.talk-build-name`: the repository's name in that head.
13 - `.talk-versions`: the versions as round chips, v1 to vN in a row that scrolls sideways; the shown one (the chosen, else the newest) is filled.
14 - `.talk-build-chosen`: a chosen version (`?v=N`) on the card surface: its subject and time, the files it changed, Close and Restore.
docs/design/areas/talk.md +16 −1
@@ -17,7 +17,7 @@
1717 - `.talk-meta` — the time under a message (who said it is for a screen reader), with the copy button.
1818 - `.talk-copy` — a quiet icon button that copies a message or a code block; under a message it shows on hover and focus where there is a mouse, always on touch.
1919 - `.talk-suggest` — the starters on an empty chat, round chips; each fills the composer and sends. Build an app is one of them.
20 - `.talk-crew` — the one line of the crew's live work (or "The crew is idle."), above the composer; a fixed one-line height that clips with an ellipsis, so it never shifts the page.
20 - `.talk-crew` — the one line of the crew's live work, at the end of the thread, only while a run is live; idle is silence on the page (the terminal still says it).
2121 - `.talk-about` — the one line naming the subject (`?about=`), above the composer; no rule of its own: it is plain `small muted` text that wraps like any paragraph.
2222 - `.talk-jump` — the one follow control, a round pill centred above the composer: Pause while a reply is written and followed, Resume once let go, Latest when above the end with nothing running; hidden otherwise.
2323 - `.talk-dot` — the accent dot on that control when something new arrived below.
@@ -102,3 +102,18 @@ The window is the thread's one scroller; the list and a side pane are sticky col
102102 - `.talk-code`, `.talk-code-head` — a code block in a reply under a quiet head naming its language, with Copy there, never over the code.
103103
104104 Prior art: Claude and ChatGPT (one centred column, the person's words in a quiet bubble, the reply as plain text, a rounded composer with one round send that becomes stop); Vercel's AI Elements (stick to bottom with a jump control, a step disclosure per reply, shimmer on the running step).
105
106 #15734, the side pane (`paneCss` in `src/web/pages/talk_preview.ts`, sent only while `data-split`):
107
108 - `.talk-pane-bar`: the pane's bar: Preview, Code and Diff as a `.seg`, the address, Reload and Open on its own.
109 - `.talk-addr`: the address of what runs, a muted pill: which environment (Production, Pull #N) and its host; hidden under 30rem.
110 - `.talk-reload`: Reload the preview, an icon button drawn `js-only`.
111 - `.talk-stage`: the frame's surface, on the card colour with a hairline; `data-busy` dims the frame while it loads again.
112 - `.talk-stage-note`: the one line over the stage: "Updating the preview…", "Starting the preview…", "Making the first version…"; it shimmers (plain under reduced motion).
113 - `.talk-stage-wait`: the stage with no frame yet, beside a build: the note alone, as tall as the frame will be.
114
115 #15734, second pass (the owner's pixel standard):
116
117 - `.talk-fill`: how full the context is, a small `meter` and a word, in the head only from 60 %; the figures themselves are `.talk-figures` at the top of the conversation menu.
118 - `.talk-figures`: the spend and context lines inside the conversation menu.
119 - `.talk-time`: a centred quiet time before the first turn and wherever the conversation paused 30 minutes or more; the time is said once a group, not under every message (a person's message keeps its time for a screen reader).
docs/design/quiet-debt.json +1 −1
@@ -617,7 +617,7 @@
617617 "caps": 4
618618 },
619619 "src/web/talk_build.ts": {
620 "bare-list": 2
620 "bare-list": 1
621621 },
622622 "src/web/ui.ts": {
623623 "bare-list": 1
docs/design/size-budget.json +2 −2
@@ -68,8 +68,8 @@
6868 "css": 48384
6969 },
7070 "/talk": {
71 "js": 29952,
72 "css": 51712
71 "js": 34048,
72 "css": 52480
7373 },
7474 "/:owner/:name/pulls/:number": {
7575 "js": 32000,
docs/features/talk-builder.md +10 −1
@@ -9,8 +9,17 @@ row: Talk as a builder
99 The terminal has the same: the Talk screen (`src/tui/screens/talk_chats.ts`) draws the same steps, names the repository in its header, and `p` flips to the pane's contents: the repository and its pull, the address of what runs (Preview), the pull's files page (Diff) and the files the chat touched (Code). Both read `src/actions/talk_workspace.ts`. A terminal cannot draw a web page, so it prints the preview's address instead of framing it.
1010
1111 - **Which repository:** the last one a tool call in the conversation named (`src/core/talk_steps.ts` `repoOf`), shown only if you can read it.
12 - **Preview:** the newest open pull's preview environment, else production, framed from the app's own origin (the page lists that one origin in `frame-src`; `originOf` takes scheme, host and port only, so a URL with userinfo names none). It reloads when a turn ends, which is when a push has deployed. Code lists the files the chat touched; Diff links the pull's files page (not frameable).
12 - **Preview:** the newest open pull's preview environment, else production, framed from the app's own origin (the page lists that one origin in `frame-src`; `originOf` takes scheme, host and port only, so a URL with userinfo names none). Code lists the files the chat touched; Diff links the pull's files page (not frameable).
1313 - **Steps, not JSON:** each run of tool calls between two pieces of the reply is one closed disclosure, one tab stop, named by its one step ("Read src/a.ts") or its count ("3 steps"); open, each call is one line ("Read src/a.ts", "Edited src/a.ts (+12)", "Opened pull #12", "Merged pull #12 and deployed"), closed in turn, its `key: value` details a tap deeper (`foldSteps` in `src/web/pages/talk.ts`; the script folds a streamed step into its run the same way). Raw JSON is never drawn. The line under a reply summarises ("Read 4 files, opened #12").
1414 - **Stop and Steer** while a reply streams, and the context meter, are unchanged.
1515
1616 Not yet: sidebar grouping by repository (a chat has no repo of its own), added/removed counts on edits (stored calls are cut short; only added lines are known), per-turn versions to go back to.
17
18 ## Watching it appear (#15734)
19
20 Beside a conversation that builds an app, the side pane is the app: its head (name, the preview's state, Publish as the one primary action, Open once published), the versions as chips (v1 to vN; a chip shows that version's files and Restore), then the bar (Preview, Code, Diff; the address of what runs; Reload; Open on its own) over the live frame. On a phone and a tablet the Chat / Preview switch sits in the conversation's head, and both stay alive: switching keeps the reply being written and the words in the box.
21
22 - **It follows the work.** Each turn that lands, and the end of the answer, read the page again and swap the panel in, so a new version appears with the turn that made it; when the count of versions grows the frame reloads under a calm "Updating the preview…" until it has loaded. A frame on a new origin (the build's first preview, or production after Publish) needs the page's own `frame-src`, so the page loads again for it once no answer is being written.
23 - **It waits honestly.** Before the first version the stage says "Making the first version…" (or that the app appears with the first change); once a version is made and its preview is not up yet, "Starting the preview…", and the page looks again every 3 seconds (40 times at most) rather than framing production in its place.
24 - **Without the script** the pane is the same page: the frame, the chips and Publish are links and forms, and a reload shows the newest version.
25 - Proof: `test/talk-build.test.ts` (the waiting page, the chips, Publish), `test/talk-page.test.ts` (the panel swapped in and the frame reloaded under its note, in the page's own script), `test/talk-steps.test.ts` (the bar's address, Reload and Open). The terminal reads the same versions (`:` then Build an app) and prints the preview's address; it has no frame to reload.
docs/features/talk.md +2 −2
@@ -44,7 +44,7 @@ A tool call is stored once its result is known (`src/crew/conversation_calls.ts`
4444
4545 ## The crew's line
4646
47 `/talk` shows one line under the composer from the live runs only (`liveCrewRows` in `src/actions/crew_now.ts`, with `crewNow`'s visibility filters but none of its planner or review-wait reads, so the common request stays fast): "The crew is working: <who> on <what>" (with the count first when several, "(3)") while an agent run is live, else "The crew is idle." It is rendered with the page, never polled, and holds a fixed one-line height so nothing shifts. The terminal twin is `ssh <forge> talk /crew`, which prints the same line (`crewLine()` in `src/web/crew_now.ts`); signed out it says the crew is idle.
47 `/talk` shows one line at the end of the thread, only while a run is live (idle is silence on the page, #15734), from the live runs only (`liveCrewRows` in `src/actions/crew_now.ts`, with `crewNow`'s visibility filters but none of its planner or review-wait reads, so the common request stays fast): "The crew is working: <who> on <what>" (with the count first when several, "(3)") while an agent run is live. It is rendered with the page, never polled, one line that clips with an ellipsis. The terminal twin is `ssh <forge> talk /crew`, which prints the same line (`crewLine()` in `src/web/crew_now.ts`); signed out it says the crew is idle.
4848
4949 ## Naming the subject: `?about=` and `--about`
5050
@@ -134,7 +134,7 @@ A reply is drawn by the README renderer and then, for Talk alone, by `linkTalk`
134134
135135 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.
136136
137 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 12,000 B, the script under 26,900 B, and a page with a code reply under 42,000 B.
137 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 13,600 B, the script under 29,400 B, and a page with a code reply under 42,000 B.
138138
139139 ## Following
140140
src/web/icons.ts +1
@@ -86,6 +86,7 @@ const PATHS = {
8686 arrowUp: `<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>`,
8787 paperclip: `<path d="m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"/>`,
8888 mic: `<path d="M12 19v3"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><rect x="9" y="2" width="6" height="13" rx="3"/>`,
89 circleHalf: `<circle cx="12" cy="12" r="10"/><path d="M12 2a10 10 0 0 1 0 20z" fill="currentColor"/>`,
8990 more: `<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>`,
9091 history: `<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>`,
9192 activity: `<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>`,
src/web/pages/talk.ts +52 −22
@@ -59,20 +59,22 @@ import { eventStream } from "../../http/sse.ts";
5959 import { signInFirst, forbiddenPage, notFoundPage } from "../chrome.ts";
6060 import { readForm } from "../form.ts";
6161 import { html, raw, type Html } from "../html.ts";
62 import { flashTo, page, redirect } from "../layout.ts";
62 import { flashTo, fragment, page, redirect } from "../layout.ts";
6363 import { linkRefs, refTarget } from "../../text/talk_links.ts";
6464 import { appLook, linkTalk, talkLook, type TalkLook } from "../../text/talk_link_words.ts";
6565 import { liveCrewRows } from "../../actions/crew_now.ts";
6666 import { crewLineHtml } from "../crew_now.ts";
6767 import { renderMarkdown } from "../markdown.ts";
6868 import { agentHtml, voiceCss, voiceOf, type Voice } from "../talk_parts.ts";
69 import { badge, btn, icon, iconBtn, menu, row, time } from "../ui.ts";
69 import { badge, btn, icon, iconBtn, menu, meter, row, time } from "../ui.ts";
70 import { inlineIcons } from "../icons.ts";
7071 import { buildCss, chosenTemplate, panelFor, templateChips } from "../talk_build.ts";
7172 import type { User } from "../../core/users.ts";
7273 import { chatBuildOf } from "../../core/chat_build.ts";
7374 import { runningStep, stepOf, repoOf, type Step } from "../../core/talk_steps.ts";
74 import { VIEWS, talkPane, type View } from "./talk_preview.ts";
75 import { paneCss, VIEWS, talkPane, type View } from "./talk_preview.ts";
7576 import { TALK_KEYS, talkCss, talkJs } from "./talk_client.ts";
77 import { liveRegionsJs } from "../client.ts";
7678
7779 /** A stream lasts this long at most; the client reconnects from its last turn id. */
7880 export const STREAM_MS = 40_000;
@@ -198,6 +200,21 @@ const stepCard = (id: string, step: Step, at: string, set = ""): Html =>
198200 const stepsWord = (run: readonly Html[]): string =>
199201 run.length === 1 ? (/<summary>([^<]*)</.exec(run[0]!.text)?.[1]?.trim() ?? "1 step") : `${run.length} steps`;
200202
203 /** A gap this long between two turns starts a new time group, with its own quiet centred time. */
204 export const TIME_GROUP_MS = 30 * 60_000;
205
206 /**
207 * The turns with a centred time line before the first and wherever the conversation paused for
208 * `TIME_GROUP_MS` or more, so the time is said once a group, not under every message.
209 */
outdated

The foldSteps JSDoc above this line now documents TIME_GROUP_MS. Move the new constant and timeGroups above that doc block, so foldSteps keeps its comment.

210 export function timeGroups(turns: readonly Turn[], drawn: readonly Html[]): Html[] {
211 return drawn.flatMap((h, i) => {
212 const at = Date.parse(turns[i]?.createdAt ?? "");
213 const before = Date.parse(turns[i - 1]?.createdAt ?? "");
214 return i === 0 || at - before >= TIME_GROUP_MS ? [html`<li class="talk-time small muted">${time(turns[i]!.createdAt)}</li>`, h] : [h];
215 });
216 }
217
201218 /**
202219 * The log's turns with each run of steps (the calls and thoughts between two words) folded into one
203220 * closed disclosure, one tab stop: "3 steps". The stream's script folds a step that arrives later
@@ -400,19 +417,21 @@ function chats(ctx: Ctx, conversation: Conversation, showArchived: boolean, type
400417 * The open conversation's head: on a phone the way to the list, then its name, what it has cost,
401418 * and one menu for Rename, Download, Pin and Archive, each a plain form or link.
402419 */
403 function hereBar(ctx: Ctx, conversation: Conversation, context: Context | undefined): Html {
420 function hereBar(ctx: Ctx, conversation: Conversation, context: Context | undefined, tabs: Html | null): Html {
404421 const archived = conversation.archivedAt !== null;
405422 const item = (action: string, field: string, value: string, label: string, ic: "pin" | "history" | "trash"): Html =>
406423 html`<form method="post" action="${urlOf(conversation)}/${action}"><input type="hidden" name="${field}" value="${value}" /><button class="menu-item" type="submit">${icon(ic)}<span class="grow">${label}</span></button></form>`;
407424 return html`<header class="talk-head">
408425 <a class="btn btn-icon talk-back" data-variant="ghost" href="${urlOf(conversation)}?chats=1" aria-label="Conversations" title="Conversations">${icon("comment")}</a>
409426 <h2 class="talk-title">${nameOf(conversation)}${archived ? " (archived)" : ""}</h2>
410 <div class="talk-spend small muted">${totalLine(conversationTotal(ctx.app.db, conversation.id))}${contextLine(context)}</div>
427 ${tabs}
428 ${context !== undefined && context.share >= CONTEXT_SHOWN ? html`<span class="talk-fill small muted" title="${contextText(context)}">${meter(context.share * 100, contextText(context))} context used</span>` : null}
411429 ${menu({
412430 trigger: icon("more"),
413431 label: "Conversation menu",
414432 triggerOptions: { variant: "ghost", extra: "btn-icon" },
415433 items: [
434 html`<div class="talk-figures small muted">${totalLine(conversationTotal(ctx.app.db, conversation.id))}${contextLine(context)}</div>`,
416435 html`<form class="talk-rename" method="post" action="${urlOf(conversation)}/rename">
417436 <input class="input" name="title" value="${conversation.title}" maxlength="${TITLE_MAX}" aria-label="Title" placeholder="Title" />
418437 ${btn("Rename", { size: "sm" })}
@@ -426,11 +445,15 @@ function hereBar(ctx: Ctx, conversation: Conversation, context: Context | undefi
426445 </header>`;
427446 }
428447
448 /** The page's own words that are new with #15734, in one place so they can be translated later. */
449 /** How full the context must be before the head shows it, as a share of the window. */
outdated

Principle 8 and no speculation: PAGE_WORDS is justified as 'so they can be translated later', but nothing translates and the other page words stay inline. Inline these words, which gives one way to do the thing.

450 const CONTEXT_SHOWN = 0.6;
451
429452 /** An empty conversation: a greeting where the eye lands, and a few ways to start as chips. */
430453 function hello(ctx: Ctx, user: User, here: string, buildMode: boolean, chosen: string | undefined): Html {
431454 return html`<li class="talk-hello">
432455 <h2>${buildMode ? "What do you want to build?" : "What should we work on?"}</h2>
433 <p class="muted">${buildMode ? "Say what it is for. You watch it appear beside the chat, and nothing is live until you publish." : "The forge acts as you, with your permissions, and asks before anything hard to undo."}</p>
456 <p class="muted">${buildMode ? "Say what it is for. You watch it appear beside the chat, and nothing is live until you publish." : "Tell it what you want. It does the work and shows you what it did."}</p>
434457 ${buildMode
435458 ? templateChips(ctx.app.db, user, here, chosen)
436459 : html`<div class="talk-suggest">${STARTER_PROMPTS.map((q) => html`<form method="post" action="${here}" data-starter><input type="hidden" name="text" value="${q}" />${btn(q, { size: "sm" })}</form>`)}<a class="btn" data-size="sm" href="${here}?build=1">${icon("rocket")} Build an app</a></div>`}
@@ -470,7 +493,11 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
470493 // A conversation that builds an app shows its versions and preview; an empty one offers to start
471494 // one from its first message (#11010): `?build=1`, with `template=` to start from one.
472495 const building = chatBuildOf(ctx.app.db, conversation.id) !== undefined;
473 const panel = building ? await panelFor(ctx, conversation.id, here) : null;
496 const built = building ? await panelFor(ctx, conversation.id, here) : null;
497 const panel = built?.html ?? null;
498 const pending = built?.pending === true;
499 // The build panel alone, for its live region and a turn that lands.
500 if (ctx.url.searchParams.get("fragment") === "build") return panel === null ? fragment(html``, { status: 404 }) : fragment(panel, { request: ctx.request });
474501 const empty = !building && !paged && turns.length === 0;
475502 const chosen = empty ? chosenTemplate(ctx.app.db, user, ctx.url.searchParams.get("template")) : undefined;
476503 const buildMode = empty && editing === undefined && (ctx.url.searchParams.get("build") === "1" || chosen !== undefined);
@@ -487,12 +514,15 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
487514 const pane = talkPane(ctx, user, cited, works, view);
488515 // The side pane is there only when it has something to show: an app being built, or one running.
489516 const split = panel !== null || pane.live;
517 // The frame shows what runs; beside a build it waits for the build's own preview.
518 const framed = pane.live && !pending;
490519 const about = editing === undefined ? aboutLine(ctx) : null;
520 // The crew's line says something only while a run is live: idle is silence.
521 const crew = liveCrewRows(ctx, user);
491522 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>
492523 <div class="talk-side">${chats(ctx, conversation, showArchived, typed)}</div>
493524 <div class="talk" data-talk data-user="${user.id}" data-c="${conversation.id}" data-here="${here}" data-paged="${paged ? "1" : "0"}" data-running="${running && !paged ? "1" : "0"}">
494 ${hereBar(ctx, conversation, context)}
495 ${split ? html`<nav class="seg talk-tabs" aria-label="Chat or preview"><a href="?pane=chat"${shown === "chat" ? raw(' aria-current="page"') : null}>Chat</a><a href="?pane=preview"${shown !== "chat" ? raw(' aria-current="page"') : null}>Preview</a></nav>` : null}
525 ${hereBar(ctx, conversation, context, split ? html`<nav class="seg talk-tabs" aria-label="Chat or preview"><a href="?pane=chat"${shown === "chat" ? raw(' aria-current="page"') : null}>Chat</a><a href="?pane=preview"${shown !== "chat" ? raw(' aria-current="page"') : null}>Preview</a></nav>` : null)}
496526 ${turns.length === DEFAULT_PAGE && turns[0] !== undefined
497527 ? html`<p class="talk-more small"><a href="${here}?before=${turns[0].id}">Earlier</a></p>`
498528 : null}
@@ -500,9 +530,10 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
500530 <ol class="talk-log" role="log" data-last="${last}" aria-label="Conversation with the forge">
501531 ${empty
502532 ? hello(ctx, user, here, buildMode, chosen)
503 : foldSteps(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)))}
533 : foldSteps(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))))}
504534 ${!paged && running ? queuedTalk(ctx.app, user, conversation.id).map(queuedHtml) : null}
505535 </ol>
536 ${crew.length === 0 ? null : crewLineHtml(crew)}
506537 <div id="end"></div>
507538 <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>
508539 <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}>
@@ -512,28 +543,26 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
512543 ${chosen === undefined ? null : html`<input type="hidden" name="template" value="${chosen}" />`}
513544 <div class="talk-box">
514545 <div class="talk-chips" data-chips role="group" aria-label="Attached files"></div>
515 <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}`) : "Ask the forge, or tell it what to change"}" aria-label="${buildMode ? "What to build" : "Talk to the forge"}" aria-keyshortcuts="/" aria-describedby="talk-error">${editing === undefined ? "" : editing.text}</textarea>
516546 <div class="talk-tools">
517 ${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 />
518 <button type="button" class="btn btn-icon talk-dictate" data-variant="ghost" data-dictate aria-pressed="false" aria-label="Dictate" title="Dictate" hidden>${icon("mic")}</button>`}
519 ${buildMode ? html`<a class="small" href="${here}">Talk instead</a>` : null}
520 <span class="spacer"></span>
521 <span class="muted small talk-hint" data-compose-hint></span>
547 ${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 />`}
548 <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>
522549 ${editing === undefined ? null : html`<a class="btn" data-size="sm" href="${here}">Keep as it was</a>`}
523550 <button type="button" class="btn talk-steer" data-size="sm" data-steer hidden title="Stop this answer and send now">Steer</button>
551 ${buildMode ? null : html`<button type="button" class="btn btn-icon talk-dictate" data-variant="ghost" data-dictate aria-pressed="false" aria-label="Dictate" title="Dictate" hidden>${icon("mic")}</button>`}
524552 <button type="button" class="btn btn-icon talk-stop" data-stop hidden aria-label="Stop the answer" title="Stop the answer">${icon("square")}</button>
525553 <button type="submit" class="btn btn-icon talk-send" data-variant="primary" aria-label="${buildMode ? "Build it" : editing === undefined ? "Send" : "Resend"}" title="${buildMode ? "Build it" : editing === undefined ? "Send" : "Resend"}">${icon("arrowUp")}</button>
526554 </div>
527555 </div>
556 ${buildMode ? html`<p class="talk-foot small"><a href="${here}">Talk instead</a></p>` : null}
528557 <p class="talk-error small" id="talk-error" data-error hidden></p>
529 <div class="talk-foot small muted"><p class="talk-status" role="status">${running ? "The forge is answering…" : ""}</p>${crewLineHtml(liveCrewRows(ctx, user))}</div>
558 <p class="talk-status small muted" role="status">${running ? "The forge is answering…" : ""}</p>
530559 <button type="button" class="btn talk-jump" data-jump hidden>${icon("pause")}${icon("arrowDown")}<span data-word></span><i class="talk-dot"></i></button>
531560 </form>
532561 <template id="talk-ico">${icon("copy")}${icon("check")}</template>
533562 </div>
534 ${split ? html`<div class="talk-work">${panel}${pane.html}</div>` : null}
563 ${split ? html`<div class="talk-work">${panel}${framed || panel === null ? pane.html : html`<aside class="talk-pane" aria-label="Preview"><div class="talk-stage talk-stage-wait" data-stage><p class="talk-stage-note small" data-stage-note>${pending ? "Starting the preview…" : running ? "Making the first version…" : "Your app appears here as soon as the first change is made."}</p></div></aside>`}</div>` : null}
535564 </div>`;
536 return page({ ctx, title: conversation.title === "" ? "Talk" : `${conversation.title} · Talk`, body, styleCss: (panel === null ? talkCss : talkCss + buildCss) + voiceCss, scriptJs: talkJs, description: "Talk to the forge.", wide: true, keyboardResizes: true, ...(pane.frame === undefined || !split ? {} : { frameSrc: pane.frame }) });
565 return page({ ctx, title: conversation.title === "" ? "Talk" : `${conversation.title} · Talk`, body, styleCss: talkCss + (split ? paneCss : "") + (panel === null ? "" : buildCss) + voiceCss, scriptJs: `${talkJs}\n${liveRegionsJs}`, description: "Talk to the forge.", wide: true, ...(pane.frame === undefined || !framed ? {} : { frameSrc: pane.frame }) });
537566 }
538567
539568 /**
@@ -766,7 +795,7 @@ export function talkStream(ctx: Ctx): Response {
766795 const block = liveBlock(app.db, conversation.id);
767796 const refs = refTarget(app.db, user, cited);
768797 const frame = {
769 html: block === undefined || block.text === "" ? "" : html`<div class="talk-body prose">${linkedOf(refs, talkLook(app.db, user, [block.text], appLook(app, user)))(renderMarkdown(block.text))}</div>`.text,
798 html: block === undefined || block.text === "" ? "" : inlineIcons(html`<div class="talk-body prose">${linkedOf(refs, talkLook(app.db, user, [block.text], appLook(app, user)))(renderMarkdown(block.text))}</div>`.text),
770799 thinking: block?.thinking === true,
771800 tool: block?.tool === undefined ? "" : runningStep(block.tool),
772801 };
@@ -798,7 +827,8 @@ export function talkStream(ctx: Ctx): Response {
798827 const voice = voiceOf(app.db, user.id, conversation.id, fresh, ctx.url.origin);
799828 const look = talkLook(app.db, user, fresh.filter((t) => t.role === "agent").map((t) => t.text), appLook(app, user));
800829 for (const turn of fresh) {
801 emit("turn", { id: turn.id, role: turn.role, html: turnHtml(turn, waiting, undefined, undefined, works.get(turn.id), sent.get(turn.id), expired, undone, refs, voice, look).text }, turn.id);
830 // A frame lands in a page whose sprite is its own: its icons are drawn inline (`inlineIcons`).
831 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);
802832 cursor = turn.id;
803833 }
804834 // The page is told at once what the block holds after these turns, empty once it is
@@ -823,7 +853,7 @@ export function talkStream(ctx: Ctx): Response {
823853 costs,
824854 total: total === undefined ? "" : totalText(total),
825855 context: context === undefined ? "" : contextText(context),
826 acts: [...exchangeActs(app.db, user.id, conversation.id, false, ((c) => (c.id === conversation.id ? HERE : urlOf(conversation)))(openConversation(app.db, user.id)))].map(([id, act]) => ({ id: `t-${id}`, html: act.text })),
856 acts: [...exchangeActs(app.db, user.id, conversation.id, false, ((c) => (c.id === conversation.id ? HERE : urlOf(conversation)))(openConversation(app.db, user.id)))].map(([id, act]) => ({ id: `t-${id}`, html: inlineIcons(act.text) })),
827857 });
828858 ended = true;
829859 close();
src/web/pages/talk_client.ts +117 −56
@@ -16,6 +16,17 @@
1616 * jumps to the latest once let go; End and Send do the same.
1717 * - A choice (`web/talk_parts.ts`) is answered once: a press of one stills every choice button in
1818 * the log, since the stream does not draw the earlier reply again.
19 * - Beside an app being built, the panel follows the work: each turn that lands and the answer's
20 * end read the page again and swap the build panel in, so a new version appears with its turn,
21 * and the frame reloads under a calm note while the app restarts. A frame on a new origin (the
22 * first preview, or production after a publish) needs the page's own frame-src, so the page is
23 * loaded again for it, once no answer is being written.
24 * - One action slot at the end of the composer: the microphone while the box is empty and
25 * dictation is there, Send once there are words (muted while the box is empty), Stop while an
26 * answer runs and the box is empty; words typed meanwhile queue, and Steer appears beside it.
27 * - While an answer runs the last exchange's actions keep their room, unseen, so nothing above
28 * them moves; the answer's end replaces them.
29 * - The conversation's head slides away while the reader scrolls down and comes back on the way up.
1930 * - Copy buttons are drawn by the script, not the server: without the script
2031 * they would do nothing.
2132 * - While a reply streams the composer stays open: Send queues the message,
@@ -37,14 +48,20 @@ body:has(.talk-page) .foot { display: none; }
3748 .talk { display: flex; flex-direction: column; width: 100%; max-width: 46rem; margin: 0 auto; min-width: 0; min-height: calc(100dvh - var(--topbar-h)); }
3849 .talk-side, .talk-work, [data-view="list"] :is(.talk, .talk-work) { display: none; }
3950 [data-view="list"] .talk-side { display: block; padding: 12px 0; }
outdated

Principle: everything works with a keyboard. The head, with the conversation menu in it, slides off screen on scroll-down. Tabbing into it leaves focus invisible. Add .talk-head:focus-within { transform: none; }, and also reveal the head on Home or End.

40 .talk-head { position: sticky; top: var(--topbar-h); z-index: 8; display: flex; align-items: center; gap: 4px; min-height: 3.5rem; background: var(--bg); }
41 .talk-title { flex: 1; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
42 .talk-spend { display: none; gap: 12px; white-space: nowrap; }
43 .talk-spend p { margin: 0; }
44 .talk-head .btn-icon, .talk-head summary.btn { min-width: 2.75rem; min-height: 2.75rem; }
51 .talk-head { position: sticky; top: var(--topbar-h); z-index: 8; display: flex; align-items: center; gap: 4px; min-height: 2.5rem; background: var(--bg); transition: transform var(--dur-2) var(--ease); }
52 .talk-head[data-away] { transform: translateY(-110%); }
53 .talk-head[data-away]:is(:focus-within, :has(details[open])) { transform: none; }
54 .talk-title { flex: 1 1 8rem; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
55 .talk-fill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
56 .talk-fill meter { width: 3rem; }
57 .talk-figures { display: grid; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
58 .talk-figures p { margin: 0; }
59 .talk-head .btn-icon, .talk-head summary.btn { position: relative; min-width: 2.5rem; min-height: 2.5rem; }
60 .talk-head .btn-icon::after, .talk-head summary.btn::after, .talk-tools .btn-icon::after, .talk-copy::after, .talk-act::after, .talk-fold summary::after, .talk-more a::after { content: ""; position: absolute; inset: -6px; }
4561 .talk-rename { display: flex; gap: 8px; padding: 8px; }
4662 .talk-rename .input { min-width: 0; flex: 1; font-size: 16px; }
47 .talk-tabs { align-self: center; margin-bottom: 8px; }
63 .talk-tabs { flex: none; }
64 [data-split] .talk-head > form { display: none; }
4865 .talk-tabs a { min-height: 2.75rem; display: inline-flex; align-items: center; }
4966 .talk-chats { display: grid; gap: 8px; }
5067 .talk-new { width: 100%; justify-content: flex-start; min-height: 2.75rem; }
@@ -56,25 +73,23 @@ body:has(.talk-page) .foot { display: none; }
5673 .talk-archived { padding: 8px; }
5774 @media (min-width: 56.25rem) {
5875 .talk-page { grid-template-columns: 16rem minmax(0, 1fr); }
59 .talk-side, [data-view="list"] .talk-side { display: block; position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; padding: 12px 16px 12px 0; border-inline-end: 1px solid var(--border); }
76 .talk-side, [data-view="list"] .talk-side { display: block; position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; padding-block: 12px; padding-inline: 0 16px; border-inline-end: 1px solid var(--border); }
6077 [data-view="list"] .talk { display: flex; }
6178 .talk { padding-inline: 24px; }
6279 .talk-back, .talk-head > form { display: none; }
63 .talk-spend { display: flex; }
6480 }
6581 @media (max-width: 79.99rem) {
6682 [data-split]:not([data-pane="chat"]) .talk-work { display: block; }
6783 [data-split]:not([data-pane="chat"]) .talk { min-height: 0; }
68 [data-split]:not([data-pane="chat"]) .talk > :not(.talk-head, .talk-tabs) { display: none; }
84 [data-split]:not([data-pane="chat"]) .talk > :not(.talk-head) { display: none; }
6985 }
7086 @media (min-width: 80rem) {
7187 [data-split] { grid-template-columns: 16rem minmax(24rem, 1fr) minmax(0, 1.25fr); }
7288 [data-split] .talk-tabs { display: none; }
73 [data-split] .talk-work { display: block; position: sticky; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h)); overflow-y: auto; padding: 12px 0 12px 16px; border-inline-start: 1px solid var(--border); }
89 [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); }
7490 }
7591 .talk-work { min-width: 0; }
76 .talk-frame { width: 100%; height: calc(100dvh - 12rem); border: 0; border-radius: var(--radius); background: var(--card); }
77 .talk-log { list-style: none; margin: 0; padding: 8px 0 24px; display: grid; gap: 24px; align-content: start; flex: 1; min-width: 0; font-size: 15px; line-height: 1.65; }
92 .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; }
7893 .talk-turn { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
7994 .talk-turn p { margin: 0 0 8px; }
8095 .talk-turn p:last-child { margin-bottom: 0; }
@@ -83,46 +98,55 @@ body:has(.talk-page) .foot { display: none; }
8398 .talk-body.prose { padding: 0; font-size: inherit; line-height: inherit; }
8499 .talk-body.prose > * { max-width: none; }
85100 .talk-body.prose table { display: block; width: fit-content; max-width: 100%; overflow-x: auto; }
101 .talk-body .table-scroll { --cover: var(--bg); width: fit-content; margin: 0 0 12px; }
102 .talk-body .table-scroll table { display: table; overflow: visible; }
86103 .talk-body.prose :is(p, ul, ol, pre, table, blockquote) { margin: 0 0 12px; }
87104 .talk-body.prose > :last-child { margin-bottom: 0; }
88105 .talk-person, .talk-agent { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
89106 .talk-person { justify-content: flex-end; }
90 .talk-person::after { content: ""; flex-basis: 100%; order: 1; }
91 .talk-person > :is(.talk-meta, .talk-acts) { order: 2; }
92 .talk-person > .talk-body { max-width: min(85%, 36rem); padding: 8px 16px; border-radius: 18px; background: var(--muted); white-space: pre-wrap; }
93 .talk-agent > .talk-body, .talk-person > .talk-body + .talk-files, .talk-agent > :is(.talk-steps, .talk-links) { flex: 1 0 100%; }
94 .talk-agent > .talk-cost { order: 1; margin: 0 8px 0 0; font-size: 12.5px; }
107 .talk-person:not(:has(.talk-files)) { flex-wrap: nowrap; }
108 .talk-person > :is(.talk-meta, .talk-acts) { order: -1; flex: none; }
109 .talk-person:has(~ .talk-person):not(:focus-within) > .talk-meta { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
110 .talk-time { justify-self: center; margin-block: 4px -4px; }
111 .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; }
112 .talk-agent > .talk-body, .talk-person > .talk-body + .talk-files, .talk-agent > .talk-steps { flex: 1 0 100%; }
113 .talk-agent > .talk-links { order: 1; margin: 0; margin-inline-end: 8px; font-size: 12.5px; }
114 .talk-links a { color: var(--muted-fg); }
115 .talk-agent > .talk-cost { order: 1; margin: 0; margin-inline-end: 8px; font-size: 12.5px; }
95116 .talk-agent > .talk-acts { order: 2; }
96117 .talk-agent > .talk-body { max-width: 100%; }
97 .talk-meta { display: flex; align-items: center; gap: 4px; margin: 0; font-size: 12.5px; }
98 .talk-agent:not(:last-child):not(:has(+ .talk-person, + [data-queued])) > .talk-meta { display: none; }
99 .talk-acts { display: flex; gap: 4px; margin-top: 4px; }
100 .talk-act, .talk-copy { min-width: 2.75rem; min-height: 2.75rem; }
118 .talk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; font-size: 12.5px; }
119 .talk-turn > :is(.talk-meta, .talk-links, .talk-cost) { margin-block: 0; }
120 .talk-agent:not(:last-child):not(:has(+ .talk-person, + [data-queued])) > :is(.talk-meta, .talk-links) { display: none; }
121 .talk-acts { display: flex; align-items: center; gap: 4px; }
122 .talk-acts form { display: flex; }
123 .talk-person > .talk-meta time { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
124 .talk-act, .talk-copy { position: relative; width: 2rem; min-width: 2rem; height: 2rem; min-height: 2rem; padding: 0; color: var(--muted-fg); }
101125 .talk-copy { display: inline-flex; align-items: center; justify-content: center; padding: 0; background: none; border: 0; border-radius: var(--radius-sm); color: inherit; cursor: pointer; }
102126 .talk-copy:hover { background: var(--muted); color: var(--fg); }
103127 @media (hover: hover) and (pointer: fine) {
104128 .talk-turn > :is(.talk-meta, .talk-acts) :is(.talk-copy, .talk-act):not(:focus-visible) { opacity: 0; transition: opacity var(--dur-2) var(--ease); }
105129 .talk-turn:is(:hover, :focus-within) > :is(.talk-meta, .talk-acts) :is(.talk-copy, .talk-act) { opacity: 1; }
106 .talk-act, .talk-copy { min-width: 2rem; min-height: 2rem; }
107130 }
108131 .talk-tool { color: var(--muted-fg); font-size: 13px; }
109132 .talk-tool summary { cursor: pointer; min-height: 2rem; display: flex; align-items: center; gap: 6px; }
110133 .talk-tool details p { margin: 0 0 8px; white-space: pre-wrap; }
111 .talk-fold { margin-block: -8px; }
134 .talk-fold { margin-block: -4px; }
112135 [data-steps] + .talk-agent > .talk-steps { display: none; }
113 .talk-fold > details > summary { cursor: pointer; min-height: 2.75rem; display: inline-flex; align-items: center; gap: 6px; color: var(--muted-fg); }
136 .talk-fold > details > summary { position: relative; cursor: pointer; min-height: 2rem; display: inline-flex; align-items: center; gap: 6px; color: var(--muted-fg); }
114137 .talk-fold > details > summary:hover { color: var(--fg); }
115 .talk-fold-list { list-style: none; margin: 0 0 0 8px; padding: 0 0 0 12px; border-inline-start: 2px solid var(--border); display: grid; gap: 2px; }
138 .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; }
116139 .talk-steps { margin: 4px 0 0; }
117 .talk-live .talk-steps:last-child, .talk-status:not(:empty) { 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; }
140 .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; }
118141 @keyframes talk-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
119 @media (prefers-reduced-motion: reduce) { .talk-live .talk-steps:last-child, .talk-status:not(:empty) { animation: none; color: var(--muted-fg); background: none; } }
142 @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; } }
120143 .talk-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 2px 0 0; font-size: 13px; }
121144 .talk-confirm { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
122145 .talk-confirm .bar { margin-top: 8px; gap: 8px; }
123146 .talk-confirm .btn { min-height: 2.75rem; flex: 1 1 8rem; }
124147 .talk:has(.talk-hello) .talk-log { flex: 0; margin-top: auto; }
125148 .talk:has(.talk-hello) .talk-compose { position: static; margin-bottom: auto; padding-bottom: 32px; }
149 .talk-crew { margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
126150 .talk-hello { align-self: center; padding: 0; text-align: center; }
127151 .talk-hello h2 { margin: 0 0 8px; font-size: 20px; font-weight: 620; letter-spacing: -.02em; }
128152 .talk-hello p { max-width: 32rem; margin: 0 auto; }
@@ -130,42 +154,43 @@ body:has(.talk-page) .foot { display: none; }
130154 /* A narrow phone keeps the greeting and the composer in the eye line whatever the fonts wrap to. */
131155 @media (max-width: 30rem) { .talk-suggest { margin-top: 16px; } .talk:has(.talk-hello) .talk-compose { padding-bottom: 16px; } .talk:has(.talk-hello) { padding-bottom: 10vh; } }
132156 .talk-suggest .btn { min-height: 2.75rem; border-radius: 999px; }
133 .talk-compose { position: sticky; bottom: var(--kb, 0px); z-index: 8; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 12px); }
134 .talk-box { display: grid; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--card); box-shadow: var(--shadow-1); transition: border-color var(--dur-2) var(--ease); }
157 .talk-compose { position: sticky; bottom: var(--kb, 0px); z-index: 8; padding: 8px 0 max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 8px); }
158 .talk-box { display: grid; border: 1px solid var(--border-strong); border-radius: 24px; background: var(--card); box-shadow: var(--shadow-1); transition: border-color var(--dur-2) var(--ease); }
135159 .talk-box:focus-within { border-color: var(--muted-fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted-fg) 22%, transparent); }
136160 .talk-box:has([aria-invalid="true"]) { border-color: var(--danger); }
137 @media (prefers-reduced-motion: reduce) { .talk-box, .talk-turn :is(.talk-copy, .talk-act) { transition: none; } }
138 .talk-input { width: 100%; min-height: 48px; max-height: 40dvh; padding: 12px 16px 4px; border: 0; background: none; color: inherit; font: inherit; font-size: 16px; line-height: 1.5; resize: none; overflow-y: auto; box-sizing: border-box; }
161 @media (prefers-reduced-motion: reduce) { .talk-box, .talk-head, .talk-turn :is(.talk-copy, .talk-act) { transition: none; } }
162 .talk-input { flex: 1; width: 100%; min-width: 0; min-height: 2.75rem; max-height: 40dvh; padding: 8px 4px; border: 0; background: none; color: inherit; font: inherit; font-size: 16px; line-height: 1.75; resize: none; overflow-y: auto; box-sizing: border-box; }
139163 .talk-input:focus-visible { outline-color: transparent; }
140164 @media (forced-colors: active) { .talk-box:focus-within { outline: 2px solid CanvasText; } }
141 .talk-tools { display: flex; align-items: center; gap: 4px; padding: 4px 8px 8px; min-width: 0; }
142 .talk-tools .btn-icon { min-width: 2.75rem; min-height: 2.75rem; border-radius: 999px; }
143 .talk-send, .talk-stop { width: 2.75rem; }
165 .talk-tools { display: flex; align-items: flex-end; gap: 2px; padding: 4px; min-width: 0; }
166 .talk-tools .btn-icon { position: relative; flex: none; width: 2.75rem; min-width: 2.75rem; min-height: 2.75rem; border-radius: 999px; }
167 .talk-send[data-empty] { background: var(--muted); border-color: transparent; color: var(--muted-fg); box-shadow: none; }
168 .talk-tools > .btn:not(.btn-icon) { align-self: center; }
144169 .talk-send[hidden], .talk-stop[hidden], .talk-steer[hidden], .talk-dictate[hidden], [data-attach][hidden], .talk-jump[hidden] { display: none; }
145 .talk-steer { min-height: 2.75rem; border-radius: 999px; }
146 .talk-hint { margin-inline-end: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
147 @media (hover: none) { .talk-hint { display: none; } }
170 .talk-steer { border-radius: 999px; }
148171 .talk-dictate[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
149 .talk-foot { display: flex; gap: 12px; min-height: 1.5em; margin: 6px 4px 0; }
150 .talk-foot p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
172 .talk-foot { margin: 6px 16px 0; }
173 .talk-status { margin: 6px 16px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
151174 .talk-status:empty { display: none; }
152175 [data-answering] .talk-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
153 .talk-status:not(:empty) + .talk-crew { display: none; }
154 .talk-crew { flex: 1; min-width: 0; }
155176 .talk-error { margin: 6px 4px 0; color: var(--danger); }
156177 .talk-error[hidden] { display: none; }
157178 .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; }
158179 .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; }
159180 .talk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
160181 .talk-code { margin: 0 0 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
161 .talk-code-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 12px; border-bottom: 1px solid var(--border); background: var(--muted); color: var(--muted-fg); font-size: 12.5px; }
182 .talk-code-head { display: flex; align-items: center; justify-content: space-between; min-height: 1.75rem; padding-inline: 12px 0; border-bottom: 1px solid var(--border); background: var(--muted); color: var(--muted-fg); font-size: 12.5px; }
162183
163 .talk-body .talk-code pre { margin: 0; border: 0; border-radius: 0; }
184 .talk-body .talk-code pre { margin: 0; padding: 12px; border: 0; border-radius: 0; }
185 .talk-code-head .talk-copy { height: 1.75rem; min-height: 1.75rem; }
186 .talk-code-head .talk-copy::after { inset: -8px -6px; }
164187 .talk-chips, .talk-files { margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
165188 .talk-chips { padding: 8px 8px 0; }
166189 .talk-chips:empty { display: none; }
167190 .talk-more { text-align: center; margin: 8px 0 0; }
168 .talk-turn:target { box-shadow: -2px 0 0 var(--muted-fg); scroll-margin-top: 8rem; }
191 .talk-more a { position: relative; }
192 .talk-more a::after { inset: -14px -4px; }
193 .talk-turn:target { outline: 2px solid var(--muted-fg); outline-offset: 4px; border-radius: var(--radius-sm); scroll-margin-top: 8rem; }
outdated

.talk-failed .btn dropped from 2.75rem to 2rem with no enlarged hit area. It is a recovery action on a phone, and the title promises 44 px targets. Restore 2.75rem or add the ::after inset.

169194 .talk-replaced { opacity: .55; }
170195 .talk-failed form { margin-top: 6px; }
171196 .talk-failed .btn { min-height: 2.75rem; }
@@ -205,6 +230,7 @@ export const dictateJs = `
205230 const mic = form.querySelector("[data-dictate]");
206231 if (Rec && mic && "processLocally" in Rec.prototype) {
207232 mic.hidden = false;
233 mic.dataset.ok = "1";
208234 let rec = null;
209235 const words = { "not-allowed": "Microphone access is blocked.", "no-speech": "Heard nothing.", "language-not-supported": "This language can't be heard on this device." };
210236 const off = () => { rec = null; mic.setAttribute("aria-pressed", "false"); mic.setAttribute("aria-label", "Dictate"); };
@@ -215,7 +241,7 @@ export const dictateJs = `
215241 rec.lang = navigator.language;
216242 rec.onresult = (e) => {
217243 const said = Array.from(e.results).slice(e.resultIndex).map((r) => r[0].transcript).join(" ").trim();
218 if (said) box.value += (box.value && !/\\s$/.test(box.value) ? " " : "") + said;
244 if (said) { box.value += (box.value && !/\\s$/.test(box.value) ? " " : "") + said; if (window.Event) box.dispatchEvent(new window.Event("input")); }
219245 };
220246 rec.onerror = (e) => say(words[e.error] || "Dictation stopped.");
221247 rec.onend = off;
@@ -322,8 +348,8 @@ if (root) {
322348 const paged = root.dataset.paged === "1";
323349 const { c: cid, here } = root.dataset;
324350 const say = (words) => { status.textContent = words; };
325 const hint = root.querySelector("[data-compose-hint]");
326 if (hint) hint.textContent = "Enter sends, Shift+Enter adds a line";
351 const head = root.querySelector(".talk-head");
352 if (head) head.addEventListener("focusin", () => head.removeAttribute("data-away"));
327353 const jump = form.querySelector("[data-jump]");
328354 const err = form.querySelector("[data-error]");
329355 box.required = false;
@@ -397,6 +423,7 @@ if (root) {
397423 const by = performance.now() - hand < 1000;
398424 if (by && t < lastTop - 2 && h >= lastH) stuck = false;
399425 else if (by && t > lastTop && atEnd()) { stuck = true; fresh = false; }
426 if (head && Math.abs(t - lastTop) > 4) head.toggleAttribute("data-away", t > lastTop && t > 120 && !head.contains(document.activeElement) && !head.querySelector("details[open]"));
400427 lastTop = t; lastH = h;
401428 draw();
402429 }, { capture: true, passive: true });
@@ -503,7 +530,7 @@ if (root) {
503530 // this script); here they only act in place. They are taken away while a turn runs and
504531 // the server sends the new ones with done.
505532 let editing = form.hasAttribute("data-edit");
506 const dropActs = () => log.querySelectorAll(".talk-acts").forEach((a) => a.remove());
533 const dropActs = (gone) => log.querySelectorAll(".talk-acts").forEach((a) => (gone ? a.remove() : (a.style.visibility = "hidden")));
507534 const again = async (how, body) => {
508535 say(how === "edit" ? "Sending…" : "Asking again…");
509536 try {
@@ -523,13 +550,13 @@ if (root) {
523550 const steerBtn = form.querySelector("[data-steer]");
524551 let answering = false;
525552 const sendWord = action.getAttribute("aria-label");
526 // One round button: Send, or Stop while an answer runs and the box is empty; words typed meanwhile
527 // queue, and Steer appears beside it to send them now. Nothing in the row wraps or moves.
528553 const paint = () => {
529 const typed = box.value.trim() !== "";
554 const typed = box.value.trim() !== "", mic = form.querySelector("[data-dictate][data-ok]");
530555 stopBtn.hidden = !answering || typed;
531556 steerBtn.hidden = !answering || !typed;
532 action.hidden = answering && !typed;
557 if (mic) mic.hidden = (typed || answering) && mic.getAttribute("aria-pressed") !== "true";
558 action.hidden = (answering && !typed) || (!!mic && !mic.hidden);
559 action.toggleAttribute("data-empty", !typed);
533560 const w = answering ? "Queue: it sends after this answer" : sendWord;
534561 action.setAttribute("aria-label", w);
535562 action.title = w;
@@ -583,6 +610,7 @@ if (root) {
583610 if (!document.getElementById("t-" + turn.id)) {
584611 place(turn.html);
585612 decorate(log);
613 pullBuild();
586614 if (!stuck) say("New message");
587615 }
588616 retry = 0;
@@ -594,9 +622,10 @@ if (root) {
594622 source.addEventListener("running", () => { dropActs(); mode(true); log.setAttribute("aria-busy", "true"); say("The forge is answering…"); });
595623 source.addEventListener("done", (e) => {
596624 log.removeAttribute("aria-busy");
597 mode(false); dropActs(); say("The forge replied."); source.close(); source = null;
625 mode(false); dropActs(true); say("The forge replied."); source.close(); source = null;
598626 setTimeout(() => { if (status.textContent === "The forge replied.") say(""); }, 4000);
599 document.querySelectorAll("[data-frame]").forEach((f) => { f.src = f.src; });
627 reframe();
628 pullBuild();
600629 const o = JSON.parse(e.data), c = root.querySelector("[data-context]"), t = root.querySelector("[data-total]");
601630 for (const k of o.costs || []) { const li = document.getElementById(k.id); if (li && !li.querySelector(".talk-cost")) li.insertAdjacentHTML("beforeend", k.html); }
602631 if (o.total && t) { t.hidden = false; t.textContent = o.total; }
@@ -649,6 +678,7 @@ if (root) {
649678 }
650679 };
651680 ${dictateJs}
681 paint();
652682 const take = (files) => { for (const f of files) upload(f); };
653683 if (picker) picker.addEventListener("change", () => { take(picker.files); picker.value = ""; });
654684 box.addEventListener("paste", (e) => {
@@ -662,7 +692,7 @@ ${dictateJs}
662692 take(e.dataTransfer.files);
663693 });
664694 const send = async (e) => {
665 if (form.hasAttribute("data-build")) return;
695 if (form.hasAttribute("data-build")) { clearTimeout(draftTimer); draft.save(""); return; }
666696 e.preventDefault();
667697 const text = box.value.trim();
668698 if (!text) { if (attached.length) say("Add a few words about what you attached."); return; }
@@ -732,13 +762,44 @@ ${dictateJs}
732762 });
733763 resume();
734764 if (root.dataset.running === "1" && !paged) { log.setAttribute("aria-busy", "true"); follow(); }
765 const reframe = () => document.querySelectorAll("[data-frame]").forEach((f) => {
766 const s = f.closest("[data-stage]"), n = s && s.querySelector("[data-stage-note]");
767 if (n) { s.setAttribute("data-busy", ""); n.hidden = false; }
768 f.addEventListener("load", () => { if (n) { s.removeAttribute("data-busy"); n.hidden = true; } }, { once: true });
769 f.src = f.src;
770 });
771 // The build panel is a live region of its own (?fragment=build), swapped as its runs and pull
772 // move, and read again when a turn lands: a new version settles in and the frame reloads; a
773 // preview that has just become ready loads the page once, since its origin joins frame-src.
774 const builtNow = () => { const b = document.querySelector(".talk-build"); return b ? [b.dataset.versions, b.dataset.preview] : null; };
775 let built = builtNow();
776 const settleBuild = () => {
777 const now = builtNow(), was = built;
778 built = now;
779 if (!now || !was) return;
780 if (now[0] !== was[0]) { const last = document.querySelector(".talk-build .talk-versions a:last-child"); if (last) last.setAttribute("data-in", ""); reframe(); }
781 if (was[1] === "pending" && now[1] === "ready" && !answering) window.location.reload();
782 };
783 document.addEventListener("forge:swapped", (e) => { if (e.target.id === "talk-build") settleBuild(); });
784 const pullBuild = async () => {
785 const b = document.querySelector(".talk-build");
786 if (!b || !b.dataset.liveSrc) return;
787 if (!built) built = [b.dataset.versions, b.dataset.preview];
788 try {
789 const t = document.createElement("template");
790 t.innerHTML = await (await fetch(b.dataset.liveSrc)).text();
791 const n = t.content.querySelector(".talk-build");
792 if (n && b.isConnected) { b.replaceWith(n); settleBuild(); }
793 } catch (_) {}
794 };
795 document.addEventListener("click", (e) => { if (e.target.closest && e.target.closest(".talk-reload")) reframe(); });
735796 document.addEventListener("click", async (e) => {
736797 const a = e.target.closest("[data-shell] :is(.talk-tabs, .talk-pane nav) a:not(.talk-back)"), shell = a && a.closest("[data-shell]");
737798 if (!a || e.metaKey || e.ctrlKey || e.shiftKey) return;
738799 e.preventDefault();
739800 const href = a.getAttribute("href");
740801 a.parentNode.querySelectorAll("a").forEach((x) => x === a ? x.setAttribute("aria-current", "page") : x.removeAttribute("aria-current"));
741 if (a.closest(".talk-tabs")) { shell.dataset.pane = href.slice(6); return; }
802 if (a.closest(".talk-tabs")) { shell.dataset.pane = href.slice(6); if (shell.dataset.pane === "chat") resume(); else { detach(); window.scrollTo({ top: 0, behavior: "instant" }); } return; }
742803 try {
743804 const t = document.createElement("template");
744805 t.innerHTML = await (await fetch(href)).text();
src/web/pages/talk_preview.ts +28 −4
@@ -17,6 +17,7 @@ import type { Work } from "../../core/talk_work.ts";
1717 import type { Ctx } from "../../http/context.ts";
1818 import { html, raw, type Html } from "../html.ts";
1919 import { emptyLine } from "../empty_words.ts";
20 import { btn, icon, iconBtn } from "../ui.ts";
2021
2122 export interface Pane {
2223 readonly html: Html;
@@ -52,14 +53,37 @@ export function talkPane(ctx: Ctx, user: User, name: string | undefined, works:
5253 : html`<p><a class="btn" href="/${name}/pulls/${String(pull)}/files">Diff of pull #${String(pull)}</a></p>`
5354 : url === undefined
5455 ? emptyLine("talkIdle")
55 : html`<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>`;
56 : 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>`;
57 // The address bar of what runs: which environment, where it lives, reload and open on its own.
58 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>`;
5659 return {
5760 frame: ws.origin,
5861 live: url !== undefined,
59 html: html`<aside class="talk-pane" aria-label="Preview of ${name}">
60 <p class="small"><strong>${name}</strong> · ${pull === undefined ? "Production" : `Pull #${String(pull)}`}${url === undefined ? null : html` · <a href="${url}" target="_blank" rel="noopener">Open on its own</a>`}</p>
61 <nav class="tabs" aria-label="Preview, code or diff">${tab("preview", "Preview")}${tab("code", "Code")}${tab("diff", "Diff")}</nav>
62 html: html`<aside class="talk-pane" aria-label="Preview of ${name}" data-pane-of="${name}">
63 <div class="talk-pane-bar">
64 <nav class="seg" aria-label="Preview, code or diff">${tab("preview", "Preview")}${tab("code", "Code")}${tab("diff", "Diff")}</nav>
65 ${where}
66 ${url === undefined || view !== "preview" ? null : iconBtn("sync", "Reload the preview", { variant: "ghost", type: "button", extra: "js-only talk-reload" })}
67 ${url === undefined ? null : btn(icon("external"), { href: url, label: `Open ${name} on its own`, title: "Open on its own", variant: "ghost", external: true, extra: "btn-icon" })}
68 </div>
6269 ${panel}
6370 </aside>`,
6471 };
6572 }
73
74 /**
75 * The pane's own styles, sent only on a page that draws one (`data-split`). Spacing is the scale.
76 */
77 export const paneCss = /* css */ `
78 .talk-pane-bar { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 8px; }
79 .talk-addr { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 999px; background: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
80 .talk-pane-bar .btn-icon { min-width: 2.75rem; min-height: 2.75rem; }
81 .talk-stage { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
82 .talk-frame { display: block; width: 100%; height: calc(100dvh - 14rem); min-height: 24rem; border: 0; transition: opacity var(--dur-3) var(--ease); }
83 .talk-stage[data-busy] .talk-frame { opacity: .35; }
84 .talk-stage-note { position: absolute; inset: auto 0 45% 0; margin: 0; padding: 0 24px; text-align: center; }
85 .talk-stage-wait { height: calc(100dvh - 14rem); min-height: 24rem; }
86 .talk-stage-note[hidden] { display: none; }
87 @media (max-width: 30rem) { .talk-addr { display: none; } }
88 @media (prefers-reduced-motion: reduce) { .talk-frame { transition: none; } }
89 `;
src/web/talk_build.ts +39 −27
@@ -18,13 +18,16 @@ import { signInFirst, notFoundPage } from "./chrome.ts";
1818 import { readForm } from "./form.ts";
1919 import { html, type Html } from "./html.ts";
2020 import { flashTo, redirect } from "./layout.ts";
21 import { btn, icon, time } from "./ui.ts";
21 import { badge, btn, envStateBadge, icon, time } from "./ui.ts";
22 import type { EnvState } from "../apps/runtime_env.ts";
2223 import type { User } from "../core/users.ts";
2324
2425 const TEMPLATE = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}\/[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/;
2526 const ID = /^[0-9a-z]{1,40}$/;
2627 /** Starters offered under the box. */
2728 const STARTERS_MAX = 4;
29 /** What a preview's environment can be doing, as `buildState` reports it. */
30 const ENV_STATES: readonly EnvState[] = ["stopped", "deploying", "running", "asleep", "failed"];
2831
2932 /** The template the person chose with a starter link, if it is one on offer to them. */
3033 export function chosenTemplate(db: Database, user: User, asked: string | null): string | undefined {
@@ -52,43 +55,46 @@ function diffHtml(diff: Diff): Html {
5255 }
5356
5457 /** The versions, the chosen one's diff and Restore, the preview, Publish. */
55 export function buildPanel(state: BuildState, base: string, chosen: number | undefined, diff: Diff | undefined): Html {
58 export function buildPanel(state: BuildState, base: string, chosen: number | undefined, diff: Diff | undefined, pending = false): Html {
5659 const newest = state.versions.at(-1);
57 return html`<aside class="talk-build" aria-label="The app being built" data-build>
58 <p class="bar"><strong>${state.repoName}</strong>
60 const shown = chosen ?? newest?.number;
61 const env = ENV_STATES.find((s) => s === state.previewState);
62 return html`<section class="talk-build" aria-label="The app being built" data-build data-versions="${String(state.versions.length)}" data-preview="${pending ? "pending" : "ready"}" id="talk-build" data-live="run.*,pull.*" data-live-repo="${state.repoName}" data-live-src="${base}?fragment=build">
63 <div class="talk-build-head">
64 <strong class="talk-build-name">${state.repoName}</strong>
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 <span class="spacer"></span>
5967 ${state.published
60 ? html`<span class="badge">published</span>`
61 : state.previewUrl === null
62 ? html`<span class="small muted">${newest === undefined ? "No version yet: the first change makes v1." : "Preview is on its way."}</span>`
63 : html`<a href="${state.previewUrl}" target="_blank" rel="noopener noreferrer">Preview${newest === undefined ? "" : ` v${newest.number}`}${state.previewState === null ? "" : ` (${state.previewState})`}</a>`}</p>
64 ${state.productionUrl === null
65 ? null
66 : html`<p class="small"><a href="${state.productionUrl}" rel="noopener noreferrer">${state.productionUrl}</a></p>`}
68 ? state.productionUrl === null
69 ? null
70 : btn("Open", { href: state.productionUrl, icon: "external", label: "Open production in a new tab", external: true })
71 : state.versions.length === 0
72 ? null
73 : html`<form method="post" action="${base}/build/publish">${btn("Publish", { variant: "primary", icon: "rocket", label: "Publish: merge to main and deploy production" })}</form>`}
74 </div>
6775 ${state.versions.length === 0
6876 ? null
69 : html`<ol class="talk-build-versions" reversed aria-label="Versions">${[...state.versions].reverse().map(
70 (v) => html`<li ${v.number === chosen ? html`aria-current="true"` : null}><a href="${base}?v=${v.number}">v${v.number}</a> ${v.subject} <span class="small muted">${time(v.date)}</span></li>`,
71 )}</ol>`}
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>`}
7280 ${chosen === undefined || diff === undefined
7381 ? null
74 : html`<div class="talk-build-chosen"><div class="bar"><strong>v${chosen}</strong>
75 <span class="spacer"></span>
76 <form method="post" action="${base}/build/restore"><input type="hidden" name="version" value="${chosen}" />${btn("Restore", { label: `Make a new version from v${chosen}` })}</form></div>
77 ${diffHtml(diff)}</div>`}
78 ${state.published || state.versions.length === 0
79 ? null
80 : html`<form method="post" action="${base}/build/publish">${btn("Publish", { label: "Publish: merge to main and deploy production" })}</form>`}
81 </aside>`;
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>
83 ${diffHtml(diff)}
84 <div class="bar"><a class="small" href="${base}">Close</a><span class="spacer"></span><form method="post" action="${base}/build/restore"><input type="hidden" name="version" value="${chosen}" />${btn(`Restore v${chosen}`, { icon: "history", label: `Make a new version from v${chosen}` })}</form></div></div>`}
85 </section>`;
8286 }
8387
8488 /** The panel for a conversation that builds, or null when it does not (or is not the person's). */
85 export async function panelFor(ctx: Ctx, conversationId: string, base: string): Promise<Html | null> {
89 export async function panelFor(ctx: Ctx, conversationId: string, base: string): Promise<{ readonly html: Html; readonly pending: boolean } | null> {
8690 const state = await buildState(ctx.app, ctx.auth.user, conversationId);
8791 if (!state.ok) return null;
8892 const v = Number(ctx.url.searchParams.get("v"));
8993 const chosen = Number.isInteger(v) && v >= 1 && state.value.versions.some((x) => x.number === v) ? v : undefined;
9094 const diff = chosen === undefined ? undefined : await versionDiff(ctx.app, ctx.auth.user, conversationId, chosen);
91 return buildPanel(state.value, base, chosen, diff?.ok ? diff.value : undefined);
95 // A version made and its preview not yet up: the page waits for it rather than frame production.
96 const pending = !state.value.published && state.value.versions.length > 0 && state.value.previewUrl === null;
97 return { html: buildPanel(state.value, base, chosen, diff?.ok ? diff.value : undefined, pending), pending };
9298 }
9399
94100 // POST /talk/build — one prompt makes the app and opens its chat.
@@ -145,7 +151,13 @@ export async function talkPublish(ctx: Ctx): Promise<Response> {
145151
146152 /** Styles for the box and the panel; added to Talk's own only on a page that draws one. Spacing is the 4px scale. */
147153 export const buildCss = /* css */ `
148 .talk-build { width: 100%; display: grid; gap: 8px; }
149 .talk-build-versions, .talk-build-files { margin: 0; padding-left: 24px; }
150 .talk-build-versions [aria-current] { font-weight: 600; }
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; }
157 .talk-versions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
158 .talk-versions .btn { min-height: 2.75rem; min-width: 2.75rem; justify-content: center; border-radius: 999px; font-variant-numeric: tabular-nums; }
159 .talk-versions [aria-current] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
160 .talk-build-chosen { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
161 .talk-build-chosen p { margin: 0 0 8px; }
162 .talk-build-files { margin: 0 0 8px; padding-inline-start: 24px; }
151163 `;
test/talk-build.test.ts +15 −1
@@ -192,7 +192,21 @@ test("the page: Build an app on an empty Talk opens the composer to build, then
192192
193193 const { branch, repo } = (await call("GET", `/api/v1/conversations/${id}/build`)).body as { branch: string; repo: string };
194194 await agentCommits(repo, branch, "Add recipe list", "one\n");
195 // v1 is made and its preview is not up yet: the panel shows it as a chip and the page waits for
196 // the build's own preview rather than framing anything else.
197 const made = await (await get(to)).text();
198 expect(made).toMatch(new RegExp(`<a class="btn" data-size="sm" href="${to}\\?v=1" aria-current="true" title="Add recipe list">v1</a>`));
199 expect(made).toContain('data-preview="pending"');
200 // The panel is a live region of its own: its runs and pull swap it in place from its own fragment.
201 expect(made).toContain(`data-live="run.*,pull.*" data-live-repo="alice/recipe-box" data-live-src="${to}?fragment=build"`);
202 const alone = await (await get(`${to}?fragment=build`)).text();
203 expect(alone.trimStart()).toMatch(/^<section[^>]* class="talk-build"/);
204 expect(alone).not.toContain("<html");
205 expect(made).toContain("Starting the preview…");
206 expect(made).not.toContain("<iframe");
207 expect(made).toMatch(/<form method="post" action="[^"]+\/build\/publish"><button[^>]*data-variant="primary"/);
195208 const one = await (await get(`${to}?v=1`)).text();
209 expect(one).toContain("Restore v1");
196210 expect(one).toContain("v1");
197211 expect(one).toContain("page.txt");
198212 expect(one).toContain(`action="${to}/build/restore"`);
@@ -202,7 +216,7 @@ test("the page: Build an app on an empty Talk opens the composer to build, then
202216 expect((await call("GET", `/api/v1/conversations/${id}/build`)).body["versions"].length).toBe(2);
203217 expect((await post(`${to}/build/publish`, {})).status).toBe(303);
204218 const done = await (await get(to)).text();
205 expect(done).toContain("published");
219 expect(done).toContain("Published");
206220 // Another person's build is not found, and a cross-origin form is refused.
207221 expect((await post("/talk/nope/build/publish", {})).status).toBe(404);
208222 const cross = await fetch(`${servers.url}${to}/build/publish`, { method: "POST", redirect: "manual", headers: { origin: "https://evil.test", cookie }, body: new URLSearchParams({}) });
test/talk-crew-now.test.ts +3 −3
@@ -57,8 +57,8 @@ describe("/talk crew line", () => {
5757 await rm(dir, { recursive: true, force: true });
5858 });
5959
60 test("idle when nobody works", async () => {
61 expect(line(await talk())).toBe(CREW_IDLE);
60 test("idle when nobody works: the page says nothing, so no row is spent on it", async () => {
61 expect(line(await talk())).toBeUndefined();
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))).toBe(CREW_IDLE);
78 expect(line(await talk(bobCookie))).toBeUndefined();
7979 expect(line(await talk())).toStartWith("The crew is working (2):");
8080 });
8181
test/talk-page.test.ts +66 −11
@@ -135,9 +135,11 @@ describe("the page", () => {
135135 expect(html).toMatch(/talk-back" data-variant="ghost" href="\/talk\/[^"?]+\?chats=1"/);
136136 expect(talkCss).toContain('.talk-side, .talk-work, [data-view="list"] :is(.talk, .talk-work) { display: none; }');
137137 expect(talkCss).toMatch(/\.talk-compose \{[^}]*position: sticky; bottom: var\(--kb, 0px\)/);
138 expect(talkCss).toMatch(/\.talk-head \.btn-icon[^{]*\{[^}]*min-height: 2\.75rem/);
138 // The head is 40 px; its buttons reach 44 px through a hit area that overlaps the head's own room.
139 expect(talkCss).toMatch(/\.talk-head \.btn-icon[^{]*\{[^}]*min-height: 2\.5rem/);
140 expect(talkCss).toMatch(/\.talk-head \.btn-icon::after[^{]*\{ content: ""; position: absolute; inset: -6px; \}/);
139141 expect(talkCss).toMatch(/\.talk-tools \.btn-icon \{[^}]*min-height: 2\.75rem/);
140 expect(talkCss).toMatch(/\.talk-input \{[^}]*min-height: 48px/);
142 expect(talkCss).toMatch(/\.talk-input \{[^}]*min-height: 2\.75rem/);
141143 });
142144
143145 test("?pane=preview with nothing running draws no pane; the list view wins over it (#15813)", async () => {
@@ -149,8 +151,9 @@ describe("the page", () => {
149151 expect(both).toContain('data-shell data-pane="preview" data-view="list">');
150152 expect(both).toMatch(/<div class="talk-side"><nav class="talk-chats"/);
151153 const { talkCss } = await import("../src/web/pages/talk_client.ts");
152 // With a pane, below 80rem it is a tab: the head and the tabs stay, the thread steps aside.
153 expect(talkCss).toContain('[data-split]:not([data-pane="chat"]) .talk > :not(.talk-head, .talk-tabs) { display: none; }');
154 // With a pane, below 80rem it is a tab: the head, which holds the tabs, stays; the thread steps
155 // aside.
156 expect(talkCss).toContain(`[data-split]:not([data-pane="chat"]) .talk > :not(.talk-head) { display: none; }`);
154157 });
155158
156159 test("signed out goes to /signin and comes back", async () => {
@@ -287,6 +290,16 @@ describe("the page", () => {
287290 expect(out).not.toMatch(/<details open/);
288291 });
289292
293 test("the page mirrors in rtl: its own sheets set no physical side, only logical ones", async () => {
294 const { talkCss } = await import("../src/web/pages/talk_client.ts");
295 const { paneCss } = await import("../src/web/pages/talk_preview.ts");
296 const { buildCss } = await import("../src/web/talk_build.ts");
297 for (const css of [talkCss, paneCss, buildCss]) {
298 expect(css).not.toMatch(/(padding|margin|border)-(left|right)\s*:/);
299 expect(css).not.toMatch(/:\s*\d+px \d+px \d+px \d+px\s*[;}]/);
300 }
301 });
302
290303 test("an agent turn carries no prose padding or measure into the column", async () => {
291304 const { talkCss } = await import("../src/web/pages/talk_client.ts");
292305 expect(talkCss).toContain(".talk-body.prose { padding: 0;");
@@ -300,7 +313,7 @@ describe("the page", () => {
300313 // a second aria-live would announce twice.
301314 expect(page).toMatch(/<ol class="talk-log" role="log" data-last/);
302315 expect(page).not.toContain("aria-live");
303 expect(page).toContain('aria-keyshortcuts="/"');
316 expect(page).toContain('aria-keyshortcuts="/ Enter Shift+Enter"');
304317 expect(talkCss).toContain("bottom: var(--kb, 0px)");
305318 expect(talkCss).not.toContain("overflow-x: clip");
306319 expect(talkCss).toMatch(/\.talk-page \{[^}]*grid-template-columns: minmax\(0, 1fr\)/);
@@ -381,12 +394,12 @@ describe("the page", () => {
381394
382395 test("the page's own bytes are held: stylesheet and script stay small", async () => {
383396 const { talkCss, talkJs } = await import("../src/web/pages/talk_client.ts");
384 expect(Buffer.byteLength(talkCss)).toBeLessThan(12_000);
385 expect(Buffer.byteLength(talkJs)).toBeLessThan(26_900);
397 expect(Buffer.byteLength(talkCss)).toBeLessThan(13_600);
398 expect(Buffer.byteLength(talkJs)).toBeLessThan(29_400);
386399 say(alice, "agent", "```ts\nlet x = 1;\n```");
387400 const page = await get("/talk", alice);
388401 const size = (await page.arrayBuffer()).byteLength;
389 expect(size).toBeLessThan(42_000);
402 expect(size).toBeLessThan(43_000);
390403 });
391404
392405 describe("the script, driven against a DOM", () => {
@@ -478,7 +491,7 @@ describe("the page", () => {
478491 const { talkJs } = await import("../src/web/pages/talk_client.ts");
479492 const window = new Window({ url: "http://localhost/talk" });
480493 const doc = window.document as any;
481 doc.body.innerHTML = `<div class="talk" data-talk data-user="${user}" data-c="${conv}" data-paged="0" data-running="1"><div>
494 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>
482495 <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>
483496 <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>`;
484497 const how = { value: "started" };
@@ -490,7 +503,7 @@ describe("the page", () => {
490503 const bodies: { files?: string[] }[] = [];
491504 const fetchStub = async (u: string, init: { body: string; method?: string }) => {
492505 urls.push(u);
493 if (u.startsWith("?pane=")) return { ok: true, text: async () => page.html };
506 if (u.startsWith("?pane=") || u === "/talk" || u.endsWith("?fragment=build")) return { ok: true, text: async () => page.html };
494507 if (u.endsWith("/files")) return { ok: true, json: async () => ({ id: "f1", name: "shot.png" }) };
495508 if (init.method === "DELETE") return { ok: true, json: async () => ({}) };
496509 if (u.includes("/queue/")) return { ok: cancel.status === 200, status: cancel.status, json: async () => ({}) };
@@ -558,6 +571,45 @@ describe("the page", () => {
558571 expect(loads).toEqual(["https://x.example/"]);
559572 });
560573
574 test("a head that slid away comes back when focus enters it, so a keyboard user never loses the conversation menu", async () => {
575 const t = await boot();
576 const head = t.doc.querySelector(".talk-head");
577 head.setAttribute("data-away", "");
578 head.querySelector("summary, button, a").dispatchEvent(new t.window.FocusEvent("focusin", { bubbles: true }));
579 expect(head.hasAttribute("data-away")).toBe(false);
580 const { talkCss } = await import("../src/web/pages/talk_client.ts");
581 expect(talkCss).toContain(".talk-head[data-away]:is(:focus-within, :has(details[open])) { transform: none; }");
582 expect(talkCss).toContain(".talk-failed .btn { min-height: 2.75rem; }");
583 });
584
585 test("beside an app being built, a turn reads the panel's own fragment again: a new version appears and the frame reloads under a note until it has loaded; the live region's swap does the same", async () => {
586 const t = await boot();
587 const work = t.doc.createElement("div");
588 work.className = "talk-work";
589 work.innerHTML = '<section class="talk-build" id="talk-build" data-versions="1" data-preview="ready" data-live-src="/talk/c1?fragment=build"><a>v1</a></section><aside class="talk-pane"><div class="talk-stage" data-stage><iframe data-frame src="https://app--2.example/"></iframe><p data-stage-note hidden>Updating the preview…</p></div></aside>';
590 t.doc.body.appendChild(work);
591 const frame = work.querySelector("[data-frame]");
592 t.page.html = '<section class="talk-build" id="talk-build" data-versions="2" data-preview="ready" data-live-src="/talk/c1?fragment=build"><a>v1</a><a>v2</a></section>';
593 t.emit("2", '<li class="talk-turn talk-tool talk-step" id="t-2" data-step><details><summary>Edited server.ts</summary></details></li>');
594 await tick();
595 expect(t.urls).toContain("/talk/c1?fragment=build");
596 expect(t.urls.some((u) => /\/talk(\?|$)/.test(u))).toBe(false);
597 expect(t.doc.querySelector(".talk-build").dataset.versions).toBe("2");
598 const stage = work.querySelector("[data-stage]");
599 expect([stage.hasAttribute("data-busy"), stage.querySelector("[data-stage-note]").hidden]).toEqual([true, false]);
600 frame.dispatchEvent(new t.window.Event("load"));
601 expect([stage.hasAttribute("data-busy"), stage.querySelector("[data-stage-note]").hidden]).toEqual([false, true]);
602 // The same count again moves nothing.
603 t.emit("3", '<li class="talk-turn talk-agent" id="t-3"><div class="talk-body"><p>Done.</p></div></li>');
604 await tick();
605 expect(stage.hasAttribute("data-busy")).toBe(false);
606 // The live region swapping in a third version settles it the same way, with no fetch of its own.
607 const panel = t.doc.querySelector("#talk-build");
608 panel.dataset.versions = "3";
609 panel.dispatchEvent(new t.window.CustomEvent("forge:swapped", { bubbles: true }));
610 expect(stage.hasAttribute("data-busy")).toBe(true);
611 });
612
561613 test("a pane tab swaps the pane in place: no reload, the stream and the composer's words kept", async () => {
562614 const t = await boot();
563615 const shell = t.doc.createElement("div");
@@ -629,7 +681,7 @@ describe("the page", () => {
629681 expect(t.key({})).toBe(false);
630682 await tick();
631683 expect(t.sent).toEqual(["hello"]);
632 expect(t.doc.querySelector("[data-compose-hint]").textContent).toContain("Enter sends");
684
633685 await t.window.happyDOM.close();
634686 });
635687
@@ -832,10 +884,13 @@ describe("the page", () => {
832884 const form = t.doc.querySelector("form.talk-compose");
833885 form.setAttribute("data-build", "");
834886 t.box.value = "a recipe box";
887 t.store["talk-draft:u1:c1"] = JSON.stringify({ t: Date.now(), v: "a recipe box" });
835888 const e = new t.window.Event("submit", { bubbles: true, cancelable: true });
836889 form.dispatchEvent(e);
837890 expect(e.defaultPrevented).toBe(false);
838891 expect(t.sent).toEqual([]);
892 // What was typed leaves with the form: it is not put back in the box of the empty conversation.
893 expect(Object.keys(t.store).filter((k) => k.startsWith("talk-draft:"))).toEqual([]);
839894 });
840895
841896 test("a code block in a streamed turn gets its Copy button too", async () => {
test/talk-steps.test.ts +4
@@ -102,6 +102,10 @@ describe("a repository the person can read", () => {
102102 expect(pane.html.text).toContain("Pull #7");
103103 expect(pane.frame).toBe("https://lab--7--site.example.test");
104104 expect(pane.live).toBe(true);
105 // The bar says which environment and where, and offers to reload it and to open it on its own.
106 expect(pane.html.text).toContain('<span class="talk-addr small" title="https://lab--7--site.example.test/"><span class="muted">Pull #7</span> lab--7--site.example.test</span>');
107 expect(pane.html.text).toContain("talk-reload");
108 expect(pane.html.text).toContain('href="https://lab--7--site.example.test/"');
105109 expect(frameSources({ frameSrc: pane.frame })).toContain("https://lab--7--site.example.test");
106110 expect(frameSources({ frameSrc: pane.frame })).not.toContain("site.example.test/");
107111 });
test/talk-voice.test.ts +1 −1
@@ -85,7 +85,7 @@ describe("talk dictation", () => {
8585 expect(dictateJs).not.toMatch(/fetch|XMLHttpRequest|sendBeacon|WebSocket|EventSource|MediaRecorder/);
8686 expect(talkCss).toMatch(/\.talk-dictate\[hidden\][^{]*\{ display: none; \}/);
8787 expect(talkCss).toMatch(/\[data-attach\]\[hidden\], \.talk-jump\[hidden\] \{ display: none; \}/);
88 expect(talkCss).toContain(".talk-tools .btn-icon { min-width: 2.75rem; min-height: 2.75rem;");
88 expect(talkCss).toMatch(/\.talk-tools \.btn-icon \{[^}]*min-width: 2\.75rem; min-height: 2\.75rem;/);
8989 expect(dictateJs.length).toBeLessThan(1400);
9090 });
9191 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs