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

Talk on a phone (#16442): pull #16532's three red checks were the shared inst… #16552

Merged opened this in answer to

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

Merged

scout/forge:scout/16551-talk-on-a-phone-16442-pull-16532-s-three → main 0 commits fork

  • Merged. scout/16551-talk-on-a-phone-16442-pull-16532-s-three was merged into main as 0f14d0b.

Review

Sign in to review this change.
7 files changed +212 −25
scripts/phone-persona/brief.md added +15
@@ -0,0 +1,15 @@
1 # The phone persona (#16442)
2
3 One more experiment beside the forge-to-forge one (#16407): a person who has only a phone.
4
5 **Doors.** The phone UI only: a browser at 390 x 844 CSS px, touch input (taps and swipes, no hover, no keyboard shortcuts, the on-screen keyboard taking the bottom third while a field is focused). It may not use the API, the MCP, git or the terminal, and it may not read the page's source: only what a thumb and an eye can reach.
6
7 **The run.**
8 1. Open the forge's address, sign up with a name, an address and a passphrase.
9 2. Open Talk. Ask for one small change to an app ("make the title bigger").
10 3. When a confirm appears in the dock above the box, read it and answer it with one thumb.
11 4. Read the result in the thread: the receipt, the link, the preview.
12
13 **What counts as stuck.** A control under 44 px, a button without a name, a sideways scroll, text under the keyboard, a line that never goes ("answering" after the answer), a box that moves while the thread grows, a list that opens at its far end, a top bar that wraps, or a step it cannot finish without leaving the phone.
14
15 **What it hands back.** Every stuck place becomes one issue: the page, the width, what it did with its thumb, what it saw, what it expected. Each issue is fixed with a test at its route; `test/talk-phone.test.ts` is where Talk's own land, measured at 360 px with touch emulation (`evaluateLoaded(..., touch = true)` in `test/helpers/chrome.ts`).
src/web/pages/talk.ts +4 −3
@@ -496,13 +496,14 @@ function displayForm(display: TalkDisplay, back: string): Html {
496496 * The open conversation's head: on a phone the way to the list, then its name, what it has cost,
497497 * and one menu for Rename, Download, Pin and Archive, each a plain form or link.
498498 */
499 function hereBar(ctx: Ctx, conversation: Conversation, context: Context | undefined, display: TalkDisplay, tabs: Html | null): Html {
499 function hereBar(ctx: Ctx, conversation: Conversation, context: Context | undefined, display: TalkDisplay, tabs: Html | null, picker: Html | null = null): Html {
500500 const archived = conversation.archivedAt !== null;
501501 const item = (action: string, field: string, value: string, label: string, ic: "pin" | "history" | "trash"): Html =>
502502 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>`;
503503 return html`<header class="talk-head">
504504 <a class="btn btn-icon talk-back" data-variant="ghost" href="${urlOf(conversation)}?chats=1" aria-label="Conversations" title="Conversations">${icon("comment")}</a>
505505 <h2 class="talk-title">${nameOf(conversation)}${archived ? " (archived)" : ""}</h2>
506 ${picker}
506507 ${tabs}
507508 ${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}
508509 ${menu({
@@ -642,7 +643,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
642643 const body = html`<div class="talk-page" data-shell${!split ? null : html` data-frame-origins="${frames.join(" ")}"`} data-pane="${shown}"${listing ? raw(" data-view=\"list\"") : null}${split ? raw(" data-split") : null}><h1 class="sr-only">Talk</h1>
643644 <div class="talk-side">${chats(ctx, conversation, showArchived, typed)}</div>
644645 <div class="talk" data-talk data-density="${display.density}" data-motion="${display.motion}" data-enter="${display.enter}" data-fold="${display.steps}" data-user="${user.id}" data-c="${conversation.id}" data-here="${here}" data-paged="${paged ? "1" : "0"}" data-running="${running && !paged ? "1" : "0"}">
645 ${hereBar(ctx, conversation, context, display, split ? html`<nav class="seg talk-tabs" aria-label="Chat or preview"><a href="?pane=chat${paneQ === "" ? "" : `&${paneQ}`}"${shown === "chat" ? raw(' aria-current="page"') : null}>Chat</a><a href="?pane=preview${paneQ === "" ? "" : `&${paneQ}`}"${shown !== "chat" ? raw(' aria-current="page"') : null}>Preview</a></nav>` : null)}
646 ${hereBar(ctx, conversation, context, display, split ? html`<nav class="seg talk-tabs" aria-label="Chat or preview"><a href="?pane=chat${paneQ === "" ? "" : `&${paneQ}`}"${shown === "chat" ? raw(' aria-current="page"') : null}>Chat</a><a href="?pane=preview${paneQ === "" ? "" : `&${paneQ}`}"${shown !== "chat" ? raw(' aria-current="page"') : null}>Preview</a></nav>` : null, picker)}
646647 ${turns.length === DEFAULT_PAGE && turns[0] !== undefined
647648 ? html`<p class="talk-more small"><a href="${here}?before=${turns[0].id}">Earlier</a></p>`
648649 : null}
@@ -676,7 +677,7 @@ async function talkPage(ctx: Ctx, conversation: Conversation, before0: string |
676677 <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>
677678 </div>
678679 </div>
679 ${buildMode ? html`<p class="talk-foot small"><a href="${here}">Talk instead</a></p>` : picker}
680 ${buildMode ? html`<p class="talk-foot small"><a href="${here}">Talk instead</a></p>` : null}
680681 <p class="talk-error small" id="talk-error" data-error hidden></p>
681682 <p class="talk-status small muted" role="status">${running ? "The forge is answering…" : ""}</p>
682683 <button type="button" class="btn talk-jump" data-jump hidden title="Jump to the latest message">${icon("pause")}${icon("arrowDown")}<span data-word></span><i class="talk-dot"></i></button>
src/web/pages/talk_client.ts +17 −14
@@ -59,10 +59,10 @@ body:has(.talk-page) .foot { display: none; }
5959 .talk { display: flex; flex-direction: column; width: 100%; max-width: 46rem; margin: 0 auto; min-width: 0; min-height: calc(100dvh - var(--topbar-h)); }
6060 .talk-side, .talk-work, [data-view="list"] :is(.talk, .talk-work) { display: none; }
6161 [data-view="list"] .talk-side { display: block; padding: 12px 0; }
62 .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); }
62 .talk-head { position: sticky; top: var(--topbar-h); z-index: 8; display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; min-height: 2.75rem; background: var(--bg); transition: transform var(--dur-2) var(--ease); }
6363 .talk-head[data-away] { transform: translateY(-110%); }
6464 .talk-head[data-away]:is(:focus-within, :has(details[open])) { transform: none; }
65 .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; }
65 .talk-title { flex: 1 1 0; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
6666 .talk-fill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
6767 .talk-fill meter { width: 3rem; }
6868 .talk-figures { display: grid; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
@@ -82,7 +82,7 @@ body:has(.talk-page) .foot { display: none; }
8282 .talk-display form { display: grid; gap: 8px; padding: 8px 12px; }
8383 .talk-display label { display: grid; gap: 4px; }
8484 .talk-display select { font-size: 16px; }
85 .talk-head .btn-icon, .talk-head summary.btn { position: relative; min-width: 2.5rem; min-height: 2.5rem; }
85 .talk-head .btn-icon, .talk-head summary.btn { position: relative; flex: none; min-width: 2.75rem; min-height: 2.75rem; }
8686 .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; }
8787 .talk-rename { display: flex; gap: 8px; padding: 8px; }
8888 .talk-rename .input { min-width: 0; flex: 1; font-size: 16px; }
@@ -100,8 +100,7 @@ body:has(.talk-page) .foot { display: none; }
100100 .talk-chats .row { min-height: 2.75rem; border-radius: var(--radius-sm); }
101101 .talk-chats .row-main { min-width: 0; }
102102 .talk-chats .row-title { overflow: hidden; text-overflow: ellipsis; }
103 .talk-chats .row-meta { overflow-wrap: anywhere; }
104 .talk-chats .row-meta { font-variant-numeric: tabular-nums; }
103 .talk-chats .row-meta { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
105104 .talk-archived { padding: 8px; }
106105 @media (min-width: 56.25rem) {
107106 .talk-page { grid-template-columns: 16rem minmax(0, 1fr); }
@@ -234,12 +233,11 @@ body:has(.talk-page) .foot { display: none; }
234233 .talk-send[hidden], .talk-stop[hidden], .talk-steer[hidden], .talk-dictate[hidden], [data-attach][hidden], .talk-jump[hidden] { display: none; }
235234 .talk-steer { border-radius: 999px; }
236235 .talk-dictate[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
237 .talk-foot, .talk-model { margin: 6px 16px 0; }
238 .talk-model { display: flex; align-items: center; gap: 8px; }
239 .talk-model select { width: auto; }
240 .talk-status { margin: 6px 16px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
241 .talk-status:empty { display: none; }
242 [data-answering] .talk-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
236 .talk-foot { margin: 6px 16px 0; }
237 .talk-model { flex: 0 1 9rem; min-width: 0; margin: 0; display: flex; align-items: center; gap: 4px; }
238 .talk-model select { width: 100%; min-width: 0; min-height: 2.5rem; font-size: 16px; text-overflow: ellipsis; }
239 .talk-status { margin: 4px 16px 0; min-height: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
240 [data-answering] .talk-status { background: none; animation: none; color: transparent; }
243241 .talk-error { margin: 6px 4px 0; color: var(--danger); }
244242 .talk-error[hidden] { display: none; }
245243 .talk-jump { position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); min-height: 2.75rem; border-radius: 999px; box-shadow: var(--shadow-2); gap: 6px; }
@@ -416,13 +414,14 @@ if (root) {
416414 let retry = 0;
417415 const paged = root.dataset.paged === "1";
418416 const { c: cid, here } = root.dataset;
417 const ANSWERING = "The forge is answering…";
419418 const say = (words) => { status.textContent = words; };
420419 const head = root.querySelector(".talk-head");
421420 if (head) head.addEventListener("focusin", () => head.removeAttribute("data-away"));
422421 const jump = form.querySelector("[data-jump]");
423422 const err = form.querySelector("[data-error]");
424423 const pick = form.querySelector("[data-model-pick]");
425 if (pick) { form.querySelector("[data-model-use]").hidden = true; pick.onchange = () => pick.form.requestSubmit(); }
424 if (pick) { root.querySelector("[data-model-use]").hidden = true; pick.onchange = () => pick.form.requestSubmit(); }
426425 box.required = false;
427426 const fail = (words) => { say(""); err.textContent = words; err.hidden = false; box.setAttribute("aria-invalid", "true"); };
428427 // The keyboard covers the layout viewport on phones: lift the composer by what it hides.
@@ -463,7 +462,9 @@ if (root) {
463462 const page = document.scrollingElement || document.documentElement;
464463 const sc = () => /auto|scroll/.test(window.getComputedStyle(root).overflowY) && root.scrollHeight > root.clientHeight ? root : page;
465464 const atEnd = () => { const s = sc(); return follows(s.scrollHeight, s.scrollTop, s.clientHeight); };
466 let stuck = true, fresh = false, lastTop = 0, lastH = 0, grown = 0, hand = -1e9;
465 let stuck = !document.querySelector('[data-view="list"]'), fresh = false, lastTop = 0, lastH = 0, grown = 0, hand = -1e9;
466 // The chat list opens at its top, whatever the browser restored or a late layout moved.
467 if (!stuck) { window.scrollTo({ top: 0, behavior: "instant" }); window.addEventListener("load", () => { if (!stuck && hand < 0) window.scrollTo({ top: 0, behavior: "instant" }); }); }
467468 const touched = () => { hand = performance.now(); };
468469 const followWords = { pause: ["Pause", "Pause scrolling and keep this place"], resume: ["Resume", "Resume following the reply"], latest: ["Latest", "Jump to the latest message"] };
469470 const draw = () => {
@@ -647,6 +648,8 @@ if (root) {
647648 };
648649 const mode = (on) => {
649650 answering = on;
651 // The answer ended, however it ended (replied, failed, stopped, a confirm answered): its line goes.
652 if (!on && status.textContent === ANSWERING) say("");
650653 form.toggleAttribute("data-answering", on);
651654 paint();
652655 // The composer and the thread's end strip just changed: a follower stays at the end now, in
@@ -704,7 +707,7 @@ if (root) {
704707 log.querySelectorAll("[data-queued]").forEach((q) => q.remove());
705708 for (const q of JSON.parse(e.data).items) log.insertAdjacentHTML("beforeend", q.html);
706709 });
707 source.addEventListener("running", () => { dropActs(); mode(true); log.setAttribute("aria-busy", "true"); say("The forge is answering…"); });
710 source.addEventListener("running", () => { dropActs(); mode(true); log.setAttribute("aria-busy", "true"); say(ANSWERING); });
708711 // The agent pointed the pane: its Preview tab draws it again where it points, or it opens.
709712 source.addEventListener("pane", () => { const a = document.querySelector("[data-split] .talk-pane nav.seg a"); if (a) a.click(); else openPane(); });
710713 source.addEventListener("done", (e) => {
src/web/talk_model.ts +9 −6
@@ -1,8 +1,8 @@
11 /**
2 * Talk's model picker, in the composer (`core/model_choice.ts`): a select of every model the person
3 * may use on a working connection, and the forge's own, saved for the conversation. A plain form
4 * post (`POST /talk/:id/model`), so it works with the script off; the script sends it on change.
5 * Absent when no connection offers a model, so a forge without connections looks as before.
2 * Talk's model picker, in the conversation's head (`core/model_choice.ts`): a select of every model
3 * the person may use on a working connection, and the forge's own, saved for the conversation. A
4 * plain form post (`POST /talk/:id/model`), so it works with the script off; the script sends it on
5 * change. Absent when no connection offers a model, so a forge without connections looks as before.
66 */
77 import { choiceLabel, choiceOf, choiceValue, FORGE_MODEL, offers, setChoice } from "../core/model_choice.ts";
88 import { connectionFor } from "../core/connections.ts";
@@ -15,7 +15,10 @@ import { field, readForm } from "./form.ts";
1515 import { html, type Html } from "./html.ts";
1616 import { flashTo } from "./layout.ts";
1717
18 /** The picker's line under the composer, its form outside it (`form=`), or null with nothing to offer. */
18 /**
19 * The picker, in the conversation's head, its form outside it (`form=`), or null with nothing to
20 * offer.
21 */
1922 export function modelPicker(ctx: Ctx, user: User, conversationId: string): Html | null {
2023 // A forge with no connection Talk could run on draws no picker and reads nothing for it.
2124 if (!anyTalkConnection(ctx.app.db)) return null;
@@ -28,7 +31,7 @@ export function modelPicker(ctx: Ctx, user: User, conversationId: string): Html
2831 // A choice whose connection stopped answering stays shown as the conversation's, never offered anew.
2932 const stale = now === undefined || listed ? undefined : connectionFor(ctx.app.db, user.id, now.connectionId);
3033 return html`<p class="talk-model small">
31 <label for="talk-model-pick">Model</label>
34 <label class="sr-only" for="talk-model-pick">Model</label>
3235 <select class="input" id="talk-model-pick" name="model" form="talk-model" data-model-pick>
3336 <option value=""${current === "" ? html` selected` : null}>${FORGE_MODEL}</option>
3437 ${now !== undefined && !listed ? html`<option value="${current}" selected>${choiceLabel(stale ?? { name: "a removed connection" }, now.model)} (not answering)</option>` : null}
test/talk-model-choice.test.ts +5
@@ -381,6 +381,11 @@ describe("the page's picker", () => {
381381 await fetch(`${servers.url}/talk/${c}`, { headers: { cookie } })
382382 ).text();
383383 expect(page).toContain('id="talk-model-pick"');
384 // On a phone it is in the head's one row (#16442), not under the composer.
385 const from = page.indexOf('<header class="talk-head">');
386 const head = page.slice(from, page.indexOf("</header>", from));
387 expect(head).toContain('id="talk-model-pick"');
388 expect(page.slice(page.indexOf('class="talk-compose"'))).not.toContain('id="talk-model-pick"');
384389 expect(page).toContain(
385390 '<form id="talk-model" method="post" action="/talk/' +
386391 c +
test/talk-page.test.ts +2 −2
@@ -143,8 +143,8 @@ describe("the page", () => {
143143 expect(html).toMatch(/talk-back" data-variant="ghost" href="\/talk\/[^"?]+\?chats=1"/);
144144 expect(talkCss).toContain('.talk-side, .talk-work, [data-view="list"] :is(.talk, .talk-work) { display: none; }');
145145 expect(talkCss).toMatch(/\.talk-compose \{[^}]*position: sticky; bottom: var\(--kb, 0px\)/);
146 // The head is 40 px; its buttons reach 44 px through a hit area that overlaps the head's own room.
147 expect(talkCss).toMatch(/\.talk-head \.btn-icon[^{]*\{[^}]*min-height: 2\.5rem/);
146 // The head is one 44 px row, its buttons 44 px themselves.
147 expect(talkCss).toMatch(/\.talk-head \.btn-icon[^{]*\{[^}]*min-height: 2\.75rem/);
148148 expect(talkCss).toMatch(/\.talk-head \.btn-icon::after[^{]*\{ content: ""; position: absolute; inset: -6px; \}/);
149149 expect(talkCss).toMatch(/\.talk-tools \.btn-icon \{[^}]*min-height: 2\.75rem/);
150150 expect(talkCss).toMatch(/\.talk-input \{[^}]*min-height: 2\.75rem/);
test/talk-phone.test.ts added +160
@@ -0,0 +1,160 @@
1 /**
2 * Talk on a phone (#16442), measured in a real Chromium at 360 px with a finger: the head is one
3 * row of the list, the title, the connection picker, the menu and New; the composer does not move
4 * as the tool-call count grows; the chat list opens at its top; the "answering" line ends with the
5 * answer. Skipped, and says so, where no Chromium starts.
6 */
7 import { afterAll, beforeAll, expect, test } from "bun:test";
8 import { mkdtemp, rm } from "node:fs/promises";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import { createApp, type App } from "../src/app.ts";
12 import { appendTurn, openConversation, createConversation, renameConversation } from "../src/core/conversations.ts";
13 import { createSession } from "../src/core/sessions.ts";
14 import { createUser } from "../src/core/users.ts";
15 import { findChromium } from "../src/looks/capture.ts";
16 import { serve, type Servers } from "../src/http/server.ts";
17 import { clock } from "../src/web/pages/talk.ts";
18 import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts";
19 import { quietLogs } from "./helpers/globals.ts";
20 import { promote } from "./helpers/members.ts";
21
22 quietLogs();
23 const found = findChromium();
24 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
25 if (chromium === undefined) console.log("SKIPPING: no chromium that starts on this machine, so Talk on a phone is not measured");
26
27 let dir: string;
28 let app: App;
29 let servers: Servers;
30 let token: string;
31 let shortId: string;
32 let manyId: string;
33 let listToken: string;
34
35 const toolTurns = (userId: string, id: string, n: number): void => {
36 appendTurn(app.db, userId, id, { role: "person", text: "change the title" });
37 for (let i = 0; i < n; i++) appendTurn(app.db, userId, id, { role: "tool", text: `step ${i}` });
38 appendTurn(app.db, userId, id, { role: "agent", text: "Done." });
39 };
40
41 beforeAll(async () => {
42 dir = await mkdtemp(join(tmpdir(), "forge-talk-phone-"));
43 app = createApp({ dataDir: dir, port: 0 });
44 servers = await serve(app);
45 const made = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true });
46 if (!made.ok) throw new Error(made.error);
47 promote(app.db, made.value);
48 token = createSession(app.db, made.value.id).token;
49 const a = openConversation(app.db, made.value.id);
50 shortId = a.id;
51 toolTurns(made.value.id, a.id, 1);
52 const b = createConversation(app.db, made.value.id);
53 if (!b.ok) throw new Error(b.error);
54 manyId = b.value.id;
55 toolTurns(made.value.id, manyId, 9);
56 // A second person with twenty chats, to see where the list opens.
57 const bob = await createUser(app.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase" });
58 if (!bob.ok) throw new Error(bob.error);
59 promote(app.db, bob.value);
60 for (let i = 0; i < 20; i++) {
61 const c = createConversation(app.db, bob.value.id);
62 if (!c.ok) throw new Error(c.error);
63 renameConversation(app.db, bob.value.id, c.value.id, `Chat number ${i}`);
64 appendTurn(app.db, bob.value.id, c.value.id, { role: "person", text: "hello" });
65 }
66 listToken = createSession(app.db, bob.value.id).token;
67 }, 30_000);
68 afterAll(async () => {
69 servers.stop();
70 app.close();
71 await rm(dir, { recursive: true, force: true });
72 });
73
74 const phone = (path: string, as: string, expression: string): Promise<any> =>
75 evaluateLoaded(chromium!, `${servers.url}${path}`, { width: 360, height: 740 }, [{ name: "forge_session", value: as }], expression, "light", true).then((v) => JSON.parse(v));
76
77 test.skipIf(chromium === undefined)("the message box does not ride when the status line speaks, nor with the tool-call count", async () => {
78 const at = `(async () => {
79 const box = () => document.querySelector(".talk-box").getBoundingClientRect().bottom;
80 const st = document.querySelector(".talk-status"), form = document.querySelector("form.talk-compose");
81 const quiet = box();
82 st.textContent = "The forge replied.";
83 const spoke = box();
84 form.setAttribute("data-answering", "");
85 st.textContent = "The forge is answering…";
86 const busy = box();
87 return JSON.stringify({ quiet, spoke, busy, sw: document.documentElement.scrollWidth });
88 })()`;
89 const few = await phone(`/talk/${shortId}`, token, at);
90 const many = await phone(`/talk/${manyId}`, token, at);
91 for (const s of [few, many]) {
92 expect(Math.abs(s.spoke - s.quiet)).toBeLessThanOrEqual(1);
93 expect(Math.abs(s.busy - s.quiet)).toBeLessThanOrEqual(1);
94 expect(s.sw).toBeLessThanOrEqual(360);
95 }
96 expect(Math.abs(few.quiet - many.quiet)).toBeLessThanOrEqual(1);
97 }, 30_000);
98
99 test.skipIf(chromium === undefined)("the head is one compact row: list, title, new chat and menu inside it, nothing wrapped", async () => {
100 const s = await phone(`/talk/${shortId}`, token, `(() => {
101 const head = document.querySelector(".talk-head"), h = head.getBoundingClientRect();
102 const kids = [...head.querySelectorAll(":scope > *")].filter((e) => e.getBoundingClientRect().width > 0).map((e) => { const r = e.getBoundingClientRect(); return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, w: r.width, h: r.height, cls: e.className }; });
103 return JSON.stringify({ h: h.height, right: h.right, kids, area: kids.filter((k) => /btn/.test(k.cls)).map((k) => [k.w, k.h]) });
104 })()`);
105 expect(s.h).toBeLessThanOrEqual(48);
106 for (const k of s.kids) { expect(k.top).toBeGreaterThanOrEqual(0); expect(k.right).toBeLessThanOrEqual(360); expect(k.bottom - 0).toBeLessThanOrEqual(s.kids[0].top + 48); }
107 for (const [w, h] of s.area) { expect(w).toBeGreaterThanOrEqual(44); expect(h).toBeGreaterThanOrEqual(44); }
108 }, 30_000);
109
110 test.skipIf(chromium === undefined)("the chat list opens at its top, the newest chat in view", async () => {
111 const s = await phone(`/talk?chats=1`, listToken, `(async () => { await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))); const first = document.querySelector(".talk-list .row"); const r = first.getBoundingClientRect(); return JSON.stringify({ y: window.scrollY, tall: document.documentElement.scrollHeight > innerHeight, top: r.top, text: first.textContent }); })()`);
112 const seen = JSON.stringify(s);
113 expect(s.y, seen).toBe(0);
114 expect(s.top, seen).toBeGreaterThanOrEqual(0);
115 expect(s.text, seen).toContain("Chat number 19");
116 expect(s.tall, seen).toBe(true);
117 }, 30_000);
118
119 test.skipIf(chromium === undefined)("the answering line is gone when the answer ends, even after a confirm was answered meanwhile", async () => {
120 const was = { tick: clock.tickMs, running: clock.running };
121 let on = true;
122 clock.tickMs = 100;
123 clock.running = () => on;
124 setTimeout(() => { on = false; }, 1800);
125 try {
126 const s = await phone(`/talk/${shortId}`, token, `(async () => {
127 const wait = (f) => new Promise((ok) => { const t = setInterval(() => { if (f()) { clearInterval(t); ok(); } }, 25); setTimeout(() => { clearInterval(t); ok(); }, 4000); });
128 const st = document.querySelector(".talk-status");
129 await wait(() => st.textContent.includes("answering"));
130 const seen = st.textContent;
131 // A confirm answered while the answer runs: the page reads the outcome and stays quiet.
132 window.fetch = async () => new Response(JSON.stringify({ message: "Already answered" }), { status: 409 });
133 const dock = document.querySelector(".talk-confirm-list");
134 dock.insertAdjacentHTML("beforeend", '<div class="talk-confirm"><button type="button" data-answer formaction="/x" value="yes">Yes</button></div>');
135 dock.querySelector("[data-answer]").click();
136 await wait(() => !document.querySelector("form[data-answering]"));
137 await wait(() => document.querySelector("[data-confirms]").hidden);
138 return JSON.stringify({ seen, after: st.textContent });
139 })()`);
140 expect(s.seen).toContain("answering");
141 expect(s.after).not.toContain("answering");
142 } finally {
143 clock.tickMs = was.tick;
144 clock.running = was.running;
145 }
146 }, 30_000);
147
148 test("without a browser: the page's script ends the answering line with the answer and does not follow the end in the chat list", async () => {
149 const { talkJs } = await import("../src/web/pages/talk_client.ts");
150 // Every way an answer ends goes through mode(false), which takes the line away.
151 expect(talkJs).toContain('if (!on && status.textContent === ANSWERING) say("")');
152 expect(talkJs).toContain("let stuck = !document.querySelector('[data-view=\"list\"]')");
153 const res = await fetch(`${servers.url}/talk?chats=1`, { headers: { cookie: `forge_session=${listToken}` } });
154 const page = await res.text();
155 expect(page).toContain('data-view="list"');
156 // Newest first: the list's first row is the latest chat.
157 expect(page).toContain("Chat number 0");
158 expect(page.indexOf("Chat number 19")).toBeLessThan(page.indexOf("Chat number 0"));
159 expect(page.indexOf("Chat number 19")).toBeGreaterThan(-1);
160 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs