Review fixes for 1204
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- Row: the <li> is `isolate`, so its raised controls (copy button, a fan's nodes and toggle, all z-10) stay under the sticky group headers and toolbar when a list scrolls under them. - Row: the link's overlay lets presses through at shell width only when the row selects (`onSelect`); a list that does not select (rounds, landings, commits) keeps the whole row as the link's hit area at every width, as the direction asks. - Row: a retryable refusal's word is in the refused role, as the status line's lead is; its RotateCcw mark stays ochre. - FamilyStrip: the delete child's node says its own state once every child landed ("delete claimed", "delete checking"), not "open to take" whatever it is; expanded children with no want are named by their short name (the whole id in the title), so they read on a phone instead of truncating to a shared prefix. - ProvenanceFacts: each copy button sits inside its `dd` (a `dl`'s groups hold only terms and values); its name is "Copy <label>". - StatusLine compact: no title, which named the mark's word and could disagree with the lead ("Waiting" over "Passed"). - Tests added red by assertion first: row (hit area with and without selection, isolation, the retry word's role), family (the delete child's word after every child landed, listed children's short names), facts (no button outside a provenance term or value).
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+210 added−25 removed
- tests:+165 added−1 removed
- other:+45 added−24 removed
Provenance
- Commit
bbace25- Tree
3b24a22- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
886b726
7 files changed+210 added−25 removed
modified:apps/web/src/features/shared/facts.tsx+5 added-6 removed
660 unmodified lines661 <div className="flex min-h-8 min-w-0 items-center gap-3" key={label}>662 <dt className="text-label text-muted-foreground w-24 shrink-0">663 {label}664 </dt>665+ <dd className="text-ui flex min-w-0 flex-1 items-center gap-3">665- <dd className="text-ui min-w-0 flex-1 truncate">666- {shown ?? <CodeValue value={value} />}666+ <span className="min-w-0 flex-1 truncate">667+ {shown ?? <CodeValue value={value} />}668+ </span>669+ <CopyAction command={value} label={`Copy ${label}`} />670 </dd>668- <CopyAction669- command={value}670- label={`Copy the ${label.toLowerCase()}`}671- />671 </div>672 ))}673 </dl>674 </section>2 unmodified linesmodified:apps/web/src/features/shared/family.tsx+18 added-7 removed
115 unmodified lines116 if (states.get(finale)?.landed !== undefined) {117 return { mark: "landed", words: "landed" };118 }119 120- return remaining === 0121- ? { mark: markFor(markOf(states.get(finale))), words: "open to take" }122- : { mark: "waiting", words: `waits for ${remaining}` };120+ if (remaining > 0) {121+ return { mark: "waiting", words: `waits for ${remaining}` };122+ }123+124+ const mark = markOf(states.get(finale));125+126+ return {127+ mark: markFor(mark),128+ words: mark === "open" ? "open to take" : words[mark],129+ };130 };131 132 const NODE =133 "text-label relative z-10 inline-flex min-w-0 items-center gap-1 no-underline hover:underline decoration-rule";127 unmodified lines261 title={wants?.get(ask) ?? ask}262 to={askPath(project, ask)}263 >264 {wants?.get(ask) ?? (258- <span className="text-mono font-mono">{ask}</span>265+ <span className="text-mono font-mono">266+ {family.nameOf(ask)}267+ </span>268 )}269 </AppLink>270+ {wants?.has(ask) === true ? (261- <span className="text-mono text-muted-foreground tablet:inline hidden shrink-0 font-mono">262- {family.nameOf(ask)}263- </span>271+ <span className="text-mono text-muted-foreground tablet:inline hidden shrink-0 font-mono">272+ {family.nameOf(ask)}273+ </span>274+ ) : null}275 <span className="text-label text-muted-foreground ml-auto shrink-0">276 {words[mark]}277 </span>278 </li>106 unmodified linesmodified:apps/web/src/features/shared/row.tsx+21 added-9 removed
1-import { Brand } from "@repo/brand";1 /**2 * One row for every list: asks, decisions, landings, commits, refs, forks,3 * credits, rounds, history. Two lines, the thing first and its state at4 * the right:13 unmodified lines18 * (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 */22+import { Brand } from "@repo/brand";23 import type { AskListing } from "@repo/protocol/domain/ask";24 import { Outcome } from "@repo/protocol/domain/outcome";25 import type { ProjectName } from "@repo/protocol/ids";26 import type { MouseEvent, ReactNode } from "react";52 unmodified lines79 80 /** The shell's width, from which a row selects rather than opens. */81 const SHELL_WIDTH = "(min-width: 70rem)";82 83-/** The word's colour: the state's role; ink for open and claimed, which have none. */84-const wordTone = (mark: StateMark) =>85- mark === "open" || mark === "claimed"86- ? "text-foreground"87- : STATE_MARKS[mark].tone;83+/**84+ * The word's colour: the state's role; ink for open and claimed, which have85+ * none. A refusal that can be retried keeps its ochre mark, but its word is86+ * a refusal's, as the status line says it.87+ */88+const wordTone = (mark: StateMark) => {89+ if (mark === "open" || mark === "claimed") {90+ return "text-foreground";91+ }92 93+ return mark === "retry" ? "text-refused" : STATE_MARKS[mark].tone;94+};95+96 /** Whether a press on `target` was meant for a link or a control in the row. */97 const onControl = (target: EventTarget) =>98 target instanceof Element &&99 target.closest("a, button, summary, input, select, textarea") !== null;28 unmodified lines128 <MetaCode>{territory}</MetaCode>129 );130 131 const LINK =125- "text-foreground no-underline outline-none after:absolute after:inset-0 after:content-[''] focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-ring focus-visible:after:outline-solid shell:after:pointer-events-none";132+ "text-foreground no-underline outline-none after:absolute after:inset-0 after:content-[''] focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-ring focus-visible:after:outline-solid";133 134+/** From the shell's width a row that selects lets a press off its link through to the row. */135+const SELECTS = "shell:after:pointer-events-none";136+137 /** A press on the row, off its link and its controls, selects it from the shell's width. */138 const selectOnPress =139 (id: string, onSelect: ((id: string) => void) | undefined) =>140 (event: MouseEvent<HTMLLIElement>) => {55 unmodified lines196 197 const link = (198 <AppLink199 aria-current={selected ? "true" : undefined}190- className={LINK}200+ className={onSelect === undefined ? LINK : `${LINK} ${SELECTS}`}201 data-list-key={id}202 search={search}203 title={title}204 to={href}6 unmodified lines211 state === undefined ? null : (212 <StateMarkIcon mark={state.mark} stamp={state.stamp === true} />213 );214 215+ // `isolate` keeps the row's raised controls (its copy button, a fan's216+ // nodes) inside the row, so a sticky header passes over them.205- const rowClass = `group/row border-rule relative -mx-2 border-b px-2 transition-colors duration-[120ms] ${217+ const rowClass = `group/row border-rule relative isolate -mx-2 border-b px-2 transition-colors duration-[120ms] ${218 selected ? "bg-surface" : "hover:bg-surface/50"219 }`;220 221 return (259 unmodified linesmodified:apps/web/src/features/shared/status-line.tsx+1 added-2 removed
31 unmodified lines32 import type { Family, Move } from "./ask-progress.ts";33 import { CommandChip } from "./copy-action.tsx";34 import { HandleLink } from "./handle.tsx";35 import { AppLink } from "./link.tsx";36-import { STATE_MARKS, StateMarkIcon } from "./marks.tsx";36+import { StateMarkIcon } from "./marks.tsx";37 import type { StateMark } from "./marks.tsx";38 import { askPath, decisionPath } from "./paths.ts";39 import { distanceInWords } from "./time.tsx";40 511 unmodified lines552 <span553 className="text-ui inline-flex min-w-0 items-center gap-1.5"554 data-mark={reading.mark}555 data-tone={reading.tone}556- title={STATE_MARKS[reading.mark].word}556 >557 <StateMarkIcon mark={reading.mark} stamp={stamp} />558 <strong className={`font-semibold ${leadTone[reading.tone]}`}>559 {reading.lead}41 unmodified linesmodified:apps/web/test/facts.test.tsx+15 added
112 unmodified lines113 expect(markup).toContain(`>${"c".repeat(7)}<`);114 expect(markup.split(patch).length - 1).toBeLessThanOrEqual(3);115 });116 117+ it("keeps each entry's copy button inside its value, so the list holds only terms and values", () => {118+ const markup = markupOf(119+ <ProvenanceFacts entries={verdictProvenance(verdictOf(checking), now)} />120+ );121+122+ const [list] = /<dl\b.*<\/dl>/su.exec(markup) ?? [""];123+124+ const outside = list125+ .replaceAll(/<dt\b.*?<\/dt>/gsu, "")126+ .replaceAll(/<dd\b.*?<\/dd>/gsu, "");127+128+ expect(list).toContain("<button");129+ expect(outside).not.toContain("<button");130+ });131+132 it("shortens a hash named by its algorithm, keeping the algorithm", () => {133 const markup = markupOf(134 <ProvenanceFacts entries={[{ label: "Suite", value: suite }]} />135 );130 unmodified linesmodified:apps/web/test/family.test.tsx+64 added
215 unmodified lines216 })217 );218 });219 220+describe("FamilyStrip, once every child landed", () => {221+ const landedAll = askStates([222+ ...children.map((child, index) =>223+ ProjectEvent.cases.AskClosed.make({224+ ask: child,225+ at,226+ landing: sha,227+ seq: index + 1,228+ })229+ ),230+ ProjectEvent.cases.Claimed.make({231+ ask: finale,232+ at,233+ claimant: tamsin,234+ seq: 10,235+ }),236+ ]);237+238+ it.effect("says where the delete child stands in its own mark's word", () =>239+ Effect.gen(function* () {240+ const text = textIn(241+ yield* renderAt(242+ "/burrow",243+ <FamilyStrip244+ expanded={false}245+ finale={finale}246+ parent={parent}247+ project={burrow}248+ stamps={new Set()}249+ states={landedAll}250+ />251+ )252+ );253+254+ expect(text).toContain("6 of 6 landed");255+ expect(text).toContain("delete claimed");256+ expect(text).not.toContain("open to take");257+ })258+ );259+});260+261+describe("FamilyStrip's listed children", () => {262+ it.effect(263+ "names a child with no want by its short name, its whole id kept in the title",264+ () =>265+ Effect.gen(function* () {266+ const markup = yield* strip({ expanded: true });267+268+ const links = [269+ ...markup.matchAll(270+ /<li\b[^>]*data-family-child[^>]*>.*?<a\b(?<attributes>[^>]*)>(?<body>.*?)<\/a>/gsu271+ ),272+ ].map((match) => [273+ attributeOf(match.groups?.attributes ?? "", "title"),274+ textIn(match.groups?.body ?? ""),275+ ]);276+277+ expect(links).toStrictEqual(278+ children.map((child, index) => [child, modules[index]])279+ );280+ })281+ );282+});283+284 describe(FamilyTree, () => {285 it.effect(286 "draws the parent, its children and the delete child, marking the member being read",287 () =>25 unmodified linesmodified:apps/web/test/row.test.tsx+86 added-1 removed
6 unmodified lines7 */8 import { describe, expect, it } from "@effect/vitest";9 import { Brand } from "@repo/brand";10 import { AskListing } from "@repo/protocol/domain/ask";11+import { Outcome } from "@repo/protocol/domain/outcome";11-import { ProjectName } from "@repo/protocol/ids";12+import { CommitSha, ProjectName } from "@repo/protocol/ids";13+import { StaleBase } from "@repo/protocol/refusal";14 import { Effect, Schema } from "effect";15 import type { ReactElement } from "react";16 17 import { AskRow, Row, RowGroup } from "../src/features/shared/row.tsx";125 unmodified lines143 expect(textIn(held)).toContain("Claimed");144 expect(held).not.toContain("Copy claim command");145 })146 );147+ it.effect(148+ "draws a refusal's word in the refused role even when it can be retried, its mark apart",149+ () =>150+ Effect.gen(function* () {151+ const markup = yield* rowsAt(152+ <AskRow153+ listing={listing("@burrow/auth")}154+ progress={{155+ lastSeq: 2,156+ latest: Outcome.cases.Refused.make({157+ refusals: [158+ new StaleBase({159+ base: CommitSha.make("a".repeat(40)),160+ conflicts: [],161+ main: CommitSha.make("b".repeat(40)),162+ }),163+ ],164+ }),165+ rounds: [],166+ }}167+ project={burrow}168+ />169+ );170+171+ const words = [172+ ...markup.matchAll(/<span class="(?<classes>[^"]*)">Refused</gu),173+ ].map((match) => match.groups?.classes ?? "");174+175+ expect(words.length).toBeGreaterThan(0);176+177+ for (const classes of words) {178+ expect(classes).toContain("text-refused");179+ expect(classes).not.toContain("text-waiting");180+ }181+ })182+ );183 });184 185 describe(Row, () => {186 it.effect(26 unmodified lines213 expect(markup).toContain('data-list-key="a"');214 })215 );216 217+ it.effect(218+ "keeps the whole row the link's to press when the list does not select, at every width",219+ () =>220+ Effect.gen(function* () {221+ const plain = yield* rowsAt(222+ <Row href="/datekit/asks/a" id="a" title="Format ordinals" />223+ );224+225+ const selecting = yield* rowsAt(226+ <Row227+ href="/datekit/asks/a"228+ id="a"229+ onSelect={() => {}}230+ title="Format ordinals"231+ />232+ );233+234+ const [link] = tagsWith(plain, "data-list-key");235+ const [selectingLink] = tagsWith(selecting, "data-list-key");236+237+ expect(link).not.toContain("shell:after:pointer-events-none");238+ expect(selectingLink).toContain("shell:after:pointer-events-none");239+ })240+ );241+242+ it.effect(243+ "keeps its raised controls inside its own layer, under the sticky headers",244+ () =>245+ Effect.gen(function* () {246+ const markup = yield* rowsAt(247+ <Row248+ action={<button type="button">Copy</button>}249+ data={{ "data-ask": "a" }}250+ href="/datekit/asks/a"251+ id="a"252+ title="Format ordinals"253+ />254+ );255+256+ const [row] = tagsWith(markup, "data-ask");257+258+ expect(attributeOf(row ?? "", "class")?.split(" ")).toContain(259+ "isolate"260+ );261+ })262+ );263+264 it.effect("heads a group with its name as a link and its counts", () =>265 Effect.gen(function* () {266 const markup = yield* renderAt(267 "/",13 unmodified lines