Skip to content
Myr

Fix the decider pages' review findings: drafted code shows, a failed choice says why, a taken finish keeps its record

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

- Drafted files (a proposal's ask file and check, an OpenProposal decision's evidence) rendered empty in the browser: Pierre's `File` draws nothing with `disableFileHeader`, so the drafted file keeps its header again, as before. - A decision page dropped a failed choice on the floor (DecisionClosed, UnknownDecision, a lapsed session, no answer): the route now draws it through `ProposalFailure` above the choices, on every subject and on a finish (above the diff, and above the phone's choices). - A finish's choice bar below 1440 px kept offering Accept and Decline after the choice was taken; it now shows the record in their place. - The decision route decodes its loader data once per read, so the finish's parsed files and read marks are not rebuilt on every render. - Propose waiting for a want says so at full strength, dashed like a field still to fill, rather than greyed out; the territory select's breakpoint is the named `tablet` one. - Evidence sets label beside value only where it has the width (a container query): in Today's inspector it reads label over value instead of a path broken over four lines. - The decision inspector marks expiry with the hourglass and the default with the shield; the phone's choice bar is 8 px shorter. - Removed the finish atoms nothing reads any more (`client/decide.ts`), and `changedFiles` reads `fileBlocks` instead of repeating its parse. - Tests: a finish taken on its page keeps the record at the diff's foot and offers no choice; a refused choice shows its refusal before the choices (both red on the previous code by assertion).

authored by oscabriel · committed by oscabriel · parent ee0e76e · Browse files · 14 files+194 added−91 removed
This commit

State

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

Diff stats

14 files+194 added−91 removed

  • tests:+51 added−4 removed
  • other:+143 added−87 removed

14 files+194 added−91 removed

modified:apps/web/src/client/decide.ts-26 removed
modified:apps/web/src/features/decision/choices.tsx+1 added-1 removed
180 unmodified lines
181 * the bottom bar; from a tablet's width, where they sit.182 */183export const stuckAboveBar = (node: ReactNode) => (184 <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 pt-3 pb-3"185 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 data-choices-bar=""187 >188 {node}189 </div>
1 unmodified line
modified:apps/web/src/features/decision/decision-page.tsx+23 added-1 removed
19 unmodified lines
20import type { Decision } from "@repo/protocol/domain/decision";21import type { Proposal } from "@repo/protocol/domain/proposal";22import type { DecisionId, ProjectName } from "@repo/protocol/ids";23import type { DateTime } from "effect";24import { Hourglass, Shield } from "lucide-react";25import type { ReactNode } from "react";2627import { signInHref } from "../auth/session-slot.tsx";28import { MarkerNote } from "../finish/annotation.tsx";
61 unmodified lines
90 <When at={decision.openedAt} now={now} />91 </dd>92 <dt className="text-label text-muted-foreground pt-0.5">Expires</dt>93 <dd className={soon ? "text-waiting font-medium" : ""} data-soon={soon}>94 <Hourglass95 aria-hidden="true"96 className="mr-1.5 inline size-4 align-[-0.1875rem]"97 strokeWidth={1.75}98 />99 <When at={decision.expiresAt} now={now} />100 <span className="text-muted-foreground font-normal">101 {" "}102 · {byWhen(decision.expiresAt)}103 </span>104 </dd>105 <dt className="text-label text-muted-foreground pt-0.5">Default</dt>100 <dd data-default={decision.default}>{decision.default}</dd>106 <dd data-default={decision.default}>107 <Shield108 aria-hidden="true"109 className="text-muted-foreground mr-1.5 inline size-4 align-[-0.1875rem]"110 strokeWidth={1.75}111 />112 {decision.default}113 </dd>114 </dl>115 </FactBlock>116);117
96 unmodified lines
214 readonly files?: readonly PatchFile[];215 /** The page for a finish, when the decision is one (the route draws it whole). */216 readonly finish?: ReactNode;217 readonly here: string;218 /** What the reader's last choice came back with, when it failed: shown above the choices. */219 readonly failure?: ReactNode;220}221222/** A decision the reader may take, whole. */223const Found = ({224 busy,225 failure,226 files,227 found,228 now,229 onDecide,
4 unmodified lines
234 readonly onDecide: (input: DecideInput) => void;235 readonly busy: boolean;236 readonly files: readonly PatchFile[];237 readonly taken: Decision | undefined;238 readonly failure: ReactNode;239}) => {240 const decision = taken ?? found.decision;241242 const subject = {
43 unmodified lines
286 soon={found.soon}287 stamp={taken !== undefined}288 >289 <WaiverDiff decision={decision} files={files} />290 <div aria-live="polite" className="empty:hidden">291 {failure}292 </div>293 </DecisionCard>294 </Workspace>295 );296};
16 unmodified lines
313314export const DecisionView = ({315 busy = false,316 data,317 failure,318 files = NO_FILES,319 finish,320 here,321 onDecide,
5 unmodified lines
327 finish328 ) : (329 <Found330 busy={busy}331 failure={failure}332 files={files}333 found={found}334 now={data.now}335 onDecide={onDecide}
39 unmodified lines
modified:apps/web/src/features/decision/evidence.tsx+5 added-3 removed
51 unmodified lines
52 readonly label: string;53}) => (54 <div className="contents">55 <dt className="text-label text-muted-foreground pt-0.5">{label}</dt>56 <dd className="text-ui tablet:mb-0 mb-1.5 min-w-0 [overflow-wrap:anywhere]">56 <dd className="text-ui mb-1.5 min-w-0 [overflow-wrap:anywhere] @lg:mb-0">57 {children}58 </dd>59 </div>60);6162const FactList = ({ children }: { readonly children: ReactNode }) => (63 <dl className="tablet:grid-cols-[minmax(7rem,auto)_1fr] grid grid-cols-1 gap-x-4 gap-y-1.5">63 // Label beside value where the evidence has the width (main), label over64 // value where it has not (the inspector, a phone).65 <dl className="grid grid-cols-1 gap-x-4 gap-y-1.5 @lg:grid-cols-[minmax(7rem,auto)_1fr]">66 {children}67 </dl>68);69
266 unmodified lines
336}) => {337 const files = filesOf(decision);338339 return (338 <div className="flex min-w-0 flex-col gap-3" data-evidence="">340 <div className="@container flex min-w-0 flex-col gap-3" data-evidence="">341 <SubjectFacts decision={decision} />342 <OtherFacts decision={decision} files={files} />343 {files.map(({ label, value }) => (344 <DraftedCode
9 unmodified lines
modified:apps/web/src/features/finish/finish-view.tsx+66 added-18 removed
38 unmodified lines
39import { statsOf } from "../code/diff-model.ts";40import { DiffPane, PANE_SCROLLER } from "../code/diff-pane.tsx";41import type { DiffAnnotation, DiffFileSlot } from "../code/diff-view.tsx";42import { shortSha } from "../code/paths.ts";43import { Choices, stuckAboveBar } from "../decision/choices.tsx";43import {44 Choices,45 DecisionRecord,46 stuckAboveBar,47} from "../decision/choices.tsx";48import { DecisionCard, ExpiryLines } from "../decision/decision-card.tsx";49import type { DecideInput } from "../decision/decision-card.tsx";50import { describeSubject } from "../decision/subject.ts";51import { CommandLine } from "../shared/command.tsx";
138 unmodified lines
190 /** The Files button, below the shell's width. */191 readonly filesButton?: ReactNode;192 /** Settle the record's mark: the choice was taken while the page was open. */193 readonly stamp?: boolean;194 /** What the reader's last choice came back with, when it failed. */195 readonly failure?: ReactNode;196}197198const NO_FILES: ReadonlySet<string> = new Set();199
47 unmodified lines
247 </Button>248 </output>249);250245/** The choices kept at the foot of the diff below 1440 px, where the inspector is a sheet. */251/**252 * The choices kept at the foot of the diff below 1440 px, where the253 * inspector is a sheet; once taken, the choice's record in their place.254 */255const DecisionBar = ({256 busy,257 decision,258 now,259 onDecide,260 soon,261 stamp,262}: {263 readonly decision: FinishDecision;264 readonly busy: boolean;265 readonly now: DateTime.Utc;266 readonly onDecide: (input: DecideInput) => void;267 readonly soon: boolean;268 readonly stamp: boolean;269}) => (270 <section271 aria-label="Your choice"272 className="border-rule bg-background codefacts:hidden flex shrink-0 flex-wrap items-start gap-x-6 gap-y-2 border-t px-4 py-3"273 data-decision-bar=""274 >275 {decision.decided === undefined ? (276 <>264 <div className="min-w-0 flex-1 basis-56">265 <ExpiryLines decision={decision} now={now} soon={soon} />266 </div>267 <div className="max-w-[34rem] min-w-0 flex-[2] basis-80">268 <Choices269 busy={busy}277 <div className="min-w-0 flex-1 basis-56">278 <ExpiryLines decision={decision} now={now} soon={soon} />279 </div>280 <div className="max-w-[34rem] min-w-0 flex-[2] basis-80">281 <Choices282 busy={busy}283 decision={decision}284 onChoose={(choice) => {285 onDecide({286 choice,287 decision: decision.id,288 project: decision.project,289 });290 }}291 />292 </div>293 </>294 ) : (295 <DecisionRecord296 decided={decision.decided}297 decision={decision}271 onChoose={(choice) => {272 onDecide({273 choice,274 decision: decision.id,275 project: decision.project,276 });277 }}298 now={now}299 stamp={stamp}300 />279 </div>301 )}302 </section>303);304305/** A choice that came back failed: said where the reader looks next, and politely. */306const Failure = ({307 children,308 className = "",309}: {310 readonly children: ReactNode;311 readonly className?: string;312}) => (313 <div aria-live="polite" className={`empty:hidden ${className}`}>314 {children}315 </div>316);317318/** On a phone: the diff one file at a time, with the way to the next and the one before. */319const OneFileAtATime = ({320 files,321 notes,
72 unmodified lines
394const WideDiff = ({395 busy,396 decision,397 draw,398 failure,399 files,400 folded,401 newerHead,402 now,
3 unmodified lines
406 placed,407 read,408 soon,409 split,410 stamp,411}: Required<412 Pick<413 FinishViewProps,414 | "busy"
5 unmodified lines
420 | "placed"421 | "read"422 | "soon"423 | "split"424 | "stamp"425 >426> &389 Pick<FinishViewProps, "folded" | "newerHead" | "onFold" | "onMark">) => {427 Pick<428 FinishViewProps,429 "failure" | "folded" | "newerHead" | "onFold" | "onMark"430 >) => {431 const refused = new Set(placed.map(({ path }) => path));432433 const plain = (434 <div className={PANE_SCROLLER}>
26 unmodified lines
461 );462463 return (464 <div className="tablet:contents hidden">465 <Failure className={`py-3 ${GUTTER}`}>{failure}</Failure>466 {newerHead === undefined ? null : <NewerHead head={newerHead} />}467 <DiffPane>468 {draw ? (469 <ClientDiffs
14 unmodified lines
484 decision={decision}485 now={now}486 onDecide={onDecide}487 soon={soon}488 stamp={stamp}489 />490 </DiffPane>491 </div>492 );
3 unmodified lines
496const PhoneFinish = ({497 ask,498 busy,499 decision,500 failure,501 files,502 newerHead,503 now,504 onDecide,
16 unmodified lines
521 | "soon"522 | "stamp"523 >524> &481 Pick<FinishViewProps, "ask" | "newerHead" | "onMark" | "verdict">) => (525 Pick<526 FinishViewProps,527 "ask" | "failure" | "newerHead" | "onMark" | "verdict"528 >) => (529 <div className={`tablet:hidden flex flex-col gap-6 ${GUTTER}`}>530 {ask === undefined ? null : (531 <p className="text-want max-w-[70ch]">{ask.brief.want}</p>532 )}
10 unmodified lines
543 />544 </div>545 )}546 {newerHead === undefined ? null : <NewerHead head={newerHead} />}547 <Failure>{failure}</Failure>548 <DecisionCard549 busy={busy}550 choices={stuckAboveBar}551 decision={decision}
160 unmodified lines
modified:apps/web/src/features/finish/patch.ts+9 added-27 removed
modified:apps/web/src/features/proposal/drafted-file.tsx-2 removed
20 unmodified lines
21}2223const options: FileOptions<undefined, undefined> = {24 ...diffsOptions,25 // The path is the section's heading already.26 disableFileHeader: true,25 overflow: "scroll",26};2728export const DraftedFile = ({ content, path }: DraftedFileProps) => {
14 unmodified lines
modified:apps/web/src/features/proposal/failure.tsx+6 added-5 removed
1/**2 * A call the propose and proposal pages sent, failed. A session that ended3 * (or never began) asks the reader to sign in and come back to the same4 * address, so the form or the proposal is where they left it; a refusal5 * reads as the platform gave it, through `RefusalView`; anything else is6 * the platform not answering, in ink, never as a refusal.2 * A call the propose, proposal or decision pages sent, failed. A session3 * that ended (or never began) asks the reader to sign in and come back to4 * the same address, so the form, the proposal or the decision is where5 * they left it; a refusal reads as the platform gave it, through6 * `RefusalView`; anything else is the platform not answering, in ink,7 * never as a refusal.8 */9import { Unauthenticated } from "@repo/protocol/principal";10import { Refusal } from "@repo/protocol/refusal";11import { Cause, Option, Schema } from "effect";
51 unmodified lines
modified:apps/web/src/features/propose/client-territory.tsx+1 added-1 removed
20 unmodified lines
21const StandIn = ({ choices, labelledBy, value }: TerritorySelectProps) => (22 <>23 <button24 aria-labelledby={labelledBy}25 className="border-input tablet:text-ui flex h-11 w-full max-w-xs items-center justify-between gap-1.5 border bg-transparent py-2 pr-2 pl-2.5 text-base sm:h-9"25 className="border-input tablet:text-ui tablet:h-9 flex h-11 w-full max-w-xs items-center justify-between gap-1.5 border bg-transparent py-2 pr-2 pl-2.5 text-base"26 data-slot="select-trigger"27 disabled28 type="button"29 >
24 unmodified lines
modified:apps/web/src/features/propose/propose-view.tsx+4 added-1 removed
255 unmodified lines
256257 {children}258259 <Button260 className="tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4"260 // Waiting for a want, it says so at full strength, dashed like any261 // field still to fill, rather than sitting grey.262 className={`tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4 ${written ? "" : "text-muted-foreground border-dashed disabled:opacity-100"}`}263 data-written={written}264 disabled={busy || !written}265 type="submit"266 variant={written ? "default" : "outline"}267 >268 {busy ? <Spinner /> : null}269 {proposeWords(written, busy)}270 </Button>
101 unmodified lines
modified:apps/web/src/features/propose/territory-select.tsx+2 added-1 removed
23 unmodified lines
24 readonly value: string;25}2627/** The trigger's look, shared with the server's stand-in for it. */28export const TRIGGER = "tablet:text-ui h-11 w-full max-w-xs text-base sm:h-9";28export const TRIGGER =29 "tablet:text-ui tablet:h-9 h-11 w-full max-w-xs text-base";3031export const TerritorySelect = ({32 choices,33 labelledBy,
30 unmodified lines
modified:apps/web/src/routes/$project/decisions/$decision.tsx+26 added-1 removed
11 unmodified lines
12import { Effect, Option, Schema } from "effect";13import type { DateTime } from "effect";14import { AsyncResult } from "effect/reactivity";15import { useCallback, useMemo, useState } from "react";16import type { ReactNode } from "react";1718import { decideAtom } from "../../../client/decide.ts";19import { projectEventsAtom } from "../../../client/events.ts";20import { watchAtom } from "../../../client/watch.ts";
21 unmodified lines
42 waiverPatchOf,43} from "../../../features/finish/patch.ts";44import type { FinishDecision } from "../../../features/finish/patch.ts";45import { marksKey, useReadMarks } from "../../../features/finish/read-marks.ts";46import { ProposalFailure } from "../../../features/proposal/failure.tsx";47import { pageHead } from "../../../features/shared/head.ts";48import { personalPage } from "../../../server/cache-headers.ts";49import { serverClient } from "../../../server/client.ts";50
49 unmodified lines
100/** A finish's page: its files, folds, layout, read marks and keys. */101const Finish = ({102 busy,103 decision,104 failure,105 found,106 now,107 onDecide,108 taken,
3 unmodified lines
112 readonly now: DateTime.Utc;113 readonly onDecide: (input: DecideInput) => void;114 readonly busy: boolean;115 readonly taken: Decision | undefined;116 readonly failure: ReactNode;117}) => {118 const { platformUrl } = root.useLoaderData();119 const router = useRouter();120 const { ask, head } = decision.subject;
97 unmodified lines
218 decision={219 taken === undefined ? decision : { ...taken, subject: decision.subject }220 }221 draw222 failure={failure}223 files={files}224 filesButton={<FinishFilesButton />}225 folded={folded}226 newerHead={newerHead}
16 unmodified lines
243 );244};245246const DecisionPage = () => {242 const data = Schema.decodeSync(DecisionPageData)(Route.useLoaderData());247 const loaded = Route.useLoaderData();248249 // Decoded once per read, so what is built from it (the diff's parsed250 // files above all) is built once too.251 const data = useMemo(252 () => Schema.decodeSync(DecisionPageData)(loaded),253 [loaded]254 );255256 const [decided, decide] = useAtom(decideAtom);257 const here = useLocation({ select: hereOf });258259 // A choice that failed says why where the choices are: its refusal, the260 // way to sign in, or that the platform did not answer.261 const failure = AsyncResult.isFailure(decided) ? (262 <ProposalFailure263 cause={decided.cause}264 doing="take this decision"265 here={here}266 />267 ) : undefined;268269 const waiverFiles = useMemo(270 () =>271 Option.getOrElse(272 Option.flatMap(foundOf(data.read), ({ decision }) =>
11 unmodified lines
284 const finish = Option.isSome(found) ? (285 <Finish286 busy={decided.waiting}287 decision={found.value.decision}288 failure={failure}289 found={found.value.found}290 now={data.now}291 onDecide={decide}292 taken={takenHere(decided, found.value.decision)}
3 unmodified lines
296 return (297 <DecisionView298 busy={decided.waiting}299 data={data}300 failure={failure}301 files={waiverFiles}302 finish={finish}303 here={here}304 onDecide={decide}
17 unmodified lines
modified:apps/web/test/decision.test.tsx+26 added-1 removed
44 unmodified lines
45} from "../src/features/decision/decision-page.tsx";46import type { DecisionPageData } from "../src/features/decision/decision-page.tsx";47import { patchFiles } from "../src/features/finish/files.ts";48import { waiverPatchOf } from "../src/features/finish/patch.ts";49import { ProposalFailure } from "../src/features/proposal/failure.tsx";50import {51 DraftRead,52 draftReadOf,53 readDraft,
492 unmodified lines
546 reason: "A quote in a code span needs the escaper's context.",547 }),548};549549const pageOf = (read: DecisionRead, chosen?: Decision) => {550const pageOf = (551 read: DecisionRead,552 chosen?: Decision,553 failure?: ReactElement554) => {555 const data: DecisionPageData = {556 decision: waiver.id,557 now,558 project: vellum,
13 unmodified lines
572 files={files}573 here="/vellum/decisions/dec-000002"574 onDecide={() => {}}575 taken={chosen}576 {...(failure === undefined ? {} : { failure })}577 />578 );579};580
49 unmodified lines
630 expect(plainTextOf(markup)).toContain("Accepted");631 expect(plainTextOf(markup)).toContain("Split out.");632 });633634 it("says why a choice came back refused, before the choices", () => {635 const closed = new DecisionClosed({ decision: waiver.id });636637 const markup = pageOf(638 found,639 undefined,640 <ProposalFailure641 cause={Cause.fail(closed)}642 doing="take this decision"643 here="/vellum/decisions/dec-000002"644 />645 );646647 const refusal = markup.indexOf('data-refusal="DecisionClosed"');648649 expect(refusal).toBeGreaterThan(-1);650 expect(refusal).toBeLessThan(markup.indexOf("data-choices="));651 });652653 it("signed out, says what a decision is and who takes it, with no choices and no evidence", () => {654 const markup = pageOf(DecisionRead.cases.SignedOut.make({}));655 const text = plainTextOf(markup);656
7 unmodified lines
modified:apps/web/test/finish.test.tsx+25 added-3 removed
61 unmodified lines
62]);6364const markupOf = (element: ReactElement) => renderToStaticMarkup(element);6566/** What a reader sees: the markup without its tags, entities decoded. */67const textOf = (element: ReactElement) =>68 markupOf(element)66/** What a reader sees of `markup`: the text without its tags, entities decoded. */67const textIn = (markup: string) =>68 markup69 .replaceAll(/<[^>]+>/gu, " ")70 .replaceAll(71 /&(?:#x27|amp|gt|lt|quot);/gu,72 (entity) => ENTITIES.get(entity) ?? entity73 )74 .replaceAll(/\s+/gu, " ");7576/** What a reader sees of `element`. */77const textOf = (element: ReactElement) => textIn(markupOf(element));7879const PLATFORM_URL = "https://platform-test.example.workers.dev";8081const datekit = ProjectName.make("datekit");82
270 unmodified lines
353 );354 });355});356357describe("a finish taken on its page", () => {358 it("keeps the choice's record at the diff's foot, where its choices were, and offers them no more", () => {359 const markup = markupOf(360 pageOf({361 ...withPatch,362 decided: { at: now, by: okonkwo, choice: "accept" },363 })364 );365366 const bar = markup.slice(markup.indexOf("data-decision-bar"));367368 expect(markup).not.toContain("data-choice=");369 expect(bar).toContain('data-decided="accept"');370 expect(textIn(bar)).toContain(371 "Accepted · Lands the answer as it is, with you as Finished-by."372 );373 });374});375376/** A browser storage over a map, as `localStorage` behaves. */377const storageOver = (kept: Map<string, string>): Storage => ({378 clear: () => {379 kept.clear();
136 unmodified lines