Read an answer's head as title, round, then outcome, and keep the ask and answer pages off dead ends
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- Answer page: the meta line (ask id, round n of n, judged) now sits under the title and before the outcome hero; a refusal drawn whole no longer buries it below the RefusalView. - Answer page: with no lanes yet, a checking answer says "No lane has run yet." rather than "No lane ran on this answer." (still said once the answer was refused before its lanes). - Answer page: an open ask that still waits on other asks gives no claim command (the claim would be refused); it says how many asks must land first and links the ask. - Ask page: a family's parent says what it waits on in the fan's terms ("Waits for 3 of 6 children and the delete step to land first"), never as a sentence of child ids; asks outside a family keep "Waits on ...". - Not found: the trail goes only as far as what exists (the project and its asks, then "No such ask"), and a project the platform says it lacks (UnknownProject) is linked neither in the trail nor onward. The answer route's not-found tab reads "No such ask", as its heading does. - Gate strip: a stage label wraps instead of truncating in the four-column phone grid ("Held-back" read "Held-b..."). - Tests: the views' new cases (meta before the hero, checking with no lanes, a blocked ask's empty answer, the parent's family wait in both states, the not-found trail and an unknown project), plus the passed lanes' command and time inside the folded line, an assertion the rewrite had dropped.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+269 added−45 removed
- tests:+107 added−1 removed
- other:+162 added−44 removed
Provenance
- Commit
613d347- Tree
1f290b4- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
706df56
7 files changed+269 added−45 removed
modified:apps/web/src/features/answer/answer-page.tsx+63 added-28 removed
175 unmodified lines176 )}`;177 178 /** The lanes the platform ran on the merged tree: what failed, open and first; what passed, in one line. */179 export const Lanes = ({180+ checking = false,181 lanes,182 project,183 }: {184 readonly lanes: readonly LaneResult[];185 readonly project: Ask["project"];186+ /** The gate is still at work on the answer: its lanes may yet run. */187+ readonly checking?: boolean;188 }) => {189 if (lanes.length === 0) {187- return <EmptyState title="No lane ran on this answer." />;190+ return (191+ <EmptyState192+ title={193+ checking ? "No lane has run yet." : "No lane ran on this answer."194+ }195+ />196+ );197 }198 199 const open = lanes.filter(({ result }) => result !== "passed");200 const passed = lanes.filter(({ result }) => result === "passed");84 unmodified lines285 /** What the hero says before any answer was judged: who holds the ask, or how to take it. */286 const NoAnswerYet = ({287 ask,288 now,280- progress,289+ states,290 }: {291 readonly ask: Ask;292 readonly now: DateTime.Utc;284- readonly progress: AskProgress | undefined;293+ readonly states: ReadonlyMap<AskId, AskProgress>;294 }) => {295+ const progress = states.get(ask.id);296+297 const toAsk = (298 <AppLink299 className="decoration-rule underline hover:decoration-current"300 to={askPath(ask.project, ask.id)}20 unmodified lines321 />322 );323 }324 325+ // What it waits on must land before anyone can claim it.326+ const waiting = ask.blockedBy.filter(327+ (blocker) => states.get(blocker)?.landed === undefined328+ ).length;329+330+ if (ask.state === "open" && waiting > 0) {331+ return (332+ <EmptyState333+ onward={toAsk}334+ title={`Nobody has answered this ask yet; it waits for ${waiting} ${335+ waiting === 1 ? "ask" : "asks"336+ } to land first.`}337+ />338+ );339+ }340+341 if (ask.state === "open") {342 return (343 <EmptyState344 command={`${Brand.cli} claim ${ask.id} --project ${ask.project}`}16 unmodified lines361 */362 const Hero = ({363 ask,364 now,338- progress,365 stamp,366+ states,367 verdict,368 }: {369 readonly ask: Ask;370 readonly now: DateTime.Utc;344- readonly progress: AskProgress | undefined;371 readonly stamp: boolean;372+ readonly states: ReadonlyMap<AskId, AskProgress>;373 readonly verdict: Verdict | undefined;374 }) => {375 const tag = verdict?.outcome._tag ?? "none";376 // Only an outcome that replaced another while the page was open settles in.4 unmodified lines381 setShown(tag);382 setChanged(true);383 }384 358- const claimant = progress?.claimant;385+ const claimant = states.get(ask.id)?.claimant;386 387 return (388 <section aria-label="Outcome" className="flex min-w-0 flex-col gap-3">389 <h2 className="sr-only">Outcome</h2>3 unmodified lines393 }394 key={tag}395 >396 {verdict === undefined ? (370- <NoAnswerYet ask={ask} now={now} progress={progress} />397+ <NoAnswerYet ask={ask} now={now} states={states} />398 ) : (399 <OutcomeView400 outcome={verdict.outcome}401 project={ask.project}40 unmodified lines442 </p>443 </Region>444 445 <Region id="answer-lanes" title="Lanes">419- <Lanes lanes={verdict.lanes} project={verdict.project} />446+ <Lanes447+ checking={Outcome.isAnyOf(["Checking"])(verdict.outcome)}448+ lanes={verdict.lanes}449+ project={verdict.project}450+ />451 </Region>452 453 {verdict.heldBack.length === 0 ? null : (454 <Region id="answer-held-back" title="Held back">214 unmodified lines669 viewer={viewer}670 />671 }672 factsHeading="This answer"642- meta={643- <AnswerMeta644- ask={ask}645- head={head}646- now={now}647- rounds={progress?.rounds ?? []}648- verdict={verdict}649- />650- }673 state={674 <StatusLine675 compact676 subject={6 unmodified lines683 }684 />685 }686 status={665- <Hero666- ask={ask}667- now={now}668- progress={progress}669- stamp={670- stamp &&671- verdict !== undefined &&672- Outcome.isAnyOf(["Landed"])(verdict.outcome)673- }674- verdict={verdict}675- />687+ // The answer's head reads title, then which answer this is, then688+ // the outcome: a refusal drawn whole would bury a line after it.689+ <div className="flex min-w-0 flex-col gap-4">690+ <div className="text-ui text-muted-foreground">691+ <AnswerMeta692+ ask={ask}693+ head={head}694+ now={now}695+ rounds={progress?.rounds ?? []}696+ verdict={verdict}697+ />698+ </div>699+ <Hero700+ ask={ask}701+ now={now}702+ stamp={703+ stamp &&704+ verdict !== undefined &&705+ Outcome.isAnyOf(["Landed"])(verdict.outcome)706+ }707+ states={states}708+ verdict={verdict}709+ />710+ </div>711 }712 title={ask.brief.want}713 >714 {verdict === undefined ? null : (10 unmodified linesmodified:apps/web/src/features/ask/ask-page.tsx+60 added-1 removed
319 unmodified lines320 </span>321 </p>322 );323 324+/**325+ * What a family's parent waits on, in the fan's terms: how many of its326+ * children have yet to land, then the delete step; never a list of ids327+ * (the fan draws each child).328+ */329+const FamilyWaits = ({330+ finale,331+ parent,332+ project,333+ states,334+}: {335+ readonly finale: AskId;336+ readonly parent: Ask;337+ readonly project: ProjectName;338+ readonly states: ReadonlyMap<AskId, AskProgress>;339+}) => {340+ const children = parent.blockedBy.filter((child) => child !== finale);341+342+ const left = children.filter(343+ (child) => states.get(child)?.landed === undefined344+ ).length;345+346+ const deleteStep = (347+ <AppLink className={LINK} to={askPath(project, finale)}>348+ the delete step349+ </AppLink>350+ );351+352+ return (353+ <p className="text-ui mt-2 flex items-start gap-2" data-state="waiting">354+ <Hourglass355+ aria-hidden="true"356+ className="text-waiting mt-0.5 size-4 shrink-0"357+ strokeWidth={1.75}358+ />359+ <span className="min-w-0">360+ Waits for{" "}361+ {left === 0 ? null : (362+ <>363+ {left} of {children.length}{" "}364+ {children.length === 1 ? "child" : "children"} and{" "}365+ </>366+ )}367+ {deleteStep} to land first; a claim waits until they do.368+ </span>369+ </p>370+ );371+};372+373 export interface AskViewProps {374 readonly ask: Ask;375 /** The brief as the platform renders it for an agent, in Markdown. */376 readonly brief: string;264 unmodified lines641 state={<StatusLine compact subject={subject} />}642 status={643 <>644 <StatusLine subject={subject} />596- {waitsOn ? <WaitsOn asks={remaining} project={ask.project} /> : null}645+ {waitsOn && family === ask && finale !== undefined ? (646+ <FamilyWaits647+ finale={finale}648+ parent={ask}649+ project={ask.project}650+ states={states}651+ />652+ ) : null}653+ {waitsOn && family !== ask ? (654+ <WaitsOn asks={remaining} project={ask.project} />655+ ) : null}656 {family === undefined ? null : (657 // Below the shell's width the family sits under the head, as a fan.658 <div className="shell:hidden mt-4">659 <FamilyStrip33 unmodified linesmodified:apps/web/src/features/ask/refused.tsx+30 added-11 removed
6 unmodified lines78910111213141516161718192021222324252627282930313233343517 unmodified lines535455565354555657585960616257585960616263646566676869707172737475767778798081828384858622 unmodified lines6 unmodified lines * encoded as `Refusals`; `NoSuchAsk` decodes them where they arrive * (AGENTS.md principle 2). */import { ProjectName } from "@repo/protocol/ids";import { UnknownProject } from "@repo/protocol/refusal";import type { Refusal } from "@repo/protocol/refusal";import { Option, Schema } from "effect";import type { Array } from "effect";
import { EmptyState } from "../shared/empty.tsx";import { PageShell } from "../shared/layout.tsx";import { AppLink } from "../shared/link.tsx";import { projectPath } from "../shared/paths.ts";import { RefusalView } from "../shared/refusal.tsx";import { Refusals } from "../shared/refusals.ts";import type { Crumb } from "../shared/shell/sections.ts";import { Workspace } from "../shared/shell/workspace.tsx";
/** What a 404 says when the address could name no ask, so no refusal came back. */export const NAMES_ONLY = "Nothing is at this address: a project's and an ask's names are lowercase words joined by single dashes.";
const LINK = "decoration-rule underline hover:decoration-current";
const isUnknownProject = Schema.is(UnknownProject);
/** Where to go from a page that names nothing: the project, then every open ask. */const Onward = ({ project }: { readonly project: ProjectName | undefined }) => ( <nav aria-label="Onward" className="text-ui flex flex-wrap gap-x-5 gap-y-1"> {project === undefined ? null : (17 unmodified lines /** The project the address names, when it could be one. */ readonly project?: ProjectName | undefined; readonly refusals: Array.NonEmptyReadonlyArray<Refusal> | undefined; readonly title: string;}) => ( <PageShell title={title}> {refusals === undefined ? ( <EmptyState title={nothing} /> ) : ( <RefusalView refusals={refusals} /> )} <Onward project={project} /> </PageShell>);}) => { // A project the platform says it lacks is no way onward. const known = refusals?.some(isUnknownProject) === true ? undefined : project;
// The trail goes as far as what exists: the project and its asks. const crumbs: readonly Crumb[] = known === undefined ? [{ label: "Asks", to: "/" }, { label: title }] : [ { label: known, to: projectPath(known) }, { label: "Asks", to: projectPath(known) }, { label: title }, ];
return ( <Workspace crumbs={crumbs} title={title}> {refusals === undefined ? ( <EmptyState title={nothing} /> ) : ( <RefusalView refusals={refusals} /> )} <Onward project={known} /> </Workspace> );};
const decodeRefusals = Schema.decodeUnknownOption(Refusals);
const decodeProject = Schema.decodeUnknownOption(ProjectName);
22 unmodified linesmodified:apps/web/src/features/shared/outcome.tsx+8 added-3 removed
199 unmodified lines200 data-stage={name}201 data-state={state}202 key={name}203 >204- <span className="text-label flex min-w-0 items-center gap-1.5">205- <StateMarkIcon mark={marks[state].mark} size="sm" />204+ <span className="text-label flex min-w-0 items-start gap-1.5">205+ <StateMarkIcon206+ className="mt-px"207+ mark={marks[state].mark}208+ size="sm"209+ />210+ {/* Four cells a row on a phone: a long label wraps rather than losing its end. */}211 <span207- className={`truncate ${212+ className={`min-w-0 break-words ${213 state === "pending" || state === "skipped"214 ? "text-muted-foreground"215 : "text-foreground"216 }`}16 unmodified linesmodified:apps/web/src/routes/$project/answers/$ask.tsx+1 added-1 removed
166 unmodified lines167 loaderDeps: ({ search }) => ({ head: search.head }),168 loader: ({ deps, params }) => answerPage({ data: { ...params, ...deps } }),169 head: ({ loaderData, params }) =>170 loaderData === undefined171- ? pageHead({ title: `Answer to ${params.ask}` })171+ ? pageHead({ title: "No such ask" })172 : pageHead({173 description: loaderData.askRead.brief.want,174 title: `Answer to ${params.ask} · ${params.project}`,175 }),5 unmodified linesmodified:apps/web/test/answer.test.tsx+51 added
235 unmodified lines236 ).toBeTruthy();237 expect(inOrder(text, ["unit", "bun test", "failed", "8.3 s"])).toBeTruthy();238 });239 240+ it("keeps each passed lane's command and how long it ran inside the folded line", () => {241+ const folded =242+ /<details\b[^>]*>(?<inner>.*)<\/details>/su.exec(243+ mainOf(markupOf(refusedPage))244+ )?.groups?.inner ?? "";245+246+ expect(247+ inOrder(plainText(folded), ["lint", "bun run lint", "passed", "1.2 s"])248+ ).toBeTruthy();249+ });250+251+ it("says no lane has run yet while the answer is checking, and that none ran once it was refused before them", () => {252+ const checking = {253+ ...verdictOf(Outcome.cases.Checking.make({ stage: "cheap" })),254+ lanes: [],255+ stage: "cheap" as const,256+ };257+258+ const refusedEarly = { ...refused, lanes: [], stage: "shape" as const };259+260+ expect(textOf(page({ verdict: checking }))).toContain(261+ "No lane has run yet."262+ );263+ expect(textOf(page({ verdict: checking }))).not.toContain("No lane ran");264+ expect(textOf(page({ verdict: refusedEarly }))).toContain(265+ "No lane ran on this answer."266+ );267+ });268+269+ it("names the ask and the round right under the title, before the outcome", () => {270+ const states = askStates([271+ claimedEvent(1, "okafor"),272+ judgedEvent(2, refused.outcome),273+ ]);274+275+ const markup = mainOf(markupOf(page({ states, verdict: refused })));276+ const round = markup.indexOf("round 1 of 1");277+278+ expect(round).toBeGreaterThan(markup.indexOf("</h1>"));279+ expect(round).toBeLessThan(markup.indexOf('aria-label="Outcome"'));280+ });281+282+ it("gives no claim command for an ask that still waits on others to land", () => {283+ const blocked = { ...ask, blockedBy: [AskId.make("split-format")] };284+ const markup = mainOf(markupOf(page({ ask: blocked, verdict: undefined })));285+286+ expect(textIn(markup)).not.toContain(`${Brand.cli} claim`);287+ expect(textIn(markup)).toContain("waits for 1 ask to land first");288+ expect(markup).toContain(`href="/datekit/asks/${askId}"`);289+ });290+291 it("names a lane's log only as the command that reads it", () => {292 const passing = verdictOf(Outcome.cases.Checking.make({ stage: "checks" }));293 const text = textOf(page({ verdict: passing }));294 395 unmodified linesmodified:apps/web/test/ask.test.tsx+56 added-1 removed
12 unmodified lines13 AskId,14 BlobSha,15 CommitSha,16 Handle,17+ ProjectName,18 RepoPath,19 } from "@repo/protocol/ids";19-import { OutOfScope, UnknownAsk, UnknownPath } from "@repo/protocol/refusal";20+import {21+ OutOfScope,22+ UnknownAsk,23+ UnknownPath,24+ UnknownProject,25+} from "@repo/protocol/refusal";26 import { explain } from "@repo/protocol/render";27 import { asTester, unanswered } from "@repo/protocol/testing";28 import { isNotFound } from "@tanstack/react-router";29 import { Effect, Layer, Ref, Schema, Stream } from "effect";318 unmodified lines348 expect(text).not.toContain("to land first");349 expect(asideOf(markup)).toContain(`data-family="${parent.id}"`);350 });351 352+ it("says a family's parent waits for its family in the family's terms, never as a list of ids", () => {353+ const { children, deleteChild, parent } = family;354+ const states = askStates([closedEvent(1, children[0] ?? parent.id)]);355+ const markup = mainOf(markupOf(page(parent, { states })));356+357+ expect(plainText(markup)).toContain(358+ "Waits for 2 of 3 children and the delete step to land first; a claim waits until they do."359+ );360+ expect(plainText(markup)).not.toContain("Waits on");361+ expect(markup).toContain(`href="/datekit/asks/${deleteChild.id}"`);362+ });363+364+ it("says a family's parent whose children all landed waits only for the delete step", () => {365+ const { children, parent } = family;366+367+ const states = askStates(368+ children.map((child, index) => closedEvent(index + 1, child))369+ );370+371+ expect(plainText(mainOf(markupOf(page(parent, { states }))))).toContain(372+ "Waits for the delete step to land first"373+ );374+ });375+376 it("names the asks an ask outside a family waits on, each linking to its page", () => {377 const blocked = {378 ...ask,379 blockedBy: [AskId.make("split-format"), AskId.make("split-parse")],78 unmodified lines458 expect(markup).toContain('href="/"');459 expect(textOf(<NoSuchAsk project="datekit" />)).toContain("Open asks");460 });461 462+ it("names the project and its asks in the trail, and no crumb for the ask that is not there", () => {463+ const refusal = new UnknownAsk({ ask: AskId.make("no-such-ask") });464+ const data = structuredClone(Schema.encodeSync(Refusals)([refusal]));465+466+ const trail = trailOf(467+ markupOf(<NoSuchAsk data={data} project="datekit" />)468+ );469+470+ expect(inOrder(plainText(trail), ["datekit", "Asks"])).toBeTruthy();471+ expect(trail).toContain('href="/datekit"');472+ expect(trail).not.toContain("no-such-ask");473+ });474+475+ it("links no project the platform says it does not have", () => {476+ const refusal = new UnknownProject({477+ project: ProjectName.make("nowhere"),478+ });479+480+ const data = structuredClone(Schema.encodeSync(Refusals)([refusal]));481+ const markup = markupOf(<NoSuchAsk data={data} project="nowhere" />);482+483+ expect(markup).not.toContain('href="/nowhere"');484+ expect(markup).toContain('href="/"');485+ });486+487 it("says what its route gives it when a not-found carries no refusal", () => {488 expect(489 textOf(<NoSuchAsk nothing="No answer is at this head." />)490 ).toContain("No answer is at this head.");189 unmodified lines