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

Talk's Stop stays for the whole answer, with words in the box too #17819

opened this

Merged 5h ago, live in production

talk-stop-stays → main 0 commits 1 thread · 1 unresolved

  • Merged. talk-stop-stays was merged into main as b51ab2e.

Review

Sign in to review this change.
6 files changed +52 −12
docs/design/areas/talk.md +2 −2
@@ -91,8 +91,8 @@ The window is the thread's one scroller; the list and a side pane are sticky col
9191 - `.talk-hello` — an empty conversation's greeting, centred, with the starters; the composer follows it mid-screen.
9292 - `.talk-box` — the composer's one rounded container: `.talk-chips`, the borderless `.talk-input`, then `.talk-tools`; its focus ring is the neutral `--muted-fg`, red only when a send failed.
9393 - `.talk-input` — the textarea, 16px so iOS does not zoom, growing to 40dvh.
94 - `.talk-tools` — the row inside the box: Attach and Dictate as icon buttons, the hint, then Steer, Stop and Send; it never wraps.
95 - `.talk-send`, `.talk-stop` — the one round button at the end: Send (an arrow up), or Stop (a square) while an answer runs and the box is empty.
94 - `.talk-tools` — the row inside the box: Attach and Dictate as icon buttons, the hint, then Stop, Steer and Send; it never wraps.
95 - `.talk-send`, `.talk-stop` — the round buttons at the end: Send (an arrow up), and Stop (a square) for the whole answer. With the box empty Stop stands alone; with words typed it keeps its place before Steer, so Steer is between Stop and Send.
9696 - `.talk-steer` — the one secondary control, shown while an answer runs and words are typed: send them now.
9797 - `.talk-hint` — "Enter sends", only where there is a mouse.
9898 - `.talk-dock` — below 56.25rem the conversation's controls in one 44 px row above the composer, inside `.talk-base` (the sticky wrapper that rides `--kb`): Chats, New, Chat/Preview when a preview is live, and the menu (#16586). `.talk-head` is the title alone there; from 56.25rem the dock is hidden.
docs/features/talk.md +1 −1
@@ -95,7 +95,7 @@ It checks identity, same origin and token scope. Viewers of `/talk` see the `Sto
9595
9696 The composer stays open while the agent works. `say()` in `src/crew/conversation.ts` takes `during`: `inject` (the old behaviour, still the default for the API without `during`, MCP and plain `ssh talk`), `queue` (kept in memory for after the turn; up to 5; each runs as its own turn, in order) or `interrupt` (stops the turn, keeps its words and the `Stopped.` line, and sends the message first). Stop clears the queue; a forge restart drops it. A file attached to a queued message is held: it cannot be removed (409) or sent with another message (`file_taken`), and one gone by the time it runs is left out.
9797
98 - **Web:** while an answer runs Send reads Queue and Steer and Stop appear. A queued message shows dimmed, "Queued: sends when this answer ends.", with Edit (the script's: it comes out of the queue and back into the box) and Drop (a post form to `POST /talk/queue/:id/cancel`, so it works without the script); every open tab sees it over the stream (`queued` frame).
98 - **Web:** while an answer runs Stop is there for the whole of it, with words in the box or without, on a phone as on a desktop; once words are typed Send reads Queue and Steer appears. A queued message shows dimmed, "Queued: sends when this answer ends.", with Edit (the script's: it comes out of the queue and back into the box) and Drop (a post form to `POST /talk/queue/:id/cancel`, so it works without the script); every open tab sees it over the stream (`queued` frame).
9999 - **Sent once:** Send shows the message in the thread at once, marked "Sending…", and empties the box; until the server answers, Send is disabled and a second press, a double tap or Enter sends nothing. Each send carries an `Idempotency-Key` (the same words sent again after a failure keep their key), so two requests for one press keep one message; without the script the form carries a key made with the page (`key`), and a resubmit of it is one message too. A send that fails puts the words back in the box. Proof: `test/talk-send-once.test.ts`, which drives it in Chromium at 390 px with touch.
100100 - **API:** `POST /api/v1/conversation/messages` with `during: "queue" | "steer"` (anything else is 422 `invalid_during`; a sixth queued message is 429 `queue_full`); `DELETE /api/v1/conversation/queue/:id` (404 for an id that is not yours or already went); `GET /api/v1/conversation/turns` lists `queued`.
101101 - **Terminal:** `ssh <forge> talk /queue <words>`, `talk /steer <words>`, `talk /queued` (ids and words), `talk /unqueue <id>`; they work with `--attach` too.
src/web/pages/talk.ts +1 −1
@@ -740,9 +740,9 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
740740 ${picker?.control ? null : input}
741741 ${editing === undefined ? null : html`<a class="btn" data-size="sm" href="${here}">Keep as it was</a>`}
742742 ${picker?.control}
743 <button type="button" class="btn btn-icon talk-stop" data-stop hidden aria-label="Stop the answer" title="Stop the answer">${icon("square")}</button>
743744 <button type="button" class="btn talk-steer" data-size="sm" data-steer hidden title="Stop this answer and send now">Steer</button>
744745 ${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>`}
745 <button type="button" class="btn btn-icon talk-stop" data-stop hidden aria-label="Stop the answer" title="Stop the answer">${icon("square")}</button>
746746 <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>
747747 </div>
748748 </div>
src/web/pages/talk_client.ts +6 −4
@@ -21,9 +21,10 @@
2121 * and the frame reloads under a calm note while the app restarts. A frame on a new origin (the
2222 * first preview, or production after a publish) needs the page's own frame-src, so the page is
2323 * 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.
24 * - The actions at the end of the composer: the microphone while the box is empty and dictation is
25 * there, Send once there are words (muted while the box is empty), and Stop for as long as an
26 * answer runs, alone while the box is empty; words typed meanwhile queue, and Steer appears
27 * between Stop and Send.
2728 * - While an answer runs the last exchange's actions keep their room, unseen, so nothing above
2829 * them moves; the answer's end replaces them.
2930 * - Motion is one vocabulary: a thing arriving fades and rises 4 px over --dur-3 with --ease, once
@@ -711,7 +712,8 @@ if (root) {
711712 const sendWord = action.getAttribute("aria-label");
712713 const paint = () => {
713714 const typed = box.value.trim() !== "", mic = form.querySelector("[data-dictate][data-ok]");
outdated

The file header (lines 24-26) still says Stop is shown 'while an answer runs and the box is empty'. Reword it to say Stop shows for the whole answer and Steer appears beside it once words are typed. The comment is wrong now, and principle 1 holds that nothing is said twice or wrongly.

714 stopBtn.hidden = !answering || typed;
715 // Stop stays for the whole answer: a silent model must be stoppable with words in the box too.
716 stopBtn.hidden = !answering;
715717 steerBtn.hidden = !answering || !typed;
716718 if (mic) mic.hidden = (typed || answering) && mic.getAttribute("aria-pressed") !== "true";
717719 action.hidden = (answering && !typed) || (!!mic && !mic.hidden);
test/helpers/talk-phone.ts +40
@@ -32,6 +32,7 @@ import { createSession } from "../../src/core/sessions.ts";
3232 import { createUser } from "../../src/core/users.ts";
3333 import { findChromium } from "../../src/looks/capture.ts";
3434 import { serve, type Servers } from "../../src/http/server.ts";
35 import { clock } from "../../src/web/pages/talk.ts";
3536 import { chromiumRuns, sharedBrowser, type SharedBrowser } from "./chrome.ts";
3637 import { quietLogs } from "./globals.ts";
3738 import { promote } from "./members.ts";
@@ -298,6 +299,45 @@ export function widthTests(width: (typeof WIDTHS)[number]): void {
298299 30_000,
299300 );
300301
302 test.skipIf(skip)(
303 `${width} px: while an answer runs and words are typed, Stop, Steer and Send are all 44 px and in the box beside the model's name`,
304 async () => {
305 const was = clock.running;
306 clock.running = () => true;
307 try {
308 const s = await phone(
309 width,
310 `/talk/${shortId}`,
311 token,
312 `(async () => {
313 ${WAIT}
314 const form = document.querySelector("form.talk-compose"), input = form.querySelector(".talk-input");
315 await wait(() => form.hasAttribute("data-answering"));
316 const r = (e) => { const b = e.getBoundingClientRect(); return { left: b.left, right: b.right, w: b.width, h: b.height }; };
317 const alone = r(form.querySelector(".talk-stop"));
318 input.value = "and one more thing";
319 input.dispatchEvent(new Event("input", { bubbles: true }));
320 await new Promise((ok) => requestAnimationFrame(() => requestAnimationFrame(ok)));
321 const row = ["[data-attach]", "[data-model-open]", ".talk-stop", ".talk-steer", ".talk-send"].map((q) => ({ q, ...r(form.querySelector(q)) }));
322 return JSON.stringify({ alone, row, box: r(document.querySelector(".talk-box")), sw: document.documentElement.scrollWidth });
323 })()`,
324 );
325 const seen = JSON.stringify(s);
326 expect(Math.min(s.alone.w, s.alone.h), seen).toBeGreaterThanOrEqual(44);
327 s.row.forEach((b: { q: string; left: number; right: number; w: number; h: number }, i: number) => {
328 expect(Math.min(b.w, b.h), `${b.q} ${seen}`).toBeGreaterThanOrEqual(44);
329 expect(b.right, seen).toBeLessThanOrEqual(s.box.right);
330 expect(b.left, seen).toBeGreaterThanOrEqual(i === 0 ? s.box.left : s.row[i - 1].right);
331 });
332 expect(s.row[1].w, seen).toBeGreaterThanOrEqual(96);
333 expect(s.sw, seen).toBeLessThanOrEqual(width);
334 } finally {
335 clock.running = was;
336 }
337 },
338 30_000,
339 );
340
301341 test.skipIf(skip)(
302342 `${width} px: with the keyboard open the dock rides with the composer above it and nothing rides under the keyboard`,
303343 async () => {
test/talk-page.test.ts +2 −4
@@ -518,12 +518,10 @@ describe("the page", () => {
518518 t.sources.at(-1)!.on["running"]!({ data: "{}" });
519519 // Running with an empty box: the one round button is Stop.
520520 expect([send.hidden, stop.hidden, steer.hidden]).toEqual([true, false, true]);
521 // Words typed meanwhile queue, and Steer appears to send them now.
521 // Words typed meanwhile queue, Steer appears to send them now, and Stop stays in reach.
522522 t.box.value = "also this";
523523 t.box.dispatchEvent(new t.window.Event("input"));
524 expect([send.hidden, send.getAttribute("aria-label"), stop.hidden, steer.hidden]).toEqual([false, "Queue: it sends after this answer", true, false]);
525 t.box.value = "";
526 t.box.dispatchEvent(new t.window.Event("input"));
524 expect([send.hidden, send.getAttribute("aria-label"), stop.hidden, steer.hidden]).toEqual([false, "Queue: it sends after this answer", false, false]);
527525 stop.dispatchEvent(new t.window.MouseEvent("click", { bubbles: true, cancelable: true }));
528526 t.doc.dispatchEvent(new t.window.KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
529527 expect(t.urls).toEqual(["/api/v1/conversation/stop", "/api/v1/conversation/stop"]);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs