Skip to content
Myr

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.

authored by oscabriel · committed by oscabriel · parent 706df56 · Browse files · 7 files+269 added−45 removed
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

7 files+269 added−45 removed

modified:apps/web/src/features/answer/answer-page.tsx+63 added-28 removed
175 unmodified lines
176 )}`;177178/** The lanes the platform ran on the merged tree: what failed, open and first; what passed, in one line. */179export 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 }198199 const open = lanes.filter(({ result }) => result !== "passed");200 const passed = lanes.filter(({ result }) => result === "passed");
84 unmodified lines
285/** What the hero says before any answer was judged: who holds the ask, or how to take it. */286const 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);296297 const toAsk = (298 <AppLink299 className="decoration-rule underline hover:decoration-current"300 to={askPath(ask.project, ask.id)}
20 unmodified lines
321 />322 );323 }324325 // 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;329330 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 }340341 if (ask.state === "open") {342 return (343 <EmptyState344 command={`${Brand.cli} claim ${ask.id} --project ${ask.project}`}
16 unmodified lines
361 */362const 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 lines
381 setShown(tag);382 setChanged(true);383 }384358 const claimant = progress?.claimant;385 const claimant = states.get(ask.id)?.claimant;386387 return (388 <section aria-label="Outcome" className="flex min-w-0 flex-col gap-3">389 <h2 className="sr-only">Outcome</h2>
3 unmodified lines
393 }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 lines
442 </p>443 </Region>444445 <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>452453 {verdict.heldBack.length === 0 ? null : (454 <Region id="answer-held-back" title="Held back">
214 unmodified lines
669 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 lines
683 }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 lines
modified:apps/web/src/features/ask/ask-page.tsx+60 added-1 removed
319 unmodified lines
320 </span>321 </p>322);323324/**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 */329const 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);341342 const left = children.filter(343 (child) => states.get(child)?.landed === undefined344 ).length;345346 const deleteStep = (347 <AppLink className={LINK} to={askPath(project, finale)}>348 the delete step349 </AppLink>350 );351352 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};372373export 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 lines
641 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 <FamilyStrip
33 unmodified lines
modified:apps/web/src/features/ask/refused.tsx+30 added-11 removed
modified:apps/web/src/features/shared/outcome.tsx+8 added-3 removed
199 unmodified lines
200 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 lines
modified:apps/web/src/routes/$project/answers/$ask.tsx+1 added-1 removed
166 unmodified lines
167 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 lines
modified:apps/web/test/answer.test.tsx+51 added
235 unmodified lines
236 ).toBeTruthy();237 expect(inOrder(text, ["unit", "bun test", "failed", "8.3 s"])).toBeTruthy();238 });239240 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 ?? "";245246 expect(247 inOrder(plainText(folded), ["lint", "bun run lint", "passed", "1.2 s"])248 ).toBeTruthy();249 });250251 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 };257258 const refusedEarly = { ...refused, lanes: [], stage: "shape" as const };259260 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 });268269 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 ]);274275 const markup = mainOf(markupOf(page({ states, verdict: refused })));276 const round = markup.indexOf("round 1 of 1");277278 expect(round).toBeGreaterThan(markup.indexOf("</h1>"));279 expect(round).toBeLessThan(markup.indexOf('aria-label="Outcome"'));280 });281282 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 })));285286 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 });290291 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 lines
modified:apps/web/test/ask.test.tsx+56 added-1 removed
12 unmodified lines
13 AskId,14 BlobSha,15 CommitSha,16 Handle,17 ProjectName,18 RepoPath,19} from "@repo/protocol/ids";19import { OutOfScope, UnknownAsk, UnknownPath } from "@repo/protocol/refusal";20import {21 OutOfScope,22 UnknownAsk,23 UnknownPath,24 UnknownProject,25} from "@repo/protocol/refusal";26import { explain } from "@repo/protocol/render";27import { asTester, unanswered } from "@repo/protocol/testing";28import { isNotFound } from "@tanstack/react-router";29import { Effect, Layer, Ref, Schema, Stream } from "effect";
318 unmodified lines
348 expect(text).not.toContain("to land first");349 expect(asideOf(markup)).toContain(`data-family="${parent.id}"`);350 });351352 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 })));356357 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 });363364 it("says a family's parent whose children all landed waits only for the delete step", () => {365 const { children, parent } = family;366367 const states = askStates(368 children.map((child, index) => closedEvent(index + 1, child))369 );370371 expect(plainText(mainOf(markupOf(page(parent, { states }))))).toContain(372 "Waits for the delete step to land first"373 );374 });375376 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 lines
458 expect(markup).toContain('href="/"');459 expect(textOf(<NoSuchAsk project="datekit" />)).toContain("Open asks");460 });461462 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]));465466 const trail = trailOf(467 markupOf(<NoSuchAsk data={data} project="datekit" />)468 );469470 expect(inOrder(plainText(trail), ["datekit", "Asks"])).toBeTruthy();471 expect(trail).toContain('href="/datekit"');472 expect(trail).not.toContain("no-such-ask");473 });474475 it("links no project the platform says it does not have", () => {476 const refusal = new UnknownProject({477 project: ProjectName.make("nowhere"),478 });479480 const data = structuredClone(Schema.encodeSync(Refusals)([refusal]));481 const markup = markupOf(<NoSuchAsk data={data} project="nowhere" />);482483 expect(markup).not.toContain('href="/nowhere"');484 expect(markup).toContain('href="/"');485 });486487 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