Skip to content
Myr

Finish the Control room: every page passes axe and a keyboard walk in both schemes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- Add apps/web/e2e/a11y.e2e.ts (WEB_URL only, never in verify): axe-core 4.10.2 loaded from cdnjs at run time (no dependency) on 39 pages of the dev world with fixtures, light and dark at 1440 and 390; no serious or critical violation, no sideways scroll at 390 or 360, no forbidden word in the web's own words; a keyboard walk (skip link first and onto main, focus visible on every stop, rail before toolbar before a row's copy button before the inspector, ? and its switch, j/k on the front page and Today, J/K on a commit and a finish, 1 copies the selected ask's claim, every sheet traps focus and gives it back on Escape). - Add apps/web/test/type-floor.test.ts: no text-xs, no arbitrary text size at or under 13 px; the shared ID, CODE and LABEL classes now use the text-mono and text-label steps (LABEL was 12 px). - j/k past the first row: the front page and a project home swapped their tree when a row was first selected (a wrapper mounted only with a selection), so the list remounted and the keys lost their place. One selectedAskAtom serves both states; the wrapper always mounts. - The file tree's filter is a field above the tree (filterTree), not Pierre's search inside role=tree (axe: aria-required-children, critical). - Code that scrolls sideways is a Tab stop with an ink focus ring inside Pierre's shadow root (diffsOptions.onPostRender, FOCUS_CSS); the agents page's JSON snippets keep their lines and scroll; the platform's / gives its command blocks tabindex. - Light syntax string, constant, comment and punctuation tokens darkened to keep 4.5:1 on a changed word's tint (axe on the finish diff). - CommandLine keeps each word whole (no break after a hyphen in a 19 rem inspector); a narrow column breaks between words. - A phone's decision choices are fixed above the bottom bar (sticky could not rise above a decision that starts low), with main keeping room at its foot. - On a phone the context bar keeps only the page's own crumb (the top bar's Back names the parent); a long group header wraps its posture rather than cutting it; RowList's top hairline runs as wide as its rows. - A family's children stay in the page while folded (hidden), and each open child has its claim button (ClaimAction, shared with AskRow), so the claim commands are DOM text on the front page and a project home. - An answer waiting on another ask says "that ask's move", not "the family's move" (the ask may be no family's); provenance gives a relative time no copy button; plain evidence labels show in sentence case (CSS, text unchanged); the why page's permalink stays on why; a drafted file no longer shows its path twice. - Markers for the forbidden-word check: data-said on a person's or a repo's words (row titles, want titles, briefs, commit bodies, notes, vouch notes), data-term on the gate's own stage and group names ("Merge"). - Tests: type-floor, pierre (scrolled code reachable), code-client (filter outside the tree), code (permalink by mode), family (claim commands folded or not), shared (command words whole), status-line and events (that ask's move), platform pages (focusable pre); ledger and refs read the command as the code element's text. - bytes:check: web JavaScript 4,074,652 of 4,075,000 (two new doc comments are line comments, which the unminified server build drops). - ASSUMPTION: Base UI's sheets trap focus one frame after Tab (its guards refocus in requestAnimationFrame); the walk waits 120 ms per stop inside a sheet.

authored by oscabriel · committed by oscabriel · parent c1423e6 · Browse files · 49 files+1351 added−140 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

49 files+1351 added−140 removed

  • tests:+206 added−7 removed
  • other:+1145 added−133 removed

49 files+1351 added−140 removed

modified:apps/platform/src/home.ts+3 added-1 removed
74 unmodified lines
75};7677const code = (text: string) => `<code>${escapeHtml(text)}</code>`;7879// Tab reaches a command that scrolls sideways on a phone, to scroll it.80const pre = (text: string) =>79const pre = (text: string) => `<pre><code>${escapeHtml(text)}</code></pre>`;81 `<pre tabindex="0"><code>${escapeHtml(text)}</code></pre>`;8283const link = (url: string, text = url) =>84 `<a href="${escapeHtml(url)}">${escapeHtml(text)}</a>`;85
121 unmodified lines
modified:apps/platform/test/pages.test.ts+12 added
353 unmodified lines
354 holdsTheFloors(rules, "dark", page.form);355 })356 );357358 it.effect("lets the keyboard reach a block that scrolls sideways", () =>359 Effect.gen(function* () {360 const html = yield* page.html;361362 // A command wider than a phone scrolls in its box: Tab reaches the363 // box, so a keyboard can scroll it.364 expect(html.match(/<pre\b[^>]*>/gu) ?? []).toStrictEqual(365 (html.match(/<pre\b[^>]*>/gu) ?? []).map(() => '<pre tabindex="0">')366 );367 })368 );369370 it.effect("reads at 16 px, inputs too", () =>371 Effect.gen(function* () {372 const rules = rulesOf(styleOf(yield* page.html));373
65 unmodified lines
added:apps/web/e2e/a11y.e2e.ts+790 added
1/**2 * Every page of the web, as a browser and a keyboard reach it, in both3 * colour schemes at 1440 and 390 px wide:4 *5 * - axe-core finds no serious or critical violation (it is loaded from6 * cdnjs into the page at run time, so no package is added for it);7 * - no page scrolls sideways at 390 or 360;8 * - no word the web keeps off its screens (review, approve, merge, queue,9 * …) appears in its own chrome; text that comes from a repository or a10 * person (a README, code, a diff, a want, a brief, a commit message, a11 * note, a refusal's own text) is left out by the marker its view sets;12 * - the keyboard: the skip link is the first stop and lands on main; focus13 * shows on every stop; the rail, the toolbar's filters, a row's copy14 * button and the inspector's commands come in that order; `?` opens the15 * keys dialog, whose switch turns `j`/`k` off; `j`/`k` move the16 * selection on the front page and Today; `J`/`K` move between files on a17 * commit and a finish; `1` copies the inspector's first command; every18 * sheet keeps focus inside it and gives it back to its button on Escape.19 *20 * It runs only against `WEB_URL`, the web's dev world with its fixtures21 * (`VITE_DEV_FIXTURES=1 bun run dev -- --port <port>`): the pages it visits22 * are the fixture project's, and it signs in through the dev world's own23 * `/auth/dev`. `A11Y_PROJECT` names the fixture project (vellum unless24 * given). It only reads, but for the keys switch, kept in this browser.25 */26import { expect, test } from "@playwright/test";27import type { Browser, BrowserContext, Page } from "@playwright/test";28import { Brand } from "@repo/brand";29import { Config, Effect, Option, Schema } from "effect";3031const settings = Effect.runSync(32 Effect.gen(function* () {33 return {34 project: yield* Config.NonEmptyString("A11Y_PROJECT").pipe(35 Config.withDefault("vellum")36 ),37 web: Option.map(38 yield* Config.option(Config.NonEmptyString("WEB_URL")),39 (url) => url.replace(/\/+$/u, "")40 ),41 };42 })43);4445const { project } = settings;4647const at = (path: string) =>48 `${Option.getOrElse(settings.web, () => "")}${path}`;4950/** axe-core, from cdnjs, at the version this check was written against. */51const AXE = "https://cdnjs.cloudflare.com/ajax/libs/axe-core/4.10.2/axe.min.js";5253/** The decider the dev world signs in. */54const DECIDER = "ines-v";5556/** A page to visit: where, whether a decider must be signed in, what it answers. */57interface Visit {58 readonly name: string;59 readonly path: string;60 readonly signedIn?: boolean;61 readonly status?: number;62}6364/**65 * The commit page's address comes from the landings page (its SHA is the66 * dev world's), so it is visited by name and found at run time: the newest67 * ask opening, which changes two files or more (the ask and its check).68 */69const COMMIT = "<the newest ask opening>";7071/** Every page group, over the fixture project's states. */72const VISITS: readonly Visit[] = [73 { name: "front", path: "/" },74 { name: "front, signed in", path: "/", signedIn: true },75 { name: "today", path: "/today", signedIn: true },76 { name: "today, signed out", path: "/today" },77 { name: "project home", path: `/${project}` },78 { name: "project home, examples", path: "/burrow" },79 { name: "project home, no open asks", path: "/mossgate" },80 { name: "ask, open", path: `/${project}/asks/lint-heading-levels` },81 {82 name: "ask, held for newcomers",83 path: `/${project}/asks/document-cli-flags`,84 },85 { name: "ask, claimed", path: `/${project}/asks/number-footnotes` },86 { name: "ask, a family", path: `/${project}/asks/retire-old-tokenizer` },87 {88 name: "answer, checking",89 path: `/${project}/answers/retire-old-tokenizer-vellum-lint`,90 },91 {92 name: "answer, waiting on a finish",93 path: `/${project}/answers/wrap-long-table-cells`,94 },95 {96 name: "answer, refused",97 path: `/${project}/answers/trim-trailing-spaces`,98 },99 {100 name: "answer, held back",101 path: `/${project}/answers/retire-old-tokenizer-vellum-parser`,102 },103 {104 name: "answer, landed",105 path: `/${project}/answers/carry-footnotes-to-epub`,106 },107 {108 name: "answer, unclaimed",109 path: `/${project}/answers/lint-heading-levels`,110 },111 { name: "ledger", path: `/${project}/ledger` },112 { name: "env shape", path: `/${project}/env` },113 { name: "policy", path: `/${project}/people` },114 { name: "refs", path: `/${project}/refs` },115 { name: "tree", path: `/${project}/tree/main` },116 { name: "folder", path: `/${project}/tree/main/packages/render/src` },117 { name: "blob", path: `/${project}/blob/main/packages/render/src/page.ts` },118 { name: "why", path: `/${project}/why/main/packages/render/src/page.ts` },119 { name: "landings", path: `/${project}/commits/main` },120 { name: "commit", path: COMMIT },121 {122 name: "decision",123 path: `/${project}/decisions/dec-000002`,124 signedIn: true,125 },126 {127 name: "decision, signed out",128 path: `/${project}/decisions/dec-000002`,129 },130 { name: "finish", path: `/${project}/decisions/dec-000004`, signedIn: true },131 { name: "proposal, ready", path: `/${project}/proposals/prop-000002` },132 { name: "proposal, failed", path: `/${project}/proposals/prop-000003` },133 {134 name: "propose",135 path: `/${project}/proposals/new`,136 signedIn: true,137 },138 { name: "propose, signed out", path: `/${project}/proposals/new` },139 { name: "person", path: `/people/${DECIDER}` },140 { name: "for agents", path: "/agents" },141 { name: "unknown project", path: "/no-such-project", status: 404 },142 {143 name: "unknown ask",144 path: `/${project}/asks/no-such-ask`,145 status: 404,146 },147 {148 name: "unknown path",149 path: `/${project}/blob/main/no/such/file.ts`,150 status: 404,151 },152];153154const SCHEMES = ["light", "dark"] as const;155156const WIDTHS = [1440, 390] as const;157158/**159 * Words the web keeps off its screens, matched whole and in any case160 * ("merged tree" passes; "merge" does not).161 */162const FORBIDDEN =163 /\b(?:review|reviewer|approve|approval|PR|pull request|issue|merge|lease|reputation|inbox|queue|dashboard|explore|trending|nit)\b/iu;164165/**166 * Text a repository or a person wrote, which the web shows as given: the167 * views mark each such block (`data-said` for a want, a brief, a commit's168 * subject or body, a note). A refusal's own text comes from the one169 * renderer every surface shares (`data-refusal`), and the gate's own names170 * for its stages ("Merge") are the protocol's (`data-term`).171 */172const NOT_OURS =173 "[data-readme], [data-code], [data-diff], [data-said], [data-refusal], [data-term], script, style, noscript";174175/** A context for `scheme` at `width`, signed in as the decider when asked. */176const contextFor = (177 browser: Browser,178 scheme: (typeof SCHEMES)[number],179 width: number,180 signedIn: boolean181) =>182 Effect.gen(function* () {183 const context = yield* Effect.promise(() =>184 browser.newContext({185 colorScheme: scheme,186 viewport: { height: width > 800 ? 900 : 844, width },187 })188 );189190 if (signedIn) {191 const page = yield* Effect.promise(() => context.newPage());192193 yield* Effect.promise(() => page.goto(at(`/auth/dev?handle=${DECIDER}`)));194195 yield* Effect.promise(() => page.close());196 }197198 return context;199 });200201/** The newest landing's commit page, read from the landings page. */202const commitPath = (context: BrowserContext) =>203 Effect.gen(function* () {204 const page = yield* Effect.promise(() => context.newPage());205206 yield* Effect.promise(() => page.goto(at(`/${project}/commits/main`)));207208 const href = yield* Effect.promise(() =>209 page210 .locator(`a[href^="/${project}/commit/"]`, { hasText: "Open ask" })211 .first()212 .getAttribute("href")213 );214215 yield* Effect.promise(() => page.close());216217 return href ?? `/${project}/commits/main`;218 });219220/** Open `path` and let the browser take the page over. */221const open = (page: Page, path: string) =>222 Effect.gen(function* () {223 const response = yield* Effect.promise(() =>224 page.goto(at(path), { waitUntil: "load" })225 );226227 // The page hydrates, then its client reads settle (lists, the tree).228 yield* Effect.promise(() => page.waitForTimeout(1500));229230 return response?.status();231 });232233/** What axe's `run` resolves to, as much of it as this check reads. */234const AxeRun = Schema.Struct({235 violations: Schema.Array(236 Schema.Struct({237 id: Schema.String,238 impact: Schema.NullOr(Schema.String),239 nodes: Schema.Array(240 Schema.Struct({ target: Schema.Array(Schema.Unknown) })241 ),242 })243 ),244});245246const decodeAxeRun = Schema.decodeUnknownEffect(AxeRun);247248/** axe's serious and critical violations on the page, as `rule (n): targets`. */249const axeOn = (page: Page) =>250 Effect.gen(function* () {251 yield* Effect.promise(() => page.addScriptTag({ url: AXE }));252253 // axe's results come from the page: decoded here, as any outside input.254 const raw: unknown = yield* Effect.promise(() =>255 page.evaluate("axe.run()")256 );257258 const result = yield* Effect.orDie(decodeAxeRun(raw));259260 return result.violations261 .filter(({ impact }) => impact === "serious" || impact === "critical")262 .map(263 ({ id, impact, nodes }) =>264 `${impact} ${id} (${nodes.length}): ${nodes265 .slice(0, 3)266 .map(({ target }) => target.join(" "))267 .join(", ")}`268 );269 });270271/** How far the page scrolls sideways, in px; 0 when it does not. */272const sideways = (page: Page) =>273 Effect.promise(() =>274 page.evaluate(275 () =>276 document.documentElement.scrollWidth -277 document.documentElement.clientWidth278 )279 );280281/** The page's own words that the web keeps off its screens. */282const forbiddenOn = (page: Page) =>283 Effect.promise(() =>284 page.evaluate(285 ({ forbidden, notOurs }) => {286 const pattern = new RegExp(forbidden, "iu");287288 const walker = document.createTreeWalker(289 document.body,290 NodeFilter.SHOW_TEXT291 );292293 const found: string[] = [];294295 for (296 let node = walker.nextNode();297 node !== null;298 node = walker.nextNode()299 ) {300 const parent = node.parentElement;301 const text = node.textContent ?? "";302303 if (304 parent !== null &&305 parent.closest(notOurs) === null &&306 parent.checkVisibility() &&307 pattern.test(text)308 ) {309 found.push(text.trim().slice(0, 80));310 }311 }312313 return found;314 },315 { forbidden: FORBIDDEN.source, notOurs: NOT_OURS }316 )317 );318319test.describe("every page, by axe, at two widths, in both schemes", () => {320 test.skip(321 Option.isNone(settings.web),322 "WEB_URL is not set: point it at the web's dev world, with its fixtures"323 );324325 for (const visit of VISITS) {326 test(`${visit.name}: no serious violation, no sideways scroll, no forbidden word`, ({327 browser,328 }) =>329 Effect.runPromise(330 Effect.gen(function* () {331 const problems: string[] = [];332333 for (const scheme of SCHEMES) {334 for (const width of WIDTHS) {335 const context = yield* contextFor(336 browser,337 scheme,338 width,339 visit.signedIn === true340 );341342 const path =343 visit.path === COMMIT ? yield* commitPath(context) : visit.path;344345 const page = yield* Effect.promise(() => context.newPage());346 const status = yield* open(page, path);347 const where = `${scheme} ${width} ${path}`;348349 if (status !== (visit.status ?? 200)) {350 problems.push(`${where}: answered ${status}`);351 }352353 for (const violation of yield* axeOn(page)) {354 problems.push(`${where}: ${violation}`);355 }356357 const over = yield* sideways(page);358359 if (over > 0) {360 problems.push(`${where}: scrolls ${over}px sideways`);361 }362363 if (width === 390) {364 yield* Effect.promise(() =>365 page.setViewportSize({ height: 780, width: 360 })366 );367368 const narrow = yield* sideways(page);369370 if (narrow > 0) {371 problems.push(372 `${where} at 360: scrolls ${narrow}px sideways`373 );374 }375 }376377 for (const words of yield* forbiddenOn(page)) {378 problems.push(`${where}: forbidden word in "${words}"`);379 }380381 yield* Effect.promise(() => context.close());382 }383 }384385 expect(problems).toStrictEqual([]);386 })387 ));388 }389});390391/** What has focus: its tag, its name, and the landmark it sits in. */392const focused = (page: Page) =>393 Effect.promise(() =>394 page.evaluate(() => {395 // Focus inside a drawing's shadow root (a code box, the file tree) is396 // the inner element's own; where it sits is its host's place.397 const { activeElement: host } = document;398399 let element = host;400401 while (element?.shadowRoot?.activeElement) {402 element = element.shadowRoot.activeElement;403 }404405 if (!(element instanceof HTMLElement) || element === document.body) {406 return null;407 }408409 const style = getComputedStyle(element);410 const after = getComputedStyle(element, "::after");411412 // Where the stop sits, first match wins.413 const places = [414 ["[role=dialog]", "dialog"],415 ["nav[aria-label=Site]", "rail"],416 ["[data-toolbar]", "toolbar"],417 ["aside[aria-label=Facts]", "facts"],418 ["main li", "row"],419 ] as const;420421 return {422 id: element.id,423 inside:424 places.find(([selector]) => host?.closest(selector) !== null)?.[1] ??425 "main",426 label: (element.getAttribute("aria-label") ?? element.textContent ?? "")427 .trim()428 .slice(0, 60),429 tag: element.tagName.toLowerCase(),430 // The ring: an outline, a row link's outline drawn on its ::after,431 // or the kit's box-shadow ring.432 visible:433 (style.outlineStyle !== "none" && style.outlineWidth !== "0px") ||434 (after.outlineStyle !== "none" && after.outlineWidth !== "0px") ||435 style.boxShadow !== "none",436 };437 })438 );439440/**441 * Tab through the page, up to `limit` stops, and what each stop was;442 * `settle` waits after each press (a sheet's trap moves focus in the next443 * frame).444 */445const tabStops = (page: Page, limit: number, settle = 0) =>446 Effect.gen(function* () {447 const stops: NonNullable<Effect.Success<ReturnType<typeof focused>>>[] = [];448449 for (let index = 0; index < limit; index += 1) {450 yield* Effect.promise(() => page.keyboard.press("Tab"));451452 if (settle > 0) {453 yield* Effect.promise(() => page.waitForTimeout(settle));454 }455456 const stop = yield* focused(page);457458 if (stop === null) {459 break;460 }461462 stops.push(stop);463 }464465 return stops;466 });467468/** A page on its own context, for a keyboard walk. */469const keyboardPage = (470 browser: Browser,471 path: string,472 width: number,473 signedIn = false474) =>475 Effect.gen(function* () {476 const context = yield* contextFor(browser, "light", width, signedIn);477478 yield* Effect.promise(() =>479 context.grantPermissions(["clipboard-read", "clipboard-write"], {480 origin: at("/"),481 })482 );483484 const page = yield* Effect.promise(() => context.newPage());485486 yield* open(page, path === COMMIT ? yield* commitPath(context) : path);487488 return { context, page };489 });490491const searchOf = (page: Page) => new URL(page.url()).searchParams;492493test.describe("the keyboard", () => {494 test.skip(495 Option.isNone(settings.web),496 "WEB_URL is not set: point it at the web's dev world, with its fixtures"497 );498499 test("the skip link comes first, lands on main, and every stop shows its focus", ({500 browser,501 }) => {502 // Every page, each tabbed through: far longer than one page's check.503 test.setTimeout(VISITS.length * 30_000);504505 return Effect.runPromise(506 Effect.gen(function* () {507 const problems: string[] = [];508509 for (const visit of VISITS) {510 const { context, page } = yield* keyboardPage(511 browser,512 visit.path,513 1440,514 visit.signedIn === true515 );516517 yield* Effect.promise(() => page.keyboard.press("Tab"));518519 const first = yield* focused(page);520521 if (first?.label !== "Skip to content") {522 problems.push(`${visit.name}: first stop is ${first?.label}`);523 }524525 yield* Effect.promise(() => page.keyboard.press("Enter"));526527 const landed = yield* Effect.promise(() =>528 page.evaluate(() => {529 const active = document.activeElement;530531 return (532 active?.id === "main" ||533 (active !== null && active.closest("#main") !== null)534 );535 })536 );537538 if (!landed || !page.url().endsWith("#main")) {539 problems.push(`${visit.name}: the skip link does not land on main`);540 }541542 const stops = yield* tabStops(page, 80);543544 for (const stop of stops.filter(({ visible }) => !visible)) {545 problems.push(546 `${visit.name}: no visible focus on ${stop.tag} "${stop.label}"`547 );548 }549550 yield* Effect.promise(() => context.close());551 }552553 expect(problems).toStrictEqual([]);554 })555 );556 });557558 test("the rail, the toolbar's filters, a row's copy button and the inspector's commands come in order", ({559 browser,560 }) =>561 Effect.runPromise(562 Effect.gen(function* () {563 const { context, page } = yield* keyboardPage(browser, "/", 1440);564565 // A row selected, so the inspector holds its commands; then the566 // same address again, tabbed from its start.567 yield* Effect.promise(() => page.keyboard.press("j"));568 yield* Effect.promise(() => page.waitForTimeout(500));569 yield* open(570 page,571 new URL(page.url()).pathname + new URL(page.url()).search572 );573574 const stops = yield* tabStops(page, 200);575576 const first = (inside: string) =>577 stops.findIndex((stop) => stop.inside === inside);578579 const copy = stops.findIndex(580 (stop) => stop.inside === "row" && stop.label.startsWith("Copy")581 );582583 const order = {584 facts: first("facts"),585 rail: first("rail"),586 rowCopy: copy,587 toolbar: first("toolbar"),588 };589590 expect(Object.values(order).every((index) => index >= 0)).toBe(true);591 expect(order.rail).toBeLessThan(order.toolbar);592 expect(order.toolbar).toBeLessThan(order.rowCopy);593 expect(order.rowCopy).toBeLessThan(order.facts);594595 yield* Effect.promise(() => context.close());596 })597 ));598599 test("? opens the keys, whose switch turns j and k off; j and k move the selection", ({600 browser,601 }) =>602 Effect.runPromise(603 Effect.gen(function* () {604 for (const [path, param, signedIn] of [605 ["/", "ask", false],606 ["/today", "decision", true],607 ] as const) {608 const { context, page } = yield* keyboardPage(609 browser,610 path,611 1440,612 signedIn613 );614615 yield* Effect.promise(() => page.keyboard.press("j"));616 yield* Effect.promise(() => page.waitForTimeout(400));617618 const firstSelected = searchOf(page).get(param);619620 expect(firstSelected).not.toBeNull();621622 yield* Effect.promise(() => page.keyboard.press("j"));623 yield* Effect.promise(() => page.waitForTimeout(400));624625 const second = searchOf(page).get(param);626627 expect(second).not.toBe(firstSelected);628629 yield* Effect.promise(() => page.keyboard.press("k"));630 yield* Effect.promise(() => page.waitForTimeout(400));631632 expect(searchOf(page).get(param)).toBe(firstSelected);633634 // The switch: off, `j` does nothing; `?` still opens the dialog.635 yield* Effect.promise(() => page.keyboard.press("?"));636637 const dialog = page.getByRole("dialog", { name: "Keys" });638639 yield* Effect.promise(() => expect(dialog).toBeVisible());640 yield* Effect.promise(() =>641 dialog.getByRole("button", { name: "Off" }).click()642 );643 yield* Effect.promise(() => page.keyboard.press("Escape"));644 yield* Effect.promise(() => expect(dialog).toBeHidden());645646 yield* Effect.promise(() => page.keyboard.press("j"));647 yield* Effect.promise(() => page.waitForTimeout(400));648649 expect(searchOf(page).get(param)).toBe(firstSelected);650651 yield* Effect.promise(() => page.keyboard.press("?"));652 yield* Effect.promise(() => expect(dialog).toBeVisible());653 yield* Effect.promise(() =>654 dialog.getByRole("button", { name: "On" }).click()655 );656 yield* Effect.promise(() => page.keyboard.press("Escape"));657 yield* Effect.promise(() => context.close());658 }659 })660 ));661662 test("1 copies the inspector's first command", ({ browser }) =>663 Effect.runPromise(664 Effect.gen(function* () {665 const { context, page } = yield* keyboardPage(browser, "/", 1440);666667 yield* Effect.promise(() => page.keyboard.press("j"));668 yield* Effect.promise(() => page.waitForTimeout(500));669 yield* Effect.promise(() => page.keyboard.press("1"));670 yield* Effect.promise(() => page.waitForTimeout(300));671672 const copied = yield* Effect.promise(() =>673 page.evaluate(() => navigator.clipboard.readText())674 );675676 const ask = searchOf(page).get("ask") ?? "";677678 // The selected row's own claim command, as its copy button holds it.679 const command = yield* Effect.promise(() =>680 page681 .locator(`li[data-ask="${ask}"] button code`)682 .first()683 .textContent()684 );685686 expect(copied).toMatch(new RegExp(`^${Brand.cli} claim ${ask} `, "u"));687 expect(copied).toBe(command);688689 yield* Effect.promise(() => context.close());690 })691 ));692693 test("J and K move between files on a commit and a finish", ({ browser }) =>694 Effect.runPromise(695 Effect.gen(function* () {696 for (const [path, signedIn] of [697 [COMMIT, false],698 [`/${project}/decisions/dec-000004`, true],699 ] as const) {700 const { context, page } = yield* keyboardPage(701 browser,702 path,703 1440,704 signedIn705 );706707 yield* Effect.promise(() => page.keyboard.press("Shift+J"));708 yield* Effect.promise(() => page.waitForTimeout(400));709710 const first = new URL(page.url()).hash;711712 expect(first).not.toBe("");713714 yield* Effect.promise(() => page.keyboard.press("Shift+J"));715 yield* Effect.promise(() => page.waitForTimeout(400));716717 const second = new URL(page.url()).hash;718719 expect(second).not.toBe(first);720721 yield* Effect.promise(() => page.keyboard.press("Shift+K"));722 yield* Effect.promise(() => page.waitForTimeout(400));723724 expect(new URL(page.url()).hash).toBe(first);725726 yield* Effect.promise(() => context.close());727 }728 })729 ));730731 test("each sheet keeps focus inside, and Escape gives it back to its button", ({732 browser,733 }) =>734 Effect.runPromise(735 Effect.gen(function* () {736 const sheets = [737 { button: "Menu", path: `/${project}`, width: 800 },738 {739 button: "Files",740 path: `/${project}/blob/main/packages/render/src/page.ts`,741 width: 390,742 },743 { button: "Projects", path: "/", width: 390 },744 { button: "More", path: `/${project}`, width: 390 },745 ] as const;746747 const problems: string[] = [];748749 for (const sheet of sheets) {750 const { context, page } = yield* keyboardPage(751 browser,752 sheet.path,753 sheet.width754 );755756 const button = page757 .getByRole("button", { exact: true, name: sheet.button })758 .first();759760 yield* Effect.promise(() => button.focus());761 yield* Effect.promise(() => page.keyboard.press("Enter"));762763 const dialog = page.getByRole("dialog");764765 yield* Effect.promise(() => expect(dialog).toBeVisible());766767 const stops = yield* tabStops(page, 30, 120);768769 if (stops.some(({ inside }) => inside !== "dialog")) {770 problems.push(`${sheet.button}: focus leaves the sheet`);771 }772773 yield* Effect.promise(() => page.keyboard.press("Escape"));774 yield* Effect.promise(() => expect(dialog).toBeHidden());775776 const back = yield* focused(page);777778 if (back?.label !== sheet.button) {779 problems.push(780 `${sheet.button}: focus returns to ${back?.label ?? "nothing"}`781 );782 }783784 yield* Effect.promise(() => context.close());785 }786787 expect(problems).toStrictEqual([]);788 })789 ));790});
modified:apps/web/src/client/ask.ts+17 added
modified:apps/web/src/features/agents/reference.tsx+3 added-1 removed
151 unmodified lines
152 <div153 className="border-rule shell:grid shell:grid-cols-[12rem_minmax(0,1fr)] shell:gap-4 flex min-w-0 flex-col gap-1 border-b py-2.5"154 key={name}155 >156 <dt className="text-ui font-medium">{name}</dt>156 <dt className="text-ui font-medium" data-term="">157 {name}158 </dt>159 <dd className="flex min-w-0 flex-wrap gap-x-3 gap-y-1">160 {members.map(({ identifier }) => (161 <a162 className={LINK}
12 unmodified lines
modified:apps/web/src/features/agents/setup-page.tsx+14 added-5 removed
modified:apps/web/src/features/answer/answer-page.tsx+1 added
707 unmodified lines
708 verdict={verdict}709 />710 </div>711 }712 said713 title={ask.brief.want}714 >715 {verdict === undefined ? null : (716 <Run
9 unmodified lines
modified:apps/web/src/features/ask/ask-page.tsx+4 added-1 removed
238 unmodified lines
239 ].filter((part) => part !== null);240241 return parts.length === 0 ? null : (242 <Region id="ask-brief" title="Brief">243 <div className="text-body flex max-w-[70ch] flex-col gap-5">{parts}</div>243 <div className="text-body flex max-w-[70ch] flex-col gap-5" data-said="">244 {parts}245 </div>246 </Region>247 );248};249
419 unmodified lines
669 </div>670 )}671 </>672 }673 said674 title={ask.brief.want}675 {...(takeable ? { primaryCommand: claimCommand(ask) } : {})}676 >677 <Brief ask={ask} />
18 unmodified lines
modified:apps/web/src/features/code/code-view.tsx+1 added
111 unmodified lines
112 : lineHash(lines)113 );114 },115 onPostRender: (node: HTMLElement) => {116 diffsOptions.onPostRender(node);117 pending.current.node = node;118 reveal(pending.current);119 },120 disableFileHeader: true,
16 unmodified lines
modified:apps/web/src/features/code/commit-view.tsx+1 added
414 unmodified lines
415 {body === "" ? null : (416 <p417 className="text-body max-w-[70ch] [overflow-wrap:anywhere] whitespace-pre-wrap"418 data-body=""419 data-said=""420 >421 {body}422 </p>423 )}
43 unmodified lines
modified:apps/web/src/features/code/diff-view.tsx+1 added-1 removed
248 unmodified lines
249 lineDiffType: "word-line",250 lineHoverHighlight: "both",251 overflow: "scroll",252 stickyHeaders: true,253 unsafeCSS: HEADER_CSS,253 unsafeCSS: `${diffsOptions.unsafeCSS}\n${HEADER_CSS}`,254 }),255 [split]256 );257
104 unmodified lines
modified:apps/web/src/features/code/file-facts.tsx+12 added-2 removed
12 unmodified lines
13import { AppLink } from "../shared/link.tsx";14import { LandingWords } from "../why/band.tsx";15import { CopyButton } from "./copy.tsx";16import { fileWords } from "./file-header.tsx";17import { blobHref, commitsHref, rawHref } from "./paths.ts";17import { blobHref, commitsHref, rawHref, whyHref } from "./paths.ts";1819const LINK = "decoration-rule underline hover:decoration-current";2021export const FileFacts = ({22 file,23 last,24 mode = "code",25 now,26 project,27 rev,28}: {29 readonly file: FileView;30 /** Which page shows the block: its permalink keeps the reader there. */31 readonly mode?: "code" | "why";32 /** The commit that last changed the file, with its landing; none when the read found none. */33 readonly last?: CommitView | undefined;34 readonly now: DateTime.Utc;35 readonly project: ProjectName;
36 unmodified lines
72 >73 <a className={LINK} href={rawHref(project, file.at, file.path)}>74 Raw75 </a>73 <AppLink className={LINK} to={blobHref(project, file.at, file.path)}>76 <AppLink77 className={LINK}78 to={(mode === "why" ? whyHref : blobHref)(79 project,80 file.at,81 file.path82 )}83 >84 Permalink85 </AppLink>86 {file.text === undefined ? null : (87 <CopyButton label="Copy the file" text={file.text} />
5 unmodified lines
modified:apps/web/src/features/code/file-keys.ts+2 added-15 removed
6 unmodified lines
7 * off too. No key acts while focus is in a field or the tree's filter.8 */9import { useEffect, useRef } from "react";1011import { intentOf, useKeys } from "../shared/keys.tsx";11import { inField, intentOf, useKeys } from "../shared/keys.tsx";1213/** Whether `event` was pressed inside something that takes typing. */14const typing = (event: KeyboardEvent) => {15 const [target] = event.composedPath();1617 return (18 target instanceof HTMLElement &&19 (target.isContentEditable ||20 target.closest(21 "input, textarea, select, [role=combobox], [role=searchbox], [role=textbox], [data-keys-off]"22 ) !== null)23 );24};2513/** The file `step` away from `current` in `paths`; the first or last when the page shows none of them. */14export const stepFrom = (15 paths: readonly string[],16 current: string | undefined,
31 unmodified lines
48 const intent = intentOf(49 {50 altKey: event.altKey,51 ctrlKey: event.ctrlKey,65 inField: typing(event),52 inField: inField(event),53 key: event.key,54 metaKey: event.metaKey,55 },56 now.on
26 unmodified lines
modified:apps/web/src/features/code/pierre.ts+42 added-1 removed
17 unmodified lines
18 * past them a file (or a line, or a changed line's pair) is drawn as plain19 * text, so a minified bundle or a lockfile cannot stall the page.20 *21 * No React and no DOM here: the module loads in Node for its test, and in22 * the browser only through the views that draw.22 * the browser only through the views that draw. A drawing hands its code23 * boxes over once drawn, so code too wide for its pane is a stop for Tab.24 */25import {26 DEFAULT_TOKENIZE_MAX_LENGTH,27 registerCustomCSSVariableTheme,
1 unmodified line
2930/** The token theme's registered name. */31export const CODE_THEME = "repo-tokens";3233/** A drawn file's code box: whether it scrolls, and whether Tab reaches it. */34interface CodeBox {35 readonly clientHeight: number;36 readonly clientWidth: number;37 readonly scrollHeight: number;38 readonly scrollWidth: number;39 tabIndex: number;40}4142/** A drawing as Pierre hands it over once drawn: its code boxes, in its shadow root. */43interface Drawn {44 readonly shadowRoot: {45 readonly querySelectorAll: (selectors: "code") => Iterable<CodeBox>;46 } | null;47}4849/**50 * Code that scrolls (a long line, a phone's width) is a stop for Tab, so a51 * keyboard can scroll it; code that fits is not, so a page of short files52 * adds no stops.53 */54const reachScrolledCode = (node: Drawn) => {55 for (const code of node.shadowRoot?.querySelectorAll("code") ?? []) {56 code.tabIndex =57 code.scrollWidth > code.clientWidth ||58 code.scrollHeight > code.clientHeight59 ? 060 : -1;61 }62};6364/**65 * The focus ring inside a drawing's shadow root, which the page's own66 * stylesheet does not reach: the page's ink, as everywhere else.67 */68export const FOCUS_CSS =69 "code:focus-visible { outline: 2px solid var(--foreground); outline-offset: -2px; }";7071/** Spread first into a drawing's own options. */72export const diffsOptions = {73 maxLineDiffLength: 1000,74 onPostRender: reachScrolledCode,75 preferredHighlighter: "shiki-js",76 theme: { dark: CODE_THEME, light: CODE_THEME },77 themeType: "system",78 tokenizeMaxLength: DEFAULT_TOKENIZE_MAX_LENGTH,79 tokenizeMaxLineLength: 1000,80 unsafeCSS: FOCUS_CSS,81} as const;8283/** The file tree's look: compact rows, plain icons (`styles.css` greys them). */84export const treesOptions = { density: "compact", icons: "minimal" } as const;
29 unmodified lines
modified:apps/web/src/features/code/repo-tree.tsx+27 added-3 removed
1/**2 * A project's files as a tree, drawn by `@pierre/trees`, in the UI's own3 * face: compact rows, plain grey icons, single-child folders flattened4 * into one row, the folders above the visible rows kept at the top as the5 * reader scrolls, and a filter. The current path is open, selected and in5 * reader scrolls, and a filter above it. The current path is open, selected and in6 * view; when it changes (the reader moved to another file and the tree7 * stayed mounted), the tree follows.8 *9 * Choosing a file calls `onOpen`, which the page answers through the
15 unmodified lines
25} from "@pierre/trees";26import { FileTree as FileTreeView, useFileTree } from "@pierre/trees/react";27import { useEffect, useMemo } from "react";2829import { Input } from "@/components/ui/input";3031import type { Counts } from "./diff-model.ts";32import { ancestorsOf } from "./paths.ts";33import { treesOptions } from "./pierre.ts";34
55 unmodified lines
90 initialExpandedPaths: openFor(current),91 initialExpansion: open ? "open" : "closed",92 initialSelectedPaths: current === undefined ? [] : [current],93 preparedInput,94 // The filter is a field above the tree (`filterTree`): a field inside95 // the tree's role would not be one of its rows to a screen reader.92 search: true,96 search: false,97 stickyFolders: true,98 // The selected row's fill is faint on paper: its name in ink at 60099 // says it too.100 unsafeCSS: SELECTED_CSS,
26 unmodified lines
127 onOpen(path);128 }129 });130131/** Narrow `tree` to the paths that match `text`; an empty filter shows every path. */132export const filterTree = (tree: Pick<FileTree, "setSearch">, text: string) => {133 tree.setSearch(text.trim() === "" ? null : text);134};135136/** Whether a tree item is a folder, which opens. */137const isFolder = (item: FileTreeItemHandle): item is FileTreeDirectoryHandle =>138 item.isDirectory();139
44 unmodified lines
184 model.scrollToPath(current, { focus: false, offset: "nearest" });185 }, [model, current]);186187 // The tree scrolls inside itself, so it takes the height its box gives.179 return <FileTreeView className="block h-full min-h-0" model={model} />;188 return (189 <div className="flex h-full min-h-0 flex-col">190 <div className="shrink-0 px-3 pb-1.5">191 <Input192 aria-label="Filter files"193 data-keys-off=""194 onChange={(event) => {195 filterTree(model, event.currentTarget.value);196 }}197 placeholder="Filter files"198 type="search"199 />200 </div>201 <FileTreeView className="block min-h-0 flex-1" model={model} />202 </div>203 );204};205206// `React.lazy` takes a module's default export.207export default RepoTree;
modified:apps/web/src/features/decision/choices.tsx+6 added-5 removed
167 unmodified lines
168 {decided.note === undefined ? null : (169 <p170 className="text-ui pl-6 [overflow-wrap:anywhere] whitespace-pre-line"171 data-note=""172 data-said=""173 >174 {decided.note}175 </p>176 )}177 </section>178);179179/**180 * Choices kept in sight while their decision is: on a phone, a bar above181 * the bottom bar; from a tablet's width, where they sit.182 */180// Choices kept in sight while their decision is: on a phone, a bar fixed181// above the bottom bar (a bar that only stuck would stay below the screen182// while its decision starts low on the page), with main keeping room for183// it at its foot (`styles.css`); from a tablet's width, where they sit.184export const stuckAboveBar = (node: ReactNode) => (185 <div185 className="border-rule bg-background tablet:static tablet:border-t-0 tablet:p-0 tablet:mx-0 sticky bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-[6] -mx-4 border-t px-4 py-2"186 className="border-rule bg-background tablet:static tablet:border-t-0 tablet:p-0 fixed inset-x-0 bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-[6] border-t px-4 py-2"187 data-choices-bar=""188 >189 {node}190 </div>
1 unmodified line
modified:apps/web/src/features/decision/decision-page.tsx+6 added-2 removed
116 unmodified lines
117118/** The ask a decision concerns: its want and its page. */119const AskFacts = ({ ask }: { readonly ask: Ask }) => (120 <FactBlock label="The ask">121 <p className="text-ui">{ask.brief.want}</p>121 <p className="text-ui" data-said="">122 {ask.brief.want}123 </p>124 <AppLink className={`text-ui ${LINK}`} to={askPath(ask.project, ask.id)}>125 <code className="text-mono font-mono">{ask.id}</code>126 </AppLink>127 </FactBlock>
1 unmodified line
129130/** The proposal a decision would open: its want, who proposed it, its page. */131const ProposalFacts = ({ proposal }: { readonly proposal: Proposal }) => (132 <FactBlock label="The proposal">131 <p className="text-ui">{proposal.want}</p>133 <p className="text-ui" data-said="">134 {proposal.want}135 </p>136 <p className="text-ui text-muted-foreground">137 Proposed by <HandleLink handle={proposal.proposer} />138 </p>139 <AppLink
239 unmodified lines
modified:apps/web/src/features/decision/evidence.tsx+5 added-1 removed
50 unmodified lines
51 readonly children: ReactNode;52 readonly label: string;53}) => (54 <div className="contents">55 {/* Sentence case, as every label on the page: the platform names some56 evidence in lower case ("answer"); the text stays the platform's. */}55 <dt className="text-label text-muted-foreground pt-0.5">{label}</dt>57 <dt className="text-label text-muted-foreground pt-0.5 first-letter:uppercase">58 {label}59 </dt>60 <dd className="text-ui mb-1.5 min-w-0 [overflow-wrap:anywhere] @lg:mb-0">61 {children}62 </dd>63 </div>
294 unmodified lines
modified:apps/web/src/features/finish/finish-view.tsx+6 added-2 removed
136 unmodified lines
137138/** What the ask wants, in one paragraph, and the way to it. */139const WantFacts = ({ ask }: { readonly ask: Ask }) => (140 <FactBlock label="The ask wants">141 <p className="text-want font-normal">{ask.brief.want}</p>141 <p className="text-want font-normal" data-said="">142 {ask.brief.want}143 </p>144 <AppLink className={`text-ui ${LINK}`} to={askPath(ask.project, ask.id)}>145 The ask <code className="text-mono font-mono">{ask.id}</code>146 </AppLink>147 </FactBlock>
381 unmodified lines
529 "ask" | "failure" | "newerHead" | "onMark" | "verdict"530 >) => (531 <div className={`tablet:hidden flex flex-col gap-6 ${GUTTER}`}>532 {ask === undefined ? null : (531 <p className="text-want max-w-[70ch]">{ask.brief.want}</p>533 <p className="text-want max-w-[70ch]" data-said="">534 {ask.brief.want}535 </p>536 )}537 {verdict === undefined ? null : (538 <div data-outcome={verdict.outcome._tag}>539 <StatusLine
176 unmodified lines
modified:apps/web/src/features/front/facts.tsx+3 added-1 removed
193 unmodified lines
194 return (195 <>196 <FactBlock label="State">197 {full === undefined ? (198 <p className="text-want font-medium">{listing.want}</p>198 <p className="text-want font-medium" data-said="">199 {listing.want}200 </p>201 ) : (202 <StatusLine203 command={false}204 subject={{
59 unmodified lines
modified:apps/web/src/features/project-people/people-view.tsx+4 added-1 removed
168 unmodified lines
169 key={handle}170 >171 <HandleLink handle={handle} />172 {note === undefined ? null : (173 <span className="text-muted-foreground">{` — ${note}`}</span>173 <span174 className="text-muted-foreground"175 data-said=""176 >{` — ${note}`}</span>177 )}178 </li>179 ))}180 </ul>
335 unmodified lines
modified:apps/web/src/features/proposal/drafted-file.tsx+2 added
20 unmodified lines
21}2223const options: FileOptions<undefined, undefined> = {24 ...diffsOptions,25 // The page names the file in its own heading above the code.26 disableFileHeader: true,27 overflow: "scroll",28};2930export const DraftedFile = ({ content, path }: DraftedFileProps) => {
14 unmodified lines
modified:apps/web/src/features/proposal/proposal-view.tsx+1 added
499 unmodified lines
500 </>501 }502 state={<StatusLine compact subject={{ kind: "proposal", proposal }} />}503 status={<ProposalStatus proposal={proposal} />}504 said505 title={proposal.want}506 >507 {Option.isSome(decision) && open ? (508 <DecisionLink decision={decision.value} project={project} />
13 unmodified lines
modified:apps/web/src/features/shared/shell/context-bar.tsx+7 added-2 removed
25 unmodified lines
26 const last = index === crumbs.length - 1;27 const face = mono ? "text-mono font-mono" : "";2829 return (30 // On a phone the top bar's Back link names the page above, so31 // the trail keeps only the page itself, whole rather than cut.32 <li31 className="flex min-w-0 items-center gap-1.5"33 className={`${last ? "flex" : "tablet:flex hidden"} min-w-0 items-center gap-1.5`}34 key={`${index}:${label}`}35 >36 {index === 0 ? null : (35 <span aria-hidden="true" className="text-muted-foreground">37 <span38 aria-hidden="true"39 className={`text-muted-foreground ${last ? "tablet:inline hidden" : ""}`}40 >41 /42 </span>43 )}44 {last || to === undefined ? (
89 unmodified lines
modified:apps/web/src/features/shared/shell/workspace.tsx+7 added-2 removed
30 unmodified lines
31 /** The trail to the page; the address's when left out. */32 readonly crumbs?: readonly Crumb[];33 /** The page head's title: the headline, or a title when it runs long. */34 readonly title: ReactNode;35 /** The title is someone's own words (a want), shown as they wrote it. */36 readonly said?: boolean | undefined;37 /** A status line under the title. */38 readonly status?: ReactNode;39 /** A 14 px muted line under the status: kind, asker, age. */40 readonly meta?: ReactNode;
29 unmodified lines
70const LONG_TITLE = 80;7172const PageHead = ({73 meta,74 said = false,75 status,76 title,74}: Pick<WorkspaceProps, "meta" | "status" | "title">) => (77}: Pick<WorkspaceProps, "meta" | "said" | "status" | "title">) => (78 <div className="flex flex-col gap-4 pt-6 pb-6">79 <h180 data-said={said ? "" : undefined}81 className={`text-balance break-words ${82 Predicate.isString(title) && title.length > LONG_TITLE83 ? "text-title"84 : "text-headline"
122 unmodified lines
207 factsKey,208 factsSummary,209 meta,210 primaryCommand,211 said,212 state,213 status,214 title,215 toolbar,
32 unmodified lines
248 primaryCommand={primaryCommand}249 state={state}250 />251 <div className={`${GUTTER} ${code ? "" : MEASURE}`}>247 <PageHead meta={meta} status={status} title={title} />252 <PageHead meta={meta} said={said} status={status} title={title} />253 </div>254 {hasFacts && !code ? (255 <CommandSlotProvider slot="facts">256 <div className={GUTTER}>
65 unmodified lines
modified:apps/web/src/features/shared/ask-progress.ts+2 added-2 removed
57 unmodified lines
58 readonly total: number;59}6061/** Who acts next on an ask. */62export type Move = "answerer" | "decider" | "family" | "none" | "platform";62export type Move = "answerer" | "decider" | "none" | "parent" | "platform";6364/** The highest event number among `events`; 0 when there are none. */65export const lastSeq = (events: readonly ProjectEvent[]): number => {66 let highest = 0;
108 unmodified lines
175 AwaitingFinish: (): Move => "decider",176 Checking: (): Move => "platform",177 Landed: (): Move => "none",178 Refused: (): Move => "answerer",179 WaitingOnParent: (): Move => "family",179 WaitingOnParent: (): Move => "parent",180 });181};182183/** One child's mark: landed first, then what its latest outcome says, then whether someone holds it. */
68 unmodified lines
modified:apps/web/src/features/shared/classes.ts+3 added-3 removed
6 unmodified lines
7/** A section's heading, the "title" step of the type scale. */8export const SECTION = "text-lg font-semibold tracking-[-0.01em]";910/** The mono face for names a terminal prints: ids, kinds, territories. */11export const ID = "font-mono text-[0.8125rem]";11export const ID = "font-mono text-mono";1213/** Text that is code: an id, a path, a SHA, a command's name; it wraps anywhere. */14export const CODE = "font-mono text-[0.8125rem] [overflow-wrap:anywhere]";14export const CODE = "font-mono text-mono [overflow-wrap:anywhere]";1516/** A link in running text: underlined in the rule colour, darker on hover. */17export const LINK = "decoration-rule underline hover:decoration-current";1819/** A field's label: small, muted, above or beside its value. */20export const LABEL = "text-muted-foreground text-xs font-medium";20export const LABEL = "text-muted-foreground text-label font-medium";
modified:apps/web/src/features/shared/command.tsx+21 added-2 removed
11 unmodified lines
12import { Button } from "../../components/ui/button.tsx";13import { useCopy } from "./copy-action.tsx";14import { useNumberedCommand } from "./keys.tsx";1516// The command's words, each kept whole on its line: a narrow column breaks17// the line between words, never after a word's own hyphen18// (`lint-heading-levels`, `--project`); a word longer than the line (a URL)19// still breaks, anywhere. The text is the command's, space for space.20const wordsOf = (command: string) =>21 command.split(/(?<space>\s+)/u).map((part, index) =>22 part.trim() === "" ? (23 part24 ) : (25 <span26 className="inline-block max-w-full [overflow-wrap:anywhere]"27 // The parts never move: their place in the command is their key.28 key={index}29 >30 {part}31 </span>32 )33 );3435const Line = ({36 command,37 number,38}: {
14 unmodified lines
53 )}54 <span aria-hidden="true" className="text-muted-foreground select-none">55 $56 </span>38 <code className="min-w-0 flex-1 py-0.5 [overflow-wrap:anywhere] break-words whitespace-pre-wrap select-all">39 {command}57 <code className="min-w-0 flex-1 py-0.5 whitespace-pre-wrap select-all">58 {wordsOf(command)}59 </code>60 <Button61 className="shrink-0 font-sans"62 onClick={copy}
31 unmodified lines
modified:apps/web/src/features/shared/copy-action.tsx+15 added
11 unmodified lines
12 *13 * Either can be numbered: while the single keys are on, its number copies14 * it, and shows in its title ("Copy claim command (1)").15 */16import { Brand } from "@repo/brand";17import { Effect, Option } from "effect";18import { Check, Copy } from "lucide-react";19import { useState } from "react";20
87 unmodified lines
108 ) : (109 <ActionButton {...props} number={undefined} />110 );111112/** An open ask's claim command, as a row's copy button. */113export const ClaimAction = ({114 ask,115 project,116}: {117 readonly ask: string;118 readonly project: string;119}) => (120 <CopyAction121 command={`${Brand.cli} claim ${ask} --project ${project}`}122 label="Copy claim command"123 />124);125126/** A command shown whole and small (a status line's next step); pressing it copies it. */127export const CommandChip = ({ command }: { readonly command: string }) => {128 const { copied, copy } = useCopy(command);129 const Icon = copied ? Check : Copy;
23 unmodified lines
modified:apps/web/src/features/shared/facts.tsx+12 added-3 removed
283 unmodified lines
284) => {285 if (props.outcome === undefined) {286 return (287 <FactBlock label="Gate">288 <p className="text-ui">288 <p className="text-ui" data-term="">289 {StageName.literals290 .map((stage) => stageNames(stage).label)291 .join(" · ")}292 </p>
11 unmodified lines
304 </summary>305 <dl className="mt-2 flex flex-col gap-1.5">306 {StageName.literals.map((stage) => (307 <div className="flex flex-col" key={stage}>308 <dt className="text-label">{stageNames(stage).label}</dt>308 <dt className="text-label" data-term="">309 {stageNames(stage).label}310 </dt>311 <dd className="text-label text-muted-foreground font-normal">312 {runs(stage)}313 </dd>314 </div>
25 unmodified lines
340 state === "pending" || state === "skipped"341 ? "text-muted-foreground"342 : ""343 }344 data-term=""345 >346 {stageNames(name).label}347 </span>348 <span className="text-label text-muted-foreground ml-auto font-normal">
319 unmodified lines
668 <dd className="text-ui flex min-w-0 flex-1 items-center gap-3">669 <span className="min-w-0 flex-1 truncate">670 {shown ?? <CodeValue value={value} />}671 </span>672 {shown === undefined ? (669 <CopyAction command={value} label={`Copy ${label}`} />673 <CopyAction command={value} label={`Copy ${label}`} />674 ) : (675 // A time reads as words, its exact instant in its own676 // title: nothing here to paste into a terminal.677 <span aria-hidden="true" className="size-8 shrink-0" />678 )}679 </dd>680 </div>681 ))}682 </dl>
3 unmodified lines
modified:apps/web/src/features/shared/family.tsx+41 added-37 removed
22 unmodified lines
23import { useId, useState } from "react";2425import { familyMarks, markOf } from "./ask-progress.ts";26import type { AskProgress, Mark } from "./ask-progress.ts";27import { ClaimAction } from "./copy-action.tsx";28import { AppLink } from "./link.tsx";29import { StateMarkIcon } from "./marks.tsx";30import type { StateMark } from "./marks.tsx";31import { askPath } from "./paths.ts";
208 unmodified lines
240 {open ? "Hide" : "Show"} {family.total} {plural}241 </span>242 </button>243 </div>244 {/* Folded, the rows stay in the page, hidden: each open child's245 claim command is text an agent reading the page still finds. */}243 {open ? (244 <ul245 className="border-rule mt-1 ml-[0.4375rem] flex flex-col border-l pl-3"246 id={rowsId}247 >248 {family.children.map(({ ask, mark }) => (249 <li250 className="flex h-8 min-w-0 items-center gap-2"251 data-family-child={ask}252 key={ask}246 <ul247 className="border-rule mt-1 ml-[0.4375rem] flex flex-col border-l pl-3"248 hidden={!open}249 id={rowsId}250 >251 {family.children.map(({ ask, mark }) => (252 <li253 className="flex h-8 min-w-0 items-center gap-2"254 data-family-child={ask}255 key={ask}256 >257 <StateMarkIcon258 mark={markFor(mark)}259 size="sm"260 // A folded row is out of sight: its stamp would play unseen.261 stamp={open && stamps.has(ask)}262 />263 <AppLink264 className="text-ui decoration-rule relative z-10 min-w-0 truncate no-underline hover:underline"265 title={wants?.get(ask) ?? ask}266 to={askPath(project, ask)}267 >254 <StateMarkIcon255 mark={markFor(mark)}256 size="sm"257 stamp={stamps.has(ask)}258 />259 <AppLink260 className="text-ui decoration-rule relative z-10 min-w-0 truncate no-underline hover:underline"261 title={wants?.get(ask) ?? ask}262 to={askPath(project, ask)}263 >264 {wants?.get(ask) ?? (265 <span className="text-mono font-mono">268 {wants?.get(ask) ?? (269 <span className="text-mono font-mono">266 {family.nameOf(ask)}267 </span>268 )}269 </AppLink>270 {wants?.has(ask) === true ? (271 <span className="text-mono text-muted-foreground tablet:inline hidden shrink-0 font-mono">270 {family.nameOf(ask)}271 </span>274 ) : null}275 <span className="text-label text-muted-foreground ml-auto shrink-0">276 {words[mark]}272 )}273 </AppLink>274 {wants?.has(ask) === true ? (275 <span className="text-mono text-muted-foreground tablet:inline hidden shrink-0 font-mono">276 {family.nameOf(ask)}277 </span>278 </li>279 ))}280 </ul>281 ) : (282 <div hidden id={rowsId} />283 )}278 ) : null}279 <span className="text-label text-muted-foreground ml-auto shrink-0">280 {words[mark]}281 </span>282 {mark === "open" ? (283 <ClaimAction ask={ask} project={project} />284 ) : null}285 </li>286 ))}287 </ul>288 </div>289 );290};291
97 unmodified lines
modified:apps/web/src/features/shared/keys.tsx+1 added-1 removed
267 unmodified lines
268/** The last registered of `set`: the page's own, over any that left late. */269const lastOf = <A,>(set: ReadonlySet<A>): A | undefined => [...set].at(-1);270271/** Whether `event` was pressed inside something that takes typing. */272const inField = (event: KeyboardEvent) => {272export const inField = (event: KeyboardEvent) => {273 const [target] = event.composedPath();274275 return (276 target instanceof HTMLElement &&
340 unmodified lines
modified:apps/web/src/features/shared/outcome.tsx+1 added
212 unmodified lines
213 state === "pending" || state === "skipped"214 ? "text-muted-foreground"215 : "text-foreground"216 }`}217 data-term=""218 >219 {stageNames(name).label}220 </span>221 </span>
12 unmodified lines
modified:apps/web/src/features/shared/row.tsx+14 added-9 removed
17 unmodified lines
18 * (its facts fill the inspector); below it the whole row is the link's to19 * press. `j` and `k` reach each row's link (`data-list-key`). Every20 * `data-*` a list carries sits on the row's `<li>`.21 */22import { Brand } from "@repo/brand";22import type { AskListing } from "@repo/protocol/domain/ask";23import { Outcome } from "@repo/protocol/domain/outcome";24import type { ProjectName } from "@repo/protocol/ids";25import type { MouseEvent, ReactNode } from "react";26import { Fragment } from "react";2728import type { AskProgress } from "./ask-progress.ts";30import { CopyAction } from "./copy-action.tsx";29import { ClaimAction } from "./copy-action.tsx";30import { useListKeys } from "./keys.tsx";31import { AppLink } from "./link.tsx";32import { STATE_MARKS, StateMarkIcon } from "./marks.tsx";33import type { StateMark } from "./marks.tsx";
163 unmodified lines
197 <AppLink198 aria-current={selected ? "true" : undefined}199 className={onSelect === undefined ? LINK : `${LINK} ${SELECTS}`}200 data-list-key={id}201 // The thing in its own words: a want, a subject, a commit's line.202 data-said=""203 search={search}204 title={title}205 to={href}206 >
98 unmodified lines
305 readonly children: ReactNode;306}) => (307 <section aria-label={label} className="flex min-w-0 flex-col">308 <div308 className={`border-rule bg-background sticky z-[5] -mx-2 flex h-8 min-w-0 items-center gap-3 border-b px-2 ${STICK[under]}`}309 // On a phone a long posture wraps under the name rather than losing310 // its last word; from a tablet the header is one 32 px line.311 className={`border-rule bg-background tablet:h-8 tablet:flex-nowrap tablet:py-0 sticky z-[5] -mx-2 flex min-h-8 min-w-0 flex-wrap items-center gap-x-3 gap-y-0.5 border-b px-2 py-1 ${STICK[under]}`}312 >313 <h2 className="text-ui shrink-0 font-semibold [&_a]:no-underline [&_a:hover]:underline">314 {name}315 </h2>316 {facts === undefined ? null : (314 <div className="text-ui text-muted-foreground flex min-w-0 items-center truncate">317 <div className="text-ui text-muted-foreground tablet:truncate flex min-w-0 items-center">318 {facts}319 </div>320 )}321 {counts === undefined ? null : (
13 unmodified lines
335}: {336 readonly children: ReactNode;337 readonly label: string;338}) => (336 <ul aria-label={label} className="border-rule flex flex-col border-t">339 // The top hairline runs as wide as the rows' own (each row reaches 8 px340 // past the list on either side, for its fill).341 <ul342 aria-label={label}343 className="border-rule -mx-2 flex flex-col border-t px-2"344 >345 {children}346 </ul>347);348
101 unmodified lines
450 return (451 <Row452 action={453 open && takeable !== false ? (446 <CopyAction447 command={`${Brand.cli} claim ${listing.ask} --project ${project}`}448 label="Copy claim command"449 />454 <ClaimAction ask={listing.ask} project={project} />455 ) : undefined456 }457 data={{458 "data-ask": listing.ask,
27 unmodified lines
modified:apps/web/src/features/shared/status-line.tsx+18 added-3 removed
157 unmodified lines
158 Match.when("decider", () => [159 decider === undefined ? "a decider's move" : `${decider}'s move`,160 ]),161 Match.when("platform", () => ["the platform's move"]),162 Match.when("family", () => ["the family's move"]),162 // The ask it waits on may be a family's or a lone one: its move.163 Match.when("parent", () => ["that ask's move"]),164 Match.when("none", () => []),165 Match.exhaustive166 );167
54 unmodified lines
222 Checking: ({ stage: at }): Reading => ({223 after: after(),224 lead: "Checking",225 mark: "checking",225 rest: <> at the {stageNames(at).words} stage</>,226 rest: (227 <>228 {" at the "}229 <span data-term="">{stageNames(at).words}</span>230 {" stage"}231 </>232 ),233 tone: "checking",234 }),235 Landed: ({ sha }): Reading => ({236 after: [],
18 unmodified lines
255 mark: refusals[0].retryable ? "retry" : "refused",256 next: refusals[0].next,257 rest: (258 <>252 {stage === undefined ? ": " : ` at ${stageNames(stage).label}: `}259 {stage === undefined ? (260 ": "261 ) : (262 <>263 {" at "}264 <span data-term="">{stageNames(stage).label}</span>265 {": "}266 </>267 )}268 <Code>{headline(refusals)}</Code>269 </>270 ),271 tone: "refused",
344 unmodified lines
modified:apps/web/src/features/why/why-view.tsx+1 added
97 unmodified lines
98 ]}99 facts={100 file === undefined ? undefined : (101 <FileFacts102 mode="why"103 file={file}104 last={last}105 now={now}106 project={project}
53 unmodified lines
modified:apps/web/src/routes/$project/index.tsx+19 added-11 removed
12 unmodified lines
13import { AsyncResult } from "effect/reactivity";14import { useMemo } from "react";15import type { ReactNode } from "react";1617import { askAtom } from "../../client/ask.ts";17import { selectedAskAtom } from "../../client/ask.ts";18import { projectCodeAtom } from "../../client/code.ts";19import { projectEventsAtom, recentLandings } from "../../client/events.ts";20import {21 asksAtom,
97 unmodified lines
119};120121const root = getRouteApi("__root__");122123/** The selected ask in full, read in the browser once it is selected. */123/**124 * The selected ask in full, read in the browser once it is selected. It125 * wraps the page whether or not a row is selected, so selecting one never126 * remounts the list (and loses the row the keys rest on).127 */128const WithFull = ({125 ask,129 children,127 project,130 pick,131}: {129 readonly ask: AskId;130 readonly project: ProjectName;132 readonly pick:133 | { readonly ask: AskId; readonly project: ProjectName }134 | undefined;135 readonly children: (full: Ask | undefined) => ReactNode;136}) => {133 const read = useAtomValue(askAtom(project, ask));137 const read = useAtomValue(selectedAskAtom(pick));138139 return children(AsyncResult.isSuccess(read) ? read.value.ask : undefined);140};141
86 unmodified lines
228 const picked = Option.filter(decodeAsk(selected), (ask) =>229 (asks ?? []).some((listing) => listing.ask === ask)230 );231228 return hydrated && Option.isSome(picked) ? (229 <WithFull ask={picked.value} project={project}>232 return (233 <WithFull234 pick={235 hydrated && Option.isSome(picked)236 ? { ask: picked.value, project }237 : undefined238 }239 >240 {view}241 </WithFull>232 ) : (233 view()242 );243};244245const ProjectPage = () => {
67 unmodified lines
modified:apps/web/src/routes/index.tsx+13 added-11 removed
14 unmodified lines
15import { AsyncResult } from "effect/reactivity";16import { useEffect, useMemo } from "react";17import type { ReactNode } from "react";1819import { askAtom } from "../client/ask.ts";19import { selectedAskAtom } from "../client/ask.ts";20import { projectEventsAtom } from "../client/events.ts";21import { frontPageAtom, projectsAtom } from "../client/front.ts";22import {23 familyEventsAtom,
55 unmodified lines
79const everyAsk = frontPageAtom({});8081const root = getRouteApi("__root__");8283/** The selected ask in full, read in the browser once it is selected. */83/**84 * The selected ask in full, read in the browser once it is selected. It85 * wraps the page whether or not a row is selected, so selecting one never86 * remounts the list (and loses the row the keys rest on).87 */88const WithFull = ({85 ask,89 children,87 project,90 pick,91}: {89 readonly ask: AskId;90 readonly project: ProjectName;92 readonly pick:93 | { readonly ask: AskId; readonly project: ProjectName }94 | undefined;95 readonly children: (full: Ask | undefined) => ReactNode;96}) => {93 const read = useAtomValue(askAtom(project, ask));97 const read = useAtomValue(selectedAskAtom(pick));9899 return children(AsyncResult.isSuccess(read) ? read.value.ask : undefined);100};101
60 unmodified lines
162 webUrl={webUrl}163 />164 );165162 return hydrated && Option.isSome(picked) ? (163 <WithFull ask={picked.value.ask} project={picked.value.project}>166 return (167 <WithFull pick={hydrated ? Option.getOrUndefined(picked) : undefined}>168 {view}169 </WithFull>166 ) : (167 view()170 );171};172173const FrontPage = () => {
71 unmodified lines
modified:apps/web/src/styles.css+19 added-5 removed
132 unmodified lines
133 --input: oklch(0.62 0.01 258);134 --skeleton: oklch(0.8 0.008 255);135136 /* Code: ink carries keywords, names and calls; strings lean teal and137 constants olive, both too grey to be mistaken for a state. */137 constants olive, both too grey to be mistaken for a state. Each keeps138 4.5:1 on a changed word's tint as well as on the paper. */139 --syntax-keyword: var(--foreground);140 --syntax-function: var(--foreground);141 --syntax-parameter: var(--foreground);141 --syntax-string: oklch(0.46 0.035 200);142 --syntax-constant: oklch(0.47 0.035 110);143 --syntax-comment: var(--muted);144 --syntax-punctuation: var(--muted);142 --syntax-string: oklch(0.42 0.035 200);143 --syntax-constant: oklch(0.42 0.035 110);144 /* A step darker than muted: a changed word's tint sits under these, and145 they keep 4.5:1 on it too. */146 --syntax-comment: oklch(0.42 0.012 258);147 --syntax-punctuation: oklch(0.42 0.012 258);148 --syntax-link: var(--syntax-string);149150 /* A diff's lines. The sign colour draws the + and -, the bars and a151 changed line's number; the line's tint is that colour mixed into the
52 unmodified lines
204 --skeleton: oklch(0.36 0.01 258);205206 --syntax-string: oklch(0.8 0.035 200);207 --syntax-constant: oklch(0.82 0.035 110);208 --syntax-comment: var(--muted);209 --syntax-punctuation: var(--muted);210211 --diff-add-sign: oklch(0.74 0.08 195);212 --diff-add-bg: color-mix(213 in lab,
155 unmodified lines
369 @apply bg-background text-foreground font-sans antialiased;370 caret-color: var(--checking);371 }372373 /* On a phone a decision's choices are a bar fixed above the bottom bar374 (decision/choices.tsx): main keeps room for it at its foot, so the375 page's last lines scroll clear of it. */376 @media (width < 40rem) {377 main:has([data-choices-bar]) {378 padding-bottom: 10rem;379 }380 }381382 ::selection {383 background: color-mix(in oklch, var(--checking) 22%, transparent);384 color: var(--foreground);385 }
151 unmodified lines
modified:apps/web/test/code-client.test.tsx+17 added
20 unmodified lines
21import { DiffCode } from "../src/features/code/diff-view.tsx";22import {23 followChoices,24 RepoTree,25 filterTree,26 treeOptionsFor,27} from "../src/features/code/repo-tree.tsx";2829const files = Schema.decodeSync(Schema.Array(ChangedFile))([
84 unmodified lines
114115 expect(opened).toStrictEqual([]);116 });117118 it("keeps its filter outside the tree, which holds only rows", () => {119 const { tree } = treeAt("src/parse.ts");120121 // A field inside a tree's role is not one of its rows to a screen122 // reader: the filter sits above the tree and narrows it from there.123 expect(treeOptionsFor({ paths: PATHS }).search).toBeFalsy();124125 filterTree(tree, "week");126127 expect(tree.getSearchValue()).toBe("week");128129 filterTree(tree, "");130131 expect(tree.isSearchOpen()).toBeFalsy();132 });133134 it("opens the folders above the page's file, and selects it", () => {135 const { tree } = treeAt("src/parse.ts");136137 expect(tree.getSelectedPaths()).toStrictEqual(["src/parse.ts"]);
15 unmodified lines
modified:apps/web/test/code.test.tsx+22 added
42 unmodified lines
43import { renderToStaticMarkup } from "react-dom/server";4445import { BlobView } from "../src/features/code/blob-view.tsx";46import { CommitView } from "../src/features/code/commit-view.tsx";47import { FileFacts } from "../src/features/code/file-facts.tsx";48import { LOG_PAGE } from "../src/features/code/log-page.ts";49import { LogView } from "../src/features/code/log-view.tsx";50import { CodeNotFound } from "../src/features/code/not-found.tsx";51import { SoftLanding } from "../src/features/code/soft-landing.ts";
349 unmodified lines
401 expect(markupOf(page)).not.toContain("<file-tree-container");402 });403});404405/** Where a file's facts link their permalink, on the page of `mode`. */406const permalink = (mode: "code" | "why") =>407 /href="(?<href>[^"]*)"[^>]*>Permalink</u.exec(408 markupOf(409 <FileFacts410 file={readme}411 mode={mode}412 now={now}413 project={datekit}414 rev="main"415 />416 )417 )?.groups?.href;418419describe("a file's facts", () => {420 it("link a permalink to the page they sit on: the code, or why", () => {421 expect(permalink("code")).toBe(`/datekit/blob/${AT}/README.md`);422 expect(permalink("why")).toBe(`/datekit/why/${AT}/README.md`);423 });424});425426describe(BlobView, () => {427 const parse = decodeFile({428 at: AT,429 binary: false,
1115 unmodified lines
modified:apps/web/test/events.test.ts+1 added-1 removed
196 unmodified lines
197 AwaitingFinish: "decider",198 Checking: "platform",199 Landed: "none",200 Refused: "answerer",201 WaitingOnParent: "family",201 WaitingOnParent: "parent",202 } satisfies Record<Outcome["_tag"], Move>);203 });204205 it("leaves a claimed ask with nothing judged to its answerer, and an open one to nobody", () => {
170 unmodified lines
modified:apps/web/test/family.test.tsx+29 added-1 removed
5 unmodified lines
6 * settles with the stamp, once. Its states come from the event fold, built7 * here from hand-made events.8 */9import { describe, expect, it } from "@effect/vitest";10import { Brand } from "@repo/brand";11import type { Ask } from "@repo/protocol/domain/ask";12import { ProjectEvent } from "@repo/protocol/domain/event";13import { Outcome } from "@repo/protocol/domain/outcome";14import {
181 unmodified lines
196 const folded = yield* strip({ expanded: false });197198 expect(textIn(folded)).toContain("Show 6 children");199 expect(folded).toMatch(/<button\b[^>]*aria-expanded="false"/u);199 expect(tagsWith(folded, "data-family-child")).toHaveLength(0);200 // Folded, the rows are out of sight and out of the reading order:201 // the list that holds them is hidden.202 expect(folded).toMatch(203 /<ul\b[^>]*hidden=""[^>]*>(?:(?!<\/ul>).)*data-family-child/su204 );205 expect(folded).not.toMatch(206 /<ul\b(?![^>]*hidden="")[^>]*>(?:(?!<\/ul>).)*data-family-child/su207 );208 })209 );210211 it.effect(212 "holds each open child's claim command as text, folded or not",213 () =>214 Effect.gen(function* () {215 for (const expanded of [false, true]) {216 const markup = yield* strip({ expanded });217218 for (const open of ["burrow-notify", "burrow-search"]) {219 expect(markup).toContain(220 `<code class="sr-only">${Brand.cli} claim ${id(open)} --project burrow</code>`221 );222 }223224 // A child someone holds, or that landed, has none.225 expect(markup).not.toContain(`claim ${id("burrow-catalog")} `);226 expect(markup).not.toContain(`claim ${id("burrow-auth")} `);227 }228 })229 );230231 it.effect(232 "lists the children as rows when expanded, the delete child apart",233 () =>234 Effect.gen(function* () {235 const open = yield* strip({ expanded: true });
105 unmodified lines
modified:apps/web/test/ledger.test.tsx+6 added-3 removed
405 unmodified lines
406 "sealed: counts, authors and a salted root",407 "write-only: names, and who set each value and when",408 ])409 ).toBeTruthy();410 expect(facts).toMatch(411 /<code\b[^>]*select-all[^>]*>[^<]*ledger --project datekit/u412 );410 // The command is the text of the one code element a tap selects whole.411 expect(412 plainText(413 /<code\b[^>]*select-all[^>]*>.*?<\/code>/u.exec(facts)?.[0] ?? ""414 )415 ).toContain("ledger --project datekit");416 });417418 it("shows a project without layers as Open, with nothing held back", () => {419 const view = <LedgerView ledger={open} now={now} />;
257 unmodified lines
modified:apps/web/test/pierre.test.ts+21 added
14 unmodified lines
15 registerCodeTheme,16 treesOptions,17} from "../src/features/code/pierre.ts";1819/** A drawn code box, wider than its pane when it `scrolls`. */20const box = (scrolls: boolean) => ({21 clientHeight: 400,22 clientWidth: 600,23 scrollHeight: 400,24 scrollWidth: scrolls ? 900 : 600,25 tabIndex: -1,26});2728describe("the options every drawing of code shares", () => {29 it("name the token theme for both schemes, so the page's scheme decides", () => {30 expect(diffsOptions.theme).toStrictEqual({31 dark: CODE_THEME,
9 unmodified lines
41 expect(diffsOptions.tokenizeMaxLineLength).toBe(1000);42 expect(diffsOptions.maxLineDiffLength).toBe(1000);43 });4445 it("let the keyboard reach code that scrolls, with its focus in sight", () => {46 const wide = box(true);47 const narrow = box(false);4849 diffsOptions.onPostRender({50 shadowRoot: { querySelectorAll: () => [wide, narrow] },51 });5253 expect([wide.tabIndex, narrow.tabIndex]).toStrictEqual([0, -1]);54 expect(diffsOptions.unsafeCSS).toContain("code:focus-visible");55 });5657 it("draw a file tree compact, with plain icons", () => {58 expect(treesOptions).toStrictEqual({59 density: "compact",60 icons: "minimal",
62 unmodified lines
modified:apps/web/test/refs.test.tsx+6 added-1 removed
153 unmodified lines
154 it("puts the clone command and what a claim fork is in its facts", () => {155 const facts = inspectorOf(markupOf(page));156157 expect(plainText(facts)).toContain(`git clone ${platformUrl}/datekit.git`);158 expect(facts).toMatch(/<code\b[^>]*select-all[^>]*>git clone /u);158 // The command is the text of the one code element a tap selects whole.159 expect(160 plainText(161 /<code\b[^>]*select-all[^>]*>.*?<\/code>/u.exec(facts)?.[0] ?? ""162 )163 ).toMatch(/^ ?git clone /u);164 expect(plainText(facts)).toContain("claim fork");165 });166167 it("never names the platform's own refs, and says tags, not releases", () => {
169 unmodified lines
modified:apps/web/test/shared.test.tsx+15 added
154 unmodified lines
155156 expect(textOf(element)).toContain(command);157 expect(markupOf(element)).toMatch(/<button\b[^>]*>.*Copy.*<\/button>/u);158 });159160 it("keeps each word whole on its line, so a narrow column breaks between words", () => {161 const command = `${Brand.cli} claim lint-heading-levels --project vellum`;162 const markup = markupOf(<CommandLine command={command} />);163164 const words = [165 ...markup.matchAll(166 /<span class="inline-block[^"]*">(?<word>[^<]*)<\/span>/gu167 ),168 ].map(([, word]) => word);169170 expect(words).toStrictEqual(command.split(" "));171 // The words keep the command's own spaces between them.172 expect(textOf(<CommandLine command={command} />)).toContain(command);173 });174});175176describe(EmptyState, () => {177 it("says what is empty and the command that would change it", () => {
67 unmodified lines
modified:apps/web/test/status-line.test.tsx+2 added-1 removed
169 unmodified lines
170 Outcome.cases.WaitingOnParent.make({171 ask: AskId.make("drop-legacy-fetch-burrow-kit"),172 }),173 "Passed, waiting for drop-legacy-fetch-burrow-kit to land first",174 // The ask it waits on may be no family's: the move is that ask's.174 "the family's move",175 "that ask's move",176 ],177 ] as const;178179 for (const [outcome, sentence, move] of waiting) {
138 unmodified lines
added:apps/web/test/type-floor.test.ts+75 added
1/**2 * The web's type floor is 13 px: nothing a person reads is set at 12 or3 * 11. Tailwind's `text-xs` is 12 px, and an arbitrary size can hide a4 * smaller one, so the web's source names neither; code-sized text is the5 * `text-mono` step of the scale, never a copy of its value.6 */7import { describe, expect, it } from "@effect/vitest";89const sources: Readonly<Record<string, string>> = import.meta.glob(10 "../src/**/*.{ts,tsx}",11 { eager: true, import: "default", query: "?raw" }12);1314/**15 * A size class under the floor, or the mono step spelled as a literal:16 * `text-xs` with any variant before it, and an arbitrary `text-[…]` size17 * in px or rem.18 */19const sizeClass =20 /(?<![\w-])text-(?:xs|\[(?<size>\d*\.?\d+)(?<unit>px|rem)\])(?![\w-])/gu;2122/** The floor, in px; the rem steps count 16 px each. */23const FLOOR = 13;2425/** Each size class in `source` that breaks the floor, or spells the mono step. */26const offending = (source: string) =>27 [...source.matchAll(sizeClass)].flatMap((match) => {28 const { size, unit } = match.groups ?? {};2930 if (size === undefined || unit === undefined) {31 return [match[0]];32 }3334 const px = unit === "rem" ? Number(size) * 16 : Number(size);3536 // 13 px as an arbitrary value is the mono step under another name.37 return px <= FLOOR ? [match[0]] : [];38 });3940describe("the type floor", () => {41 it("reads every source file of the web", () => {42 expect(Object.keys(sources).length).toBeGreaterThan(100);43 });4445 it("sets nothing under 13 px, and names the mono step by its token", () => {46 const found = Object.entries(sources).flatMap(([path, source]) => {47 const classes = offending(source);4849 return classes.length === 0 ? [] : [`${path}: ${classes.join(", ")}`];50 });5152 expect(found).toStrictEqual([]);53 });5455 it("catches each size the floor refuses", () => {56 expect(57 offending(58 "a text-xs b sm:text-xs c text-[0.6875rem] d text-[0.75rem] e text-[11px] f text-[12px] g text-[0.8125rem] h text-[13px]"59 )60 ).toStrictEqual([61 "text-xs",62 "text-xs",63 "text-[0.6875rem]",64 "text-[0.75rem]",65 "text-[11px]",66 "text-[12px]",67 "text-[0.8125rem]",68 "text-[13px]",69 ]);7071 expect(72 offending("text-mono text-ui text-label text-[0.875rem] text-xsmall")73 ).toStrictEqual([]);74 });75});