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

A known block's groups say themselves: an icon, the label, and what it means, on the page and in the terminal #16319

Merged opened this

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

Merged

talk/ksu-heads → main 0 commits 2 threads · 2 unresolved

  • Merged. talk/ksu-heads was merged into main as ba3d3b4.

Review

Sign in to review this change.
5 files changed +35 −16
docs/design/areas/talk.md +1 −1
@@ -76,7 +76,7 @@ Talk's voice (`src/web/talk_parts.ts`, docs/features/talk-voice.md): the forge's
7676 - `.talk-card-missing` — "Result not found." where a handle names no card of this conversation, and the one line saying how many placings and blocks past the caps were left as text (markup only); `.talk-card-again` is the one-line pointer a repeated placing draws to the first (markup only).
7777 - `.talk-choices` — the agent's question and one button per option (a starter form, so it works with the script off); `.talk-choices-options` is their row, which wraps where there is room and stacks, each the reply's width, below 40rem. None is primary.
7878 - `.talk-plan` — the agent's plan, a plain row per step at regular weight: its icon, then the step; a done or skipped step is muted. The state is in words in the row's name (`.sr-only`), and shown as `.talk-plan-state` only for a skipped step, so it never rests on colour.
79 - `.talk-known` — Known, Suspected, Unknown, each a bare list at regular weight under a small muted label; an item's source, a result it names, follows its words as `.talk-known-src` (the result's title: a link where the reply places it, quiet text otherwise); an item that names none is its words alone.
79 - `.talk-known` — Known, Suspected, Unknown, each a bare list at regular weight under its head (`.talk-known-head`: an icon, the label, its meaning for a hover and a screen reader); `.talk-known-unknown` is muted; an item's source, a result it names, follows its words as `.talk-known-src` (the result's title: a link where the reply places it, quiet text otherwise); an item that names none is its words alone.
8080
8181 ## #15734: one scroller, one column
8282
docs/features/talk-voice.md +1 −1
@@ -91,7 +91,7 @@ choices
9191
9292 - `choices`: `question` (up to 300 characters) and `options`, 2 to 4 strings of up to 120 characters that still differ once cleaned. Drawn as the question, at the reply's own weight, and one button per option (none primary; they sit in a row where there is room and stack the width of the reply on a phone); a press sends that option, as cleaned and as shown, as the person's next message (a starter form, so it also works with the script off). It is the person's own message: the fence treats it as their words, the same as if they had typed it, so an option is only ever what the person read on the button. Only the last reply's choices are buttons: once the person has said something after it, they are plain text, and with the script on a press stills every choice button at once and puts the cursor back in the message box.
9393 - `plan`: `steps`, 1 to 12 of `{"text": "...", "state": "todo" | "doing" | "done" | "skipped"}`, text up to 200 characters. Drawn as plain rows at the reply's own weight, each starting with its state's icon; a done or skipped step is muted. The state is in words in each row's name for a screen reader, and on the page for a skipped step, so it never rests on an icon or a colour alone.
94 - `known`: `known`, `suspected` and `unknown`, each a list of up to 8 items of up to 300 characters, with at least one item in all. Items are inline Markdown (code, emphasis, http(s) links). Drawn as three quiet groups, each under a small muted label, items at the reply's own weight; an empty one is left out. An Unknown item names what would settle it in its own words, or as `{"item": "...", "settle": "..."}`, drawn as one row ("...; to settle: ..."), so the two read together. A `::show c7` inside an item is its source: the result's title, linked to the card where this reply places it, and quiet text when the reply does not place it; a handle that names nothing kept draws nothing. No item is ever marked as lacking a source.
94 - `known`: `known`, `suspected` and `unknown`, each a list of up to 8 items of up to 300 characters, with at least one item in all. Items are inline Markdown (code, emphasis, http(s) links). Drawn as three quiet groups, items at the reply's own weight, an empty one left out. Each group says itself: an icon (a closed circle, a half circle, a question), its label, and what the label means (Known: read just now; Suspected: likely, not confirmed; Unknown: could not be found out) as its hover and its screen-reader words. The weight steps down from Known to Unknown, which is muted; no group has a colour of its own. The terminal prints the same heads with the same meanings, "Known (read just now):" (`KNOWN_WORDS`, `src/core/talk_voice.ts`). An Unknown item names what would settle it in its own words, or as `{"item": "...", "settle": "..."}`, drawn as one row ("...; to settle: ..."), so the two read together. A `::show c7` inside an item is its source: the result's title, linked to the card where this reply places it, and quiet text when the reply does not place it; a handle that names nothing kept draws nothing. No item is ever marked as lacking a source.
9595
9696 ## What the agent is told
9797
src/core/talk_voice.ts +13 −4
@@ -339,6 +339,15 @@ export type Part =
339339 | { readonly kind: "plan"; readonly steps: readonly { readonly text: string; readonly state: PlanState }[] }
340340 | { readonly kind: "known"; readonly known: readonly string[]; readonly suspected: readonly string[]; readonly unknown: readonly string[] };
341341
342 /** A known block's three groups. */
343 export type KnownGroup = "known" | "suspected" | "unknown";
344 /** Each group's label and what it means, said the same by the page and the terminal. */
345 export const KNOWN_WORDS: Readonly<Record<KnownGroup, readonly [string, string]>> = {
346 known: ["Known", "read just now"],
347 suspected: ["Suspected", "likely, not confirmed"],
348 unknown: ["Unknown", "could not be found out"],
349 };
350
342351 /**
343352 * The most one reply draws: distinct cards, pointers back to one already drawn, and blocks. Past
344353 * them a line or a block stays the text it is, and one quiet line says how many, so a reply cannot
@@ -689,11 +698,11 @@ export function plainVoice(text: string, cards: ReadonlyMap<number, ShownCard>):
689698 case "known":
690699 return (
691700 [
692 ["Known", p.known],
693 ["Suspected", p.suspected],
694 ["Unknown", p.unknown],
701 ["known", p.known],
702 ["suspected", p.suspected],
703 ["unknown", p.unknown],
695704 ] as const
696 ).flatMap(([label, items]) => (items.length === 0 ? [] : [`${label}:`, ...items.map((x) => ` - ${x}`)]));
705 ).flatMap(([group, items]) => (items.length === 0 ? [] : [`${KNOWN_WORDS[group][0]} (${KNOWN_WORDS[group][1]}):`, ...items.map((x) => ` - ${x}`)]));
697706 }
698707 })
699708 .join("\n");
src/web/talk_parts.ts +11 −4
@@ -16,7 +16,7 @@
1616 import type { Database } from "bun:sqlite";
1717 import type { ShownCard } from "../core/talk_voice.ts";
1818 import type { Turn } from "../core/conversations.ts";
19 import { cardsPlaced, NOT_FOUND_WORDS, overWords, planWord, voiceParts, wholeSoFar, withUnit, type Part, type PlanState } from "../core/talk_voice.ts";
19 import { cardsPlaced, KNOWN_WORDS, NOT_FOUND_WORDS, overWords, planWord, voiceParts, wholeSoFar, withUnit, type KnownGroup, type Part, type PlanState } from "../core/talk_voice.ts";
2020 import { fresh, mayAct } from "../actions/talk_act.ts";
2121 import { escapeHtml, html, raw, type Html } from "./html.ts";
2222 import { formatValue, sayLabels } from "../boards/chart.ts";
@@ -221,18 +221,23 @@ function partHtml(p: Exclude<Part, { kind: "text" }>, live: boolean, voice: Voic
221221 },
222222 );
223223 case "known": {
224 const part = (label: string, items: readonly string[]): Html | null =>
224 // Each group says itself: an icon, its label, and what the label means one hover or one
225 // screen-reader phrase away; the weight steps down from Known to Unknown, never colour alone.
226 const part = (group: KnownGroup, items: readonly string[]): Html | null =>
225227 items.length === 0
226228 ? null
227229 : listCard(
228230 items.map((x) => row({ title: itemHtml(x, placed, voice?.cards ?? new Map()) })),
229 { extra: "bare talk-known", head: html`<span class="small muted">${label}</span>` },
231 { extra: `bare talk-known talk-known-${group}`, head: html`<span class="talk-known-head small" title="${KNOWN_WORDS[group][1]}">${icon(KNOWN_ICON[group])}${KNOWN_WORDS[group][0]}<span class="sr-only">: ${KNOWN_WORDS[group][1]}</span></span>` },

Principle 1/8: the meaning lives only in title and sr-only text, so touch users never see it. Next: show it as muted text, or make it tappable.

230232 );
231 return html`${part("Known", p.known)}${part("Suspected", p.suspected)}${part("Unknown", p.unknown)}`;
233 return html`${part("known", p.known)}${part("suspected", p.suspected)}${part("unknown", p.unknown)}`;
232234 }
233235 }
234236 }
235237
238 /** A known block's groups at a glance: a closed circle, a half circle, a question. */
239 const KNOWN_ICON: Readonly<Record<KnownGroup, IconName>> = { known: "issueClosed", suspected: "circleHalf", unknown: "help" };
240
236241 /**
237242 * An agent reply's body: its Markdown (each run through `linked`, the page's `#12` links), its
238243 * shown results and its blocks. A reply with neither is `linked(renderMarkdown(text))`, as before.
@@ -499,6 +504,8 @@ p.talk-card-from { padding-inline-start: 24px; }
499504 .talk-plan > .card-head, .talk-known > .card-head { padding: 0 0 4px; }
500505 .talk-plan .row, .talk-known .row { padding: 4px 0; min-height: 0; align-items: baseline; }
501506 .talk-plan .row-title, .talk-known .row-title { font-weight: inherit; }
507 .talk-known-head { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--fg); }
508 .talk-known-unknown .talk-known-head, .talk-known-unknown .row-title { color: var(--muted-fg); font-weight: 400; }
502509 .talk-plan .row-lead { align-self: center; }
503510 .talk-plan li[data-state="done"] .row-title, .talk-plan li[data-state="skipped"] .row-title, .talk-plan-state { color: var(--muted-fg); }
504511 ` + widgetCss;
test/talk-blocks.test.ts +9 −6
@@ -199,9 +199,11 @@ describe("each block, valid, is drawn as its shape", () => {
199199 unknown: ["Whether it flakes"],
200200 }),
201201 );
202 expect(html).toContain('<span class="small muted">Known</span>');
203 expect(html).toContain('<span class="small muted">Unknown</span>');
204 expect(html).not.toContain(">Suspected<");
202 // Each group says itself: an icon, its label, and what the label means for a hover and a screen reader.
203 expect(html).toMatch(/<span class="talk-known-head small" title="read just now"><svg[^>]*>.*?<\/svg>Known<span class="sr-only">: read just now<\/span><\/span>/s);
204 expect(html).toMatch(/title="could not be found out"><svg[^>]*>.*?<\/svg>Unknown</s);
205 expect(html).toContain("talk-known-unknown");

Suspected is only asserted absent; add a case where it is present and check its icon and "likely, not confirmed".

206 expect(html).not.toContain("Suspected");
205207 expect(html).toContain(
206208 '<a href="/alice/w/runs/1" rel="nofollow noopener">run</a>',
207209 );
@@ -382,7 +384,7 @@ describe("anything invalid is the code block it always was", () => {
382384 test("known: an unknown item may come with what would settle it, as the brief asks (a real reply)", () => {
383385 const real = '{"known": ["Diff of 06b1627: +2/-0 in src/beacon.ts", "::show c3"], "suspected": ["The drift is not fixed"], "unknown": [{"item": "Whether tests reference beacon.ts", "settle": "List the repo root on main"}]}';
384386 const html = drawn("```known\n" + real + "\n```");
385 expect(html).toContain('class="card bare talk-known"');
387 expect(html).toContain('class="card bare talk-known talk-known-unknown"');
386388 expect(html).toContain("Whether tests reference beacon.ts; to settle: List the repo root on main");
387389 expect(html).not.toContain("&quot;known&quot;");
388390 });
@@ -483,7 +485,7 @@ describe("a README is untouched", () => {
483485 describe("the page's rules and links", () => {
484486 test("the stylesheet is small, uses tokens, and says sides logically", () => {
485487 // The widgets' own rules ride on the same sheet and are held by test/widget-view.test.ts.
486 expect(Buffer.byteLength(voiceCss) - Buffer.byteLength(widgetCss)).toBeLessThan(2_600);
488 expect(Buffer.byteLength(voiceCss) - Buffer.byteLength(widgetCss)).toBeLessThan(2_800);
487489 expect(voiceCss).not.toMatch(
488490 /#[0-9a-f]{3,6}\b|rgb\(|(?:margin|padding)-(?:left|right)/i,
489491 );
@@ -540,7 +542,8 @@ describe("the terminal prints the same parts", () => {
540542 expect(out).toContain("Result not found.");
541543 expect(out).toContain("Plan:\n 1. [done] Read");
542544 expect(out).toContain("Which?\n 1. a\n 2. b");
543 expect(out).toContain("Known:\n - k\nUnknown:\n - u");
545 // The terminal says each group's meaning too, in the same words.
546 expect(out).toContain("Known (read just now):\n - k\nUnknown (could not be found out):\n - u");
544547 expect(out).not.toContain("Suspected");
545548 expect(plainVoice("plain words", new Map())).toBe("plain words");
546549 // Every spelling of a block's fence prints the same; a code block labelled with a kind stays

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs