Strip non-essential comments from the rest of the web's features
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parent 88206c4 · Browse files · 83 files·+126 added−1922 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
83 files+126 added−1922 removed
- other:+126 added−1922 removed
Provenance
- Commit
9c0cf6e- Tree
9e8d7d4- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
88206c4
83 files changed+126 added−1922 removed
modified:apps/web/src/features/agents/catalog.ts-5 removed
1234512345/** * The CLI's commands, from `@repo/agent-kit`'s one list (the contracts the * CLI projects, then the commands written by hand in it), so `llms.txt` * lists what the CLI has rather than a copy. */import { commandDocs } from "@repo/agent-kit/command-doc";import type { CommandDoc } from "@repo/agent-kit/command-doc";import { Contracts } from "@repo/protocol/contracts";
export const commands: readonly CommandDoc[] = commandDocs(Contracts);modified:apps/web/src/features/agents/forward.ts-10 removed
123456789121234562 unmodified lines/** * The paths the platform serves and the web host only passes on: * the CLI's install script and releases, the projects' * skills (`/.well-known/agent-skills/*`) and a project's raw files * (`/<project>/raw/<rev>/<path>`, under the platform's sandboxing headers). The request goes to the backend * as it came, for GET and for HEAD only: the platform only reads on these * paths (it answers any other method 405), so the web passes no other * method on. */import type { Backend } from "../../server/rpc.ts";
/** A route's GET and HEAD handlers, each handing the request to `backend` with `env`. */export const forwarded = (backend: Backend, env: Env) => { const forward = ({ request }: { readonly request: Request }) => backend(request, env);
2 unmodified linesmodified:apps/web/src/features/agents/llms.ts+2 added-7 removed
123456782345676 unmodified lines/** * What an agent, or a person, reads first on the web host: `/llms.txt`, * `/<owner>/<name>/llms.txt` and the MCP card at `/.well-known/mcp.json`, and the * banner under the title of the web's other Markdown. The text lives in * `@repo/agent-kit`'s `host-doc`, which the platform's own `/` serves too, * so both hosts say the same thing; the routes import it from here. * `/llms-full.txt` imports its text from `@repo/agent-kit/full-llms` itself, * so no page that loads this module carries the sections the docs share. * `/llms-full.txt` imports its text from `@repo/agent-kit/full-llms` itself, so * no page that loads this module carries the sections the docs share. */export { frontLlms, indexBanner,6 unmodified linesmodified:apps/web/src/features/agents/manifest.ts+2 added-10 removed
1234567234567813910111211 unmodified lines2425262733282936303132336 unmodified lines40414243514445/** * The web app manifest, so Today installs on a phone. No file * spells the name: `vite.config.ts` writes this into the client output as * `manifest.webmanifest` at each build, from `Brand.name`. The colours are * the paper's (`features/shared/theme.ts`); the icons are the files under * `public/icons/`, drawn from `icon.svg`, with the mark inside the maskable * safe zone, so one drawing serves both purposes. * `vite.config.ts` writes this into the client output as `manifest.webmanifest` * at each build, so no file spells the name. */import { Brand } from "@repo/brand";
import { themeColors } from "../shared/theme.ts";
/** Each raster icon, by its size in pixels. */const rasters = [192, 512] as const;
const icons = [ ...rasters.flatMap((size) =>11 unmodified lines type: "image/svg+xml", },];
/** Where the manifest is served, as the root route's `<link rel="manifest">` names it. */export const MANIFEST_PATH = "/manifest.webmanifest";
/** The manifest, as JSON a browser reads. */export const webManifest = () => ({ background_color: themeColors.light, description: `Open asks, answers and a decider's Today on ${Brand.name}.`, display: "standalone",6 unmodified lines start_url: "/today", theme_color: themeColors.light,});
/** The manifest's text, as the build writes it. */export const webManifestText = () => `${JSON.stringify(webManifest(), null, 2)}\n`;modified:apps/web/src/features/agents/reference.tsx+2 added-22 removed
1-/**2- * The For agents page's reference sections, set like a man page: the3- * CLI's synopsis, the endpoints, the limits and the refusals. Every word4- * that is not a heading comes from `@repo/agent-kit` (`synopsis`,5- * `agentEndpoints`, `agentLimits`) or the refusal union itself, so the6- * page and `/agents.md` say the same. Mono only for what a terminal takes:7- * commands, addresses and tags.8- */1 import type {2 Endpoint,3 Limit,4 SynopsisLine,1 unmodified line6 import { groups } from "@repo/protocol/refusal";7 import { Fragment } from "react";8 import type { ReactNode } from "react";9 18-/** A link in running text: the rule colour's underline, ink on hover. */10 export const LINK =11 "decoration-rule underline underline-offset-[0.2em] hover:decoration-current";12 22-/** One section of the reference: its heading at Title size, in the sans, then its body. */13 export const ReferenceSection = ({14 children,15 id,16 title,10 unmodified lines27 {children}28 </section>29 );30 41-/**42- * A usage line that wraps only between its words, never inside a flag43- * (`[--json]` stays whole), so a phone reads it as typed.44- */31 const Usage = ({ usage }: { readonly usage: string }) => (32 <code className="text-mono font-mono">33 {usage.split(" ").map((word, index) => (34 <Fragment key={index}>3 unmodified lines38 ))}39 </code>40 );41 56-/** Every command as typed, each over what it does, set close like a man page's synopsis. */42 export const Synopsis = ({43 lines,44 }: {45 readonly lines: readonly SynopsisLine[];7 unmodified lines53 ))}54 </ul>55 );56 72-/** Each address an agent reads, one line each, linked where a browser can open it. */57 export const Endpoints = ({58 endpoints,59 }: {60 readonly endpoints: readonly Endpoint[];11 unmodified lines72 className="border-rule flex min-w-0 flex-col gap-0.5 border-b py-2.5"73 key={url}74 >75 {readable ? (92- // A server's own text, not a page of the app.76 <a className={`${LINK} w-fit max-w-full`} href={url}>77 {address}78 </a>79 ) : (5 unmodified lines85 })}86 </ul>87 );88 106-/** The limits, as a plain table. */89 export const Limits = ({ limits }: { readonly limits: readonly Limit[] }) => (90 <table className="text-ui w-full max-w-[48rem] border-collapse text-left">91 <thead>92 <tr className="border-rule border-b">18 unmodified lines111 </table>112 );113 114 /**133- * Where `/llms-full.txt` lists a refusal: a text fragment on its table row134- * (`` `Tag` | Group ``), which nothing else in the file reads. A dash ends135- * a fragment's word, so it is escaped as well.115+ * A text fragment on the refusal's row in `/llms-full.txt` (`` `Tag` | Group116+ * ``). A dash ends a fragment's word, so it is escaped as well.117 */118 const rowOf = (tag: string, group: string) =>119 `/llms-full.txt#:~:text=${encodeURIComponent(`\`${tag}\` | ${group}`).replaceAll("-", "%2D")}`;120 140-/** Every refusal of the union, by group, each tag linked to its row. */121 export const Refusals = () => (122 <>123 <p className="text-ui text-muted-foreground max-w-[70ch]">124 Each tag opens its row in{" "}30 unmodified linesmodified:apps/web/src/features/agents/respond.ts-9 removed
123451283411567891011121321141516251718192021/** * How the agents' documents go out: Markdown as `text/markdown`, JSON as * `application/json`, each kept briefly by caches, since a landing or a * new project changes them. */import type { McpCard } from "./llms.ts";
/** A minute: long enough to spare the platform a burst, short enough to stay current. */const BRIEFLY = "public, max-age=60";
/** `text` as a Markdown document. */export const markdown = (text: string, status = 200) => new Response(text, { headers: { "cache-control": status === 200 ? BRIEFLY : "no-store", "content-type": "text/markdown; charset=utf-8", }, status, });
/** The MCP card as a JSON document. */export const cardResponse = (card: McpCard) => Response.json(card, { headers: { "cache-control": BRIEFLY } });
/** The platform did not answer: try again soon, and keep nothing. */export const unavailable = () => markdown( "# Unavailable\n\nThe platform did not answer. Try again in a minute.\n", 503 );modified:apps/web/src/features/agents/setup-page.tsx-20 removed
1-/**2- * The For agents page: one reference, in the order a reader reaches for3- * it: the CLI's synopsis, the ways to connect, the endpoints, the limits4- * and the refusals. The inspector is its contents. Every snippet and every5- * line of reference is `@repo/agent-kit`'s (`agentSetup` and its6- * neighbours), so the page has no text of its own for any of them7- * (principle 4). A shell line is a `CommandLine`; JSON and text to paste8- * sit in a block with the same copy affordance. A view: the CLI's commands9- * and the two hosts' URLs in, markup out.10- */1 import {2 agentEndpoints,3 agentLimits,4 agentSetup,18 unmodified lines23 Refusals,24 Synopsis,25 } from "./reference.tsx";26 37-/** The reference's sections, in order: each one's anchor and heading. */27 const SECTIONS = [28 { id: "synopsis", title: "Synopsis" },29 { id: "connect", title: "Connect" },30 { id: "endpoints", title: "Endpoints" },31 { id: "limits", title: "Limits" },32 { id: "refusals", title: "Refusals" },33 ] as const;34 46-/**47- * JSON or text to paste: whole, with a button that copies it. It keeps its48- * own lines and indentation and scrolls sideways where the screen is49- * narrower than a line, as code does everywhere on the web, rather than50- * wrapping a value under its key; the keyboard reaches it to scroll.51- */35 const SnippetBlock = ({ snippet }: { readonly snippet: SetupSnippet }) => {36 const { copied, copy } = useCopy(snippet.text);37 38 return (39 <div className="border-rule bg-surface flex max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3">40 <pre41 aria-label={snippet.label}42 className="text-mono leading-terminal min-w-0 flex-1 overflow-x-auto py-0.5 font-mono whitespace-pre"60- // A box that scrolls is a stop for Tab, so a keyboard can scroll it.43 // oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- a scrolling region must take focus to be scrolled without a pointer (WCAG 2.1.1)44 tabIndex={0}45 >46 <code className="select-all">{snippet.text}</code>24 unmodified lines71 )}72 </figure>73 );74 93-/** One way to connect: its name, the agent it is for, and what to copy. */75 const Channel = ({ channel }: { readonly channel: SetupChannel }) => (76 <div className="border-rule flex min-w-0 flex-col gap-3 border-t pt-4">77 <h3 className="text-want font-semibold">{channel.title}</h3>78 <p className="max-w-[70ch]">{channel.useWhen}</p>4 unmodified lines83 </div>84 </div>85 );86 106-/** The inspector: the sections, as anchors. */87 const Contents = () => (88 <nav aria-label="Contents">89 <ul className="flex flex-col">90 {SECTIONS.map(({ id, title }) => (48 unmodified linesmodified:apps/web/src/features/answer/answer-page.tsx+2 added-69 removed
1-/**2- * An answer, read like a run of the gate: where it stands first, then the3- * stages it passed, the lanes (failed ones open, passed ones folded into a4- * line), the held-back checks as one line per area, and, once it landed,5- * the landing's credit and its commit. What was judged (head, base, merged6- * tree, patch id) is plumbing, so it sits last, in the inspector.7- *8- * - The outcome is the hero: the status line a step up, whose move it is,9- * and a refusal drawn whole by `RefusalView`, as `git push` printed it.10- * When the outcome changes while the page is open its word and mark11- * settle in, and a landing that happened then is stamped once.12- * - A stage the answer never needed (no decider took part, no held-back13- * checks judged it) reads not needed, never passed.14- * - With no answer judged yet, the page says who holds the ask, or gives15- * the command that claims it: never a dead end.16- *17- * Held-back checks show only what `HeldBackResult` carries: an area, how18- * many passed of how many, and the suite's root. A lane's log is named19- * only by the command that reads it. The head and the merged tree live in20- * the claim's fork, which the code browser never reads, so only the base21- * and the landing link their commit pages.22- */1 import { Brand } from "@repo/brand";2 import type {3 HeldBackResult,4 LaneOutcome,44 unmodified lines49 roundOf,50 roundsAsTheyStand,51 } from "./subject.ts";52 75-/** How long a lane ran: "640 ms", "8.3 s", "2 min 5 s". */53 export const durationText = (millis: number) => {54 if (millis < 1000) {55 return `${millis} ms`;56 }6 unmodified lines63 64 return `${Math.floor(seconds / 60)} min ${seconds % 60} s`;65 };66 90-/** Each lane result as a mark, a word and its role colour: the word first. */67 const results = {68 blocked: { mark: "waiting", tone: "text-waiting", word: "blocked" },69 failed: { mark: "refused", tone: "text-refused", word: "failed" },70 flaked: { mark: "retry", tone: "text-waiting", word: "flaked" },3 unmodified lines74 LaneOutcome,75 { readonly mark: StateMark; readonly tone: string; readonly word: string }76 >;77 102-/** The page's trail: the project, its asks, the ask, then this answer. */78 export const answerCrumbs = (ask: Ask): readonly Crumb[] => [79 { label: ask.project, to: `/${ask.project}` },80 { label: "Asks", to: `/${ask.project}` },81 { label: ask.id, mono: true, to: askPath(ask.project, ask.id) },82 { label: "Answer" },83 ];84 110-/** What reads a lane's log, when the platform kept one. */85 const LaneLog = ({86 lane,87 project,88 }: {14 unmodified lines103 />104 );105 };106 133-/** One lane: its mark, name and command, its result in a word, and how long it ran. */107 const LaneRow = ({108 lane,109 project,110 }: {31 unmodified lines142 </li>143 );144 };145 173-/** "6 lanes passed in 41 s": the lanes run one after another, so their times add up. */146 const passedLine = (lanes: readonly LaneResult[]) =>147 `${lanes.length} ${lanes.length === 1 ? "lane" : "lanes"} passed in ${durationText(148 lanes.reduce((total, { durationMs }) => total + durationMs, 0)149 )}`;150 179-/** The lanes the platform ran on the merged tree: what failed, open and first; what passed, in one line. */151 export const Lanes = ({152 checking = false,153 lanes,154 project,155 }: {156 readonly lanes: readonly LaneResult[];157 readonly project: Ask["project"];187- /** The gate is still at work on the answer: its lanes may yet run. */158 readonly checking?: boolean;159 }) => {160 if (lanes.length === 0) {161 return (43 unmodified lines205 </div>206 );207 };208 239-/** Held-back checks: one line per area, as the landing's trailer spells it, and nothing else. */209 export const HeldBackBits = ({210 results: areas,211 }: {212 readonly results: readonly HeldBackResult[];21 unmodified lines234 ))}235 </ul>236 );237 269-/** A git id, short as git prints it, whole on hover. */238 const Sha = ({ sha }: { readonly sha: string }) => (239 <code className="text-mono font-mono" title={sha}>240 {shortSha(sha)}241 </code>242 );243 276-/** Content the inspector shows, left out of the facts drawn inline in main below the shell's width. */244 export const InspectorOnly = ({245 children,246 }: {247 readonly children: ReactNode;2 unmodified lines250 {children}251 </div>252 );253 287-/**288- * Every push the gate checked, newest first, the one the page reads289- * selected: first in main, once there is more than one, so a verdict is290- * read against its round.291- */254 const RoundsRegion = ({255 ask,256 current,257 now,2 unmodified lines260 }: {261 readonly ask: AskId;262 readonly project: ProjectName;263 readonly rounds: readonly Round[];302- /** The head the page shows. */264 readonly current: CommitSha | undefined;265 readonly now: DateTime.Utc;266 }) => {306- // The page reads the last round at its head.267 const read =268 current === undefined269 ? 0270 : rounds.findLastIndex(({ head }) => head === current) + 1;25 unmodified lines296 </Region>297 );298 };299 340-/**341- * What a waiting answer's contributor needs, from its rounds: there is342- * nothing to run, and what another push would start.343- */300 const waitingSentence = (round: ReturnType<typeof roundOf>) =>301 round === undefined302 ? "Nothing for you to run."303 : `Nothing for you to run. Pushing again starts round ${round.of + 1}; this verdict stays as round ${round.number}.`;304 349-/** What the hero says before any answer was judged: who holds the ask, or how to take it. */305 const NoAnswerYet = ({306 ask,307 now,308 states,31 unmodified lines340 />341 );342 }343 389- // What it waits on must land before anyone can claim it.344 const waiting = ask.blockedBy.filter(345 (blocker) => states.get(blocker)?.landed === undefined346 ).length;347 24 unmodified lines372 />373 );374 };375 422-/**423- * The outcome, a step up: settled in when it changes while the page is424- * open (never on the first paint), and stamped once on a live landing.425- */376 const Hero = ({377 ask,378 now,379 stamp,6 unmodified lines386 readonly states: ReadonlyMap<AskId, AskProgress>;387 readonly verdict: Verdict | undefined;388 }) => {389 const tag = verdict?.outcome._tag ?? "none";440- // Only an outcome that replaced another while the page was open settles in.390 const [shown, setShown] = useState(tag);391 const [changed, setChanged] = useState(false);392 393 if (shown !== tag) {28 unmodified lines422 </section>423 );424 };425 477-/** The answer's run: the gate, the lanes, the held-back checks, and the landing. */426 const Run = ({427 holds,428 landing,429 now,2 unmodified lines432 }: {433 readonly holds: ReturnType<typeof holdsOf>;434 readonly landing: LandingView | undefined;435 readonly now: DateTime.Utc;488- /** Which round the verdict is, of how many. */436 readonly round: ReturnType<typeof roundOf>;437 readonly verdict: Verdict;438 }) => (439 <>44 unmodified lines484 )}485 486 {landing === undefined ? null : (487 <Region id="answer-landing" title="Landing">541- {/* The landing told as a sentence before it is shown as a hash:542- the page's job is to credit the people. */}488+ {/* The landing told as a sentence before it is shown as a hash. */}489 <p className="text-title flex min-w-0 flex-wrap items-baseline gap-x-2 font-normal">490 <span className="flex items-center gap-2 font-semibold">491 <StateMarkIcon mark="landed" />492 <span className="text-landed">Landed</span>54 unmodified lines547 </AppLink>548 </Region>549 )}550 605- {/* Below the shell's width the inspector's facts sit above the run, so606- the plumbing comes here, last. */}551+ {/* Below the shell's width the inspector's facts sit above the run, so the plumbing comes here, last. */}552 <div className="shell:hidden">553 <ProvenanceFacts entries={verdictProvenance(verdict, now)} />554 </div>555 </>556 );557 558 export interface AnswerViewProps {614- /** The ask the answer is to: its want titles the page. */559 readonly ask: Ask;616- /** The verdict on the answer; none before one was judged. */560 readonly verdict: Verdict | undefined;618- /** The landing it made, once it landed. */561 readonly landing?: LandingView | undefined;562 readonly now: DateTime.Utc;621- /** Where each ask stands, from the project's events (`askStates`). */563 readonly states?: ReadonlyMap<AskId, AskProgress>;623- /** The family's parent, when the ask is a member of one. */564 readonly parent?: Ask | undefined;625- /** The head the address names, when it names an earlier answer. */565 readonly head?: CommitSha | undefined;627- /** It landed while the page was open: stamp the landing's mark, once. */566 readonly stamp?: boolean;629- /** Who is reading, to tell the claimant the claim is theirs. */567 readonly viewer?: Handle | undefined;568 }569 570 const NONE: ReadonlyMap<AskId, AskProgress> = new Map();571 635-/** The answer's facts: its state, claim, family, territory and check, then what was judged. */572 const AnswerFacts = ({573 ask,574 now,575 parent,55 unmodified lines631 </>632 );633 };634 699-/** The line under the hero's title: the ask, the round, when it was judged, and the way to the latest answer. */635 const AnswerMeta = ({636 ask,637 head,638 now,91 unmodified lines730 }731 />732 }733 status={799- // The answer's head reads title, then which answer this is, then800- // the outcome: a refusal drawn whole would bury a line after it.734 <div className="flex min-w-0 flex-col gap-4">735 <div className="text-ui text-muted-foreground">736 <AnswerMeta737 ask={ask}43 unmodified linesmodified:apps/web/src/features/answer/reads.ts-38 removed
1-/**2- * What the ask page and the answer page read on the server, before either3- * draws: the subject, then what is read beside it (the project's events,4- * the family's parent, the check's source, the landing). A read beside the5- * subject that fails leaves its part out; the subject's own refusal is the6- * page's 404 (`notFoundFor`). The routes call these from their server7- * functions only, so none of it reaches the browser's first load.8- */1 import { Client } from "@repo/protocol/contracts";2 import { Verdict } from "@repo/protocol/domain/answer";3 import { Ask } from "@repo/protocol/domain/ask";4 import { CheckSpec } from "@repo/protocol/domain/check";13 unmodified lines18 19 import { notFoundFor } from "../shared/refusals.ts";20 import { keptEvents, readEvents, readParent } from "./subject.ts";21 30-/** An ask's address, not yet decoded. */22 export interface AskAddress {23 readonly ask: string;24 readonly project: string;25 }26 36-/** The address, decoded: names the platform could hold. */27 const AskPath = Schema.Struct({ ask: AskId, project: ProjectName });28 39-/** The check's file, as the page carries it. */29 const CheckRead = Schema.Struct({30 path: RepoPath,31 sha: BlobSha,32 text: Schema.String,33 });34 46-/**47- * What the page's loader carries from the server, encoded: the ask and its48- * brief, the family's parent, the verdict on its latest answer, the49- * check's source, the events about them (and the last number of all the50- * project's), and when it was read.51- */35 export const AskPageData = Schema.Struct({36 ask: Ask,37 brief: Schema.NonEmptyString,38 check: Schema.UndefinedOr(CheckRead),5 unmodified lines44 });45 46 export type AskPageData = typeof AskPageData.Type;47 65-/** The check's source on main, when the check is a file that reads as text; none when it cannot be read. */48 const readCheck = (ask: Ask) =>49 Effect.gen(function* () {50 if (!CheckSpec.guards.RedThenGreen(ask.check)) {51 return Option.none<typeof CheckRead.Type>();12 unmodified lines64 Effect.orElseSucceed(() => Option.none<typeof CheckRead.Type>())65 );66 });67 86-/**87- * The page's reads: the ask, the project's events and the latest verdict88- * at once, then the family's parent (if it is in one) and the check's89- * source; or a not-found carrying the platform's refusal (a 404).90- */68 export const readAsk = (params: AskAddress) =>69 Effect.gen(function* () {70 const path = yield* Schema.decodeEffect(AskPath)(params).pipe(71 Effect.mapError(() => notFound())33 unmodified lines105 ),106 });107 });108 132-/** The page's address, not yet decoded: the path's names and `?head=`. */109 export interface AnswerAddress {110 readonly ask: string;111 readonly head?: string | undefined;112 readonly project: string;113 }114 139-/** The address, decoded: names the platform could hold, and a commit id. */115 const AnswerPath = Schema.Struct({116 ask: AskId,117 head: Schema.optionalKey(CommitSha),118 project: ProjectName,119 });120 146-/**147- * What the page's loader carries from the server, encoded: the ask, the148- * verdict and its landing, the family's parent, the events about them (and149- * the last number of all the project's), and when it was read.150- */121 export const AnswerPageData = Schema.Struct({122 ...AnswerPath.fields,123 askRead: Ask,124 brief: Schema.NonEmptyString,6 unmodified lines131 });132 133 export type AnswerPageData = typeof AnswerPageData.Type;134 165-/** The landing a verdict's answer made, when it landed. */135 export const landedBy = (136 verdict: Verdict | undefined137 ): LandedSha | undefined =>138 verdict !== undefined && Outcome.isAnyOf(["Landed"])(verdict.outcome)139 ? verdict.outcome.sha140 : undefined;141 173-/** The landing at `sha`; none for no landing, or one the platform no longer finds. */142 const readLanding = (project: ProjectName, sha: LandedSha | undefined) =>143 Effect.gen(function* () {144 if (sha === undefined) {145 return Option.none<LandingView>();2 unmodified lines148 const client = yield* Client;149 150 return yield* client.landing({ project, sha }).pipe(151 Effect.map((found) => Option.some(found.landing)),184- // The verdict names a landing the platform no longer finds: show the verdict alone.152 Effect.catchTag("UnknownCommit", () => Effect.succeedNone)153 );154 });155 189-/**190- * The page's reads: the verdict, the ask and the project's events at191- * once, then the landing (if it landed) and the family's parent (if it is192- * in one); or a not-found carrying the refusal (a 404).193- */156 export const readAnswer = ({ ask, head, project }: AnswerAddress) =>157 Effect.gen(function* () {158 const path = yield* Schema.decodeEffect(AnswerPath)(159 head === undefined ? { ask, project } : { ask, head, project }34 unmodified linesmodified:apps/web/src/features/answer/subject.ts+4 added-38 removed
1-/**2- * What an ask's page and its answer's page read beside their subject, and3- * the plain readings over it:4- *5- * - the project's events (`watch`, replayed from the first), kept to the6- * ones about the asks the page draws: the ask, what it waits on, and its7- * family. The fold over them (`askStates`) says who holds each ask, its8- * rounds and whether it landed, with no contract of its own;9- * - a family member's parent (`showAsk`), whose stored children count the10- * family, since a listing drops the ones that landed;11- * - what a verdict holds, so the gate's strip draws a stage the answer12- * never needed as not needed.13- *14- * A read beside the subject that fails leaves its part out; it never fails15- * the page.16- */1 import { Client } from "@repo/protocol/contracts";2 import type { Verdict } from "@repo/protocol/domain/answer";3 import type { Ask } from "@repo/protocol/domain/ask";4 import { ProjectEvent } from "@repo/protocol/domain/event";5 unmodified lines10 import { lastSeq } from "../shared/ask-progress.ts";11 import type { AskProgress, Round } from "../shared/ask-progress.ts";12 import type { StageHolds } from "../shared/outcome.tsx";13 30-/** The ask an event is about: one, or none. */14 const askOf = (event: ProjectEvent): readonly AskId[] =>15 ProjectEvent.match(event, {16 AskClosed: ({ ask }) => [ask],17 AskOpened: ({ ask }) => [ask.ask],9 unmodified lines27 Released: ({ ask }) => [ask],28 Warned: ({ ask }) => [ask],29 });30 48-/** The events about `asks`, in the order given. */31 export const eventsAbout = (32 events: readonly ProjectEvent[],33 asks: ReadonlySet<AskId>34 ): readonly ProjectEvent[] =>35 events.filter((event) => askOf(event).some((about) => asks.has(about)));36 55-/**56- * The delete child among a family parent's stored children: the one named57- * for the parent, as the platform names it when it splits a migrate ask.58- */37+/** The platform names a split's delete child after its parent. */38 export const deleteChildOf = (parent: Ask): AskId | undefined =>39 parent.blockedBy.find((child) => child === `${parent.id}-delete`);40 62-/** The parent of the family `ask` is in: the one read for it, or the ask itself when it heads one. */41 export const familyHead = (ask: Ask, parent: Ask | undefined) =>42 parent ?? (deleteChildOf(ask) === undefined ? undefined : ask);43 66-/** Every ask whose events the page needs: the ask, what it waits on, and its family. */44 export const asksAround = (45 ask: Ask,46 parent: Ask | undefined47 ): ReadonlySet<AskId> =>2 unmodified lines50 ...ask.blockedBy,51 ...(parent === undefined ? [] : [parent.id, ...parent.blockedBy]),52 ]);53 77-/** The project's events from the first; none when they cannot be read. */54 export const readEvents = (project: ProjectName) =>55 Effect.gen(function* () {56 const client = yield* Client;57 3 unmodified lines61 62 return events;63 });64 89-/** The parent ask of a family member; none for an ask in no family, or one the platform no longer finds. */65 export const readParent = (ask: Ask) =>66 Effect.gen(function* () {67 if (ask.parent === undefined) {68 return Option.none<Ask>();8 unmodified lines77 Effect.orElseSucceed(() => Option.none<Ask>())78 );79 });80 106-/** What a page carries of the events: those about its asks, and the last number of all of them. */81 export const keptEvents = (82 events: readonly ProjectEvent[],83 ask: Ask,84 parent: Ask | undefined1 unmodified line86 events: eventsAbout(events, asksAround(ask, parent)),87 lastSeq: lastSeq(events),88 });89 116-/** Whether an outcome waited on a person: a decision, or a decider's finish. */90 const waitedOnPerson = Outcome.isAnyOf(["AwaitingDecision", "AwaitingFinish"]);91 119-/**120- * What a verdict holds beyond its stage: whether a decider took part (the121- * landing's `Decided-by`, or a round of the same answer that waited on one)122- * and whether held-back checks judged it.123- */92 export const holdsOf = (93 verdict: Verdict,94 landing: LandingView | undefined,95 rounds: readonly Round[]5 unmodified lines101 ),102 heldBack: verdict.heldBack.length > 0,103 });104 137-/** Which round the answer at `head` is, of how many: the last round judged at that head. */105 export const roundOf = (106 rounds: readonly Round[],107 head: CommitSha108 ): { readonly number: number; readonly of: number } | undefined => {2 unmodified lines111 return index === -1 ? undefined : { number: index + 1, of: rounds.length };112 };113 114 /**148- * Each round with the last word on it: a round's own event says what the149- * gate said when it judged the push (often that it was still checking),150- * so the verdict on that head, and the landing that closed the ask, speak151- * for it once they came.115+ * A round's own event says what the gate said when it judged the push (often116+ * still checking), so the verdict on that head, and the landing that closed the117+ * ask, speak for it once they came.118 */119 export const roundsAsTheyStand = (120 progress: AskProgress | undefined,121 verdict: Verdict | undefined22 unmodified linesmodified:apps/web/src/features/ask/ask-page.tsx-55 removed
1-/**2- * An ask, as a person reads it: the want as the title, then where it3- * stands in one line (open to take, claimed by someone, refused at a4- * stage, landed), whose move that is and what runs next. Below, the brief,5- * the check (the spec: its source inline), and every answer judged so far,6- * one row each. The inspector holds the typed facts: its state, how to7- * take it or who holds it, its territory and check, its family, and its8- * project's posture.9- *10- * A family member says what it waits on in the family's terms ("waiting11- * for 4 of 6 children to land") and draws the family as a fan; once every12- * sibling has landed, the delete child reads open to take. Who holds an13- * ask and its rounds come from the project's events (`askStates`), with14- * no contract of their own.15- *16- * Agents read the same ask as Markdown (`markdown.ts`); the page shows the17- * brief exactly as they read it, and links the Markdown.18- */1 import { Brand } from "@repo/brand";2 import type { Verdict } from "@repo/protocol/domain/answer";3 import type { Ask } from "@repo/protocol/domain/ask";4 import { CheckSpec } from "@repo/protocol/domain/check";38 unmodified lines43 import { When } from "../shared/time.tsx";44 import { Region } from "./fields.tsx";45 import { markdownPath } from "./markdown.ts";46 65-/** The check's file, as the page read it: enough to draw its source. */47 export interface CheckSource {48 readonly path: string;68- /** The blob's id: the drawing's cache key. */49 readonly sha: string;50 readonly text: string;51 }52 53 const LINK = "decoration-rule underline hover:decoration-current";54 55 const NONE: ReadonlyMap<AskId, AskProgress> = new Map();56 77-/** How many lines of the check show before the reader asks for the whole. */57 const CHECK_LINES = 30;58 80-/** The page's trail: the project, its asks, then the ask. */59 export const askCrumbs = (ask: Ask): readonly Crumb[] => [60 { label: ask.project, to: `/${ask.project}` },61 { label: "Asks", to: `/${ask.project}` },62 { label: ask.id, mono: true },63 ];64 87-/** The command that claims an ask, run in a clone of its project. */65 export const claimCommand = (ask: Ask) =>66 `${Brand.cli} claim ${ask.id} --project ${ask.project}`;67 91-/** What judges an answer, by the check's kind, in words; its file linked when it has one. */68 const CheckSummary = ({ ask }: { readonly ask: Ask }) =>69 CheckSpec.match(ask.check, {70 LintToZero: ({ rule, territory }) => (71 <>39 unmodified lines111 </>112 ),113 });114 139-/**140- * The check's source, drawn as the code browser draws a file: its first141- * thirty lines until the reader asks for the whole, the server's plain142- * lines first and the highlighted drawing in place of them.143- */115 const CheckFile = ({ source }: { readonly source: CheckSource }) => {116 const [whole, setWhole] = useState(false);117 const lines = linesOf(source.text);118 const long = lines.length > CHECK_LINES;11 unmodified lines130 {lines.length} {lines.length === 1 ? "line" : "lines"}131 </span>132 </figcaption>133 <ClientFile163- // Each cut of the file is its own drawing.134 fallback={<NumberedLines text={shown} />}135 key={whole ? "whole" : "head"}136 path={source.path}137 sha={whole || !long ? source.sha : `${source.sha}:${CHECK_LINES}`}42 unmodified lines180 ))}181 </ul>182 );183 214-/** The brief's sections, as prose; the want is the page's title. */184 const Brief = ({ ask }: { readonly ask: Ask }) => {185 const { context, current, outOfScope, terms } = ask.brief;186 187 const parts = [27 unmodified lines215 </Region>216 );217 };218 250-/** Every answer judged, one row each, oldest first, each linking its verdict. */219 const Answers = ({220 ask,221 now,222 rounds,35 unmodified lines258 </AppLink>259 </Region>260 );261 294-/** The asks an ask outside a family still waits on, each linked. */262 const WaitsOn = ({263 asks,264 project,265 }: {23 unmodified lines289 </span>290 </p>291 );292 326-/**327- * What a family's parent waits on, in the fan's terms: how many of its328- * children have yet to land, then the delete step; never a list of ids329- * (the fan draws each child).330- */293 const FamilyWaits = ({294 finale,295 parent,296 project,38 unmodified lines335 };336 337 export interface AskViewProps {338 readonly ask: Ask;377- /** The brief as the platform renders it for an agent, in Markdown. */339 readonly brief: string;340 readonly now: DateTime.Utc;380- /** Where the project is cloned from. */341 readonly platformUrl: string;382- /** Where each ask stands, from the project's events (`askStates`). */342 readonly states?: ReadonlyMap<AskId, AskProgress>;384- /** The family's parent, when the ask is a member of one. */343 readonly parent?: Ask | undefined;386- /** The verdict on its latest answer, to say at which stage a refusal came. */344 readonly verdict?: Verdict | undefined;388- /** The check's source, when it is a file the page could read. */345 readonly check?: CheckSource | undefined;390- /** The project's posture, once the list of projects has it. */346 readonly posture?: Posture | undefined;392- /** Who is reading, to tell the claimant the claim is theirs. */347 readonly viewer?: Handle | undefined;348 }349 396-/** Where the ask stands, as its status line reads it. */350 const subjectOf = (351 ask: Ask,352 states: ReadonlyMap<AskId, AskProgress>,353 verdict: Verdict | undefined,10 unmodified lines364 project: ask.project,365 };366 }367 415- // A refusal says at which stage it came, which only the verdict holds.368 const lastRound = progress?.rounds.at(-1);369 370 if (371 latest !== undefined &&22 unmodified lines394 takeable,395 };396 };397 446-/** Where an ask stands for its page: what it still waits on, whether it can be taken, and its family. */398 const standing = (399 ask: Ask,400 states: ReadonlyMap<AskId, AskProgress>,401 parent: Ask | undefined13 unmodified lines415 held: progress?.claimant !== undefined || ask.state === "claimed",416 progress,417 remaining,418 takeable: ask.state === "open" && remaining.length === 0,468- // A family member says what it waits on in the family's terms, and a469- // wait the latest outcome already names needs no second line.419 waitsOn:420 ask.parent === undefined &&421 remaining.length > 0 &&422 !(latest !== undefined && Outcome.isAnyOf(["WaitingOnParent"])(latest)),423 };424 };425 477-/** The ask's facts: its state, how to take it or who holds it, its territory and check, its family, its project's posture. */426 const AskFacts = ({427 ask,428 now,429 parent,58 unmodified lines488 </>489 );490 };491 544-/** The line under the title: the kind, who asked (and mentors), and when it opened. */492 const AskMeta = ({493 ask,494 now,495 }: {17 unmodified lines513 ]}514 />515 );516 570-/** The Markdown an agent reads, shown whole on demand, and its own address. */517 const ForAgents = ({518 ask,519 brief,520 }: {80 unmodified lines601 {waitsOn && family !== ask ? (602 <WaitsOn asks={remaining} project={ask.project} />603 ) : null}604 {family === undefined ? null : (659- // Below the shell's width the family sits under the head, as a fan.605 <div className="shell:hidden mt-4">606 <FamilyStrip607 expanded={false}608 parent={family}32 unmodified linesmodified:apps/web/src/features/ask/fields.tsx-16 removed
1-/**2- * Labelled values, in two forms:3- *4- * - `Definitions` and `Definition`: a definition list, each term in the5- * label's style over its value, side by side from the shell's width;6- * the form records and agents' pages use (the ledger, the env shape, the7- * policy, For agents).8- * - `Fields` and `Field`: the grid of ruled rows the pages not yet moved9- * still use; from `lg` two fields share a row.10- *11- * Values that are code (ids, paths, SHAs) wrap anywhere, so a phone never12- * scrolls sideways.13- */1 import type { ReactNode } from "react";2 3 export const Fields = ({4 children,22 unmodified lines27 <dd className="min-w-0 [overflow-wrap:anywhere]">{children}</dd>28 </div>29 );30 44-/** A list of terms and their values: one ruled row each. */31 export const Definitions = ({32 children,33 label,34 }: {4 unmodified lines39 {children}40 </dl>41 );42 57-/** One term over its value; beside it from the shell's width. */43 export const Definition = ({44 children,45 term,46 }: {5 unmodified lines52 <dd className="text-ui min-w-0 [overflow-wrap:anywhere]">{children}</dd>53 </div>54 );55 71-/** A titled region of a page: a heading over its content, 32 px from the next. */56 export const Region = ({57 children,58 id,59 title,12 unmodified linesmodified:apps/web/src/features/ask/markdown.ts+3 added-43 removed
1-/**2- * An ask as Markdown, for agents: a harness reads an ask with one plain3- * fetch, either with `Accept: text/markdown` on the ask's own URL or at the4- * same URL with `.md`. The request decides; no user-agent list does.5- *6- * The brief is the platform's: `showAsk` renders it once, and the web only7- * serves it, with the banner that names the web's indexes under its title. A refusal is8- * set the way `git push` printed it, from `@repo/protocol/render`9- * (AGENTS.md principle 3), then its next command.10- * Pure: a `Request` or an `Exit` in, a string or a `Response` out.11- */1 import { indexBanner, underTitle } from "@repo/agent-kit/host-doc";2 import { Brand } from "@repo/brand";3 import type { Visibility } from "@repo/protocol/annotations";4 import type { ProjectName } from "@repo/protocol/ids";2 unmodified lines7 import { Array, Cause, Exit, Option, Schema } from "effect";8 9 const MARKDOWN = "text/markdown; charset=utf-8";10 22-/** A contract's `Visibility`: a `public` one's answer may be cached for a minute, a `maintainers` one's never. */11 export type ContractVisibility = ReturnType<typeof Visibility.defaultValue>;12 25-/** One range of an `Accept` header: `text/markdown;q=0.8`. */13 interface MediaRange {14 readonly quality: number;15 readonly subtype: string;16 readonly type: string;17 }18 32-/** A q-value as RFC 9110 writes it: 0 to 1, at most three decimals; anything else is no range. */19+/** A q-value as RFC 9110 writes it: 0 to 1, at most three decimals. */20 const QUALITY = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/u;21 22 const rangesOf = (accept: string): readonly MediaRange[] =>23 accept.split(",").flatMap((entry) => {9 unmodified lines33 ? []34 : [{ quality: Number(quality), subtype, type }];35 });36 50-/** How closely `range` names `type/subtype`: 3 by name, 2 by `type/*`, 1 by `*\/*`, 0 not at all. */37 const closeness = (range: MediaRange, type: string, subtype: string) => {38 if (range.type === type) {39 if (range.subtype === subtype) {40 return 3;4 unmodified lines45 46 return range.type === "*" && range.subtype === "*" ? 1 : 0;47 };48 63-/** The quality the closest range gives `type/subtype` (RFC 9110 §12.5.1), and how close it was. */49 const preferenceFor = (50 ranges: readonly MediaRange[],51 type: string,52 subtype: string11 unmodified lines64 return best;65 };66 67 /**83- * Whether the request asks for the ask as Markdown: it names `text/markdown`84- * itself, with a quality above zero and at least the quality it gives85- * `text/html`. A wildcard alone (`*\/*`, `text/*`, or no `Accept` at all)86- * gets the page, as a browser does.68+ * A wildcard alone (`*\/*`, `text/*`, or no `Accept` at all) gets the page, as69+ * a browser does.70 */71 export const wantsMarkdown = (request: Request) => {72 const ranges = rangesOf(request.headers.get("accept") ?? "");73 const markdown = preferenceFor(ranges, "text", "markdown");5 unmodified lines79 markdown.quality >= html.quality80 );81 };82 100-/** The longest run of backticks in `text`. */83 const longestTicks = (text: string) =>84 Math.max(0, ...[...text.matchAll(/`+/gu)].map(([run]) => run.length));85 104-/** `text` as inline code, its delimiter longer than any backticks inside it. */86 const inlineCode = (text: string) => {87 const ticks = longestTicks(text);88 const fence = "`".repeat(ticks + 1);89 90 return ticks === 0 ? `${fence}${text}${fence}` : `${fence} ${text} ${fence}`;91 };92 112-/**113- * Refusals as an agent reads them in Markdown: every refusal's `explain`114- * lines in one text block, verbatim (git's `remote:` lines, without the115- * prefix), then each distinct `next` command once, as its own paragraph.116- */93 export const refusalsMarkdown = (94 refusals: Array.NonEmptyReadonlyArray<Refusal>95 ) => {96 const lines = explain(refusals);19 unmodified lines116 },117 status,118 });119 144-/** What a Markdown answer may be cached for, by its contract's visibility. */120 const cacheFor = (visibility: ContractVisibility) =>121 visibility === "public" ? "public, max-age=60" : "private, no-store";122 123 const isRefusal = Schema.is(Refusal);124 150-/** What the web says when the platform gave neither the ask nor a refusal. */125 const UNANSWERED = [126 "The platform did not answer, so the web cannot read this ask now. Ask again in a moment.",127 "",128 ].join("\n");129 156-/** Where the web's indexes are, for the banner under an ask's title. */130 export interface AskIndex {131 readonly project: ProjectName;132 readonly webUrl: string;133 }134 162-/**163- * How reading an ask ended, as the Markdown response: the brief (200,164- * cacheable as its contract's visibility allows), with the banner naming165- * `index`'s `llms.txt` files under its title; a refusal (404, its166- * Markdown, no banner); or no answer from the platform (502). Only a brief167- * is cached.168- */135 export const askMarkdownResponse = <E>(136 result: Exit.Exit<{ readonly brief: string }, E>,137 visibility: ContractVisibility,138 index: AskIndex12 unmodified lines151 cacheFor(visibility)152 ),153 });154 189-/**190- * The answer to a path that can name no ask: a project's and an ask's names191- * are lowercase words joined by single dashes, so the platform is not asked.192- */155 export const noAskAt = (path: string) =>156 markdown(157 [158 `No ask is at ${inlineCode(path)}: a project's and an ask's names are lowercase words joined by single dashes.`,4 unmodified lines163 404,164 "no-store"165 );166 205-/** Where an ask's Markdown lives: its page's URL with `.md`. */167 export const markdownPath = (project: string, ask: string) =>168 `/${project}/asks/${ask}.md`;169 209-/** The `Link` header that names an ask page's Markdown as an alternate of it. */170 export const markdownAlternate = (project: string, ask: string) =>171 `<${markdownPath(project, ask)}>; rel="alternate"; type="text/markdown"`;modified:apps/web/src/features/ask/refused.tsx-20 removed
1-/**2- * The page for an address that names no ask, or no answer: a 404 whose body3- * is the refusal the platform gave (`UnknownProject`, `UnknownAsk`), as4- * `git push` printed it, so a person reads what an agent reads in Markdown,5- * then the way onward: the project, when the address names one, and the6- * open asks. The refusals travel from the server in a not-found's data,7- * encoded as `Refusals`; `NoSuchAsk` decodes them where they arrive8- * (AGENTS.md principle 2).9- */1 import { ProjectName } from "@repo/protocol/ids";2 import { UnknownProject } from "@repo/protocol/refusal";3 import type { Refusal } from "@repo/protocol/refusal";4 import { Option, Schema } from "effect";6 unmodified lines11 import { Refusals } from "../shared/refusals.ts";12 import type { Crumb } from "../shared/shell/sections.ts";13 import { Workspace } from "../shared/shell/workspace.tsx";14 24-/** What a 404 says when the address could name no ask, so no refusal came back. */15 export const NAMES_ONLY =16 "Nothing is at this address: a project's and an ask's names are lowercase words joined by single dashes.";17 18 const LINK = "decoration-rule underline hover:decoration-current";19 20 const isUnknownProject = Schema.is(UnknownProject);21 32-/** Where to go from a page that names nothing: the project, then every open ask. */22 const Onward = ({ project }: { readonly project: ProjectName | undefined }) => (23 <nav aria-label="Onward" className="text-ui flex flex-wrap gap-x-5 gap-y-1">24 {project === undefined ? null : (25 <AppLink className={LINK} to={projectPath(project)}>12 unmodified lines38 refusals,39 title,40 }: {41 readonly nothing?: string;53- /** The project the address names, when it could be one. */42 readonly project?: ProjectName | undefined;43 readonly refusals: Array.NonEmptyReadonlyArray<Refusal> | undefined;44 readonly title: string;45 }) => {58- // A project the platform says it lacks is no way onward.46 const known = refusals?.some(isUnknownProject) === true ? undefined : project;47 61- // The trail goes as far as what exists: the project and its asks.48 const crumbs: readonly Crumb[] =49 known === undefined50 ? [{ label: "Asks", to: ASKS_PATH }, { label: title }]51 : [17 unmodified lines69 const decodeRefusals = Schema.decodeUnknownOption(Refusals);70 71 const decodeProject = Schema.decodeUnknownOption(ProjectName);72 87-/**88- * A route's not-found page: the refusals its loader's not-found carried,89- * decoded; `nothing` when it carried none (the address could name no ask).90- * `project` is the address's own segment, linked only when a project could91- * have that name.92- */73 export const NoSuchAsk = ({74 data,75 nothing = NAMES_ONLY,76 project,12 unmodified linesmodified:apps/web/src/features/auth/session-slot.tsx+3 added-23 removed
1-/**2- * The session, wherever the shell shows it (the rail's foot, the tablet's3- * top bar, the phone's More sheet): who is signed in, with sign-out, or a4- * link to sign in that comes back to this page. Signing in is only for5- * deciders (PRODUCT.md), so the slot stays quiet: the handle in ink, the6- * action in muted text.7- *8- * `SessionView` draws it from props; `SessionSlot` wires it to `whoAtom`9- * and the location. Sign-in is a server route, so its link is a plain10- * anchor that loads the document; the handle's page is the router's.11- */1 import { useAtomValue } from "@effect/atom-react";2 import type { Handle } from "@repo/protocol/ids";3 import { useLocation } from "@tanstack/react-router";4 import { Option } from "effect";4 unmodified lines9 import { personPath } from "../shared/paths.ts";10 import { whoAtom } from "./who.ts";11 12 /**24- * Where sign-in comes back to: the page the reader is on, without its25- * `#fragment`. The server never sees a fragment, so a link that carried one26- * would differ between the server's render and the browser's (`#L3`).13+ * Without its `#fragment`: the server never sees one, so a link that carried it14+ * would differ between the server's render and the browser's.15 */16 export const hereOf = (location: {17 readonly pathname: string;18 readonly searchStr: string;19 }) => `${location.pathname}${location.searchStr}`;20 33-/** Sign-in, coming back to `here` afterwards. */21 export const signInHref = (here: string) =>22 `/auth/signin?${new URLSearchParams({ return: here }).toString()}`;23 37-/** The session's own action style: muted text, ink on hover. */24 const ACTION =25 "text-muted-foreground hover:text-foreground text-ui inline-flex cursor-pointer items-center gap-1.5 no-underline transition-colors duration-150";26 41-/**42- * Where the slot sits: `rail` stacks the handle over its action in the43- * rail's foot and the More sheet; `bar` keeps both on the top bar's line.44- */27 export type SessionLayout = "bar" | "rail";28 29 export const SessionView = ({30 handle,22 unmodified lines53 <p className="text-ui flex min-w-0 items-baseline gap-1">54 <span className="text-muted-foreground sr-only shrink-0">55 Signed in as56 </span>75- {/* A long handle is cut short for the line it shares; its title76- is whole. */}57+ {/* A long handle is cut short; its title is whole. */}58 <AppLink59 className="decoration-rule hover:decoration-foreground max-w-[12rem] min-w-0 truncate font-medium underline-offset-4 hover:underline"60 title={signedIn}61 to={personPath(signedIn)}26 unmodified lines88 />89 );90 };91 111-/** Whether someone is signed in, as far as this browser knows yet. */92 export const useSignedIn = (): boolean => {93 const who = useAtomValue(whoAtom);94 95 return AsyncResult.isSuccess(who) && Option.isSome(who.value);1 unmodified linemodified:apps/web/src/features/auth/who.ts-12 removed
1-/**2- * Who is signed in, as the browser learns it: the web's own `/auth/whoami`3- * (a same-origin server route that asks the platform with the session4- * cookie the page's JavaScript cannot read). It runs in the browser only:5- * on the server the slot renders as signed out, the page's first paint, and6- * the browser fills it in.7- *8- * Not a contract, so not an atom over `ContractsClient` (`src/surfaces.ts`):9- * the session is the web's, not the platform's.10- */1 import { Handle } from "@repo/protocol/ids";2 import { Effect, Option, Schema } from "effect";3 import { FetchHttpClient, HttpClient, HttpClientResponse } from "effect/http";4 import { Atom } from "effect/reactivity";5 16-/** `/auth/whoami`'s answer: the handle signed in, or nothing. */6 const Who = Schema.Struct({ handle: Schema.optionalKey(Handle) });7 19-/** The handle signed in in this browser, once known; signed out on the server and on any failure. */8 export const whoAtom = Atom.make(9 HttpClient.get("/auth/whoami").pipe(10 Effect.flatMap(HttpClientResponse.schemaBodyJson(Who)),11 Effect.map(({ handle }) => Option.fromUndefinedOr(handle)),4 unmodified linesmodified:apps/web/src/features/decision/choices.tsx+2 added-22 removed
1-/**2- * A decider's choices on one decision: one button per choice its subject3- * allows, each taken with one tap (there is no confirm and no undo, as the4- * platform has none), and under each, in a muted line, what the platform5- * then does. The default (what happens if nobody decides) is the outline6- * button, with the word "default" beside its name.7- *8- * Once taken, the record replaces the buttons: who chose what, when, the9- * note, and what it did, in the landed role only for a choice that made10- * something happen.11- */1 import type { Choice, Decision } from "@repo/protocol/domain/decision";2 import type { DateTime } from "effect";3 import { Option } from "effect";4 import { useId } from "react";12 unmodified lines17 takenWords,18 tookEffect,19 } from "./subject.ts";20 32-/** Why a choice waits, and whether it waits on something that will come. */21 export interface Held {22 readonly reason: string;23 readonly waiting: boolean;24 }25 38-/** How the choices sit: two to a row (main, a phone's open row), or one under another (the inspector). */26 export type ChoicesLayout = "grid" | "stack";27 28 const LAYOUTS = {29 grid: "grid grid-cols-2 gap-x-3 gap-y-3",7 unmodified lines37 layout = "grid",38 onChoose,39 }: {40 readonly decision: Decision;54- /** A choice on its way: every button waits. */41 readonly busy: boolean;56- /** Why Accept waits, when it does (a proposal whose draft is not read yet). */42 readonly held?: Option.Option<Held>;43 readonly layout?: ChoicesLayout;44 readonly onChoose: (choice: Choice) => void;45 }) => {51 unmodified lines97 </fieldset>98 );99 };100 116-/** A choice taken, in one line: its word in its role, then what it did. */101 export const TakenLine = ({102 choice,103 decision,104 stamp = false,105 }: {106 readonly decision: Decision;107 readonly choice: Choice;124- /** Settle the mark once: the decider took it while the page was open. */108 readonly stamp?: boolean;109 }) => {110 const effect = tookEffect(decision, choice);111 18 unmodified lines130 </p>131 );132 };133 151-/** The record of a taken decision: the line, then who, when and the note. */134 export const DecisionRecord = ({135 decided,136 decision,137 now,20 unmodified lines158 )}159 </section>160 );161 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.162+// Fixed, not sticky, on a phone: a bar that only stuck would stay below the163+// screen while its decision starts low on the page.164 export const stuckAboveBar = (node: ReactNode) => (165 <div166 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"167 data-choices-bar=""4 unmodified linesmodified:apps/web/src/features/decision/decision-card.tsx+4 added-48 removed
1-/**2- * One decision, as a decider takes it: when it expires and what happens if3- * nobody decides (the decision's own `default`), its evidence typed by its4- * subject, a note to keep with the choice, and the choices with what each5- * does. Once taken, the record replaces the choices. Today's inspector, a6- * phone's open row and the decision's own page each draw this one card.7- *8- * An `OpenProposal` holds Accept until its draft has been read, and while9- * the platform's agent is drafting it again: the draft is passed in, or10- * read from `showProposal` in the browser when it is not, so the server11- * never renders an Accept the browser might then hold.12- *13- * The subject's words follow GLOSSARY.md (ask, answer, landing, finish,14- * vouch). The default's word is the decision's `default` field as the15- * platform set it: the web keeps no table of defaults by subject.16- */1 import type { Decide } from "@repo/protocol/contracts";2 import { DecisionSubject } from "@repo/protocol/domain/decision";3 import type { Choice, Decision } from "@repo/protocol/domain/decision";4 import { DraftState } from "@repo/protocol/domain/proposal";19 unmodified lines24 describeDefault,25 describeSubject,26 } from "./subject.ts";27 44-/** What a decider sends when they choose: the `decide` contract's payload, from its one schema. */28 export type DecideInput = typeof Decide.payloadSchema.Type;29 47-/** Whether a decision opens a proposed ask. */30 const opensAsk = DecisionSubject.isAnyOf(["OpenProposal"]);31 50-/** Whether a draft is still being written. */32 const isDraftingNow = DraftState.isAnyOf(["Drafting"]);33 53-/**54- * Why Accept on a proposal waits, if it does: its draft not read yet, its55- * read failed, or the draft being written. Once read it may be accepted: a56- * ready draft, a want alone, or a failed round (which keeps an earlier57- * ready draft, or leaves the want alone).58- */34 const acceptHeld = (read: DraftRead): Option.Option<Held> =>35 DraftRead.$match(read, {36 Read: ({ draft }) =>37 Option.exists(draft, isDraftingNow)6 unmodified lines44 : { reason: "Reading the draft…", waiting: true }45 ),46 });47 73-/** When it expires, and what happens if nobody decides. */48 export const ExpiryLines = ({49 decision,50 now,51 soon,27 unmodified lines79 </p>80 </div>81 );82 109-/** A note kept with the choice, behind a disclosure. */83 const NoteField = ({84 note,85 onNote,86 }: {36 unmodified lines123 readonly decision: Decision;124 readonly layout: ChoicesLayout;125 }126 154-/** The choices on a proposal whose draft state was not passed: read from `showProposal`. */127+/**128+ * Read in the browser, so the server never renders an Accept the browser might129+ * then hold.130+ */131 const ProposalChoices = ({132 proposal,133 ...props134 }: ChoiceProps & { readonly proposal: ProposalId }) => {9 unmodified lines144 />145 );146 };147 172-/**173- * What ends the card: the choices while the decision is open (a174- * proposal's held until its draft is read), the record once it is taken.175- */148 const Ending = ({149 draft,150 now,151 stamp,39 unmodified lines191 />192 );193 };194 223-/** How many files a finish's diff changes, when it carries one. */195 export const finishFileCount = (decision: Decision): number | undefined =>196 Option.getOrUndefined(197 Option.map(patchOf(decision), (patch) => changedFiles(patch).length)198 );14 unmodified lines213 }: {214 readonly decision: Decision;215 readonly now: DateTime.Utc;216 readonly onDecide: (input: DecideInput) => void;246- /** Whether it expires within the day (Today's `expiringSoon`). */217 readonly soon?: boolean;248- /** Whether a choice on it is on its way: its buttons wait. */218 readonly busy?: boolean;250- /** What a page shows after the evidence, before the note (a waiver's diff). */219 readonly children?: ReactNode;252- /**253- * Where the choices go: in place (the default), or handed to the page,254- * which puts them where they stay in sight (a phone's sticky bar).255- */220 readonly choices?: (node: ReactNode) => ReactNode;257- /** Whether it says when it expires and its default (off where the page says so already). */221 readonly expiry?: boolean;259- /** Whether a finish links to its own page, where its diff is (off on that page). */222 readonly finishLink?: boolean;223 readonly layout?: ChoicesLayout;262- /** Settle the record's mark once: the choice was taken while the page was open. */224 readonly stamp?: boolean;264- /**265- * For an `OpenProposal`, what has been read of the proposal's draft:266- * Accept waits until it is read, and while it is drafting. Read from267- * `showProposal` in the browser when not passed.268- */225 readonly draft?: DraftRead | undefined;226 }) => {227 const [note, setNote] = useState("");228 46 unmodified linesmodified:apps/web/src/features/decision/decision-page.tsx-29 removed
1-/**2- * One decision on its own page, every subject but a finish (which reads as3- * the code browser does, `features/finish/finish-view.tsx`). The title is4- * the subject in plain words; under it, when it expires, its default and5- * whose move it is. Main holds the evidence at the page's width (a6- * waiver's marker drawn at its line in the answer's diff, when the7- * decision carries the diff), a note, and the choices, each saying what8- * it does; on a phone the choices stay in a bar above the bottom bar.9- * The inspector holds the decision's own facts (its deciders, when it10- * opened and expires, its default), the ask or proposal it concerns, and,11- * for a posture change, the project's posture.12- *13- * Once taken, the record replaces the choices. Signed out, the page says14- * what a decision is and that its deciders take it on Today: no choices,15- * and nothing of its evidence.16- */1 import { Brand } from "@repo/brand";2 import type { Ask } from "@repo/protocol/domain/ask";3 import { DecisionSubject } from "@repo/protocol/domain/decision";4 import type { Decision } from "@repo/protocol/domain/decision";33 unmodified lines38 const waives = DecisionSubject.isAnyOf(["Waiver"]);39 40 const finishes = DecisionSubject.isAnyOf(["Finish"]);41 58-/** No files: a decision that carries no diff. */42 const NO_FILES: readonly PatchFile[] = [];43 44 const LINK = "decoration-rule underline hover:decoration-current";45 63-/** The trail to a decision: its project, Today, its id. */46 const crumbsOf = (project: ProjectName, id: DecisionId) => [47 { label: project, to: `/${project}` },48 { label: "Today", to: "/today" },49 { label: id, mono: true },50 ];51 70-/** The decision's own facts: who decides it, when it opened and expires, its default. */52 const DecisionFacts = ({53 decision,54 now,55 soon,39 unmodified lines95 </dl>96 </FactBlock>97 );98 118-/** The ask a decision concerns: its want and its page. */99 const AskFacts = ({ ask }: { readonly ask: Ask }) => (100 <FactBlock label="The ask">101 <p className="text-ui" data-said="">102 {ask.brief.want}3 unmodified lines106 </AppLink>107 </FactBlock>108 );109 130-/** The proposal a decision would open: its want, who proposed it, its page. */110 const ProposalFacts = ({ proposal }: { readonly proposal: Proposal }) => (111 <FactBlock label="The proposal">112 <p className="text-ui" data-said="">113 {proposal.want}9 unmodified lines123 </AppLink>124 </FactBlock>125 );126 148-/** The waiver's marker drawn at its line, in the answer's diff of that file. */127 export const WaiverDiff = ({128 decision,129 files,130 }: {27 unmodified lines158 </section>159 );160 };161 184-/** What a decision is, for a reader who does not decide it here. */162 const ForAnyone = ({163 children,164 id,165 project,22 unmodified lines188 export interface DecisionViewProps {189 readonly data: DecisionPageData;190 readonly onDecide: (input: DecideInput) => void;191 readonly busy?: boolean;215- /** The decision as the decider's choice left it, once taken here. */192 readonly taken?: Decision | undefined;217- /** The waiver's diff, parsed, when the decision carries one. */193 readonly files?: readonly PatchFile[];219- /** The page for a finish, when the decision is one (the route draws it whole). */194 readonly finish?: ReactNode;195 readonly here: string;222- /** What the reader's last choice came back with, when it failed: shown above the choices. */196 readonly failure?: ReactNode;197 }198 226-/** A decision the reader may take, whole. */199 const Found = ({200 busy,201 failure,202 files,67 unmodified lines270 </Workspace>271 );272 };273 302-/** The page for a decision that cannot be shown whole, with why. */274 const Apart = ({275 children,276 data,277 }: {72 unmodified linesmodified:apps/web/src/features/decision/evidence.tsx+3 added-32 removed
1 import type { Evidence as Fact } from "@repo/protocol/domain/common";2-// A decision's evidence, typed by what it is about: the commits a stray3-// push moved between (each a link to its page), the proposal's draft and4-// files, a ratchet's before and after, a waiver's marker at its line, a5-// posture's from and to beside the ledger, the hosts a proxy may now reach,6-// the item a stored value matched, the person a vouch admits, the answer a7-// finish lands. Then whatever else the platform put on it, as label and8-// value, the diff and the fork left to the finish.9-//10-// Every value that is code is mono; every link is the router's.2 import { DecisionSubject } from "@repo/protocol/domain/decision";3 import type { Decision } from "@repo/protocol/domain/decision";4 import type { Posture } from "@repo/protocol/posture";5 import { ArrowRight, FileDiff, FileText } from "lucide-react";13 unmodified lines19 20 const CODE = "text-mono font-mono [overflow-wrap:anywhere]";21 22 /**32- * Whether an evidence line holds a file: its label is a path (one word with33- * a slash or a dot, as the ask file under the config folder, or a check34- * at the root, `offset.test.ts`), where every other label is words.23+ * A label that is a path: one word with a slash or a dot, where every other24+ * label is words.25 */26 const isFileFact = ({ label }: Fact) => /^\S*[./]\S*$/u.test(label);27 28 const opensAsk = DecisionSubject.isAnyOf(["OpenProposal"]);29 40-/** The files an `OpenProposal` decision holds, shown as code; none for any other subject. */30 export const filesOf = (decision: Decision): readonly Fact[] =>31 opensAsk(decision.subject) ? decision.evidence.filter(isFileFact) : [];32 44-/** One fact: its label over (or beside) its value. */33 const FactRow = ({34 children,35 label,36 }: {37 readonly children: ReactNode;38 readonly label: string;39 }) => (40 <div className="contents">53- {/* Sentence case, as every label on the page: the platform names some54- evidence in lower case ("answer"); the text stays the platform's. */}41+ {/* Sentence case: the platform names some evidence in lower case. */}42 <dt className="text-label text-muted-foreground pt-0.5 first-letter:uppercase">43 {label}44 </dt>45 <dd className="text-ui mb-1.5 min-w-0 [overflow-wrap:anywhere] @lg:mb-0">2 unmodified lines48 </div>49 );50 51 const FactList = ({ children }: { readonly children: ReactNode }) => (65- // Label beside value where the evidence has the width (main), label over66- // value where it has not (the inspector, a phone).52 <dl className="grid grid-cols-1 gap-x-4 gap-y-1.5 @lg:grid-cols-[minmax(7rem,auto)_1fr]">53 {children}54 </dl>55 );56 72-/** A link to a page of the web, with its mark. */57 const PageLink = ({58 children,59 icon: Icon,60 to,10 unmodified lines71 {children}72 </AppLink>73 );74 91-/** A posture as a mark and its name, in its role. */75 const PostureWord = ({ posture }: { readonly posture: Posture }) => (76 <span className="inline-flex items-center gap-1.5">77 <Mark look={POSTURE_MARKS[posture]} size="sm" />78 <code className={CODE}>{posture}</code>79 </span>80 );81 99-/** From one value to another, the arrow hidden from a screen reader, which hears "to". */82 const FromTo = ({83 from,84 to,85 }: {27 unmodified lines113 {shortSha(sha)}114 </AppLink>115 );116 135-/** The facts each subject carries in its own fields, typed. */117 const SubjectFacts = ({ decision }: { readonly decision: Decision }) =>118 DecisionSubject.match(decision.subject, {119 Finish: ({ ask, head }) => (120 <FactList>122 unmodified lines243 </FactList>244 ),245 });246 266-/** A whole commit id in running evidence. */247 const WHOLE_SHA = /\b[0-9a-f]{40}\b/u;248 269-/** `text` with each whole commit id cut to its first seven, whole in its title. */249 const ShortShas = ({ text }: { readonly text: string }) =>250 text.split(/(?<sha>\b[0-9a-f]{40}\b)/u).map((part, index) =>251 WHOLE_SHA.test(part) ? (252 <code className={CODE} key={`${index}:${part}`} title={part}>3 unmodified lines256 part257 )258 );259 281-// The labels the subject's own facts already say (a waiver's escape, a282-// ratchet's count), or the finish draws.260 const SHOWN_ELSEWHERE: ReadonlySet<string> = new Set([261 PATCH_LABEL,262 FORK_LABEL,263 "escape",264 "ratchet",265 ]);266 290-/** The rest of what the platform put on the decision, as label and value. */267 const OtherFacts = ({268 decision,269 files,270 }: {8 unmodified lines279 <FactList>280 {facts.map(({ href, label, value }) => (281 <FactRow282 key={`${label}:${value}`}307- // Who pushed the answer, at which head: the subject's own row308- // is already the answer.283 label={label === "answer" ? "Pushed by" : label}284 >285 {href === undefined ? (286 <ShortShas text={value} />7 unmodified lines294 </FactList>295 );296 };297 324-/** The way from a `Finish` decision to its answer's diff, with how many files it changes. */298 export const FinishLink = ({299 decision,300 files,301 }: {8 unmodified lines310 {files === undefined ? "" : ` (${files} ${files === 1 ? "file" : "files"})`}311 </PageLink>312 );313 341-/** A decision's evidence: its subject's facts, the rest, and a proposal's files as code. */314 export const DecisionEvidence = ({315 decision,316 heading = "h4",317 }: {318 readonly decision: Decision;347- /** The heading level a proposal's file paths take. */319 readonly heading?: "h3" | "h4";320 }) => {321 const files = filesOf(decision);322 15 unmodified linesmodified:apps/web/src/features/decision/read.ts+2 added-27 removed
1 /**2- * What a decision's page reads, in a module with no view of its own: a3- * route's loader runs before its page's view loads, so the route reaches4- * these without carrying the page.5- *6- * The decision comes from the reader's Today in its project alone, read7- * with their own session: someone who decides nothing there gets why, and8- * no evidence. Beside it, what it concerns, each read on its own (one that9- * fails is left out): the ask, the proposal, the project's posture; for a10- * finish, the verdict on its head and, from the project's events, where11- * the answer's earlier rounds were refused and whether a newer head came.2+ * Kept apart from the page's view: a route's loader runs before the view loads,3+ * so the route reaches this without carrying the page.4 */5 import { Client } from "@repo/protocol/contracts";6 import { Verdict } from "@repo/protocol/domain/answer";7 import { Ask } from "@repo/protocol/domain/ask";10 unmodified lines18 19 import { askStates } from "../shared/ask-progress.ts";20 import { findDecision, readOfCause, TodayRead } from "../today/read.ts";21 30-/** A refusal from an answer's round that points at a line, as the page's loader sends it. */22 export const Placed = Schema.Struct({23 line: Schema.Int,24 path: Schema.String,25 refusal: Refusal,26 round: Schema.Int,27 });28 38-/** What the page read for its reader: the decision and what it concerns, or why there is none. */29 export const DecisionRead = Schema.TaggedUnion({30 Found: {41- /** The ask it concerns, when it concerns one. */31 ask: Schema.optionalKey(Ask),32 decision: Decision,44- /** A head pushed to the answer after the one a finish names. */33 newerHead: Schema.optionalKey(CommitSha),46- /** Refusals from the answer's rounds that point at a line. */34 placed: Schema.Array(Placed),48- /** The project's posture, for a posture change. */35 posture: Schema.optionalKey(36 Schema.Struct({ label: Schema.String, posture: Posture })37 ),52- /** The proposal it would open, for an `OpenProposal`. */38 proposal: Schema.optionalKey(Proposal),39 soon: Schema.Boolean,55- /** The verdict on a finish's head. */40 verdict: Schema.optionalKey(Verdict),41 },42 NotOnToday: {},43 Refused: { refusal: Refusal },4 unmodified lines48 export type DecisionRead = typeof DecisionRead.Type;49 50 export type FoundDecision = Extract<DecisionRead, { readonly _tag: "Found" }>;51 68-/** What a decision's loader sends: whose page, what it read, and when. */52 export const DecisionPageData = Schema.Struct({53 decision: DecisionId,54 now: Schema.DateTimeUtcFromString,55 project: ProjectName,1 unmodified line57 });58 59 export type DecisionPageData = typeof DecisionPageData.Type;60 78-/** The refusals among an outcome, when it refused. */61 const refusalsOf = (outcome: Outcome): readonly Refusal[] =>62 Outcome.guards.Refused(outcome) ? outcome.refusals : [];63 82-/** Every refusal of an ask's rounds that points at a line, with the round it came from. */64 const placedIn = (events: readonly ProjectEvent[], ask: AskId) =>65 (askStates(events).get(ask)?.rounds ?? []).flatMap(({ outcome }, index) =>66 refusalsOf(outcome).flatMap((refusal) =>67 refusal.at === undefined8 unmodified lines76 ]77 )78 );79 99-/** The head last pushed to `ask`, when it is not `head`. */80 export const newerThan = (81 events: readonly ProjectEvent[],82 ask: AskId,83 head: CommitSha2 unmodified lines86 87 return last === undefined || last === head ? undefined : last;88 };89 110-/** The ask a subject concerns, when it concerns one. */90 const askOf = DecisionSubject.match({91 Finish: ({ ask }) => Option.some(ask),92 OpenProposal: () => Option.none(),93 PostureChange: () => Option.none(),4 unmodified lines98 Vouch: () => Option.none(),99 Waiver: ({ ask }) => Option.some(ask),100 });101 123-/** What a decision concerns, each read on its own: one that fails is left out. */102 const concerning = (decision: Decision, soon: boolean) =>103 Effect.gen(function* () {104 const client = yield* Client;105 const { project, subject } = decision;37 unmodified lines143 Effect.orElseSucceed(() => Option.none())144 ),145 });146 169- // A finish's rounds, from the project's events: where earlier rounds170- // were refused, and whether a newer head was pushed.147 const events = Option.isSome(finish)148 ? yield* Stream.runCollect(client.watch({ project, since: 0 })).pipe(149 Effect.map((all): readonly ProjectEvent[] => all),150 Effect.orElseSucceed((): readonly ProjectEvent[] => [])33 unmodified lines184 }),185 });186 });187 212-/** The decision for its page, and what it concerns, read with the reader's session. */188 export const readDecision = (params: {189 readonly project: string;190 readonly decision: string;191 }) =>40 unmodified linesmodified:apps/web/src/features/decision/subject.ts+2 added-53 removed
1-/**2- * What a decision is about and what each choice on it does, in words, with3- * no view of its own: Today's rows, the inspector, a decision's page and4- * its finish all say a subject the same way.5- *6- * - `describeSubject`: the subject as one plain sentence, the row's link.7- * - `allowedChoices`: the choices its deciders have, in its own words.8- * - `consequenceOf`: what the platform does once a choice is taken, one9- * line under each button, written from what the platform's code does for10- * that subject. Where a choice changes nothing anyone can see, the line11- * says so rather than promising something.12- *13- * Each table names every subject, so a new kind fails to compile until it14- * has its sentence, its choices and its lines.15- */1 import { DecisionSubject } from "@repo/protocol/domain/decision";2 import type { Choice, Decision } from "@repo/protocol/domain/decision";3 import { DateTime, Match } from "effect";4 5 const yesOrNo: readonly Choice[] = ["accept", "decline"];6 7 /**23- * The choices a subject's deciders have: a stray push is adopted or24- * reverted, anything else accepted or declined. The platform reads `accept`25- * on a stray push as `adopt` too, but the page offers each subject its own26- * words only.8+ * The platform reads `accept` on a stray push as `adopt` too, but the page9+ * offers each subject its own words only.10 */11 export const allowedChoices = DecisionSubject.match({12 Finish: () => yesOrNo,13 OpenProposal: () => yesOrNo,7 unmodified lines21 });22 23 const short = (sha: string) => sha.slice(0, 7);24 42-/** A ref as people say it: `main` for `refs/heads/main`. */25 export const refWords = (ref: string) => ref.replace(/^refs\/heads\//u, "");26 45-/** What a decision is about, in one plain sentence. */27 export const describeSubject = DecisionSubject.match({28 Finish: ({ ask, head }) =>29 `Finish the passing answer to ${ask}, at ${short(head)}`,30 OpenProposal: ({ proposal }) => `Open the ask proposed in ${proposal}`,11 unmodified lines42 Waiver: ({ ask, at, marker, reason }) =>43 `Allow ${marker} at ${at.path}:${at.line} in the answer to ${ask}: ${reason}`,44 });45 65-/** A subject's kind as a row's metadata names it. */46 export const subjectKind = DecisionSubject.match({47 Finish: () => "finish",48 OpenProposal: () => "proposal",49 PostureChange: () => "posture change",4 unmodified lines54 Vouch: () => "vouch",55 Waiver: () => "waiver",56 });57 78-/** What saying yes and saying no do, for one subject. */58 interface Lines {59 readonly yes: string;60 readonly no: string;61 }62 84-/** What the platform takes no step on: the choice is kept, and nothing else moves. */63 const RECORDED =64 "Your choice is kept on the decision; the platform takes no other step on it.";65 88-/**89- * What each choice does, by subject, as the platform's code does it:90- *91- * - an accepted proposal opens its ask (its files land on main, decided by92- * the decider); a declined one closes;93- * - an accepted finish lands the answer at its head with the decider as94- * `Finished-by`; a declined one leaves it waiting;95- * - a waiver, a ratchet raise or a posture change holds an answer: yes lets96- * it go on with the decider as `Decided-by`, no refuses it with the97- * refusal the decision stood for;98- * - a stray push to main is adopted as a landing, or reverted by one, with99- * the decider as `Decided-by`; a push to another ref moves nothing;100- * - a vouch lands a line in the vouch file;101- * - a widened proxy or a stored value found in an answer is recorded, and102- * nothing else follows yet.103- */66 const linesOf = (subject: DecisionSubject): Lines =>67 Match.value(subject).pipe(68 Match.tagsExhaustive({69 Finish: (): Lines => ({34 unmodified lines104 }),105 })106 );107 146-/** Whether a choice says yes, in any subject's words. */108 const saysYes = {109 accept: true,110 adopt: true,111 decline: false,112 revert: false,113 } as const satisfies Record<Choice, boolean>;114 154-/** What taking `choice` on `subject` does, in one line. */115 export const consequenceOf = (116 subject: DecisionSubject,117 choice: Choice118 ): string => {1 unmodified line120 121 return saysYes[choice] ? lines.yes : lines.no;122 };123 164-/** Each choice as its button says it. */124 export const choiceWords = {125 accept: "Accept",126 adopt: "Adopt",127 decline: "Decline",128 revert: "Revert",129 } as const satisfies Record<Choice, string>;130 172-/** Each choice once taken. */131 export const takenWords = {132 accept: "Accepted",133 adopt: "Adopted",134 decline: "Declined",135 revert: "Reverted",136 } as const satisfies Record<Choice, string>;137 180-/**181- * Whether a taken choice made something happen: what lands, opens or is182- * put back is drawn in the landed role; a choice that leaves things as they183- * were is ink.184- */138 export const tookEffect = (decision: Decision, choice: Choice): boolean =>139 saysYes[choice]140 ? consequenceOf(decision.subject, choice) !== RECORDED141 : DecisionSubject.guards.StrayPush(decision.subject) &&142 refWords(decision.subject.ref) === "main";143 191-/** An expiry as a decider reads it on any phone: weekday, date and time, in UTC. */144 export const byWhen = (at: DateTime.Utc) =>145 `${DateTime.formatUtc(at, {146 day: "numeric",147 hour: "2-digit",3 unmodified lines151 month: "short",152 weekday: "short",153 })} UTC`;154 203-/** What happens when nobody decides in time: the decision's own default, and by when. */155 export const describeDefault = (decision: Decision) =>156 `If nobody decides by ${byWhen(decision.expiresAt)}: ${decision.default}`;157 207-/** A decision's own page. */158 export const decisionHref = (decision: Decision) =>159 `/${decision.project}/decisions/${decision.id}`;160 211-/** A decision's place in a Today that may hold several projects. */161 export const decisionKey = ({ id, project }: Decision) => `${project}/${id}`;modified:apps/web/src/features/docs/docs-view.tsx-10 removed
1-/**2- * The docs on the web: the index, every page under Guides then Reference3- * with its summary, and one page, its Markdown under its title with the4- * pages listed in the inspector. Every word on them is `@repo/agent-kit`'s5- * (`docPages`); a view: pages in, markup out.6- */1 import type { DocPage, DocPart } from "@repo/agent-kit/docs/index";2 3 import { SiteMarkdown } from "../markdown/markdown.tsx";4 import { AppLink } from "../shared/link.tsx";5 import { docsPath } from "../shared/paths.ts";6 import { Workspace } from "../shared/shell/workspace.tsx";7 import { docsMarkdownPath } from "./head.ts";8 15-/** Each part's heading, in the order the index shows them. */9 const PARTS = [10 { part: "guide", title: "Guides" },11 { part: "reference", title: "Reference" },12 ] as const satisfies readonly { part: DocPart; title: string }[];13 14 const LINK =15 "decoration-rule hover:decoration-foreground underline underline-offset-4";16 24-/** Only the page itself is current. */17 const EXACT = { exact: true, includeSearch: false } as const;18 19 export const DocsIndexView = ({20 pages,25 unmodified lines46 ))}47 </Workspace>48 );49 58-/** The pages, for the inspector: the one being read is current. */50 const Contents = ({ pages }: { readonly pages: readonly DocPage[] }) => (51 <nav aria-label="Docs">52 {PARTS.map(({ part, title }) => (53 <div className="mb-3" key={part}>17 unmodified lines71 ))}72 </nav>73 );74 84-/** A page's Markdown past its title and summary, which the page head shows. */75 const bodyOf = ({ markdown, summary, title }: DocPage) =>76 markdown.slice(`# ${title}\n\n${summary}\n\n`.length);77 78 export const DocsPageView = ({27 unmodified linesmodified:apps/web/src/features/docs/head.ts+2 added-6 removed
1 /**2- * What the docs' pages put in their head, in a module with no view of its3- * own: a route's `head` runs before its page's view loads, so the Markdown4- * renderer stays off every page's first load.2+ * Kept apart from the view: a route's `head` runs before its page's view loads,3+ * so the Markdown renderer stays off every page's first load.4 */5 import type { DocEntry } from "@repo/agent-kit/docs/entries";6 7 import { markdownAlternateLink } from "../front/markdown.ts";8 import { pageHead } from "../shared/head.ts";9 import { docsPath } from "../shared/paths.ts";10 12-/** Where a page's Markdown is. */11 export const docsMarkdownPath = (slug: string) => `${docsPath(slug)}.md`;12 15-/** A page's head: its title, its summary, and its Markdown. */13 export const docsHead = (page: DocEntry) => ({14 ...pageHead({ description: page.summary, title: page.title }),15 links: [markdownAlternateLink(docsMarkdownPath(page.slug))],16 });17 21-/** The index's head. */18 export const docsIndexHead = () =>19 pageHead({20 description: "Guides, and a reference read from the platform's schema.",21 title: "Docs",1 unmodified linemodified:apps/web/src/features/env/env-page.tsx+2 added-43 removed
1 /**2- * A project's env shape: every item its committed `.env.schema` declares,3- * parsed at the landed commit and never resolved (ADR 0009). The status4- * line counts the items and says who set the sensitive ones. Sensitive5- * items come first, each saying on its own line that it is sensitive and6- * who set its value and when (or that nobody has); then every item's type,7- * whether it is required, its `@proxy` hosts, tags, docs and description.8- * The inspector says where the schema was read and how a value is set.9- *10- * Never a value, and nothing that would take or show one: a value is set11- * only from a terminal (`setEnv` is RPC and CLI alone), so the page shows12- * that command line instead of a form. The placeholder unlanded code sees13- * is not shown either: it is not a value, but it reads like one.14- *15- * Props in, markup out: the route reads the env shape16- * (`src/client/env.ts`) and hands it here. (Lint keeps "shape" out of code17- * names, so the prop is the env schema's view: `schema`.)2+ * Never a value, and nothing that would take or show one: `setEnv` is RPC and3+ * CLI alone. Lint keeps "shape" out of code names, so the prop is `schema`.4 */5 import { Brand } from "@repo/brand";6 import type { EnvItem, EnvSchemaView } from "@repo/protocol/domain/env";7 import type { ProjectName } from "@repo/protocol/ids";12 unmodified lines20 import { AppLink } from "../shared/link.tsx";21 import { Workspace } from "../shared/shell/workspace.tsx";22 import { distanceInWords, When } from "../shared/time.tsx";23 38-/** Where varlock, whose `.env.schema` format this is, documents it. */24 const VARLOCK = "https://varlock.dev";25 26 const LINK = "decoration-rule underline hover:decoration-current";27 5 unmodified lines33 34 const plural = (count: number, one: string, many: string) =>35 `${count} ${count === 1 ? one : many}`;36 52-/**53- * When the env shape was read, at the latest: `now`, or the newest time a54- * value was set if that is later. The page keeps the `now` it was served55- * with while it reads the env shape again as values are set, and a value56- * that was set is never set in the future.57- */37 const readAt = (schema: EnvSchemaView, now: DateTime.Utc) => {38 let latest = now;39 40 for (const { value } of schema.items) {4 unmodified lines45 46 return latest;47 };48 70-/** The items, sensitive ones first; each kind in the schema's own order. */49 const sensitiveFirst = (items: readonly EnvItem[]) => [50 ...items.filter(({ sensitive }) => sensitive),51 ...items.filter(({ sensitive }) => !sensitive),52 ];53 76-/** The newest value set among `items`, if any was. */54 const newestSet = (items: readonly EnvItem[]) => {55 let newest: EnvItem["value"];56 57 for (const { value } of items) {8 unmodified lines66 67 return newest;68 };69 93-/**94- * The sensitive items in words: "1 sensitive, set by ines-v 1 d ago",95- * "1 sensitive, not set", "3 sensitive: 2 set, latest by ines-v 1 d ago".96- */70 const sensitiveWords = (items: readonly EnvItem[], now: DateTime.Utc) => {71 const sensitive = items.filter((item) => item.sensitive);72 const set = sensitive.filter(({ value }) => value !== undefined);73 const newest = newestSet(sensitive);12 unmodified lines86 ? `1 sensitive, set ${by}`87 : `${sensitive.length} sensitive: ${set.length} set, latest ${by}`;88 };89 117-/** Whether `docs` is a web address, so a link to it can go nowhere else. */90 const isWebAddress = (docs: string) => /^https?:\/\//iu.test(docs);91 92 const requiredWords = (required: EnvItem["required"]) => {93 if (required === "depends") {2 unmodified lines96 97 return required ? "yes" : "no";98 };99 128-/** The proxy's hosts, then what it is limited to: "sentry.io, only /api/**". */100 const Proxy = ({101 proxy,102 }: {103 readonly proxy: NonNullable<EnvItem["proxy"]>;26 unmodified lines130 ) : (131 <span className="[overflow-wrap:anywhere]">{docs}</span>132 );133 163-/** Who set a write-only value and when, or that nobody has; never the value. */134 const Value = ({135 now,136 value,137 }: {8 unmodified lines146 <When at={value.setAt} now={now} />147 </span>148 );149 180-/** The item's line: its key, then, for a sensitive one, the lock, the word and who set it. */150 const ItemLine = ({151 item,152 now,153 }: {70 unmodified lines224 </Definitions>225 </li>226 );227 259-/** The caption that credits the format: "env shape: varlock's .env.schema format". */228 const Caption = () => (229 <>230 env shape:{" "}231 <a className={LINK} href={VARLOCK} rel="noreferrer">1 unmodified line233 </a>234 </>235 );236 269-/** One fact of where the schema was read, its label beside it. */237 const Read = ({238 children,239 term,240 }: {7 unmodified lines248 </dd>249 </div>250 );251 285-/** How a decider sets a value: from a terminal, never here. */252 const SetValueFacts = ({ project }: { readonly project: ProjectName }) => (253 <FactBlock label="Set a value">254 <p className="text-ui text-muted-foreground">255 A decider sets one from a terminal; nobody reads it back.4 unmodified lines260 />261 </FactBlock>262 );263 298-/** The project's posture, once the list of projects has brought it. */264 const PostureOf = ({265 posture,266 project,267 }: {53 unmodified lines321 posture,322 schema,323 }: {324 readonly now: DateTime.Utc;360- /** The project's posture, from the list of projects; it may come after the page. */325 readonly posture?: Posture | undefined;326 readonly schema: EnvSchemaView;327 }) => {328 const { items } = schema;23 unmodified lines352 </Workspace>353 );354 };355 392-/**393- * A project whose main has not landed yet: there is no landed394- * `.env.schema` to read, so there is no env shape, which is not the same as395- * no project.396- */356 export const NothingLanded = ({357 project,358 }: {359 readonly project: ProjectName;8 unmodified linesmodified:apps/web/src/features/finish/annotation.tsx-11 removed
1-/**2- * What a decider's diff marks under one of its lines: a refusal that3- * pointed there (in the rubric, its lines as `explain` printed them, the4- * round it came from), or a marker that waits on a decision (in ochre, the5- * marker and its reason). Compact, one block under the line, the same in6- * the server's plain diff and in the browser's drawing.7- */1 import type { Refusal } from "@repo/protocol/refusal";2 import { explain } from "@repo/protocol/render";3 import { Hourglass, OctagonX, RotateCcw } from "lucide-react";4 12-/** A refusal placed in a diff: its file and line, and the round it came from. */5 export interface PlacedRefusal {6 readonly refusal: Refusal;7 readonly path: string;8 readonly line: number;17- /** The round it refused, counting from 1. */9 readonly round: number;10 }11 21-/** A refusal under its line, as git printed it. */12 export const RefusalNote = ({ placed }: { readonly placed: PlacedRefusal }) => {13 const [first = "", ...rest] = explain([placed.refusal]).filter(14 (line) => !line.startsWith(" at: ")15 );31 unmodified lines47 </div>48 );49 };50 61-/** A marker that waits on a decider, under its line. */51 export const MarkerNote = ({52 marker,53 reason,54 }: {18 unmodified linesmodified:apps/web/src/features/finish/files.ts-35 removed
1-/**2- * The files a decision's diff changes, as its page draws them: parsed once3- * by the drawing's own parser (`@pierre/diffs`' `parsePatchFiles`), so the4- * server's plain text and the browser's drawing hold the same hunks; each5- * file's `+n −m`, its id for the read marks, and its part of the change.6- *7- * The order is a rule, never a model's: the ask's territory first, then8- * tests, then anything else, each part by path in the order a tree lists9- * them.10- *11- * A diff's lines are numbered from its hunk headers (a patch holds only12- * the hunks, not the whole files), so a refusal's `at` line finds the line13- * it names.14- *15- * No React and no DOM: the server's render and the browser's both read it.16- */1 import { parsePatchFiles } from "@pierre/diffs";2 import type { FileDiffMetadata } from "@pierre/diffs";3 import type { ChangedFile } from "@repo/protocol/domain/code";4 import { RepoPath } from "@repo/protocol/ids";8 unmodified lines13 } from "../code/diff-model.ts";14 import type { DrawnFile } from "../code/diff-model.ts";15 import { fileBlocks, patchIdOf } from "./patch.ts";16 33-/** Which part of the change a file is in. */17 export type Part = "territory" | "tests" | "other";18 36-/** A changed file as the finish page holds it. */19 export interface PatchFile extends DrawnFile {20 readonly part: Part;39- /** This file's change, as an id: what a read mark is kept against. */21 readonly patchId: string;22 }23 24 const STATUS = {11 unmodified lines36 } as const satisfies Record<Part, number>;37 38 const decodePath = Schema.decodeUnknownOption(RepoPath);39 59-/** The part a path is in: the territory's, the tests', or the rest. */40 export const partOf =41 (territory: readonly string[]) =>42 (path: string): Part => {43 if (isTestPath(path)) {4 unmodified lines48 ? "territory"49 : "other";50 };51 72-/** Whether a file's block holds no text lines to draw: git's binary notes. */52 const isBinary = (block: string) =>53 /^(?:Binary files .* differ|GIT binary patch)$/mu.test(block);54 76-/**77- * The files `patch` changes, parsed and counted, territory first, then78- * tests, then the rest. `key` names the change, so the drawing caches each79- * file's highlighting once.80- */55 export const patchFiles = (56 patch: string,57 territory: readonly string[],58 key: string40 unmodified lines99 treeOrder(a.file.path, b.file.path)100 );101 };102 129-/** One numbered line of a patch, on its side. */103 export interface PatchLine {104 readonly kind: "addition" | "context" | "deletion";132- /** Its number in the new file (context and additions) or the old one (deletions). */105 readonly number: number;106 readonly text: string;107 }108 137-/** One row of a patch's unified view: a line, or the unchanged lines a hunk skips. */109 export type PatchRow =110 | { readonly kind: "separator"; readonly lines: number }111 | PatchLine;112 142-/** A line as the diff stores it, without its line ending. */113 const bare = (line: string | undefined) => (line ?? "").replace(/\r?\n$/u, "");114 145-/**146- * `diff` as unified rows, each line numbered from its hunk's header: a147- * context line and an addition by the new file, a deletion by the old.148- */115 export const patchRows = (diff: FileDiffMetadata): readonly PatchRow[] => {116 const rows: PatchRow[] = [];117 118 for (const hunk of diff.hunks) {39 unmodified lines158 159 return rows;160 };161 196-/** The new file's line numbers a diff draws: where an annotation at a line can sit. */162 export const drawnLines = (diff: FileDiffMetadata): ReadonlySet<number> =>163 new Set(164 patchRows(diff).flatMap((row) =>165 row.kind === "addition" || row.kind === "context" ? [row.number] : []2 unmodified linesmodified:apps/web/src/features/finish/finish-files-button.tsx+2 added-5 removed
1 /**2- * The Files button on a finish's page below the shell's width, where the3- * rail is not drawn: it opens the changed files as a sheet from the left,4- * loaded on its first press. `import.meta.env.SSR` is `true` in the5- * Worker's build, so the Worker bundles none of the sheet.2+ * `import.meta.env.SSR` is `true` in the Worker's build, so the Worker bundles3+ * none of the sheet.4 */5 import { FolderTree } from "lucide-react";6 import { lazy, Suspense, useState } from "react";7 2 unmodified lines10 const Sheet = import.meta.env.SSR11 ? undefined12 : lazy(() => import("./finish-files-sheet.tsx"));13 16-/** The changed files below the shell's width: a Files button, and the list as a sheet, loaded on its first press. */14 export const FinishFilesButton = () => {15 const [open, setOpen] = useState(false);16 17 return (20 unmodified linesmodified:apps/web/src/features/finish/finish-files-sheet.tsx-6 removed
1-/**2- * A finish's changed files below the shell's width, as a sheet from the3- * left, loaded on the first press of Files (`finish-rail.tsx`). Choosing a4- * file moves the diff to it, and the sheet closes.5- */1 import { Option } from "effect";2 3 import { Sheet, SheetContent } from "../../components/ui/sheet.tsx";4 import { FinishFiles, useFinish } from "./finish-rail-body.tsx";12 unmodified lines17 <SheetContent side="left" title="Changed files">18 <div19 className="flex h-full min-h-0 flex-col"20 onClick={(event) => {26- // A file chosen moves the diff to it: the sheet has done its work.21 if (22 event.target instanceof Element &&23 event.target.closest("a") !== null24 ) {14 unmodified linesmodified:apps/web/src/features/finish/finish-files.tsx-11 removed
1-/**2- * A finish's changed files as a list the rail (or, below the shell's3- * width, a sheet) holds: the ask's territory first, then tests, then the4- * rest, each a row with its change as a letter (A, M or D, in the diff's5- * tints), its path, its `+n −m`, whether this reader marked it read (a6- * muted check, the word for a screen reader) and whether a refusal pointed7- * into it (the refused cross). Choosing one scrolls the diff to it.8- */1 import { Check, OctagonX } from "lucide-react";2 3 import { diffAnchor } from "../code/paths.ts";4 import { ChangeCounts } from "../code/plain-diff.tsx";11 unmodified lines16 territory: "In the territory",17 tests: "Tests",18 } as const satisfies Record<Part, string>;19 28-/** A path as two parts: its name first, then its folder, muted, which gives way first. */20 const PathWords = ({ path }: { readonly path: string }) => {21 const slash = path.lastIndexOf("/");22 23 return (15 unmodified lines39 read,40 refused,41 }: {42 readonly files: readonly PatchFile[];52- /** The page's own address, which each row adds its file's anchor to. */43 readonly href: string;44 readonly read: ReadonlySet<string>;45 readonly refused: ReadonlySet<string>;56- /** The file the diff stands at. */46 readonly current?: string | undefined;47 }) => (48 <nav49 aria-label="Changed files"75 unmodified linesmodified:apps/web/src/features/finish/finish-plain.tsx-16 removed
1-/**2- * A decider's diff as plain text: what the server sends, and what a reader3- * sees until the browser has drawn the highlighted diff over it (or, on a4- * phone, the one file being read). It takes the code browser's measures5- * (a 44 px sticky file header, 13 px code on 20 px lines, the gutter, the6- * sign column, the diff's own tints), so the drawing arrives in place.7- *8- * Under a line it draws what the page puts there (a refusal that pointed9- * at it, a marker waiting on a decision); a note whose line the diff does10- * not show sits at the top of its file, saying which line it means.11- */1 import { Option } from "effect";2 import type { ReactNode } from "react";3 4 import { diffAnchor } from "../code/paths.ts";2 unmodified lines7 import type { PatchFile, PatchLine } from "./files.ts";8 import { MarkRead } from "./mark-read.tsx";9 import type { MarkedFile } from "./read-marks.ts";10 22-/** Something drawn under one line of one file. */11 export interface LineNote {12 readonly path: string;13 readonly line: number;14 readonly node: ReactNode;18 unmodified lines33 34 const GUTTER =35 "border-background min-w-[calc(6ch+2px)] border-r-2 pr-[1ch] pl-[2ch] text-right tabular-nums select-none";36 49-/** The notes on one file: under a line it draws, and those it does not. */37 const notesFor = (file: PatchFile, notes: readonly LineNote[]) => {38 const mine = notes.filter(({ path }) => path === file.file.path);39 40 const shown = Option.match(file.diff, {7 unmodified lines48 elsewhere: mine.filter(({ line }) => !shown.has(line)),49 };50 };51 65-/** One file's lines, with its notes under theirs. */52 const Lines = ({53 file,54 notes,55 }: {69 unmodified lines125 refused,126 }: {127 readonly files: readonly PatchFile[];128 readonly notes: readonly LineNote[];143- /** The files this reader marked read; each header offers "Mark read" when given. */129 readonly read?: ReadonlySet<string> | undefined;130 readonly onMark?: ((file: MarkedFile, read: boolean) => void) | undefined;146- /** The files a refusal points into, marked in their headers. */131 readonly refused?: ReadonlySet<string> | undefined;132 readonly folded?: ReadonlySet<string> | undefined;133 readonly onFold?: ((path: string, folded: boolean) => void) | undefined;134 }) => (59 unmodified linesmodified:apps/web/src/features/finish/finish-rail-body.tsx-12 removed
1-/**2- * A finish's changed files, for the rail (`finish-rail.tsx`, which loads3- * this in the browser) and, below the shell's width, a sheet behind a4- * Files button in the diff's toolbar: territory first, each with its5- * change, its counts, this reader's read mark and the refused cross.6- *7- * Both read the page's own loader data (its match), so the list and the8- * diff come from one read, and the read marks from one store.9- */1 import { DecisionSubject } from "@repo/protocol/domain/decision";2 import { useLocation, useMatch } from "@tanstack/react-router";3 import { Option, Schema } from "effect";4 import { useMemo } from "react";6 unmodified lines11 import { marksKey, useReadMarks } from "./read-marks.ts";12 13 const decode = Schema.decodeUnknownOption(DecisionPageData);14 24-/** The finish on the page, its files in order; none for any other page. */15 export const useFinish = () => {16 const data: unknown = useMatch({17 from: "/$owner/$project/decisions/$decision",18 select: (match) => match.loaderData,31 unmodified lines50 };51 52 export type Finish = Option.Option.Value<ReturnType<typeof useFinish>>;53 64-/** The finish's files, with this reader's marks and the file the diff stands at. */54 export const FinishFiles = ({ finish }: { readonly finish: Finish }) => {55 const marked = useMemo(56 () =>57 finish.files.map(({ file, patchId }) => ({ patchId, path: file.path })),30 unmodified lines88 </>89 );90 };91 103-/** The finish's changed files, in the rail's slot. */92 export const FinishRailFiles = () =>93 Option.match(useFinish(), {94 onNone: () => null,95 onSome: (found) => <FinishFiles finish={found} />,4 unmodified linesmodified:apps/web/src/features/finish/finish-rail.tsx+2 added-9 removed
1 /**2- * The rail of a decision's page. A route's `staticData` loads with every3- * page, so this module stays light: it tells a finish from any other4- * decision by the shape of the page's data alone, holds the way back to5- * Today and to who decides for any other, and for a finish loads its6- * changed files in the browser7- * (`finish-rail-body.tsx`), with the list's place held until they come.2+ * A route's `staticData` loads with every page, so this module stays light and3+ * loads a finish's files in the browser.4 */5 import { ClientOnly, useMatch } from "@tanstack/react-router";6 import { Option, Schema } from "effect";7 import { lazy, Suspense } from "react";8 9 import { AppLink } from "../shared/link.tsx";10 import { RailSlot } from "../shared/shell/rail-slot.tsx";11 16-/** A finish's page data, by its shape: found, and about a finish. */12 const FinishPageData = Schema.Struct({13 read: Schema.TaggedStruct("Found", {14 decision: Schema.Struct({15 subject: Schema.TaggedStruct("Finish", {}),2 unmodified lines18 });19 20 const isFinishPage = Schema.decodeUnknownOption(FinishPageData);21 27-/** A row of the slot, as the rail draws its rows. */22 const ROW =23 "text-ui text-foreground hover:bg-surface mx-2 flex h-8 min-w-0 items-center px-2 no-underline transition-colors duration-[120ms] focus-visible:outline-offset-[-2px]";24 25 const Body = import.meta.env.SSR26 ? undefined27 : lazy(() => import("./finish-rail-body.tsx"));28 35-/** The list's place: its count line's height, until the list is drawn. */29 const Placeholder = () => (30 <div aria-hidden="true" className="border-rule h-10 shrink-0 border-b" />31 );32 43 unmodified linesmodified:apps/web/src/features/finish/finish-view.tsx+1 added-50 removed
1-/**2- * A `Finish` decision's page: the one page where a decider reads an3- * answer's diff, laid out as the code browser is. The changed files sit in4- * the rail (territory first, then tests, then the rest); the diff fills5- * main, file by file under sticky headers, each with a "Mark read" button,6- * and a refusal from an earlier round sits under the line it pointed at.7- * The want, the verdict, the choices and the three lines that finish it8- * from a clone sit in the inspector from 1440 px; below that, the choices9- * stay in a bar at the foot of the diff. On a phone the page reads the10- * want, the verdict and the choices first, then the diff one file at a11- * time.12- *13- * The read marks are this browser's alone (`read-marks.ts`). A head pushed14- * to the answer while the page is open says so above the diff, and the15- * diff stays as it was until the reader reloads it.16- *17- * What the page reads from the decision's evidence: `patch`, the answer's18- * unified diff, and `fork`, the name of the answer's fork19- * (`<key>--<ask>--<handle>`), where a finish fetches the head and pushes20- * its commits. Without a patch the page shows the lines and no diff;21- * without a fork it names the fork by the claim fork's pattern and leaves22- * the answerer's handle for the decider to fill in. The web never calls23- * `finish` itself.24- */1+/** The web never calls `finish` itself. */2 import { Brand } from "@repo/brand";3 import type { Verdict } from "@repo/protocol/domain/answer";4 import type { Ask } from "@repo/protocol/domain/ask";5 import type { ChangedFile } from "@repo/protocol/domain/code";40 unmodified lines46 export type { FinishDecision } from "./patch.ts";47 48 const LINK = "decoration-rule underline hover:decoration-current";49 73-/** Where the answer's head lives: its fork's git URL on the platform. */50 const remoteOf = (decision: FinishDecision, platformUrl: string) =>51 Arr.findFirst(decision.evidence, ({ label }) => label === FORK_LABEL).pipe(52 Option.map(53 ({ href, value }) => href ?? `${platformUrl}/${value.trim()}.git`3 unmodified lines57 `${platformUrl}/${decision.project}--${decision.subject.ask}--<answerer>.git`58 )59 );60 85-/** The three lines that take the answer's head into a clone, put the decider's commits on it, and finish it. */61 export const finishLines = (62 decision: FinishDecision,63 platformUrl: string,64 verdict: Verdict | undefined17 unmodified lines82 },83 ] as const;84 };85 111-/** The three finish lines, numbered, each under what it does. */86 const FinishLines = ({87 decision,88 platformUrl,89 verdict,18 unmodified lines108 </p>109 </FactBlock>110 );111 138-/** What the ask wants, in one paragraph, and the way to it. */112 const WantFacts = ({ ask }: { readonly ask: Ask }) => (113 <FactBlock label="The ask wants">114 <p className="text-want font-normal" data-said="">115 {ask.brief.want}3 unmodified lines119 </AppLink>120 </FactBlock>121 );122 150-/** The verdict on the head: its line, and the gate's stages in a strip. */123 const VerdictFacts = ({ verdict }: { readonly verdict: Verdict }) => (124 <FactBlock label={`Verdict at ${shortSha(verdict.head)}`}>125 <div className="flex flex-col gap-2" data-outcome={verdict.outcome._tag}>126 <StatusLine17 unmodified lines144 readonly now: DateTime.Utc;145 readonly onDecide: (input: DecideInput) => void;146 readonly busy?: boolean;147 readonly soon?: boolean;176- /** The diff's files, territory first (`patchFiles`); none without a patch. */148 readonly files: readonly PatchFile[];178- /** Refusals from the answer's rounds that point into its files. */149 readonly placed?: readonly PlacedRefusal[];180- /** The head last pushed to the answer, when it is not the one decided on. */150 readonly newerHead?: CommitSha | undefined;182- /** The files this reader marked read. */151 readonly read?: ReadonlySet<string>;152 readonly onMark?: (file: MarkedFile, read: boolean) => void;153 readonly split?: boolean;154 readonly onSplit?: (split: boolean) => void;155 readonly folded?: ReadonlySet<string> | undefined;156 readonly onFold?: (path: string, folded: boolean) => void;157 readonly onFoldAll?: (folded: boolean) => void;190- /** Draw the diff in the browser over the plain text (the page does; a test reads the plain text). */158 readonly draw?: boolean;192- /** The Files button, below the shell's width. */159 readonly filesButton?: ReactNode;194- /** Settle the record's mark: the choice was taken while the page was open. */160 readonly stamp?: boolean;196- /** What the reader's last choice came back with, when it failed. */161 readonly failure?: ReactNode;162 }163 164 const NO_FILES: ReadonlySet<string> = new Set();165 166 const NO_REFUSALS: readonly PlacedRefusal[] = [];167 204-/** No whole files: a decision's diff comes parsed from its patch. */168 const NO_CHANGED: readonly ChangedFile[] = [];169 207-/** A file's state in its header: a refusal pointed into it, or this reader read it. */170 const slotOf = (171 path: string,172 header: ReactNode,173 refused: ReadonlySet<string>,5 unmodified lines179 180 return read.has(path) ? { header, path, status: "read" } : { header, path };181 };182 221-/** The refusals among `placed`, as notes under their lines. */183 const refusalNotes = (placed: readonly PlacedRefusal[]): readonly LineNote[] =>184 placed.map((each) => ({185 line: each.line,186 node: <RefusalNote placed={each} />,187 path: each.path,188 }));189 229-/** A head pushed after the one the decision names: said above the diff, never swapped in. */190 const NewerHead = ({ head }: { readonly head: CommitSha }) => (191 <output192 className={`border-rule bg-surface flex flex-wrap items-center gap-x-3 gap-y-2 border-b py-2 ${GUTTER}`}193 data-newer-head={head}15 unmodified lines209 </Button>210 </output>211 );212 253-/**254- * The choices kept at the foot of the diff below 1440 px, where the255- * inspector is a sheet; once taken, the choice's record in their place.256- */213 const DecisionBar = ({214 busy,215 decision,216 now,42 unmodified lines259 )}260 </section>261 );262 307-/** A choice that came back failed: said where the reader looks next, and politely. */263 const Failure = ({264 children,265 className = "",266 }: {4 unmodified lines271 {children}272 </div>273 );274 320-/** On a phone: the diff one file at a time, with the way to the next and the one before. */275 const OneFileAtATime = ({276 files,277 notes,278 onMark,66 unmodified lines345 </section>346 );347 };348 395-/** The diff from a tablet's width: plain from the server, drawn over in the browser, the choices at its foot. */349 const WideDiff = ({350 busy,351 decision,352 draw,93 unmodified lines446 </div>447 );448 };449 497-/** On a phone: the want, the verdict and the choices first, then the diff a file at a time. */450 const PhoneFinish = ({451 ask,452 busy,453 decision,67 unmodified lines521 )}522 </div>523 );524 573-/** The inspector's facts: the want, the verdict, the decision, the lines that finish it, the diff's stats. */525 const FinishFacts = ({526 ask,527 busy,528 decision,138 unmodified linesmodified:apps/web/src/features/finish/mark-read.tsx-6 removed
1-/**2- * A changed file's "Mark read" button, in its header: the word in sight3- * (never an icon alone), pressed once read, and the file's path for a4- * screen reader. A mark is this reader's alone (`read-marks.ts`).5- */1 import { Check } from "lucide-react";2 3 import type { PatchFile } from "./files.ts";4 import type { MarkedFile } from "./read-marks.ts";5 11-/** A file's "Mark read" button: its word in sight, and what it marks for a screen reader. */6 export const MarkRead = ({7 file,8 onMark,9 read,24 unmodified linesmodified:apps/web/src/features/finish/patch.ts+4 added-29 removed
1-/**2- * The answer's diff, where a `Finish` decision carries it: the evidence3- * entry labelled `patch`, a unified diff (`git diff <base> <head>`). No other4- * decision carries one (`Decision.evidence` holds no diff unless5- * the kind allows a finish), and the web never fetches one another way.6- */1 import { DecisionSubject } from "@repo/protocol/domain/decision";2 import type { Decision } from "@repo/protocol/domain/decision";3 import { Array as Arr, Option } from "effect";4 11-/** The evidence label a `Finish` decision's diff travels under. */5 export const PATCH_LABEL = "patch";6 14-/** The evidence label naming the answer's fork, the repo a finish fetches from and pushes to. */7 export const FORK_LABEL = "fork";8 17-/** A decision whose subject is a finish. */9 export type FinishDecision = Decision & {10 readonly subject: Extract<DecisionSubject, { readonly _tag: "Finish" }>;11 };12 13 const finishes = DecisionSubject.isAnyOf(["Finish"]);14 24-/** Whether a decision is a finish: the one subject whose page shows a diff. */15 export const isFinishDecision = (16 decision: Decision17 ): decision is FinishDecision => finishes(decision.subject);18 29-/** The diff a `Finish` decision carries, if it carries one; never another subject's. */19 export const patchOf = (decision: Decision): Option.Option<string> =>20 isFinishDecision(decision)21 ? Option.map(22 Arr.findFirst(decision.evidence, ({ label }) => label === PATCH_LABEL),23 ({ value }) => value24 ).pipe(Option.filter((patch) => patch.trim().length > 0))25 : Option.none();26 38-// git ends a `---`/`+++` line with a tab when its path holds a space, and39-// `diff -u` puts its timestamp after one: the path stops at the tab.27+// git ends a `---`/`+++` line with a tab when its path holds a space, and `diff28+// -u` puts its timestamp after one: the path stops at the tab.29 const NEW_FILE = /^\+\+\+ (?:b\/)?(?<path>[^\t]+)(?:\t.*)?$/u;30 31 const OLD_FILE = /^--- (?:a\/)?(?<path>[^\t]+)(?:\t.*)?$/u;32 33 const RENAMED = /^rename to (?<path>.+)$/u;34 35 const HEADER = /^diff --git a\/.+ b\/(?<path>.+)$/u;36 48-/** One file's block of a unified diff: the path it ends up at (or the path it leaves). */37 const pathOf = (block: readonly string[]): Option.Option<string> => {38 const first = (pattern: RegExp) =>39 Arr.findFirst(block, (line) => pattern.test(line)).pipe(40 Option.flatMap((line) =>13 unmodified lines54 Option.orElse(() => first(HEADER))55 );56 };57 70-/** The text of each file's block of a unified diff, by the path it ends up at. */58 export const fileBlocks = (patch: string): ReadonlyMap<string, string> => {59 const lines = patch.split("\n");60 const gitHeaders = lines.some((line) => HEADER.test(line));61 20 unmodified lines82 )83 );84 };85 99-/**100- * The files a unified diff changes, in its order: each `diff --git` block's101- * new path (its old path when the file is deleted). A diff without git's102- * headers counts as one block per `---`/`+++` pair.103- */86 export const changedFiles = (patch: string): readonly string[] => [87 ...fileBlocks(patch).keys(),88 ];89 90 /**109- * A short, stable id for one file's change: a polynomial hash over its110- * block of the diff, kept under a 32-bit prime. A new head that changes111- * the file changes its id, so whatever was kept against the old one no112- * longer matches.91+ * A new head that changes the file changes its id, so a mark kept against the92+ * old one no longer matches.93 */94 export const patchIdOf = (text: string): string => {95 let hash = 7;96 5 unmodified lines102 };103 104 const waives = DecisionSubject.isAnyOf(["Waiver"]);105 126-/**127- * The answer's diff a `Waiver` decision carries, when it carries one under128- * the same `patch` label a finish uses: the page draws the marker's file129- * from it, with the marker at its line.130- */106 export const waiverPatchOf = (decision: Decision): Option.Option<string> =>107 waives(decision.subject)108 ? Option.map(109 Arr.findFirst(decision.evidence, ({ label }) => label === PATCH_LABEL),3 unmodified linesmodified:apps/web/src/features/finish/read-marks.ts+3 added-25 removed
1 /**2- * Which of a finish's files its reader has marked read: kept in this3- * browser alone, never sent anywhere, and about files, never a person. A4- * mark is kept against the decision, the file and that file's change (its5- * patch id), and the whole set against the answer's head: a new head6- * pushed to the answer clears them, and a file whose change differs reads7- * unread.8- *9- * The browser's storage may be missing, full or refused (a private window);10- * every read and write is tried, and a refused one keeps nothing, so the11- * page works the same with no marks.12- *13- * The rail and the diff both show the marks; a change made in one is told14- * to the other with an event on the window.2+ * Kept in this browser alone, never sent anywhere. Storage may be missing, full3+ * or refused (a private window), so every read and write is tried and a refused4+ * one keeps nothing.5 */6 import { Option, Result, Schema } from "effect";7 import { useCallback, useEffect, useState } from "react";8 19-/** What one decision's marks are kept as. */9 const Kept = Schema.Struct({10 head: Schema.String,11 read: Schema.Record(Schema.String, Schema.String),12 });13 14 const decodeKept = Schema.decodeUnknownOption(Schema.fromJsonString(Kept));15 27-/** Where one decision's marks are kept. */16 export const marksKey = (project: string, decision: string) =>17 `finish.read:${project}/${decision}`;18 31-/** The event a change to the marks is told by. */19 const CHANGED = "finish-read-marks";20 34-/** A file and its change, as a mark is kept against it. */21 export interface MarkedFile {22 readonly path: string;23 readonly patchId: string;24 }25 40-/** The paths marked read, at `head`, whose change is still the one marked. */26 export const readMarks = (27 storage: Storage | undefined,28 key: string,29 head: string,16 unmodified lines46 : new Set(),47 });48 };49 65-/** Mark `file` read or unread at `head`; marks kept at another head are dropped. A refused write keeps nothing. */50 export const writeMark = (51 storage: Storage | undefined,52 key: string,53 head: string,17 unmodified lines71 72 Result.try(() => storage?.setItem(key, JSON.stringify({ head, read: next })));73 };74 91-/** The browser's storage, when there is one this page may use. */75 const browserStorage = (): Storage | undefined =>76 Result.getOrUndefined(Result.try(() => globalThis.localStorage));77 95-/**96- * The marks on `files` at `head`, read once the page runs (the server97- * draws none), and the way to set one. Every view of the same decision98- * hears a change made in another.99- */78 export const useReadMarks = (79 key: string,80 head: string,81 files: readonly MarkedFile[],27 unmodified linesmodified:apps/web/src/features/front/facts.tsx+1 added-30 removed
1-/**2- * The facts a list of asks shows beside it: with nothing selected on the3- * front page, where to start and every project with its posture; with an4- * ask selected (the front page and a project's home alike), that ask's5- * state, how to take it, where it may change things, its family and its6- * project's posture, and the way to its page.7- *8- * Only what the list read is needed to draw them; what the full ask adds9- * (its territory's paths, its check, its mentor) fills in once the browser10- * has read it, in a block of the same size.11- */1 import { installCommand } from "@repo/agent-kit/install";2 import { Brand } from "@repo/brand";3 import type { Ask, AskListing } from "@repo/protocol/domain/ask";4 import type { ProjectListing } from "@repo/protocol/domain/front-page";16 unmodified lines21 import { StatusLine } from "../shared/status-line.tsx";22 23 const LINK = "decoration-rule underline hover:decoration-current";24 36-/** One numbered step: what it does, then its command. */25 export const Step = ({26 command,27 label,28 }: {5 unmodified lines34 <CommandLine command={command} numbered />35 </div>36 );37 50-/** A link onward, at a block's foot. */38 export const Onward = ({39 children,40 to,41 }: {8 unmodified lines50 <ArrowRight aria-hidden="true" className="size-3.5" strokeWidth={1.75} />51 </AppLink>52 );53 67-/** Where an agent reads the same thing: a server route, so a plain link. */54+/** A server route, so a plain link. */55 export const ForAgents = ({ href }: { readonly href: string }) => (56 <p className="text-ui text-muted-foreground border-rule border-t pt-3 first:border-t-0">57 For agents:{" "}58 <a className={`text-foreground text-mono font-mono ${LINK}`} href={href}>1 unmodified line60 </a>61 </p>62 );63 77-/** The three ways in from the front page: the CLI, the asks it lists, a claim. */64 export const StartHere = ({ webUrl }: { readonly webUrl: string }) => (65 <FactBlock label="Take an ask">66 <Step command={installCommand(webUrl)} label="Install the command line" />67 <Step command={`${Brand.cli} front`} label="List every open ask" />4 unmodified lines72 <ForAgents href="/llms.txt" />73 </FactBlock>74 );75 90-/** A count and its noun: "1 open ask", "7 open asks". */76 export const plural = (count: number, one: string, many: string) =>77 `${count} ${count === 1 ? one : many}`;78 94-/**95- * Every project the platform lists, by its open asks; bars until the list96- * arrives. Each project's posture is its group header's to say, once.97- */79 export const ProjectsFacts = ({80 projects,81 }: {82 readonly projects: readonly ProjectListing[] | undefined;23 unmodified lines106 </ul>107 </FactBlock>108 );109 129-/** Who may take an ask, from what its listing says (the full ask adds the mentor). */110 const whoMayTake = (111 listing: AskListing,112 project: ProjectName,113 full: Ask | undefined8 unmodified lines122 ? "Held for people, not agents"123 : `Anyone vouched in ${project}, or with a record in its area`;124 };125 146-/** A family the selected ask belongs to, as the page knows it. */126 export interface SelectedFamily {127 readonly parent: Ask;128 readonly finale: AskId;129 readonly states: ReadonlyMap<AskId, AskProgress>;130 }131 153-/** The selected ask's project posture, in the platform's words. */132 export interface SelectedPosture {133 readonly label: string;134 readonly posture: Posture;135 }136 159-/**160- * The selected ask: its state, how to take it (the claim numbered first),161- * where it may change things and what judges it, its family, its project's162- * posture, and its page.163- */137 export const SelectedAskFacts = ({138 family,139 full,140 listing,4 unmodified lines145 takeable,146 }: {147 readonly listing: AskListing;148 readonly project: ProjectName;176- /** Whether the viewer may take it (the front page knows); open and unheld when not known. */149 readonly takeable: boolean;178- /** The full ask, once the browser has read it. */150 readonly full: Ask | undefined;151 readonly progress: AskProgress | undefined;152 readonly family: SelectedFamily | undefined;153 readonly posture: SelectedPosture | undefined;74 unmodified linesmodified:apps/web/src/features/front/families.ts+3 added-25 removed
1-// Which listed asks form a family, read from the names a migrate ask's split2-// gives its members: the platform opens a child per module as3-// `<parent>-<module>` and a delete child as `<parent>-delete`, and the4-// parent waits on all of them. A listing names no parent (the full ask does,5-// one read away), so a family is read from what the list holds: an ask that6-// waits on an ask named after it is a family's parent, and its members are7-// the listed asks it waits on, and its delete child.8-//9-// An ask that waits on another not named after it (one fix after another)10-// is no family: it stays a row of its own that reads as waiting.1+// A listing names no parent, so a family is read from names: a split opens2+// `<parent>-<module>` children and a `<parent>-delete` child, and the parent3+// waits on all of them.4 import type { AskListing } from "@repo/protocol/domain/ask";5 import { AskId } from "@repo/protocol/ids";6 14-/** One family, as a list holds it. */7 export interface ListedFamily {8 readonly parent: AskId;17- /** Its members the list holds, in the list's order: the children still open, and the delete child. */9 readonly members: readonly AskId[];19- /** The delete child, which waits on every other child. */10 readonly finale: AskId;11 }12 23-/** The delete child a split gives `parent`. */13 export const finaleOf = (parent: AskId): AskId =>14 AskId.make(`${parent}-delete`);15 27-/** Whether `parent` waits on an ask named after it, as a split names its members. */16 const isParent = ({ ask, blockedBy }: AskListing) =>17 blockedBy.some((blocker) => blocker.startsWith(`${ask}-`));18 31-/** Every family among `listings`, each at its parent's place in the list. */19 export const familiesIn = (20 listings: readonly AskListing[]21 ): readonly ListedFamily[] =>22 listings.flatMap((parent) => {14 unmodified lines37 },38 ];39 });40 54-/** A list's item: an ask of its own, or a family drawn as one row. */41 export type Arranged<L extends AskListing = AskListing> =42 | { readonly kind: "ask"; readonly listing: L }43 | {44 readonly kind: "family";1 unmodified line46 readonly members: readonly L[];47 readonly finale: AskId;48 };49 64-/**65- * `listings` as a list draws them: each family at its parent's place, its66- * members taken out of the list (they are drawn under the parent's fan),67- * every other ask where it was.68- */50 export const arrange = <L extends AskListing>(51 listings: readonly L[]52 ): readonly Arranged<L>[] => {53 const families = familiesIn(listings);23 unmodified lines77 ];78 });79 };80 100-// The listings with each ask's blockers cut to those still listed: an ask101-// that landed has left the list, and nothing waits on it any more (as the102-// front page's entries name only what they still wait on).81 export const stillWaiting = <L extends AskListing>(listings: readonly L[]) => {82 const listed = new Set(listings.map(({ ask }) => ask));83 84 return listings.map((listing) => ({4 unmodified linesmodified:apps/web/src/features/front/filter.ts+2 added-26 removed
1-/**2- * The front page's filter, read from its address3- * (`?kind=bug&take=open&project=datekit`), in a module with no view of its4- * own: the route decodes its search with it before the page's view loads.5- */1 import { Reserve } from "@repo/protocol/domain/ask";2 import type { FrontPageEntry } from "@repo/protocol/domain/front-page";3 import { KindName, ProjectName } from "@repo/protocol/ids";4 import { Option, Schema } from "effect";5 6 import { ASKS_PATH } from "../shared/paths.ts";7 13-/** Asks the viewer may take now: the one value `?take=` has. */8 export const Take = Schema.Literal("open");9 10 export type Take = typeof Take.Type;11 18-/**19- * What the front page is narrowed to: one kind; asks open to take, or held20- * for someone; one project.21- */12 export interface FrontFilter {13 readonly kind?: KindName;14 readonly reserved?: Reserve;15 readonly take?: Take;16 readonly project?: ProjectName;17 }18 29-/** A filter as an address may write it: a key set to `undefined` is no filter. */19 export type FrontFilterInput = {20 readonly [Key in keyof FrontFilter]?: FrontFilter[Key] | undefined;21 };22 4 unmodified lines27 const decodeTake = Schema.decodeUnknownOption(Take);28 29 const decodeProject = Schema.decodeUnknownOption(ProjectName);30 42-/** `{ [key]: value }` when there is a value, and nothing when there is none. */31 const present = <A, B>(value: A | undefined, field: (a: A) => B) =>32 Option.match(Option.fromUndefinedOr(value), {33 onNone: () => ({}),34 onSome: field,35 });36 49-/** `input` with every key left undefined dropped. */37 export const compact = (input: FrontFilterInput): FrontFilter => ({38 ...present(input.kind, (kind) => ({ kind })),39 ...present(input.project, (project) => ({ project })),40 ...present(input.reserved, (reserved) => ({ reserved })),41 ...present(input.take, (take) => ({ take })),42 });43 44 /**58- * The filter in an address's search: each value that decodes is kept, and59- * one that does not is dropped, so a stale or mistyped link shows the whole60- * list rather than an error.45+ * A value that does not decode is dropped, so a stale or mistyped link shows46+ * the whole list rather than an error.47 */48 export const readFilter = (search: {49 readonly kind?: unknown;50 readonly project?: unknown;6 unmodified lines57 reserved: Option.getOrUndefined(decodeReserve(search.reserved)),58 take: Option.getOrUndefined(decodeTake(search.take)),59 });60 75-/** The front page's address for `filter`, in one key order. */61 export const frontPath = (filter: FrontFilterInput) => {62 const search = new URLSearchParams(63 (["kind", "take", "reserved", "project"] as const).flatMap((key) => {64 const value = filter[key];4 unmodified lines69 70 return search === "" ? ASKS_PATH : `${ASKS_PATH}?${search}`;71 };72 88-/** Whether `entry` passes every part of `filter`. */73 export const passes = (filter: FrontFilter) => (entry: FrontPageEntry) =>74 (filter.kind === undefined || entry.ask.kind === filter.kind) &&75 (filter.reserved === undefined || entry.ask.reserve === filter.reserved) &&76 (filter.take === undefined || entry.takeable) &&77 (filter.project === undefined || entry.project === filter.project);78 95-/**96- * The entries `filter` keeps, the ones the viewer may take first; each group97- * keeps the order given (the platform's: newest ask first).98- */79 export const filterEntries = (80 entries: readonly FrontPageEntry[],81 filter: FrontFilter82 ): readonly FrontPageEntry[] => {4 unmodified lines87 ...shown.filter(({ takeable }) => !takeable),88 ];89 };90 111-/**112- * How many entries `filter` would keep with `part` set as given and the113- * rest of the filter as it is: the count beside each filter option.114- */91 export const countWith = (92 entries: readonly FrontPageEntry[],93 filter: FrontFilter,94 part: FrontFilterInput1 unmodified linemodified:apps/web/src/features/front/front-page.tsx+2 added-38 removed
1-/**2- * The front page: the open asks of every project, grouped by project, the3- * ones the viewer may take first; a family drawn as one row with its fan;4- * a toolbar that narrows the list by kind, by who may take an ask and by5- * project; and beside it, where to start, or the selected ask's facts.6- * Props in, markup out: the route reads the entries, the families' parents7- * and their projects' events on the server, the list of projects in the8- * browser (it may arrive after the rows, and moves none of them), and9- * hands them here.10- *11- * Each project's posture is said once, on its group's header, from the12- * list of projects; a row says only its own state. The filter is a link13- * (`/asks?kind=bug&take=open`), so a filtered list is an address to share.14- */1 import { Brand } from "@repo/brand";2 import { Reserve } from "@repo/protocol/domain/ask";3 import type { Ask } from "@repo/protocol/domain/ask";4 import type { ProjectEvent } from "@repo/protocol/domain/event";28 unmodified lines33 import { countWith, filterEntries, frontPath } from "./filter.ts";34 import type { FrontFilter, FrontFilterInput } from "./filter.ts";35 import { EXPLAINER } from "./head.ts";36 51-/** The list's count, as the context bar says it: "10 open asks, 8 open to take". */37 export const frontCount = (shown: readonly FrontPageEntry[]) =>38 `${plural(shown.length, "open ask", "open asks")}, ${39 shown.filter(({ takeable }) => takeable).length40 } open to take`;1 unmodified line42 export interface FrontPageProps {43 readonly entries: readonly FrontPageEntry[];44 readonly filter: FrontFilter;45 readonly now: DateTime.Utc;61- /** Each family's parent as the platform stores it: its children, all of them. */46 readonly parents: readonly Ask[];63- /** The events of each project that holds a family on the page. */47 readonly events: ReadonlyMap<ProjectName, readonly ProjectEvent[]>;65- /** The children that landed while the page was open, by project. */48 readonly stampsOf?: (project: ProjectName) => ReadonlySet<AskId>;67- /** Every project with its posture; none until the list arrives. */49 readonly projects: readonly ProjectListing[] | undefined;50 readonly platformUrl: string;51 readonly webUrl: string;71- /** The selected ask in full, once the browser has read it. */52 readonly selectedAsk?: Ask | undefined;53 }54 75-/** The entries of each project, in the order its first entry comes. */55 const byProject = (shown: readonly FrontPageEntry[]) => {56 const groups = new Map<ProjectName, FrontPageEntry[]>();57 58 for (const entry of shown) {2 unmodified lines61 62 return [...groups];63 };64 86-/** One option of a filter: its words and its count, the current one marked. */65 const FilterOption = ({66 count,67 current,68 label,18 unmodified lines87 </AppLink>88 </li>89 );90 113-/** A filter's options, under its name for a screen reader. */91 const Segment = ({92 children,93 label,94 }: {4 unmodified lines99 {children}100 </ul>101 );102 126-/** The kinds on the page, and the one filtered to, each once, by name. */103 const kindsOf = (entries: readonly FrontPageEntry[], filter: FrontFilter) =>104 [105 ...new Set([106 ...entries.map(({ ask }) => ask.kind),107 ...(filter.kind === undefined ? [] : [filter.kind]),108 ]),109 ].toSorted();110 135-/** The projects on the page, and the one filtered to, each once, by name. */111 const projectsOf = (entries: readonly FrontPageEntry[], filter: FrontFilter) =>112 [113 ...new Set([114 ...entries.map(({ project }) => project),6 unmodified lines121 people: "Held for people",122 } as const satisfies Record<Reserve, string>;123 124 /**150- * The projects as a menu: a disclosure of links, so it opens and narrows151- * with no script. A new address closes it (its key is the filter's152- * project).125+ * A disclosure of links, so it works with no script. Its key is the filter's126+ * project, so a new address closes it.127 */128 const ProjectMenu = ({129 entries,130 filter,35 unmodified lines166 </ul>167 </details>168 );169 196-/** The toolbar: kind; open to take or held for newcomers; project. */170 const Toolbar = ({171 entries,172 filter,173 }: {62 unmodified lines236 </>237 );238 };239 267-/**268- * The front page with no open ask: with no project yet, the command that269- * brings one; with projects, the command that opens an ask.270- */240 const NoAsks = ({241 projects,242 }: {243 readonly projects: readonly ProjectListing[] | undefined;9 unmodified lines253 title="No open asks on any project. A decider opens one from an ask file."254 />255 );256 288-/** A project's group of rows, as the page reads it. */257 interface Group {258 readonly project: ProjectName;259 readonly entries: readonly FrontPageEntry[];260 readonly items: readonly Arranged[];261 readonly states: ReadonlyMap<AskId, AskProgress>;262 }263 296-/** The row ids in the order the page shows them: what `j` and `k` walk. */264 const rowIds = (groups: readonly Group[]) =>265 groups.flatMap(({ items }) =>266 items.map((item) =>267 item.kind === "ask" ? item.listing.ask : item.parent.ask268 )269 );270 304-/** A project's group: its header (name, posture once, counts), then its rows. */271 const ProjectGroup = ({272 group,273 listing,274 now,51 unmodified lines326 const parent = parents.find(327 (ask) => ask.project === project && ask.id === item.parent.ask328 );329 364- // A parent the platform did not give in full: its members stay rows.330 if (parent === undefined) {331 return [332 row(item.parent),333 ...item.members.map((member) => row(member)),20 unmodified lines354 </RowGroup>355 );356 };357 393-/** The selected entry's facts, with its family when it is a member. */358 const Selected = ({359 entry,360 full,361 parents,159 unmodified linesmodified:apps/web/src/features/front/head.ts+2 added-12 removed
1 /**2- * What the list pages put in their head and their first lines, in a module3- * with no view of its own: a route's `head` runs with the route, before its4- * page's view loads, so a view's imports (the Markdown renderer) stay out of5- * every page's first load.2+ * Kept apart from the views: a route's `head` runs before its page's view3+ * loads, so the Markdown renderer stays out of every page's first load.4 */5 8-/** What an ask is, and how one lands: the page's one sentence. */6 export const EXPLAINER =7 "Each ask is one change a project wants, with a check that fails on its main today. Claim one, make the check pass, and push: the gate lands it.";8 12-/** A block that is no paragraph of prose: a heading, a quote, a table, a list, a fence, HTML, an image. */9 const NOT_PROSE = /^(?:#|>|\||[-*+]\s|\d+[.)]\s|```|~~~|<|!\[|\[!\[)/u;10 15-/** A paragraph's inline Markdown as plain words: links and code as their text, emphasis dropped. */11 const plainWords = (text: string) =>12 text13 .replaceAll(/!\[[^\]]*\]\([^)]*\)/gu, "")14 .replaceAll(/\[(?<label>[^\]]*)\]\([^)]*\)/gu, "$<label>")4 unmodified lines19 )20 .replaceAll(/\s+/gu, " ")21 .trim();22 28-/**29- * A README's first sentence, as plain words: the first paragraph of prose30- * (past its title, badges, quotes, tables and lists), to its first full31- * stop. None when the README opens with no paragraph of prose.32- */23 export const ledeOf = (text: string): string | undefined => {24 const paragraph = text25 .split(/\n\s*\n/u)26 .map((block) => block.trim())12 unmodified linesmodified:apps/web/src/features/front/markdown.ts-10 removed
1-/**2- * A list page that also answers agents: the same URL gives the page to a3- * browser and Markdown to a request that asks for it (`Accept:4- * text/markdown`), so the answer varies by `Accept`, and the page names its5- * Markdown as an alternate, in its head and in a `Link` header.6- */7-8-/** `response`, marked as one of several answers to its URL, chosen by `Accept`. */1 export const variedByAccept = (response: Response): Response => {2 const headers = new Headers(response.headers);3 4 headers.set("vary", "Accept");5 6 return new Response(response.body, { headers, status: response.status });7 };8 17-/** The `Link` header naming `href` as the page's Markdown. */9 export const markdownLink = (href: string) =>10 `<${href}>; rel="alternate"; type="text/markdown"`;11 21-/** The head's link naming `href` as the page's Markdown. */12 export const markdownAlternateLink = (href: string) => ({13 href,14 rel: "alternate",15 type: "text/markdown",1 unmodified linemodified:apps/web/src/features/front/stamps.ts+2 added-25 removed
1-/**2- * Which landings an open page stamps: a child of a family that lands while3- * the page is open settles with the stamp, once, and a landing the page's4- * first read already held never does.5- *6- * The first read the page settles on sets `mountSeq` (the highest event7- * number it held); each later read stamps the asks it shows landed that the8- * read before did not, closed by an event after `mountSeq`9- * (`stampsFrom`). Whether the stream or a poll brought the later read, a10- * landing stamps once: the stamped set only grows, so a mark keeps its11- * stamp through every later render rather than settling again.12- */1 import type { ProjectEvent } from "@repo/protocol/domain/event";2 import type { AskId } from "@repo/protocol/ids";3 import { useState } from "react";4 5 import { askStates, lastSeq, stampsFrom } from "../shared/ask-progress.ts";6 import type { AskProgress } from "../shared/ask-progress.ts";7 20-/** What a page remembers between reads of one project's events. */8 export interface StampMemory {22- /** The highest event number of the first read. */9 readonly mountSeq: number;24- /** Where each ask stood in the read before. */10 readonly previous: ReadonlyMap<AskId, AskProgress>;26- /** Every ask stamped so far. */11 readonly stamped: ReadonlySet<AskId>;12 }13 30-/** The page's memory after one more read of `events`; the first read stamps nothing. */14 export const stampStep = (15 memory: StampMemory | undefined,16 events: readonly ProjectEvent[]17 ): StampMemory => {14 unmodified lines32 : new Set([...memory.stamped, ...fresh]),33 };34 };35 53-/** Each project's memory after one more read of each project's events. */36 const stepAll = (37 memory: ReadonlyMap<string, StampMemory>,38 reads: ReadonlyMap<string, readonly ProjectEvent[]>39 ): ReadonlyMap<string, StampMemory> =>3 unmodified lines43 stampStep(memory.get(project), events),44 ])45 );46 65-/**66- * The asks each project's page should stamp, from its events as the page67- * reads them (a new map each time a read changes). A project's first read68- * stamps nothing.69- */47 export const useStamps = (48 reads: ReadonlyMap<string, readonly ProjectEvent[]>49 ): ((project: string) => ReadonlySet<AskId>) => {50 const [seen, setSeen] = useState(reads);51 const [memory, setMemory] = useState(() => stepAll(new Map(), reads));52 76- // A new read: step the memory now, in this render, as React's guide to77- // state from the previous render does, so the stamp draws with the read.53+ // Step the memory in this render, as React's guide to state from the previous54+ // render does, so the stamp draws with the read.55 let current = memory;56 57 if (reads !== seen) {58 current = stepAll(memory, reads);6 unmodified linesmodified:apps/web/src/features/home/home-page.tsx-21 removed
1-/**2- * A signed-in reader's own page: their work (each claim, its ask's want and3- * where its answer stands, with the command that runs next); the decisions4- * waiting for them when they decide somewhere; the open asks they may take;5- * and the way to their record. No score and no count of credit (DESIGN.md).6- * Signed out, it says what the page is and how to sign in. A view: what the7- * server read, and the instant, in; markup out.8- */1 import { Brand } from "@repo/brand";2 import type { Today } from "@repo/protocol/domain/decision";3 import type { FrontPageEntry } from "@repo/protocol/domain/front-page";4 import { Outcome } from "@repo/protocol/domain/outcome";42 unmodified lines47 WORK_SHOWN,48 } from "./read.ts";49 import type { Work } from "./read.ts";50 59-/** What the page is, said to a reader who is not signed in. */51 const WHAT_HOME_IS =52 "Home is your own page: the asks you hold and where each answer stands, the decisions waiting for you, and the asks you may take next.";53 63-/** The decisions the page lists; the rest are on Today. */54 const DECISIONS_SHOWN = 5;55 56 const LINK =57 "decoration-rule hover:decoration-foreground font-medium underline underline-offset-4";58 69-/** A block's empty state, under its header like its rows would be. */59 const Empty = (props: Parameters<typeof EmptyState>[0]) => (60 <li className="pt-3">61 <EmptyState {...props} />62 </li>63 );64 76-/**77- * What runs next on a claim: a refusal's own `next`, or, while the claim78- * runs with nothing refused, its local check before a push.79- */65 const nextOf = ({ answer, claim }: Work) => {66 if (answer !== undefined) {67 return Outcome.guards.Refused(answer.outcome)68 ? {172 unmodified lines241 {children}242 </RowGroup>243 );244 260-/** A decider's waiting decisions, or that none waits. */245 const Waiting = ({ today }: { readonly today: Today }) => {246 const waiting = today.decisions.length + today.overflow;247 248 return (9 unmodified lines258 </DecisionsGroup>259 );260 };261 278-/** The decisions block: a decider's waiting decisions; nothing for anyone else. */262 const DecisionsBlock = ({ decisions }: { readonly decisions: Decisions }) =>263 Decisions.match(decisions, {264 Decides: ({ today }) => <Waiting today={today} />,265 NotDecider: () => null,24 unmodified lines290 Every open ask291 </AppLink>292 );293 311-/** The asks block's empty state: none to take, or none came. */294 const NoAsks = ({ title }: { readonly title: string }) => (295 <Empty command={`${Brand.cli} front`} onward={EVERY_ASK} title={title} />296 );297 316-/** The asks the reader may take, or why none shows. */298 const AskList = ({ asks }: { readonly asks: Takeable }) =>299 Takeable.match(asks, {300 Listed: ({ asks: listed }) =>301 listed.length === 0 ? (15 unmodified lines317 <AskList asks={asks} />318 </RowGroup>319 );320 340-/** Who is signed in, the way to their record, and the way to import a repo. */321 const Record = ({ handle }: { readonly handle: Handle }) => (322 <>323 Signed in as <HandleLink handle={handle} />.{" "}324 <AppLink className={LINK} to={personPath(handle)}>26 unmodified lines351 </div>352 </Workspace>353 );354 375-/** Signed out: what the page is, the way in, and the command. */355 const SignedOut = () => (356 <Workspace crumbs={[{ label: "Home" }]} title="Home">357 <div className="flex max-w-[70ch] flex-col items-start gap-3">358 <p className="text-body">{WHAT_HOME_IS}</p>27 unmodified linesmodified:apps/web/src/features/home/read.ts-42 removed
1-/**2- * What `/home` reads, in a module with no view of its own: a route's loader3- * runs before its page's view loads.4- *5- * - `HomeRead`: the reader's work (each claim from `status`, its ask's want6- * and its latest answer), their Today when they decide somewhere, the7- * open asks they may take (`frontPage`, read as them), or why there is8- * none of it.9- * - `readHome`: that read, made with whatever `Client` the caller gives10- * (the server's, carrying the reader's own session).11- */1 import { Client } from "@repo/protocol/contracts";2 import { AnswerView } from "@repo/protocol/domain/answer";3 import { ClaimView } from "@repo/protocol/domain/claim";4 import { Today } from "@repo/protocol/domain/decision";13 unmodified lines18 } from "effect";19 20 import { isSignedOut } from "../today/read.ts";21 33-/** The asks the page lists: the first few the reader may take; the rest are at `/asks`. */22 const ASKS_SHOWN = 8;23 36-/** The claims the page lists, running first, then the newest; the rest are in `status`. */24 export const WORK_SHOWN = 10;25 39-/** How many reads of one kind the page makes at once. */26 const AT_ONCE = 4;27 42-/** One claim of the reader's, its ask's want, and its latest answer. */28 export const Work = Schema.Struct({29 answer: Schema.optionalKey(AnswerView),30 claim: ClaimView,46- /** Absent when the ask did not come: the row names it by its id. */31 want: Schema.optionalKey(Schema.NonEmptyString),32 });33 34 export type Work = typeof Work.Type;35 52-/** The decisions block: the reader's Today, or why there is none. */36 export const Decisions = Schema.TaggedUnion({37 Decides: { today: Today },38 NotDecider: {},39 Unreachable: {},40 });41 42 export type Decisions = typeof Decisions.Type;43 61-/** The asks block: the first the reader may take, or that the list did not come. */44 export const Takeable = Schema.TaggedUnion({45 Listed: { asks: Schema.Array(FrontPageEntry) },46 Unreachable: {},47 });48 49 export type Takeable = typeof Takeable.Type;50 69-/** What the page read for its reader: their work, or why there is none. */51 export const HomeRead = Schema.TaggedUnion({52 Read: {53 asks: Takeable,54 decisions: Decisions,55 handle: Handle,75- /** Every claim the reader holds, of which `work` is the first `WORK_SHOWN`. */56 held: Schema.Int,77- /** How many of those are still running. */57 running: Schema.Int,58 work: Schema.Array(Work),59 },60 SignedOut: {},1 unmodified line62 });63 64 export type HomeRead = typeof HomeRead.Type;65 87-/** What the loader sends: the read, and the instant it was made. */66 export const HomePageData = Schema.Struct({67 now: Schema.DateTimeUtcFromString,68 read: HomeRead,69 });70 71 export type HomePageData = typeof HomePageData.Type;72 95-/** A claim still running: its holder's to push to. */73 export const isRunning = (claim: ClaimView) =>74 claim.state === "live" || claim.state === "warned";75 76 const openedOrder = Order.mapInput(77 DateTime.Order,78 (claim: ClaimView) => claim.openedAt79 );80 104-/** Running claims first, then the newest. */81 const workOrder: Order.Order<ClaimView> = Order.combine(82 Order.mapInput(Order.Boolean, (claim: ClaimView) => !isRunning(claim)),83 Order.flip(openedOrder)84 );4 unmodified lines89 );90 91 const isNotDecider = Schema.is(NotDecider);92 117-/** Where a claim's ask lives: one key per (project, ask). */93 export const askKey = ({ ask, project }: ClaimView) => `${project}/${ask}`;94 120-/**121- * The asks whose id the reader's claims hold in more than one project.122- * `status` names an answer's ask but not its project, so those asks' answers123- * are read again one project at a time.124- */95 const sharedAsks = (claims: readonly ClaimView[]) =>96 new Set(97 Object.entries(Arr.groupBy(claims, ({ ask }) => ask)).flatMap(98 ([ask, holding]) =>99 new Set(holding.map(({ project }) => project)).size > 1 ? [ask] : []100 )101 );102 133-/** The reader's answers in each of `projects`; a project that did not answer gives none. */103 const answersIn = (projects: readonly ProjectName[]) =>104 Effect.gen(function* () {105 const client = yield* Client;106 9 unmodified lines116 )117 );118 });119 151-/** Each shown claim's ask's want, by `askKey`; an ask that did not come is left out. */120 const wantsOf = (claims: readonly ClaimView[]) =>121 Effect.gen(function* () {122 const client = yield* Client;123 const asks = Arr.dedupeWith(claims, (a, b) => askKey(a) === askKey(b));10 unmodified lines134 ).pipe(Effect.map((found) => found.flat()))135 );136 });137 170-/** The claims the page lists: running first, then the newest, the first `WORK_SHOWN`. */138 const shownOf = (claims: readonly ClaimView[]) =>139 Arr.sort(claims, workOrder).slice(0, WORK_SHOWN);140 174-/**175- * The reader's first claims, each with its want and its latest answer. An176- * answer belongs to the newest claim on its ask in its project; an older177- * claim on the same ask shows its own state. An ask whose id the reader178- * holds in two projects takes its answers from `again`, read per project.179- */141 export const pairWork = ({142 again,143 answers,144 claims,5 unmodified lines150 readonly wants: ReadonlyMap<string, string>;151 }): readonly Work[] => {152 const shared = sharedAsks(claims);153 193- /** The claim each (project, ask) gives its answer to: the newest, set last. */154 const newest = new Map(155 Arr.sort(claims, openedOrder).map(156 (claim) => [askKey(claim), claim] as const157 )27 unmodified lines185 }),186 }));187 };188 229-/** `pairWork` over what the platform answers: the wants, and answers read again where needed. */189 const workOf = (claims: readonly ClaimView[], answers: readonly AnswerView[]) =>190 Effect.gen(function* () {191 const shown = shownOf(claims);192 const shared = sharedAsks(claims);14 unmodified lines207 208 return pairWork({ again, answers, claims, wants });209 });210 252-/** The reader's home, or why there is none, encoded for the page. */211 export const readHome = Effect.gen(function* () {212 const client = yield* Client;213 214 const [status, today, front] = yield* Effect.all(51 unmodified linesmodified:apps/web/src/features/import/client-owner.tsx-12 removed
1-/**2- * The owner select, drawn in the browser only. The server renders its3- * stand-in: the trigger as it will look, holding the choice in sight and4- * in the form (a hidden input), never a native `<select>`; after5- * hydration the browser loads the kit's select over it6- * (`owner-select.tsx`), whose trigger takes the same `TRIGGER`.7- * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic8- * import below is dead code there and the Worker bundles none of it.9- */1 import type { Owner } from "@repo/protocol/ids";2 import { ClientOnly } from "@tanstack/react-router";3 import { ChevronDown } from "lucide-react";4 import { lazy, Suspense } from "react";5 6 export interface OwnerSelectProps {16- /** The owners to choose from, the default first. */7 readonly choices: readonly Owner[];8 readonly labelledBy: string;9 readonly describedBy: string;10 readonly onChange: (value: Owner) => void;11 readonly value: Owner | undefined;12 }13 24-/** The trigger's size, the kit's select and the stand-in alike. */14 export const TRIGGER =15 "tablet:text-ui tablet:h-9 h-11 w-full max-w-sm text-base";16 17 const SelectLater = import.meta.env.SSR18 ? undefined19 : lazy(() => import("./owner-select.tsx"));20 32-/** The select's place before it is drawn: its trigger, showing the choice. */21 const StandIn = ({ describedBy, labelledBy, value }: OwnerSelectProps) => (22 <>23 <button24 aria-describedby={describedBy}30 unmodified linesmodified:apps/web/src/features/import/import-form.tsx-38 removed
1-/**2- * The import form: a signed-in person pastes a public repo's HTTPS URL,3- * may name a branch, picks the owner and the name, and presses Import. The4- * owner and the name follow the URL until the person changes them: the5- * URL's source namespace (`github.com/pallets`) when its host is one the6- * platform knows, else their handle; the URL's last segment as the name.7- * At a source namespace's address the owner is the address's, fixed.8- * Signed out, it says what would be imported and links to sign-in, coming9- * back to `here`. Props in, markup out: the route reads who is signed in,10- * sends the payload, and goes to the project once it is made.11- *12- * Nothing is imported until Import is pressed; nothing here asks a host13- * anything.14- */1 import { Brand } from "@repo/brand";2 import type {3 Handle,4 Owner,19 unmodified lines24 prefillFrom,25 } from "./prefill.ts";26 import type { ImportPayload } from "./prefill.ts";27 42-/** What the form starts with: a URL, and the owner and name it gives. */28 export interface ImportPrefill {29 readonly url: string;30 readonly owner?: SourceNamespace | undefined;31 readonly name?: ShortName | undefined;32 }33 49-/** Who is importing, and what became of the last press. */34 export interface Importer {51- /** The handle signed in in this browser; none signed out. */35 readonly handle: Option.Option<Handle>;53- /** Whether the browser is still learning who is signed in. */36 readonly checking?: boolean | undefined;55- /** Whether an import is on its way: the button waits. */37 readonly busy?: boolean | undefined;57- /** Sends the payload; the route goes to the project once it is made. */38 readonly onImport?: ((payload: ImportPayload) => void) | undefined;59- /** What the last import came back with, when it was refused. */39 readonly refusal?: ReactNode | undefined;40 }41 42 export interface ImportFormProps extends Importer {43 readonly prefill?: ImportPrefill | undefined;65- /** The owner the address fixes, at a source namespace's address. */44 readonly fixedOwner?: SourceNamespace | undefined;67- /** The page's own address, where sign-in comes back to. */45 readonly here: string;46 }47 71-/** The import as a command, for a reader in a terminal. */48 export const importCommand = (project = "<owner>/<name>", url = "<url>") =>49 `${Brand.cli} init --project ${project} --import ${url}`;50 51 const LINK = "decoration-rule font-medium underline hover:decoration-current";52 77-/** A field's label and the words under it. */53 const LABEL = "text-ui font-medium";54 55 const HINT = "text-label text-muted-foreground font-normal";56 82-/**83- * A text field in mono: 16 px on a phone, so it does not zoom on focus, and84- * without ligatures, as code shows what was typed (`://` stays three).85- */57 const MONO_FIELD =58 "tablet:h-9 tablet:text-mono h-11 font-mono text-base [font-feature-settings:'calt'_0,'liga'_0]";59 89-/** What Import says, by where the form stands: why it waits, or what it does. */60 const IMPORT_WORDS = {61 busy: "Importing…",62 noName: "Name the project",63 noOwner: "No owner you may import under",2 unmodified lines66 } as const;67 68 type FormState = keyof typeof IMPORT_WORDS;69 100-/** Where the form stands: importing, waiting on a field, or ready. */70 const formState = ({71 branch,72 busy,73 owner,79 unmodified lines153 </section>154 );155 };156 188-/** The owner, fixed by the address: in sight, and in the form. */157 const FixedOwner = ({158 hintId,159 owner,160 }: {7 unmodified lines168 <input name="owner" type="hidden" value={owner} />169 </>170 );171 204-/** What the hint under Owner says, by what may be chosen. */172 const ownerHint = (fixed: boolean, choices: readonly Owner[]) => {173 if (fixed) {174 return "The address names it: the project keeps its source's account.";175 }2 unmodified lines178 ? "The URL's own account, or your handle."179 : "Your handle: this URL's host is not one a project may be owned by.";180 };181 215-/** Under Name: the project's address once the name is one, else what a name is. */182 const NameHint = ({183 payload,184 }: {185 readonly payload: Option.Option<ImportPayload>;73 unmodified lines259 onChange={(event) => {260 setUrl(event.target.value);261 }}262 placeholder="https://github.com/pallets/click"297- // At a source namespace's address the URL is the address's own.263 readOnly={busy || fixedOwner !== undefined}264 required265 spellCheck={false}266 type="url"76 unmodified lines343 {refusal}344 345 <div className="flex flex-col gap-2">346 <Button382- // Waiting for a URL or a name, it says so at full strength, dashed383- // like any field still to fill, rather than sitting grey.347 className={`tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4 ${state === "ready" || state === "busy" ? "" : "text-muted-foreground border-dashed disabled:opacity-100"}`}348 data-state={state}349 disabled={state !== "ready"}350 type="submit"13 unmodified lines364 </form>365 );366 };367 405-/** The form, the way to sign in, or the wait while the browser learns who is signed in. */368 export const ImportForm = ({369 busy,370 checking = false,371 fixedOwner,27 unmodified linesmodified:apps/web/src/features/import/import-offer.tsx-13 removed
1-/**2- * The import a source namespace's address offers when nobody has made the3- * project (`/github.com/pallets/click`): the form prefilled with the URL4- * the address rebuilds (read-only), the owner fixed to the namespace, and5- * the name; signed out, the way to sign in. It never imports on its own.6- * The route draws it in place of the not-found when `offerFor` names the7- * address's project. Props in, markup out.8- */1 import {2 isSourceNamespace,3 ownerOf,4 ProjectName,7 unmodified lines12 import { sourceUrlOf } from "./prefill.ts";13 14 const decodeProject = Schema.decodeUnknownOption(ProjectName);15 24-/**25- * The project an address that names none offers to import: its name, when26- * its owner is a source namespace; none for a person's address and for27- * one that names no possible project.28- */16 export const offerFor = (name: string): Option.Option<ProjectName> =>17 Option.filter(decodeProject(name), (project) =>18 isSourceNamespace(ownerOf(project))19 );30 unmodified linesmodified:apps/web/src/features/import/import-page.tsx-12 removed
1-/**2- * `/import`: the import form under the page's head, and beside it what an3- * import does and the same import as a command. A URL in the address4- * (`?url=`) fills the form. Props in, markup out: the route reads who is5- * signed in, sends the payload and goes to the project once it is made.6- */1 import { CommandLine } from "../shared/command.tsx";2 import { FactBlock } from "../shared/facts.tsx";3 import { Workspace } from "../shared/shell/workspace.tsx";4 import { ImportForm, importCommand } from "./import-form.tsx";5 import type { Importer } from "./import-form.tsx";6 13-/** What an import does, and the same import from a terminal. */7 export const ImportFacts = () => (8 <>9 <FactBlock label="What an import does">10 <ul className="text-ui flex list-disc flex-col gap-1.5 pl-4">18 unmodified lines29 url = "",30 here,31 ...importer32 }: Importer & {40- /** The URL the address carries, to fill the form with. */33 readonly url?: string | undefined;42- /** The page's own address, where sign-in comes back to. */34 readonly here: string;35 }) => (45- // Below the shell's width the form comes first, and what an import does46- // follows it, rather than standing between the reader and the form.36 <div className="contents [&_[data-facts=inline]]:hidden">37 <Workspace38 crumbs={[{ label: "Import a repo" }]}39 facts={<ImportFacts />}3 unmodified lines43 >44 <ImportForm45 {...importer}46 here={here}58- // The name follows the URL until the person types one.47 prefill={url === "" ? undefined : { url }}48 />49 <div className="shell:hidden border-rule flex flex-col border-t pt-4">50 <ImportFacts />4 unmodified linesmodified:apps/web/src/features/import/owner-select.tsx-9 removed
1-/**2- * The owner an import is made under, chosen with the kit's select: the3- * URL's source namespace first when its host is one the platform knows,4- * then the person's handle. Drawn in the browser only (`client-owner.tsx`):5- * Base UI's select and its positioning are the browser's to run, and the6- * Worker bundles none of them.7- */1 import {2 Select,3 SelectContent,4 SelectItem,13 unmodified lines18 <Select19 items={choices.map((choice) => ({ label: choice, value: choice }))}20 name="owner"21 onValueChange={(chosen) => {29- // The select hands back one of its items' values: find it, an owner.22 const owner = choices.find((choice) => choice === chosen);23 24 if (owner !== undefined) {25 onChange(owner);17 unmodified lines43 </SelectContent>44 </Select>45 );46 55-// `React.lazy` takes a module's default export.47 export default OwnerSelect;modified:apps/web/src/features/import/prefill.ts-33 removed
1-/**2- * What the import form reads from a pasted URL, and what it sends. Pure:3- * no view, no transport. The owner is the URL's source namespace4- * (`github.com/pallets`) when its host is one the platform knows; the name5- * is the URL's last segment, without `.git`, lowercased. Nothing here asks6- * a host anything: the platform clones the URL when Import is pressed.7- */1 import type { InitProject } from "@repo/protocol/contracts";2 import { ImportSource } from "@repo/protocol/domain/policy";3 import {4 Owner,3 unmodified lines8 } from "@repo/protocol/ids";9 import type { Handle, ProjectName, SourceNamespace } from "@repo/protocol/ids";10 import { Array, Option, Schema } from "effect";11 19-/** What `initProject` takes, from its one schema. */12 export type ImportPayload = typeof InitProject.payloadSchema.Type;13 22-/** What a URL prefills: the owner its host gives, and the name it ends in. */14 export interface Prefill {15 readonly owner: Option.Option<SourceNamespace>;16 readonly name: Option.Option<ShortName>;17 }18 28-// `https://<host>/<path>`: the path's last non-empty segment is the repo's.19 const HTTPS_URL = /^https:\/\/[^/?#\s]+\/(?<path>[^?#\s]+)$/u;20 21 const decodeShortName = Schema.decodeUnknownOption(ShortName);22 23 const decodeOwner = Schema.decodeUnknownOption(Owner);24 25 const decodeSource = Schema.decodeUnknownOption(ImportSource);26 37-/** The name a URL ends in, without `.git` and lowercased; none when it is no name. */27 const nameIn = (url: string): Option.Option<ShortName> => {28 const path = HTTPS_URL.exec(url.trim())?.groups?.path ?? "";29 const last = path.split("/").findLast((segment) => segment !== "") ?? "";30 31 return decodeShortName(last.replace(/\.git$/u, "").toLowerCase());32 };33 45-/** The owner and the name `url` prefills. */34 export const prefillFrom = (url: string): Prefill => ({35 name: nameIn(url),36 owner: sourceNamespaceOf(url.trim()),37 });38 51-/** A source namespace as an owner: every one is (a host is never a reserved word). */39 export const ownerOfNamespace = (40 namespace: SourceNamespace41 ): Option.Option<Owner> => decodeOwner(namespace);42 56-/** A handle as an owner, lowercased; none for one no owner can spell. */43 export const ownerOfHandle = (handle: Handle): Option.Option<Owner> =>44 decodeOwner(handle.toLowerCase());45 60-/**61- * The owners a person may import `url` under: the URL's source namespace62- * first when its host is one the platform knows (the default then), and63- * their own handle.64- */46 export const ownerChoices = (47 handle: Option.Option<Handle>,48 url: string49 ): readonly Owner[] =>1 unmodified line51 ...Option.toArray(Option.flatMap(prefillFrom(url).owner, ownerOfNamespace)),52 ...Option.toArray(Option.flatMap(handle, ownerOfHandle)),53 ]);54 74-/**75- * The URL a source namespace's project was imported from:76- * `github.com/pallets/click` is `https://github.com/pallets/click`.77- */55 export const sourceUrlOf = (project: ProjectName) => `https://${project}`;56 80-/**81- * The source the form names, as `initProject` takes it: the URL and the82- * branch trimmed, the branch only when named. None for a URL the contract83- * would refuse (no public HTTPS URL).84- */57 export const importSourceOf = (form: {58 readonly url: string;59 readonly branch: string;60 }): Option.Option<ImportSource> => {2 unmodified lines63 64 return decodeSource(branch === "" ? { url } : { branch, url });65 };66 95-/**96- * The form's fields as `initProject`'s payload: its source, and the97- * project the owner and the name make. None when the contract would refuse98- * the name or the URL before the platform ever read it.99- */67 export const importPayload = (form: {68 readonly url: string;69 readonly branch: string;70 readonly owner: Owner;8 unmodified linesmodified:apps/web/src/features/import/use-importer.tsx-20 removed
1-/**2- * The import form's wiring, for the two pages that draw it (`/import` and3- * a source namespace's address nobody has made): who is signed in, read in4- * the browser; `importAtom`, sent only when Import is pressed; the move to5- * the project once it is made; and a refusal, drawn as the platform gave6- * it, under the form.7- */1 import { useAtom, useAtomValue } from "@effect/atom-react";2 import { ownerOf } from "@repo/protocol/ids";3 import type { ProjectName } from "@repo/protocol/ids";4 import { useLocation, useNavigate, useRouter } from "@tanstack/react-router";6 unmodified lines11 import { whoAtom } from "../auth/who.ts";12 import { ProposalFailure } from "../proposal/failure.tsx";13 import type { Importer } from "./import-form.tsx";14 22-/**23- * Where an import that made `made` goes from a page at `at`: nowhere when24- * it is the project this address names (its page reads it again), else to25- * the project's page.26- */15 export const afterImport = (made: ProjectName, at?: ProjectName) =>16 made === at17 ? Option.none()18 : Option.some({19 params: { owner: ownerOf(made), project: made },20 to: "/$owner/$project" as const,21 });22 35-/**36- * Who is importing and what became of the last press. `at` is the project37- * this page's address names, if any: a project made there is read again38- * where it stands; any other is gone to.39- */23 export const useImporter = (at?: ProjectName): Importer => {24 const navigate = useNavigate();25 const router = useRouter();26 const here = useLocation({ select: hereOf });27 const who = useAtomValue(whoAtom);28 const [imported, send] = useAtom(importAtom);46- // Set once this page sends: a project the atom still holds from an47- // earlier visit never moves the page.29 const [sent, setSent] = useState(false);30 const made = sent ? Option.getOrUndefined(importMade(imported)) : undefined;31 32 useEffect(() => {1 unmodified line34 return;35 }36 37 Option.match(afterImport(made, at), {57- // The loader read this address as no project: it reads it again.38 onNone: () => {39 void router.invalidate();40 },41 onSome: (to) => {20 unmodified linesmodified:apps/web/src/features/landing/landing-page.tsx-24 removed
1-/**2- * The landing: what the platform is, said once, and the way to the open3- * asks first. Its evidence is the screen `git push` prints when the gate4- * refuses, set as git sets it, not a picture of one. Every sentence on it is5- * the README's or the glossary's. A view: the platform's address, the web's6- * own and the projects in; markup out.7- */1 import { installCommand } from "@repo/agent-kit/install";2 import { Brand } from "@repo/brand";3 import type { ReactNode } from "react";4 16 unmodified lines21 import { LandingProjects } from "./projects.ts";22 import { pushTranscript } from "./transcript.ts";23 import { LEDE, WHAT_IT_IS } from "./words.ts";24 32-/** A link in a plain row (the top, the foot): ink, underlined only on hover. */25 const ROW_LINK = "no-underline hover:underline";26 35-/** The primary action: an ink button that is a link. */27 const PRIMARY = buttonVariants({ className: "no-underline" });28 38-/** Where an agent's reference is. */29 const AGENTS_PATH = "/agents";30 41-/** Text git prints or takes, inside a sentence. */31 const Code = ({ children }: { readonly children: ReactNode }) => (32 <code className={ID}>{children}</code>33 );34 46-/** The branch's name, as git takes it. */35 const MAIN = "main";36 49-/** The lede, its one branch name set as git takes it. */37 const Lede = () => {38 const [before, after] = LEDE.split(MAIN);39 40 return (4 unmodified lines45 </>46 );47 };48 62-/** One part of the page under its name, parted from the last by a hairline. */49 const Part = ({50 children,51 id,52 title,12 unmodified lines65 {children}66 </section>67 );68 83-/** A noun a contributor meets, and what GLOSSARY.md says it is. */69 interface Noun {70 readonly noun: string;71 readonly means: ReactNode;72 }73 89-/** The four nouns, in the glossary's words. */74 const NOUNS: readonly Noun[] = [75 {76 means: (77 <>19 unmodified lines97 noun: "Refusal",98 },99 ];100 117-/** The core loop, in the README's six lines. */101 const LOOP: readonly ReactNode[] = [102 <>103 A decider opens an ask; <Code>{`${Brand.cli} ask open`}</Code> lands it only104 once its check fails on <Code>main</Code> twice the same way, by an17 unmodified lines122 every person, or answers with a refusal.123 </>,124 ];125 143-/** One thing a platform can do that a setting cannot: the README's lead, and its words. */126 interface Power {127 readonly lead: string;128 readonly says: ReactNode;129 }130 149-/** What a platform can do that a setting on a code host cannot, in the README's words. */131 const POWERS: readonly Power[] = [132 {133 lead: "Judge with checks the answer cannot touch.",134 says: (34 unmodified lines169 ),170 },171 ];172 192-/** The wordmark and the ways in, as a plain row. */173 const Top = () => (174 <header className="border-rule flex flex-wrap items-center justify-between gap-x-6 gap-y-2 border-b py-4">175 <AppLink className="text-want font-semibold no-underline" to="/">176 {Brand.name}14 unmodified lines191 </nav>192 </header>193 );194 215-/** A line of the screen, with the refusal's tag in the refused colour wherever git names it. */195 const Printed = ({196 tag,197 text,198 }: {17 unmodified lines216 </>217 );218 };219 241-/** The push, and what git prints back when the gate refuses it. */220 const Transcript = ({ platformUrl }: { readonly platformUrl: string }) => {221 const { command, lines, tag } = pushTranscript(platformUrl);222 223 return (22 unmodified lines246 </figure>247 );248 };249 272-/** The projects on the platform, each with its posture, or that the list did not come. */250 const Projects = ({ projects }: { readonly projects: LandingProjects }) =>251 LandingProjects.match(projects, {252 Listed: ({ projects: listed }) => (253 <ul className="flex flex-col">16 unmodified lines270 ),271 Unreachable: () => <UnreachableNotice />,272 });273 297-/** The landing, as everyone reads it. */274 export const LandingView = ({275 platformUrl,276 projects,277 webUrl,100 unmodified linesmodified:apps/web/src/features/landing/projects.ts-7 removed
1-/**2- * The landing's projects block: the eight that lead (the most open asks3- * first, a tie by name), or that the list did not come. The read that4- * fills it is `read.ts`'s.5- */1 import { ProjectListing } from "@repo/protocol/domain/front-page";2 import { Schema } from "effect";3 4 import { leadingProjects, PROJECTS_SHOWN } from "../shared/project-order.ts";5 11-/** The projects block: the ones that lead, or that the list did not come. */6 export const LandingProjects = Schema.TaggedUnion({7 Listed: { projects: Schema.Array(ProjectListing) },8 Unreachable: {},9 });10 11 export type LandingProjects = typeof LandingProjects.Type;12 19-/** The block from a list that came: the eight that lead. */13 export const listedProjects = (14 projects: readonly ProjectListing[]15 ): LandingProjects =>16 LandingProjects.cases.Listed.make({2 unmodified linesmodified:apps/web/src/features/landing/read.ts+2 added-9 removed
1 /**2- * The landing's read on the server, as nobody, by the route's loader: the3- * platform's project list, so the page arrives with its projects for every4- * reader (a crawler and a reader with no script included) and the edge may5- * keep it. The list ignores the caller, so nobody's read is everyone's.2+ * The list ignores the caller, so nobody's read is everyone's and the edge may3+ * keep it.4 */5 import { Client } from "@repo/protocol/contracts";6 import { Effect } from "effect";7 8 import { LandingProjects, listedProjects } from "./projects.ts";9 12-/**13- * The first few projects, or, when the platform did not answer (a refusal,14- * or a call that died on the way), the block that says so. It never fails:15- * the page leads to the asks either way.16- */10 export const readLandingProjects: Effect.Effect<11 LandingProjects,12 never,13 Client10 unmodified linesmodified:apps/web/src/features/landing/transcript.ts+3 added-11 removed
1 /**2- * The landing's evidence: the screen `git push` prints when an answer3- * strays outside its ask's territory, as the platform's gateway writes it.4- * The refusal's lines come from the one renderer (`explain`, `headline`),5- * so they cannot drift from what the gateway sends; git's own lines around6- * them (`To`, `! [remote rejected]`, `error:`) and the fork are the README's7- * screen, which `apps/platform/test/core-loop.test.ts` asserts from real8- * git.2+ * The refusal's lines come from the one renderer, so they cannot drift from3+ * what the gateway sends; git's own lines around them are what4+ * `apps/platform/test/core-loop.test.ts` asserts from real git.5 */6 import { RepoPath } from "@repo/protocol/ids";7 import { OutOfScope } from "@repo/protocol/refusal";8 import { explain, headline } from "@repo/protocol/render";9 14-/** The fork the push goes to: datekit's `parse-iso`, claimed by alice. */10 const FORK = "datekit--parse-iso--alice.git";11 12 const refusals = [13 new OutOfScope({ paths: [RepoPath.make("README.md")] }),14 ] as const;15 21-/** One line of the screen, and whether git printed it as the platform's (`remote:`). */16 export interface TranscriptLine {17 readonly text: string;18 readonly remote: boolean;19 }20 27-/** The push and what git prints back, against the platform at `platformUrl`. */21 export const pushTranscript = (platformUrl: string) => {22 const remote = `${platformUrl.replace(/\/+$/u, "")}/${FORK}`;23 const tag = headline(refusals);24 25 return {26 command: "git push",34- /** The refusal's tag, which the page sets in the refused colour. */27 tag,28 lines: [29 ...explain(refusals).map((text): TranscriptLine => ({30 remote: true,14 unmodified linesmodified:apps/web/src/features/landing/words.ts+2 added-5 removed
1 /**2- * The landing's two opening sentences, the README's, in a module of their3- * own: the route's `head` unfurls with the lede, and a route's head is4- * bundled with the route tree every page loads, so it must pull in no view.2+ * A module of their own: a route's head is bundled with the route tree every3+ * page loads, so it must pull in no view.4 */5 7-/** The README's opening line: what the platform is. */6 export const WHAT_IT_IS =7 "A Git platform for the boundary between a project and everyone else.";8 11-/** The README's lede, the sentence the page unfurls with when its link is shared. */9 export const LEDE =10 "Everything a project ships is public, its contribution process is typed code on main, and a push lands only by passing a typed gate.";modified:apps/web/src/features/ledger/areas.ts-32 removed
1-/**2- * What a ledger says about its sealed areas, folded from its entries, and3- * the one sentence its page opens on: the posture label, then each area's4- * count and authors ("Open with sealed evidence. export: 7 sealed checks5- * by 3 people."). A module with no view of its own.6- */1 import { LedgerEntry } from "@repo/protocol/domain/visibility";2 import type { Ledger } from "@repo/protocol/domain/visibility";3 import type { AreaName, SuiteRoot } from "@repo/protocol/ids";4 import type { DateTime } from "effect";5 import { Option } from "effect";6 13-/** An admission's evidence: when, how many green runs on main, how many known-bad trees it failed. */7 export interface Admission {8 readonly at: DateTime.Utc;9 readonly knownBadCaught: number;10 readonly mainRuns: number;11 }12 20-/** One sealed area, as its entries leave it. */13 export interface AreaSummary {22- /** The admission of the area's current root; none when that root joined without one. */14 readonly admission: Option.Option<Admission>;15 readonly area: AreaName;25- /** How many people wrote the suite, as its latest commitment counts them. */16 readonly authors: Option.Option<number>;27- /** When any entry about the area was last recorded. */17 readonly changedAt: DateTime.Utc;29- /** How many sealed checks the area holds, as its latest count or commitment says. */18 readonly checks: number;31- /** The suite's salted root, as its latest commitment or admission names it. */19 readonly root: Option.Option<SuiteRoot>;20 }21 35-/** What one entry says about an area, if it is about one. */22 interface AreaFact {23 readonly admitted: Option.Option<Admission & { readonly suite: SuiteRoot }>;24 readonly area: AreaName;25 readonly at: DateTime.Utc;1 unmodified line27 readonly checks: Option.Option<number>;28 readonly root: Option.Option<SuiteRoot>;29 }30 45-/** A fact that says nothing yet: each kind of entry fills in what it knows. */31 const noFact: Omit<AreaFact, "area" | "at"> = {32 admitted: Option.none(),33 authors: Option.none(),34 checks: Option.none(),29 unmodified lines64 Released: () => [],65 ValueSet: () => [],66 });67 83-/** The ledger's entries in the order they were recorded. */68 const recorded = (ledger: Ledger) =>69 ledger.entries.toSorted((one, other) => one.seq - other.seq);70 87-/** An area as its facts so far leave it: each later fact overrides what it says. */71 interface Folded {72 readonly admissions: ReadonlyMap<SuiteRoot, Admission>;73 readonly area: AreaName;74 readonly authors: Option.Option<number>;14 unmodified lines89 checks: Option.orElse(fact.checks, () => before?.checks ?? Option.none()),90 root: Option.orElse(fact.root, () => before?.root ?? Option.none()),91 });92 110-/**111- * Each sealed area's latest count, authors and root, when it last changed,112- * and the admission of its current root, folded from the entries in the113- * order they were recorded; areas by name.114- */93 export const areaSummaries = (ledger: Ledger): readonly AreaSummary[] => {94 const areas = new Map<AreaName, Folded>();95 96 for (const fact of recorded(ledger).flatMap(factsOf)) {16 unmodified lines113 114 export const plural = (count: number, one: string, many: string) =>115 `${count} ${count === 1 ? one : many}`;116 139-/** "export: 7 sealed checks by 3 people". */117 export const areaHeadline = ({ area, authors, checks }: AreaSummary) =>118 `${area}: ${plural(checks, "sealed check", "sealed checks")}${Option.match(119 authors,120 {1 unmodified line122 onSome: (count) => ` by ${plural(count, "person", "people")}`,123 }124 )}`;125 149-/** The ledger's head sentence: what leads it, and the rest. */126 export interface LedgerHead {127 readonly lead: string;128 readonly rest: string;129 }130 155-/**156- * The ledger in one sentence, in two parts: its lead, the posture label,157- * and the rest, every sealed area's headline, or what it holds back when158- * no area is counted yet. A label that names the sealed areas ("Open with159- * sealed evidence · sealed checks in export, parser") leads with its160- * posture alone when the areas follow with their counts, so no area is161- * named twice; any other label leads whole.162- */131 export const ledgerHead = (ledger: Ledger): LedgerHead => {132 const areas = areaSummaries(ledger);133 134 if (areas.length > 0) {19 unmodified linesmodified:apps/web/src/features/ledger/ledger-page.tsx+3 added-31 removed
1 /**2- * A project's ledger, facts first. Its status line is one sentence: the3- * posture label the platform computed, then each sealed area's count and4- * authors ("Open with sealed evidence. export: 7 sealed checks by 35- * people."). Then each declared layer (its audience, holdings, disclosure,6- * reason and who reads and writes it), each sealed area folded from the7- * entries (its salted root, its admission record, when it last changed),8- * and the history: one typed line per entry, newest first. The inspector9- * holds the posture, what is held back, the CLI line and what each10- * disclosure means.11- *12- * Props in, markup out: the route reads the ledger (`src/client/ledger.ts`)13- * and hands it here. The ledger carries no path, no check name and no file14- * name, and nothing here adds one; the layer read log is maintainers' data15- * and never reaches the public ledger.2+ * The ledger carries no path, no check name and no file name, and nothing here3+ * adds one; the layer read log is maintainers' data and never reaches the4+ * public ledger.5 */6 import { Brand } from "@repo/brand";7 import { LedgerEntry } from "@repo/protocol/domain/visibility";8 import type { Layer, Ledger, Members } from "@repo/protocol/domain/visibility";24 unmodified lines33 import { When } from "../shared/time.tsx";34 import { areaHeadline, areaSummaries, ledgerHead, plural } from "./areas.ts";35 import type { AreaSummary } from "./areas.ts";36 48-/** A day as a reader skims it: "Oct 11", in UTC. */37 const dayOf = (at: DateTime.Utc) =>38 DateTime.formatUtc(at, { day: "numeric", locale: "en-US", month: "short" });39 52-/**53- * When the ledger was read, at the latest: `now`, or its newest entry's54- * time if that is later. The page keeps the `now` it was served with while55- * it reads the ledger again as entries arrive, and a recorded entry is never56- * in the future.57- */40 const readAt = (ledger: Ledger, now: DateTime.Utc) => {41 let latest = now;42 43 for (const entry of ledger.entries) {2 unmodified lines46 47 return latest;48 };49 68-/** The ledger's entries, newest first. */50 const newestFirst = (ledger: Ledger) =>51 ledger.entries.toSorted((one, other) => other.seq - one.seq);52 53 const Code = ({ children }: { readonly children: ReactNode }) => (1 unmodified line55 {children}56 </code>57 );58 78-/** The posture label leads, in its role; the areas follow in ink. */59 const postureTone = {60 open: "text-foreground",61 openCore: "text-sealed",62 openOnSchedule: "text-sealed",63 openWithSealedEvidence: "text-sealed",64 sourceAvailable: "text-foreground",65 } as const satisfies Record<Ledger["posture"], string>;66 87-/** The ledger's status line: its posture, then every sealed area, in one sentence. */67 const HeadSentence = ({ ledger }: { readonly ledger: Ledger }) => {68 const { lead, rest } = ledgerHead(ledger);69 70 return (12 unmodified lines83 </p>84 );85 };86 108-/** Handles, each linked to their page, comma-separated. */87 const Handles = ({ handles }: { readonly handles: readonly Handle[] }) =>88 handles.map((handle, index) => (89 <Fragment key={handle}>90 {index === 0 ? null : ", "}45 unmodified lines136 </Definitions>137 </li>138 );139 162-/** "admitted Oct 11; passes main 3/3; catches 2 known-bad", or why there is none. */140 const admissionWords = (summary: AreaSummary) =>141 Option.match(summary.admission, {142 onNone: () => "joined without admission runs",143 onSome: ({ at, knownBadCaught, mainRuns }) =>40 unmodified lines184 </Definitions>185 </li>186 );187 211-/** Each kind of entry's word, and whether it is about something sealed. */188 const kindOf = Match.type<LedgerEntry>().pipe(189 Match.tagsExhaustive({190 Admitted: () => ({ sealed: true, word: "Admitted" }),191 CommitmentPublished: () => ({ sealed: true, word: "Commitment changed" }),4 unmodified lines196 ValueSet: () => ({ sealed: true, word: "Value set" }),197 })198 );199 224-/** One entry in words, as the ledger records it; its root, if it names one, is apart. */200 const EntryWords = ({201 entry,202 project,203 }: {48 unmodified lines252 ),253 })254 );255 281-/** The salted root an entry names, if it names one. */256 const rootOf = (entry: LedgerEntry): Option.Option<string> =>257 LedgerEntry.match(entry, {258 Admitted: ({ suite }) => Option.some(suite),259 CommitmentPublished: ({ suite }) => Option.some(suite),3 unmodified lines263 Released: () => Option.none(),264 ValueSet: () => Option.none(),265 });266 293-/** One entry on one line: when, its kind's word, what it says, and its root. */267 const EntryRow = ({268 entry,269 now,270 project,53 unmodified lines324 ))}325 </ol>326 );327 355-/** What each disclosure lets the public learn, one line each. */328 const Disclosures = () => (329 <FactBlock label="What each disclosure shows">330 <ul className="flex flex-col gap-1.5">331 {Object.values(disclosureWords).map((words) => (92 unmodified linesmodified:apps/web/src/features/markdown/markdown.tsx+4 added-48 removed
1-/**2- * A Markdown file from a project's repo, rendered: a README on the3- * project and tree pages, a `.md` file on the blob page. Its links and4- * images resolve against `dir` at the commit `at`, so they stay inside the5- * project at that commit. The site's own Markdown (the docs) is drawn the6- * same way by `SiteMarkdown`, with nothing to resolve.7- *8- * react-markdown builds React elements (no `dangerouslySetInnerHTML`), so9- * the same component renders in the Worker and in the browser. What may10- * reach the page is decided by the plugin chain in `pipeline.ts`; this11- * file only draws the elements that come out of it.12- */1 import type { CommitSha, ProjectName } from "@repo/protocol/ids";2 import type { AnyRouter, RegisteredRouter } from "@tanstack/react-router";3 import { Link, useRouter } from "@tanstack/react-router";4 import type { ComponentProps, ReactNode } from "react";3 unmodified lines8 import { literalPath } from "../shared/link.tsx";9 import { rehypePluginsFor, remarkPlugins, sitePlugins } from "./pipeline.ts";10 11 export interface RepoMarkdownProps {24- /** The commit the file was read at; links and images point there. */12 readonly at: CommitSha;26- /** The file's directory, relative to the repo root; `""` is the root. */13 readonly dir: string;14 readonly project: ProjectName;29- /** The file's text. */15 readonly source: string;16 }17 18 type AnchorProps = ComponentProps<"a"> & ExtraProps;19 35-/** A path on this origin (`/p/blob/…`), as `resolve.ts` leaves every in-project link. */20 const isSameOrigin = (href: string) =>21 href.startsWith("/") && !href.startsWith("//") && !href.startsWith("/\\");22 39-/**40- * A link inside the project: a router `Link` when a router is there (the41- * app), so it opens without a full load; a plain link when none is (a42- * view rendered on its own, as the pages' tests render it).43- */23 const ProjectLink = ({24 children,25 href,26 // The sanitizer never lets a `target` through.7 unmodified lines34 <a {...props} href={href}>35 {children}36 </a>37 ) : (59- // `href`, not `to`: the router parses a built href into path, query60- // and fragment, where `to` would keep `?raw=1#L3` inside the path. Its61- // `$` and braces escaped (`literalPath`): a file's name, never a param62- // the router fills from the page being read. A `string` target makes63- // `to` optional in the Link's props.38+ // `href`, not `to`: the router parses a built href into path, query and39+ // fragment, where `to` would keep `?raw=1#L3` inside the path.40+ // `literalPath` escapes its `$` and braces, so a file's name is never a41+ // param.42 <Link<RegisteredRouter, string, string> {...props} href={literalPath(href)}>43 {children}44 </Link>45 );46 };47 70-/** `a`: in-project links through the router; links that leave go with no referrer and no endorsement. */48 const Anchor = ({ children, href, node: _node, ...props }: AnchorProps) => {49 if (href !== undefined && isSameOrigin(href)) {50 return (51 <ProjectLink {...props} href={href}>16 unmodified lines68 </a>69 );70 };71 95-/** `img`: loaded when scrolled to, decoded off the main thread, and sent with no referrer. */72 const Image = ({73 alt,74 node: _node,75 ...props8 unmodified lines84 );85 86 const components: Components = { a: Anchor, img: Image };87 112-/**113- * A README in the page's own type: body text at 16 px on a 70-character114- * measure, headings under the page's headline, code in the mono size on115- * the surface, links in ink. Colours come from the tokens116- * (`prose-tokens` in `styles.css`), so both schemes share these classes.117- */88 const PROSE = [89 "prose prose-tokens text-body max-w-[70ch] min-w-0",120- // Headings on the scale: h1 and h2 at the title size, so the page's own121- // headline leads, the h1 ruled beneath; h3 and h4 at the want's size.90 "prose-headings:font-semibold prose-headings:tracking-[-0.01em]",91 "prose-h1:text-title prose-h1:mb-3 prose-h1:border-b prose-h1:border-rule prose-h1:pb-2",92 "prose-h2:text-title prose-h2:mt-8 prose-h2:mb-3",93 "prose-h3:text-want prose-h4:text-want",126- // Inline code: the mono face on a surface field, without backticks.94 "prose-code:before:content-none prose-code:after:content-none prose-code:font-normal",95 "[&_:not(pre)>code]:bg-surface [&_:not(pre)>code]:text-mono [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-px",129- // A code block: a field on the surface, ruled in a hairline.96 "prose-pre:bg-surface prose-pre:text-foreground prose-pre:border prose-pre:border-rule prose-pre:rounded-none",97 "prose-pre:text-mono prose-pre:leading-terminal prose-pre:px-4 prose-pre:py-3",132- // Links: ink, underlined in a hairline that darkens under the pointer.98 "prose-a:font-normal prose-a:decoration-input hover:prose-a:decoration-foreground",134- // Quotes as plain indented text, without the plugin's quotation marks.99 "prose-blockquote:font-normal prose-blockquote:not-italic",100 "[&_blockquote_p]:before:content-none [&_blockquote_p]:after:content-none",137- // Images inside the measure, set in the line as a README sets them.101 "prose-img:my-0 prose-img:inline-block prose-img:max-w-full",102 "prose-table:text-ui prose-th:font-semibold",103 ].join(" ");104 14 unmodified lines119 </Markdown>120 </div>121 );122 160-/**161- * The site's own Markdown (a page of the docs), in the README's type: its162- * links are the site's paths, through the router, and leave nothing to163- * resolve against a repo.164- */123 export const SiteMarkdown = ({124 source,125 }: {126 readonly source: string;9 unmodified lines136 </Markdown>137 </div>138 );139 182-/** A README that is not Markdown (`README`, `README.txt`, `README.rst`): its text as written. */140 export const RepoText = ({141 source,142 }: {143 readonly source: string;4 unmodified lines148 );149 150 const markdownExtension = /\.(?:markdown|md|mdown|mdwn|mkd|mkdn)$/iu;151 195-/** Whether a file renders as Markdown (`RepoMarkdown`) or as text (`RepoText`), by its name. */152 export const isMarkdownPath = (path: string) => markdownExtension.test(path);modified:apps/web/src/features/markdown/pipeline.ts+19 added-56 removed
1 /**2- * The plugin chain that turns a project's Markdown into a safe tree, in3- * the one order that makes it safe (ADR 0019). It is the security property4- * of the README renderer, so it lives here alone and is tested whole5- * (`test/markdown.test.tsx`):6- *7- * 1. `remarkGfm`: tables, task lists, strikethrough, autolinks, footnotes;8- * 2. `rehypeRaw`: the README's own HTML (`<p align="center"><img …>`)9- * becomes elements, so everything after sees it;10- * 3. `rehypeRepoUrls`: relative links and media point into the project at11- * the SHA (`resolve.ts`), before the sanitizer judges them;12- * 4. `rehypeFootnoteIds`: the footnotes' ids and links lose the13- * `user-content-` remark-rehype gave them, since the sanitizer gives14- * every id that prefix next, and twice made `user-content-user-content-15- * fn-1` while the links named `user-content-fn-1`;16- * 5. `rehypeSanitize` with `schema`: GitHub's allow-list, the last gate on17- * what comes in (no script, no handler, no `javascript:` or `data:`18- * URL, no iframe, style or form; every `id` and `name` prefixed19- * `user-content-`, so a README cannot clobber the page's own globals);20- * 6. `rehypeSlug`: heading ids, after the sanitizer, so `#usage` finds21- * `## Usage` unprefixed;22- * 7. `rehypeFragmentLinks`: last, once every id is final, a `#x` link with23- * no `x` in the file points at `user-content-x` when that is there (a24- * footnote, a README's own `<a id>` or `<a name>`), as GitHub's page25- * script does. It only changes where a link inside the file points,26- * never an id.27- *28- * react-markdown's `defaultUrlTransform` stays on as a second net.2+ * The order is the security property: 1. `remarkGfm`; 2. `rehypeRaw`, so3+ * everything after sees the README's own HTML; 3. `rehypeRepoUrls`, before the4+ * sanitizer judges the URLs; 4. `rehypeFootnoteIds`, dropping remark-rehype's5+ * `user-content-` prefix, which the sanitizer adds next; 5. `rehypeSanitize`6+ * with `schema`, the last gate (no script, handler, `javascript:` or `data:`7+ * URL, iframe, style or form; every `id` and `name` prefixed, so a README8+ * cannot clobber the page's globals); 6. `rehypeSlug`, after the sanitizer, so9+ * `#usage` finds `## Usage` unprefixed; 7. `rehypeFragmentLinks`, last, once10+ * every id is final. react-markdown's `defaultUrlTransform` stays on as a11+ * second net.12 */13 import { Predicate } from "effect";14 import type { Element, Properties, Root } from "hast";15 import type { Options } from "react-markdown";6 unmodified lines22 23 import { resolveRepoUrl } from "./resolve.ts";24 import type { RepoUrlContext } from "./resolve.ts";25 43-/** A list of unified plugins, each with its options, as react-markdown takes them. */26 export type PluggableList = NonNullable<Options["rehypePlugins"]>;27 46-/** Where a Markdown file was read: the project, the commit, and the file's directory (`""` is the root). */28 export type MarkdownAt = Omit<RepoUrlContext, "kind">;29 30 /**50- * GitHub's allow-list (`hast-util-sanitize`'s `defaultSchema`), with a51- * code block's `language-…` class kept on `code`, and a `style` element52- * dropped with its CSS (the default drops only a `script` whole, so a53- * style's rules would show as text).31+ * A code block's `language-…` class is kept, and a `style` element is dropped32+ * with its CSS (the default drops only a `script` whole, so a style's rules33+ * would show as text).34 */35 export const schema: Schema = {36 ...defaultSchema,37 strip: [...(defaultSchema.strip ?? []), "style"],5 unmodified lines43 ],44 },45 };46 67-/** Elements whose URL loads bytes into the page: they read the raw file. */47 const media = new Set(["img", "source", "video"]);48 70-/** One `srcset` candidate (`url [descriptor]`), its URL resolved. */49 const candidate = (value: string, at: RepoUrlContext) => {50 const [url = "", ...descriptor] = value.trim().split(/\s+/u);51 52 return [resolveRepoUrl(url, at), ...descriptor].join(" ");53 };54 77-/** Rewrite one URL property, when the element carries it as a string. */55 const rewrite = (56 properties: Properties,57 key: "href" | "src" | "srcSet",58 to: (value: string) => string18 unmodified lines77 78 const here = { ...at, kind: "media" } as const;79 80 rewrite(node.properties, "src", (src) => resolveRepoUrl(src, here));104- // rehype-raw keeps `srcset` as written: one string, candidates split by commas.81+ // rehype-raw keeps `srcset` as written: one string, candidates split by82+ // commas.83 rewrite(node.properties, "srcSet", (srcSet) =>84 srcSet85 .split(",")86 .map((value) => candidate(value, here))87 .join(", ")88 );89 };90 113-/**114- * A rehype plugin: every `a[href]` and every `img`, `video` and `source`115- * `src` (and `srcset`) resolved into the project at the SHA.116- */91 export const rehypeRepoUrls = (at: MarkdownAt) => (tree: Root) => {92 visit(tree, "element", (node) => {93 resolveElement(node, at);94 });95 };96 123-/** The prefix the sanitizer puts on every `id` and `name` (`hast-util-sanitize`'s default). */97 const CLOBBER = schema.clobberPrefix ?? "user-content-";98 99 const unprefixed = (value: string, lead = "") =>100 value.startsWith(`${lead}${CLOBBER}`)101 ? `${lead}${value.slice(lead.length + CLOBBER.length)}`102 : value;103 131-/** Drop the prefix from one property, when the element carries it as a string. */104 const unprefix = (properties: Properties, key: "href" | "id", lead = "") => {105 const value = properties[key];106 107 if (Predicate.isString(value)) {1 unmodified line109 }110 };111 112 /**141- * A rehype plugin: the footnotes remark-rehype made (a reference, a142- * footnote's item, a back-reference) lose the prefix it gave their ids and143- * links, so the sanitizer's prefix is their only one.113+ * So the sanitizer's prefix is their only one; twice made114+ * `user-content-user-content-fn-1`.115 */116 export const rehypeFootnoteIds = () => (tree: Root) => {117 visit(tree, "element", (node, _index, parent) => {118 const { properties } = node;21 unmodified lines140 });141 };142 143 /**173- * A rehype plugin, run last: a link to `#x` where the file has no `x` but174- * has `user-content-x` (the sanitizer's prefix) points there, so a175- * footnote and a README's own anchor jump. A target is an element's `id`176- * or an anchor's `name`, the two a browser scrolls to for a fragment.144+ * As GitHub's page script does: a link to `#x` where the file has no `x` but145+ * has `user-content-x` points there.146 */147 export const rehypeFragmentLinks = () => (tree: Root) => {148 const ids = new Set<string>();149 29 unmodified lines179 };180 181 export const remarkPlugins: PluggableList = [remarkGfm];182 214-/** The rehype half of the chain for one file, in its fixed order. */183 export const rehypePluginsFor = (at: MarkdownAt): PluggableList => [184 rehypeRaw,185 [rehypeRepoUrls, at],186 rehypeFootnoteIds,1 unmodified line188 rehypeSlug,189 rehypeFragmentLinks,190 ];191 224-/**225- * The rehype half of the chain for the site's own text (the docs): no raw226- * HTML and no repo to resolve links against, still sanitized, with heading227- * ids and fragment links as a README gets.228- */192 export const sitePlugins: PluggableList = [193 [rehypeSanitize, schema],194 rehypeSlug,195 rehypeFragmentLinks,1 unmodified linemodified:apps/web/src/features/markdown/resolve.ts+6 added-22 removed
1 /**2- * Where a link or an image in a project's Markdown file points, inside the3- * web: the file was read at one commit, in one directory, so a relative4- * URL names a path in that commit's tree, as GitHub resolves a README's5- * links. The result always names the SHA, never `main`, so it reads the6- * same tree forever (and a raw image caches forever, ADR 0019).7- *8- * Pure, so the rules are table-tested on their own; `pipeline.ts` runs it9- * over the rendered tree before the sanitizer sees it.2+ * The result always names the SHA, never `main`, so it reads the same tree3+ * forever.4 */5 import type { CommitSha, ProjectName } from "@repo/protocol/ids";6 13-/** Where the file was read: the project, the commit, its directory, and what kind of URL this is. */7 export interface RepoUrlContext {15- /** The file's directory, relative to the repo root; `""` is the root. */8 readonly dir: string;17- /** A link opens a page (`blob`, or `tree` for a folder); media loads the raw bytes. */9 readonly kind: "link" | "media";10 readonly project: ProjectName;11 readonly sha: CommitSha;12 }13 23-/** A URL scheme (`https:`, `mailto:`, `javascript:` …): the URL leaves the repo, and the sanitizer judges it. */14+/**15+ * A URL scheme (`https:`, `mailto:`, `javascript:` …): the URL leaves the repo,16+ * and the sanitizer judges it.17+ */18 const scheme = /^[a-z][a-z0-9+.-]*:/iu;19 26-/** A base no reader resolves against; only its path is kept. */20 const base = "https://repo.invalid/";21 22 const edgeSlashes = /^\/+|\/+$/gu;23 31-/** Media reads raw bytes; a link opens a folder (`tree`) when its path ends in `/`, else a file (`blob`). */24 const routeOf = (kind: RepoUrlContext["kind"], pathname: string) => {25 if (kind === "media") {26 return "raw";27 }1 unmodified line29 return pathname.endsWith("/") ? "tree" : "blob";30 };31 32 /**41- * Resolve `url` against the file's directory at `sha`:42- *43- * - `#…`, `""`, `//host…` and anything with a scheme come back as written;44- * - `/x` starts at the repo root, anything else at `dir`; `..` stops at45- * the root (the URL parser clamps it), and a `?query` and `#hash` stay;46- * - a link becomes `/<project>/blob/<sha>/<path>`, or `/tree/` when it ends47- * in `/` (a folder); media becomes `/<project>/raw/<sha>/<path>`.48- *33 * Only the parsed path is kept, so a URL the parser reads as another host34 * (`/\host/x`) still lands inside the project.35 */36 export const resolveRepoUrl = (url: string, at: RepoUrlContext): string => {27 unmodified linesmodified:apps/web/src/features/people/person-page.tsx+2 added-23 removed
1 /**2- * A person's page: their credit, read from the trailers on landed commits,3- * grouped by project and then by area, each area one sentence of the roles4- * they hold there ("Answered and asked in datekit/src"), linked to the5- * project's landings. Credit gates nothing and ranks no one (GLOSSARY.md6- * "Credit", "Record"): the read counts landings per role, and the page7- * draws none of those counts, orders by name, and adds nothing up.2+ * Credit gates nothing and ranks no one: the page draws none of the read's3+ * counts, orders by name, and adds nothing up.4 */5 import { CreditRole } from "@repo/protocol/domain/credit";6 import type { CreditSummary } from "@repo/protocol/domain/record";7 import type { Handle, ProjectName } from "@repo/protocol/ids";6 unmodified lines14 import { MetaCode, MetaLine, Row, RowGroup } from "../shared/row.tsx";15 import { projectSections } from "../shared/shell/sections.ts";16 import { Workspace } from "../shared/shell/workspace.tsx";17 22-/** One area of a project: each role a person holds there. */18 export interface AreaCredit {19 readonly area: string;20 readonly roles: readonly CreditRole[];21 }22 28-/** One project: the areas a person is credited in. */23 export interface ProjectCredit {24 readonly areas: readonly AreaCredit[];25 readonly project: ProjectName;26 }27 34-/** Each role as the sentence says it, in the past: the trailer names what they did. */28 const ROLE_WORD = {29 "Advised-by": "advised",30 "Asked-by": "asked",31 "Decided-by": "decided",2 unmodified lines34 "Released-by": "released",35 "Signed-off-by": "answered",36 } as const satisfies Record<CreditRole, string>;37 45-/**46- * The order a sentence names roles in: the answer first (it is the work47- * the landing is), then the trailers' own order.48- */38 const SENTENCE_ORDER: readonly CreditRole[] = [39 "Signed-off-by",40 ...CreditRole.literals.filter((role) => role !== "Signed-off-by"),41 ];1 unmodified line43 const bySentence = Order.mapInput(Order.Number, (role: CreditRole) =>44 SENTENCE_ORDER.indexOf(role)45 );46 58-/** Words joined as a sentence lists them: `a`, `a and b`, `a, b and c`. */47 const listed = (words: readonly string[]) =>48 words.length < 249 ? words.join("")50 : `${words.slice(0, -1).join(", ")} and ${words.at(-1) ?? ""}`;51 64-/** Where an area sits, in words: "the whole project" for its root. */52 const whereOf = (project: string, area: string) =>53 area === "." || area === "" ? "the whole project" : `${project}/${area}`;54 68-/**69- * An area's roles as one sentence: "Answered and asked in datekit/src",70- * "Decided in the whole project".71- */55 export const areaSentence = (56 project: string,57 area: string,58 roles: readonly CreditRole[]6 unmodified lines65 66 return `${sentence.charAt(0).toUpperCase()}${sentence.slice(1)}`;67 };68 86-/** `rows` grouped by `key`, the groups in the order their keys sort. */69 const groupBy = <A,>(70 rows: readonly A[],71 key: (row: A) => string72 ): readonly Array.NonEmptyReadonlyArray<A>[] =>73 Object.entries(Array.groupBy(rows, key))74 .toSorted(([one], [other]) => one.localeCompare(other))75 .map(([, group]) => group);76 95-/** A person's credit by project, then by area (each by name), each area's roles once each. */77 export const creditsByProject = (78 credits: readonly CreditSummary[]79 ): readonly ProjectCredit[] =>80 groupBy(credits, ({ project }) => project).map((inProject) => ({8 unmodified lines89 })),90 project: Array.headNonEmpty(inProject).project,91 }));92 112-/** The project's landings, where an area's credits are the trailers. */93 const landingsOf = (project: ProjectName) =>94 projectSections(project).find(({ tab }) => tab === "landings")?.to ??95 projectPath(project);96 58 unmodified lines155 </Workspace>156 );157 };158 179-/** The page for an address whose last part cannot be a handle. */159 export const NoSuchPersonView = () => (160 <PageShell title="No such person">161 <EmptyState162 onward={<AppLink to={ASKS_PATH}>Open asks</AppLink>}4 unmodified linesmodified:apps/web/src/features/project/asks.tsx-15 removed
1-/**2- * A project's open asks as rows: each ask its want first and its state at3- * the right, with its claim command when it is open; a family drawn as its4- * parent's row with the fan under it and its children listed, so a reader5- * sees how many of them landed and which wait.6- */1 import type { Ask, AskListing } from "@repo/protocol/domain/ask";2 import type { AskId, ProjectName } from "@repo/protocol/ids";3 import type { DateTime } from "effect";4 import type { ReactNode } from "react";2 unmodified lines7 import type { AskProgress } from "../shared/ask-progress.ts";8 import { FamilyStrip } from "../shared/family.tsx";9 import { AskRow, RowList } from "../shared/row.tsx";10 17-/** Whether an ask is open to take as its listing says: nobody holds it, it waits on nothing, and it is held for nobody. */11 export const openToTake = (listing: AskListing) =>12 !listing.claimed &&13 listing.blockedBy.length === 0 &&14 listing.reserve === undefined;15 23-/**24- * The asks a project counts as open: every one listed, but a family's25- * delete child while it waits on its siblings (it opens when they land).26- */16 export const openAsks = (listings: readonly AskListing[]) => {17 const finales = new Set(18 arrange(listings).flatMap((item) =>19 item.kind === "family" ? [item.finale] : []4 unmodified lines24 ({ ask, blockedBy }) => !(finales.has(ask) && blockedBy.length > 0)25 );26 };27 39-/** The project's asks, families as fans with their children listed. */28 export const AskList = ({29 asks,30 now,31 onSelect,5 unmodified lines37 }: {38 readonly asks: readonly AskListing[];39 readonly now: DateTime.Utc;40 readonly project: ProjectName;53- /** Each family's parent in full, which counts its children. */41 readonly parents: readonly Ask[];42 readonly states: ReadonlyMap<AskId, AskProgress>;43 readonly stamps: ReadonlySet<AskId>;44 readonly selected: string | undefined;20 unmodified lines65 }66 67 const parent = parents.find(({ id }) => id === item.parent.ask);68 82- // A parent the platform did not give in full: its members stay rows.69 if (parent === undefined) {70 return [71 row(item.parent),72 ...item.members.map((member) => row(member)),20 unmodified lines93 </RowList>94 );95 };96 111-/** Row ids in the order `AskList` draws them: what `j` and `k` walk. */97 export const askListIds = (asks: readonly AskListing[]) =>98 arrange(asks).map((item) =>99 item.kind === "ask" ? item.listing.ask : item.parent.ask100 );modified:apps/web/src/features/project/landings.tsx+2 added-17 removed
1-/**2- * A project's recent landings as one-line credits: what the landing did (the3- * ask it answered or opened), who is credited, in one sentence of roles,4- * and when. The full trailers are the landing's own, on its commit's page.5- */1 import type { LandingView } from "@repo/protocol/domain/landing";2 import { Option } from "effect";3 import type { DateTime } from "effect";4 2 unmodified lines7 import { askPath } from "../shared/paths.ts";8 import { When } from "../shared/time.tsx";9 import { askOf } from "../why/rows.ts";10 16-/** How many landings the project's home shows. */11 export const RECENT_SHOWN = 3;12 13 /**20- * A landing's subject line. The platform writes `Answer <ask>` on a landing21- * that answers an ask; `LandingView` carries no subject for the rest, so22- * those read by what they are: an ask's opening as `Open ask <ask>`, then a23- * decider's own landing and the first adoption.14+ * `LandingView` carries a subject only for `Answer <ask>`, so the rest read by15+ * what they are.16 */17 export const landingSubject = (landing: LandingView) =>18 Option.match(askOf(landing), {19 onNone: () =>1 unmodified line21 onSome: ({ ask, kind }) =>22 kind === "opened" ? `Open ask ${ask}` : `Answer ${ask}`,23 });24 33-/**34- * The landings the project's home shows, newest first: the last three35- * answers once three have landed, so the landings that set the project up36- * (its first push, its openings) give way to the work people did; before37- * then, the last three of any kind.38- */25 export const recentShown = (26 landings: readonly LandingView[]27 ): readonly LandingView[] => {28 const answers = landings.filter((landing) => landing.ask !== undefined);41 unmodified lines70 </li>71 );72 };73 88-/** The landings given, each as one line of credit. */74 export const LandingList = ({75 landings,76 now,77 }: {9 unmodified linesmodified:apps/web/src/features/project/posture-label.ts+3 added-11 removed
1 /**2- * A posture in the words GLOSSARY.md gives it ("Posture"). The project list3- * and the front page carry only the literal; the fuller label the platform4- * computes from a project's visibility config ("Open · sealed checks in5- * parser") is the ledger's. Until a listing carries that6- * label, each posture reads as its own name, never as a claim about what is7- * sealed.2+ * The project list carries only the literal; until it carries the platform's3+ * full label, each posture reads as its own name, never as a claim about what4+ * is sealed.5 */6 import type { Posture } from "@repo/protocol/posture";7 8 const labels = {5 unmodified lines14 } as const satisfies Record<Posture, string>;15 16 export const postureLabel = (posture: Posture): string => labels[posture];17 21-/**22- * A posture in its short form: the one the rail and a project's head both23- * say, so a project reads the same in both places (the platform's full24- * label is its title).25- */18 const words = {19 open: "Open",20 openCore: "Open core",21 openOnSchedule: "Open on schedule",5 unmodified linesmodified:apps/web/src/features/project/project-nav.tsx-11 removed
1-/**2- * A project's section row: Asks, Code, Landings, Refs, Policy, Ledger and3- * Env shape, one line under the page's head where the rail is not drawn4- * (below 1120 px; from there the rail lists them). The line scrolls5- * sideways inside itself and never wraps, so it never pushes the page6- * sideways. The page being read is marked `aria-current` and underlined in7- * ink; a page under none of them (a proposal) marks none.8- *9- * Its links are the router's (`AppLink`), so moving between sections never10- * reloads the page.11- */1 import type { ProjectName } from "@repo/protocol/ids";2 import type { ReactNode } from "react";3 4 import { AppLink } from "../shared/link.tsx";29 unmodified linesmodified:apps/web/src/features/project/project-page.tsx+5 added-65 removed
1-/**2- * A project's home, which is its list of asks: its name, its posture and3- * when it last landed; its open asks, a family drawn as a fan with its4- * children listed; then its README. Beside them, how a change lands here:5- * the posture, the gate, who decides, what is held back, the commands that6- * take part, and the last landings; or the selected ask's facts, one Escape7- * from them. Props in, markup out: the route reads the asks, the ledger,8- * the events, the policy and the code on the server and keeps them live in9- * the browser, and hands them here.10- */1 import { IMPORTED_NOTE } from "@repo/agent-kit/docs/imported-note";2 import { Brand } from "@repo/brand";3 import type { Ask, AskListing } from "@repo/protocol/domain/ask";4 import type { FileView, TreeListing } from "@repo/protocol/domain/code";38 unmodified lines43 import { postureLabel, postureWord } from "./posture-label.ts";44 import { ProjectNav } from "./project-nav.tsx";45 import { ReadmeSection } from "./readme-section.tsx";46 57-/** A project's code as its home reads it: the root folder at main, and its README. */47 export interface ProjectCode {48 readonly readme?: FileView | undefined;49 readonly root: TreeListing;50 }51 63-/** Who decides for which paths, as the project's policy says. */52 export interface Deciders {53 readonly handles: readonly Handle[];54 readonly paths: Glob;55 }56 69-/** One area a layer holds checks in, and how many. */57 export interface HeldBackArea {58 readonly area: AreaName;72- /** How many sealed checks it holds. */59 readonly checks: number;60 readonly detail: string;61 }62 77-/** An entry that says nothing about an area's count. */63 const noCount = (): readonly (readonly [AreaName, number])[] => [];64 80-/**81- * What a project holds back, from its ledger: each sealed area and how many82- * checks it holds, as the latest count or commitment says.83- */65 export const heldBackOf = (ledger: Ledger): readonly HeldBackArea[] => {66 const checks = new Map(67 ledger.entries68 .toSorted((a, b) => a.seq - b.seq)21 unmodified lines90 }));91 };92 93 /**113- * The project as its home knows it: its name, its open asks, when it last114- * landed, and its posture once its own ledger has said it. Until then the115- * page says no posture, never one it was not told.94+ * Until its own ledger has said it, the page says no posture, never one it was95+ * not told.96 */97 export type HomeListing = Omit<ProjectListing, "posture"> & {98 readonly posture?: Posture | undefined;99 };100 121-/** The project for its home, from what was read: the posture only from its own ledger. */101 export const homeListing = ({102 asks,103 ledger,104 project,6 unmodified lines111 posture: ledger?.posture,112 project,113 });114 136-/** A posture known, in the platform's words. */115 interface KnownPosture {116 readonly label: string;117 readonly posture: Posture;118 }119 120 export interface ProjectViewProps {143- /** The open asks; none while they are read, and none when they could not be. */121 readonly asks: readonly AskListing[] | undefined;145- /** Whether the asks could not be read: the platform did not answer. */122 readonly unreachable?: boolean;147- /** The project's landings, newest first. */123 readonly landings: readonly LandingView[];149- /** The project: its posture (once its ledger is read), when it last landed, its open asks. */124 readonly listing: HomeListing;151- /** When it last landed, as its events say, over what the listing says. */125 readonly lastLanded?: DateTime.Utc | undefined;153- /** Its posture in the platform's words, from its own ledger. */126 readonly postureLabel?: string | undefined;155- /** What it holds back, from its ledger; none while it is read. */127 readonly heldBack?: readonly HeldBackArea[] | undefined;157- /** Who decides for which paths; none while the policy is read or when it has none. */128 readonly deciders?: readonly Deciders[] | undefined;159- /** Where it was imported from; none for a project that started empty, or while the policy is read. */129 readonly importedFrom?: ImportSource | undefined;130 readonly now: DateTime.Utc;131 readonly platformUrl: string;163- /** The root folder at main and its README, once read. */132 readonly code?: ProjectCode | undefined;165- /** Each family's parent in full, which counts its children. */133 readonly parents?: readonly Ask[];167- /** Where each ask stands, from the project's events. */134 readonly states?: ReadonlyMap<AskId, AskProgress>;169- /** The children that landed while the page was open. */135 readonly stamps?: ReadonlySet<AskId>;171- /** The selected ask in full, once the browser has read it. */136 readonly selectedAsk?: Ask | undefined;173- /** Whether someone is signed in, who may propose an ask. */137 readonly signedIn?: boolean;138 }139 177-/** Who decides, one line per set of paths, at most three, then the policy. */140 const WhoDecides = ({141 deciders,142 project,143 }: {29 unmodified lines173 </FactBlock>174 );175 };176 215-/** Where an imported project came from: its source, the branch adopted, and what a copy is. */177 const ImportedFrom = ({ source }: { readonly source: ImportSource }) => (178 <FactBlock label="Imported from">179 <p className="text-ui">180 <a15 unmodified lines196 </p>197 </FactBlock>198 );199 239-/** The four commands that take part, in the order a newcomer runs them. */200 const TakePart = ({201 platformUrl,202 project,203 }: {20 unmodified lines224 </FactBlock>225 );226 227 /**268- * The last landings. Before the project's main first lands, the push that269- * lands it is its initializer's; after it, the replay may still hold no270- * landing event, since adopting main is not one: say so, never "nothing271- * landed".228+ * Adopting main is not a landing event, so the replay may hold no landing:229+ * never say "nothing landed".230 */231 const RecentLandings = ({232 landedAt,233 landings,33 unmodified lines267 268 return <FactBlock label="Recent landings">{shown}</FactBlock>;269 };270 313-/** How a change lands here: the facts with nothing selected; the posture is the head's to say. */271 const HowItLands = ({272 deciders,273 heldBack,274 importedFrom,30 unmodified lines305 <ForAgents href={`/${listing.project}/llms.txt`} />306 </>307 );308 352-/**353- * How a change lands here, in one sentence built only from typed facts:354- * the gate, the paths deciders are set for, what is held back (the ledger355- * linked from it), and when it last landed. The one place the project's356- * own pages state it; the inspector carries the same as facts.357- */309 const RuleSentence = ({310 deciders,311 heldBack,312 landedAt,38 unmodified lines351 </p>352 );353 };354 404-/** The project line: its posture and its open asks; its README's first sentence; then its one rule sentence. */355 const ProjectLine = ({356 count,357 lede,358 posture,5 unmodified lines364 readonly rule: ReactNode;365 }) => (366 <div className="flex flex-col gap-3">367 <p className="text-ui text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1">418- {/* The posture in the short form the rail says, the platform's own419- label its title; its dot after it, so a line never opens on one. */}368+ {/* Its dot after it, so a line never opens on one. */}369 {posture === undefined ? null : (370 <span className="flex items-center gap-x-2">371 <PostureBadge372 label={postureWord(posture.posture)}13 unmodified lines386 {rule}387 </div>388 );389 441-/** The asks' place on the page, as far as they have been read. */390 const AsksSection = ({391 asks,392 now,393 onSelect,57 unmodified lines451 </section>452 );453 };454 507-/** Whichever facts the inspector shows: how a change lands here, or the selected ask's. */455 const PageFacts = ({456 landedAt,457 picked,458 posture,44 unmodified lines503 />504 );505 };506 560-/** A list's count at the context bar's end: "7 open asks, 6 open to take". */507 const countOf = (open: readonly AskListing[]) =>508 `${plural(open.length, "open ask", "open asks")}, ${509 open.filter(openToTake).length510 } open to take`;511 566-/** The page, with the selection the list keeps (or none, outside a router). */512 const ProjectPanes = ({513 props,514 select,515 selected,100 unmodified lines616 617 return <ProjectPanes props={props} select={select} selected={selected} />;618 };619 675-/**676- * The project's home. Inside the router its list selects (`?ask=`) and `j`677- * and `k` walk it; a view rendered alone draws the same page with nothing678- * selected.679- */620 export const ProjectView = (given: ProjectViewProps) => {621 const props = {622 ...given,623 asks: given.asks && stillWaiting(given.asks),8 unmodified linesmodified:apps/web/src/features/project/readme-section.tsx-6 removed
1-/**2- * A README (or any Markdown file) under its own name, rendered on the3- * project's prose: a project's home shows its root README below its asks,4- * and a folder or a Markdown file shows its own. Its first sentence is the5- * project's lede, under the project's name (`ledeOf`, `features/front/head.ts`).6- */1 import type { FileView } from "@repo/protocol/domain/code";2 import type { ProjectName } from "@repo/protocol/ids";3 4 import { dirOf } from "../code/paths.ts";31 unmodified linesmodified:apps/web/src/features/project/unknown-project.tsx-7 removed
1-/**2- * The page for an address that names no project: the platform's own3- * refusal, `UnknownProject`, as `git` and the CLI would print it, then the4- * way onward. An address that cannot be a project's name at all says so in5- * a sentence.6- */1 import { ProjectName } from "@repo/protocol/ids";2 import { UnknownProject } from "@repo/protocol/refusal";3 import { Option, Schema } from "effect";4 6 unmodified lines11 const decodeProject = Schema.decodeUnknownOption(ProjectName);12 13 const LINK = "decoration-rule underline hover:decoration-current";14 21-/** Where to go instead: every open ask. */15 const Onward = () => (16 <div className="text-ui flex flex-wrap gap-x-4 gap-y-1">17 <AppLink className={LINK} to={ASKS_PATH}>18 Open asks24 unmodified linesmodified:apps/web/src/features/project-people/people-view.tsx-44 removed
1-/**2- * A project's policy (its section reads "Policy"; its address stays3- * `/$project/people`), as its config folder states it at the landed4- * commit: who decides which paths, the vouch rule and the vouch file's5- * lines, the caps, budget and timings, and whether landings disclose6- * agents. The layers are one line that links the ledger, where who reads7- * and writes each one is told. The head says which commit and which file8- * it is read from; the inspector says how to change any of it.9- *10- * Props in, markup out: the route reads `projectPolicy` and `ledger`11- * (`src/client/{policy,ledger}.ts`) and hands them here. With no policy at12- * the landed commit, the page says why (`unevaluated`: no config folder, or13- * one that did not evaluate), names the commit and says what makes it14- * evaluate; with no reason either, nothing has landed yet. The page is15- * read-only: the one way to change any of it is to land a change to the16- * config folder, and it says so with the commands.17- */1 import { Brand } from "@repo/brand";2 import type { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";3 import type { Ledger } from "@repo/protocol/domain/visibility";4 import type { Handle, ProjectName } from "@repo/protocol/ids";13 unmodified lines18 import { Workspace } from "../shared/shell/workspace.tsx";19 20 type Vouches = PublicPolicy["vouches"];21 39-/** The project's config file, `project.ts` in the config folder. */22 const PROJECT_FILE = `${Brand.configDir}/project.ts`;23 42-/** The config folder as a reader writes it: `<configDir>/`. */24 const CONFIG_DIR = `${Brand.configDir}/`;25 26 const HOUR_MS = 3_600_000;27 1 unmodified line29 30 const plural = (count: number, one: string, many: string) =>31 `${count} ${count === 1 ? one : many}`;32 52-/** A claim timing as a reader says it: whole hours up to two days, then days. */33 const spanOf = (ms: number) => {34 if (ms % HOUR_MS !== 0) {35 return plural(Math.round(ms / 60_000), "minute", "minutes");36 }4 unmodified lines41 ? plural(hours / 24, "day", "days")42 : plural(hours, "hour", "hours");43 };44 65-/** What a vouch gates, in words. */45 const vouchModes = {46 all: "For everything: claiming an ask, offering a sealed answer and proposing an ask all need a vouch.",47 bansOnly:48 "Bans only: nobody needs a vouch, but a denounced person still may not claim, push or propose.",6 unmodified lines55 {children}56 </code>57 );58 80-/** A file or a commit in running text: mono, linked. */59 const CodeLink = ({60 children,61 to,62 }: {4 unmodified lines67 {children}68 </AppLink>69 );70 93-/** Handles, each linked to their page, comma-separated. */71 const Handles = ({ handles }: { readonly handles: readonly Handle[] }) =>72 handles.map((handle, index) => (73 <Fragment key={handle}>74 {index === 0 ? null : ", "}75 <HandleLink handle={handle} />76 </Fragment>77 ));78 102-/** "As of 71fda27, from <config folder>/project.ts", each linked; or the platform's defaults. */79 const AsOf = ({80 policy,81 project,82 }: {17 unmodified lines100 )}101 </>102 );103 128-/** Who decides each path: the path in mono, then its deciders. */104 const Deciders = ({105 deciders,106 }: {107 readonly deciders: PublicPolicy["deciders"];84 unmodified lines192 </Region>193 );194 };195 221-/** A number a reader compares: set in tabular figures. */196 const Num = ({ children }: { readonly children: string }) => (197 <span className="tabular-nums">{children}</span>198 );199 47 unmodified lines247 </p>248 </Region>249 );250 277-/** The layers' one line: each by name and disclosure, and a link to the ledger. */251 const LayersLine = ({252 ledger,253 project,254 }: {33 unmodified lines288 .289 </p>290 );291 319-/**320- * The layers in one line, under a heading of their own: each by name and321- * disclosure, held back, and the ledger, where who reads and writes each322- * one is told. Nothing else.323- */292 const Layers = ({293 ledger,294 project,295 }: {4 unmodified lines300 <LayersLine ledger={ledger} project={project} />301 </Region>302 );303 336-/** The page over an evaluated policy: each of its sections. */304 const Evaluated = ({305 ledger,306 policy,307 project,15 unmodified lines323 <Layers ledger={ledger} project={project} />324 </>325 );326 360-/** The landed commit, short and linked: "The config at the landed commit <sha> has not been evaluated". */327 const NotEvaluated = ({328 at,329 project,330 }: {6 unmodified lines337 {" has not been evaluated"}338 </>339 );340 375-/**376- * Why the config at the landed commit has not been evaluated, and what377- * makes it evaluate: a `project.ts` naming the test command, or a fix to378- * the folder that did not evaluate. Either way, it evaluates again at379- * every landing.380- */341 const Pending = ({342 pending,343 project,344 }: {45 unmodified lines390 </p>391 </div>392 );393 434-/** One way to change the policy: what it does, then its command, a flag to a line. */394 const Step = ({395 command,396 label,397 }: {5 unmodified lines403 <CommandLine command={command} numbered />404 </div>405 );406 448-/** `command`, then each flag with its value on a line of its own. */407 const lines = (command: string, flags: readonly string[]) =>408 [command, ...flags].join(" \\\n ");409 452-/** How the policy changes: by a landing to the config folder, never here. */410 const ChangeFacts = ({ project }: { readonly project: ProjectName }) => (411 <FactBlock label="How to change these">412 <p className="text-ui">413 {`Land a change to ${CONFIG_DIR}: open an ask for it, or, as a decider, land your own from a clone.`}28 unmodified lines442 }: {443 readonly ledger: Ledger;444 readonly policy: Option.Option<PublicPolicy>;445 readonly project: ProjectName;489- /** Why there is no policy at the landed commit; none before the first landing. */446 readonly unevaluated: Option.Option<PolicyPending>;447 }): ReactNode => (448 <Workspace449 facts={<ChangeFacts project={project} />}22 unmodified linesmodified:apps/web/src/features/proposal/client-file.tsx+2 added-10 removed
1 /**2- * A drafted file (the ask file or its check), drawn in the browser only.3- * The server renders the file's path as a heading and its text in a4- * `<pre>`; after hydration the browser loads `@pierre/diffs` and draws it5- * highlighted. `import.meta.env.SSR` is `true` in the Worker's build, so the6- * dynamic import below is dead code there and the Worker bundles none of it7- * (`bytes:check`), as `features/code/client-code.tsx` does.2+ * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic import3+ * below is dead code there and the Worker bundles none of it.4 */5 import { ClientOnly } from "@tanstack/react-router";6 import { lazy, Suspense } from "react";7 12-// A type-only import is erased, so the server bundles nothing of it.8 import type { DraftedFileProps } from "./drafted-file.tsx";9 10 const DraftedFileLater = import.meta.env.SSR11 ? undefined12 : lazy(() => import("./drafted-file.tsx"));13 19-/** The file's text as the server and a reader without JavaScript see it. */14 const Plain = ({ content }: { readonly content: string }) => (15 <pre className="border-rule bg-surface text-mono leading-code overflow-x-auto border px-3 py-2 font-mono">16 {content}17 </pre>18 );19 26-/** One drafted file under its path: a heading, then the code. */20 export const DraftedCode = ({21 content,22 heading: Heading = "h3",23 path,24 }: DraftedFileProps & {32- /** The heading level the path takes in its page. */25 readonly heading?: "h3" | "h4";26 }) => {27 const fallback = <Plain content={content} />;28 17 unmodified linesmodified:apps/web/src/features/proposal/drafted-file.tsx-10 removed
1-/**2- * One drafted file, drawn by `@pierre/diffs`: the ask file or its check,3- * highlighted by Shiki's JavaScript engine (never its WASM one). Nothing is4- * selectable or anchored here: a page may hold several of these, and the5- * file's own page is the place for `#L` anchors.6- *7- * The library and Shiki's grammars are megabytes, so only the browser8- * loads this module (`client-file.tsx`); the Worker never bundles it.9- */1 import { File } from "@pierre/diffs/react";2 import type { FileOptions } from "@pierre/diffs/react";3 import { useMemo } from "react";4 8 unmodified lines13 }14 15 const options: FileOptions<undefined, undefined> = {16 ...diffsOptions,26- // The page names the file in its own heading above the code.17 disableFileHeader: true,18 overflow: "scroll",19 };20 17 unmodified linesmodified:apps/web/src/features/proposal/failure.tsx-10 removed
1-/**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- */1 import { Unauthenticated } from "@repo/protocol/principal";2 import { Refusal } from "@repo/protocol/refusal";3 import { Cause, Option, Schema } from "effect";4 import { LogIn } from "lucide-react";11 unmodified lines16 doing,17 here,18 }: {19 readonly cause: Cause.Cause<unknown>;28- /** What the reader was doing, as "Sign in to …" ends: `propose it`. */20 readonly doing: string;30- /** The page's own address (`hereOf`), where sign-in comes back to. */21 readonly here: string;22 }) => {23 const error = Cause.findErrorOption(cause);24 28 unmodified linesmodified:apps/web/src/features/proposal/live-draft.ts-15 removed
1-/**2- * Where a proposal's draft stands, read live for a view that is not handed3- * it: the decision card on Today holds Accept until the browser has read the4- * proposal's draft, and while the platform's agent drafts it again. The read5- * is `showProposal` (`client/proposal.ts`), which `ProposalDrafted`6- * refreshes; on the server, and until it answers, nothing is read yet.7- */1 import { useAtomValue } from "@effect/atom-react";2 import type { ShowProposal } from "@repo/protocol/contracts";3 import type { DraftState } from "@repo/protocol/domain/proposal";4 import type { ProjectName, ProposalId } from "@repo/protocol/ids";1 unmodified line6 import { AsyncResult } from "effect/reactivity";7 8 import { proposalAtom } from "../../client/proposal.ts";9 17-/**18- * What the browser has read of a proposal's draft: nothing (`Unread`), yet19- * or because the read `failed`; or the draft it read, `None` for a20- * proposal no agent drafted (a want alone).21- */10 export type DraftRead = Data.TaggedEnum<{11 Read: { readonly draft: Option.Option<DraftState> };12 Unread: { readonly failed: boolean };13 }>;14 27-/** Constructors and guards for a draft read. */15 export const DraftRead = Data.taggedEnum<DraftRead>();16 30-/** A draft read: `draft`, or none for a proposal no agent drafted. */17 export const readDraft = (draft?: DraftState): DraftRead =>18 DraftRead.Read({ draft: Option.fromUndefinedOr(draft) });19 34-/** The draft a `showProposal` read holds: once it answered, or why there is none yet. */20 export const draftReadOf = (21 result: AsyncResult.AsyncResult<22 typeof ShowProposal.successSchema.Type,23 unknown11 unmodified linesmodified:apps/web/src/features/proposal/proposal-view.tsx+4 added-47 removed
1-/**2- * One proposal, as its proposer and its deciders follow it. The title is3- * its want; under it, where the platform's draft stands in the outcome's4- * words: drafting (the checking role), ready and waiting for a decider (the5- * waiting role), or a failed round, drawn by `RefusalView` when the round6- * failed with a refusal the page can draw whole, else as an ink line. Then7- * the draft read as a guide, in the order it was made: the ask file (its8- * want, territory and kind as rows, its source behind a disclosure), the9- * check (its source), and red first (the run that failed twice the same10- * way, its assertion once).11- *12- * "Let the platform's agent draft it" (or "Draft again"), with a note for13- * the agent, is the proposer's or a decider's while the proposal is open14- * and not drafting; a decider also gets the way to the decision that would15- * open the ask. The inspector holds who proposed it, when it expires, the16- * decision, and the draft's round.17- *18- * Nothing here edits the drafted files: a member proposes again, or a19- * decider sends the draft back with a note.20- */1 import { Brand } from "@repo/brand";2 import type { ConfigFile } from "@repo/protocol/domain/common";3 import { DraftState } from "@repo/protocol/domain/proposal";4 import type { Proposal } from "@repo/protocol/domain/proposal";19 unmodified lines24 import { When } from "../shared/time.tsx";25 import { DraftedCode } from "./client-file.tsx";26 27 /**48- * How many attempts a draft round makes before it fails: the platform's49- * `DRAFT_ROUNDS` (`@repo/project/draft-runs`), which the web's production50- * code does not import; `test/proposal.test.tsx` holds the two equal.28+ * The platform's `DRAFT_ROUNDS`, which the web's production code does not29+ * import; `test/proposal.test.tsx` holds the two equal.30 */31 export const DRAFT_ATTEMPTS = 3;32 54-/** The longest note `draftAsk` takes. */33 const NOTE_LIMIT = 2000;34 57-/** Where a proposal stands in one word: its draft's while it is open, else its own. */35 export const standing = (proposal: Proposal) =>36 proposal.state === "open" && proposal.draft !== undefined37 ? proposal.draft._tag38 : proposal.state;1 unmodified line40 const draftingNow = DraftState.isAnyOf(["Drafting"]);41 42 const failedNow = DraftState.isAnyOf(["Failed"]);43 67-/** Whether the platform's agent is drafting the proposal's ask right now. */44 export const isDrafting = (proposal: Proposal) =>45 proposal.draft !== undefined && draftingNow(proposal.draft);46 71-/** Every refusal of the union, to find one by the tag a failed draft kept. */47 const refusalKinds = groups.flatMap(({ members }) => [...members]);48 49 /**75- * The refusal a failed round ended with, when its tag alone makes one: a76- * draft keeps only the tag, so a refusal that needs fields of its own77- * cannot be drawn whole, and is said in words instead.50+ * A draft keeps only the tag, so a refusal that needs fields of its own cannot51+ * be drawn whole.52 */53 export const refusalOfTag = (tag: string): Option.Option<Refusal> =>54 Arr.findFirst(refusalKinds, (kind) => kind.identifier === tag).pipe(55 Option.flatMap((kind): Option.Option<Refusal> =>2 unmodified lines58 kind.makeOption({} as never)59 )60 );61 88-/** Whether a drafted file is the ask file: under the config folder, or named as one. */62 const isAskFile = ({ path }: ConfigFile) =>63 path.startsWith(`${Brand.configDir}/`) || path.endsWith(".ask.ts");64 92-/** The draft's files in the order it made them: the ask file, the check, then what the check reads. */65 const filesInOrder = (files: readonly ConfigFile[]) => {66 const askFile = files.find(isAskFile);67 const rest = files.filter((file) => file !== askFile);68 const checks = rest.filter(({ path }) => isTestPath(path));1 unmodified line70 71 return { askFile, checks, others };72 };73 102-/** The kind an ask file names (`kinds.fix`), when it names one plainly. */74 const kindIn = (source: string) =>75 /\bkinds\.(?<kind>[A-Za-z]+)/u.exec(source)?.groups?.kind;76 77 const Step = ({25 unmodified lines103 <dd className="text-ui min-w-0 [overflow-wrap:anywhere]">{children}</dd>104 </div>105 );106 136-/** The ask file: what it states, then its source behind a disclosure. */107 const AskFileStep = ({108 file,109 proposal,110 }: {35 unmodified lines146 </Step>147 );148 };149 180-/** Red first: the run that failed twice the same way on main, its assertion once. */150 const RedFirst = ({ draft }: { readonly draft: DraftState }) =>151 DraftState.match(draft, {152 Drafting: () => null,153 Failed: () => null,15 unmodified lines169 </Step>170 ),171 });172 204-/** A round that failed: the refusal whole when the page can draw it, else in words, in ink. */173 const FailedRound = ({ draft }: { readonly draft: DraftState }) =>174 DraftState.match(draft, {175 Drafting: () => null,176 Failed: ({ attempts, model, refusal, round }) =>24 unmodified lines201 }),202 Ready: () => null,203 });204 237-/** "Draft again", with a note the agent reads. */205 const Redraft = ({206 again,207 busy,208 onRedraft,51 unmodified lines260 </section>261 );262 };263 297-/** The way to the open decision that would open the ask. */264 const DecisionLink = ({265 decision,266 project,267 }: {9 unmodified lines277 Decide it: {decision}278 </AppLink>279 );280 315-/** The draft's round, in a line: its number and where it stands. */281 const roundLine = (draft: DraftState) =>282 DraftState.match(draft, {283 Drafting: ({ round }) => `Round ${round}, drafting now`,284 Failed: ({ attempts, round }) =>1 unmodified line286 Ready: ({ attempts, round }) =>287 `Round ${round} ready after ${attempts} of ${DRAFT_ATTEMPTS} attempts`,288 });289 325-/** The inspector's facts: who proposed it, when it expires, its decision, the draft's round. */290 const ProposalFacts = ({291 decision,292 now,293 project,43 unmodified lines337 )}338 </>339 );340 377-/** Where the proposal stands, under its title: the status line, or a failed round; then what drafting means and its note. */341 const ProposalStatus = ({ proposal }: { readonly proposal: Proposal }) => {342 const { draft } = proposal;343 const drafting = draft !== undefined && draftingNow(draft);344 28 unmodified lines373 </div>374 );375 };376 414-/** The draft as a guide, in the order it was made; a want alone says so. */377 const DraftGuide = ({378 files,379 proposal,380 }: {47 unmodified lines428 proposal,429 }: {430 readonly project: ProjectName;431 readonly proposal: Proposal;470- /** The files the proposal holds (the ask file and its check), as `showProposal` read them. */432 readonly files: readonly ConfigFile[];472- /** The open decision on the proposal, when the reader's Today holds it. */433 readonly decision: Option.Option<DecisionId>;474- /** Whether the reader is its proposer or one of the project's deciders. */434 readonly mayRedraft: boolean;435 readonly onRedraft?: (note: string | undefined) => void;477- /** Whether a "Draft again" is on its way: the button waits. */436 readonly busy?: boolean;479- /** What the last "Draft again" came back with, when it was refused. */437 readonly children?: ReactNode;438 readonly now?: DateTime.Utc;439 }): ReactNode => {440 const open = proposal.state === "open";43 unmodified linesmodified:apps/web/src/features/propose/client-territory.tsx+2 added-8 removed
1 /**2- * The territory select, drawn in the browser only. The server renders its3- * stand-in: the trigger as it will look, holding the choice in sight and4- * in the form (a hidden input), never a native `<select>`; after5- * hydration the browser loads the kit's select over it.6- * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic7- * import below is dead code there and the Worker bundles none of it.2+ * `import.meta.env.SSR` is `true` in the Worker's build, so the dynamic import3+ * below is dead code there and the Worker bundles none of it.4 */5 import { ClientOnly } from "@tanstack/react-router";6 import { ChevronDown } from "lucide-react";7 import { lazy, Suspense } from "react";8 13-// A type-only import is erased, so the server bundles nothing of it.9 import type { TerritorySelectProps } from "./territory-select.tsx";10 11 const SelectLater = import.meta.env.SSR12 ? undefined13 : lazy(() => import("./territory-select.tsx"));14 20-/** The select's place before it is drawn: its trigger, showing the choice. */15 const StandIn = ({ choices, labelledBy, value }: TerritorySelectProps) => (16 <>17 <button18 aria-labelledby={labelledBy}29 unmodified linesmodified:apps/web/src/features/propose/propose-link.tsx+2 added-5 removed
1 /**2- * The way to the propose form, for signed-in members only. Who is signed in3- * is the browser's to learn (`whoAtom`), after the first paint, so the4- * server renders no link and the browser adds it, as the header's session2+ * Who is signed in is the browser's to learn, after the first paint, so the3+ * server renders no link and the browser adds it.5- * slot does (`features/auth/session-slot.tsx`).4 */5 import { useAtomValue } from "@effect/atom-react";6 import type { ProjectName } from "@repo/protocol/ids";7 import { Option } from "effect";13 unmodified lines21 Propose an ask22 </a>23 );24 27-/** `ProposeLink` once the browser knows someone is signed in; nothing before or otherwise. */25 export const SignedInProposeLink = ({26 project,27 }: {28 readonly project: ProjectName;4 unmodified linesmodified:apps/web/src/features/propose/propose-view.tsx+2 added-39 removed
1-/**2- * The propose form: a signed-in member writes a want, may name the3- * territory it belongs to (one of the project's top folders), and lets the4- * platform's agent draft the ask file and its failing check from it,5- * checked by default. A line from the why page (`?about&line&at`) starts the6- * want with where it points. The inspector says what makes a good want and7- * gives the same proposal as a command. Props in, markup out: the route8- * reads who is signed in and the project's paths, sends the payload, and9- * goes to the proposal once it is made.10- *11- * Only the want, the territory and the draft box: the files are the12- * agent's to write, or a person's through `propose --files` in the CLI.13- * Propose waits until there is a want, and says so on itself.14- */1 import { Brand } from "@repo/brand";2 import type { ProposeAsk } from "@repo/protocol/contracts";3 import type { CommitSha, ProjectName, RepoPath } from "@repo/protocol/ids";4 import { Option } from "effect";11 unmodified lines16 import { FactBlock } from "../shared/facts.tsx";17 import { Workspace } from "../shared/shell/workspace.tsx";18 import { ClientTerritorySelect } from "./client-territory.tsx";19 34-/** What `proposeAsk` takes, from its one schema. */20 export type ProposePayload = typeof ProposeAsk.payloadSchema.Type;21 37-/** A line a why page points at: the file, the line and the commit it was read at. */22 export interface About {23 readonly path: RepoPath;24 readonly line: number;25 readonly at: CommitSha;26 }27 28 /**45- * The form's fields as `proposeAsk`'s payload: the want trimmed, the46- * territory when one is named, and `draft: true` only when the box is47- * checked (the contract takes no `draft: false`).29+ * `draft: true` only when the box is checked: the contract takes no `draft:30+ * false`.31 */32 export const proposalPayload = (form: {33 readonly project: ProjectName;34 readonly want: string;9 unmodified lines44 45 return form.draft ? { ...named, draft: true } : named;46 };47 65-/** How a want about one line starts: `In \`src/format.ts\` line 12 at 4c2e6a8: `. */48 export const wantAbout = ({ at, line, path }: About) =>49 `In \`${path}\` line ${line} at ${at.slice(0, 7)}: `;50 69-/**70- * The form's address for `project`, at the line a why page names when it71- * names one: where the project page links, and where sign-in comes back to.72- */51 export const proposeFormPath = (52 project: ProjectName,53 about: Option.Option<About> = Option.none()54 ) =>2 unmodified lines57 onSome: ({ at, line, path }) =>58 `/${project}/proposals/new?${new URLSearchParams({ about: path, at, line: String(line) }).toString()}`,59 });60 83-/** The value the territory takes when the agent chooses it. */61 const AGENT_CHOOSES = "";62 86-/** The territories the form offers: the agent's choice first, then each top folder. */63 export const territoryChoices = (modules: readonly RepoPath[]) => [64 { label: "Let the agent choose", value: AGENT_CHOOSES },65 ...modules.map((module) => ({ label: module, value: module })),66 ];67 92-/** What Propose says: why it waits, or what it does. */68 const proposeWords = (written: boolean, busy: boolean) => {69 if (!written) {70 return "Write the want first";71 }72 73 return busy ? "Proposing" : "Propose";74 };75 101-/** The proposal as a command, for a reader in a terminal. */76 const PROPOSE_COMMAND = `${Brand.cli} propose --draft "<want>"`;77 78 const SignInFirst = ({79 about,31 unmodified lines111 <CommandLine command={PROPOSE_COMMAND} />112 </section>113 );114 141-/** What makes a good want, and the same proposal from a terminal. */115 const GoodWant = () => (116 <>117 <FactBlock label="A good want">118 <ul className="text-ui flex list-disc flex-col gap-1.5 pl-4">110 unmodified lines229 230 {children}231 232 <Button260- // Waiting for a want, it says so at full strength, dashed like any261- // field still to fill, rather than sitting grey.233 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"}`}234 data-written={written}235 disabled={busy || !written}236 type="submit"5 unmodified lines242 </form>243 );244 };245 275-/** The form, the way to sign in, or the wait while the browser learns who is signed in. */246 const ProposeBody = ({247 about,248 busy,249 checking,46 unmodified lines296 signedIn,297 }: {298 readonly project: ProjectName;299 readonly signedIn: boolean;330- /** Whether the browser is still learning who is signed in. */300 readonly checking?: boolean;301 readonly about: Option.Option<About>;333- /** The project's top folders, each a territory to choose. */302 readonly modules: readonly RepoPath[];335- /** Sends the payload; the route goes to the proposal once it is made. */303 readonly onPropose?: (payload: ProposePayload) => void;337- /** Whether a proposal is on its way: the button waits. */304 readonly busy?: boolean;339- /** What the last proposal came back with, when it was refused. */305 readonly children?: ReactNode;306 }): ReactNode => (342- // Below the shell's width the form comes first, and what makes a good343- // want follows it, rather than standing between the reader and the form.307 <div className="contents [&_[data-facts=inline]]:hidden">308 <Workspace309 crumbs={[310 { label: project, to: `/${project}` },24 unmodified linesmodified:apps/web/src/features/propose/territory-select.tsx-9 removed
1-/**2- * The territory a proposal names, chosen with the kit's select: the agent's3- * choice first, then each of the project's top folders in mono. Drawn in4- * the browser only (`client-territory.tsx`): Base UI's select, its5- * positioning and its scroll lock are the browser's to run, and the Worker6- * bundles none of them.7- */1 import {2 Select,3 SelectContent,4 SelectItem,1 unmodified line6 SelectValue,7 } from "../../components/ui/select.tsx";8 9 export interface TerritorySelectProps {17- /** What the select offers, the agent's choice (`""`) first. */10 readonly choices: readonly {11 readonly label: string;12 readonly value: string;13 }[];1 unmodified line15 readonly onChange: (value: string) => void;16 readonly value: string;17 }18 27-/** The trigger's look, shared with the server's stand-in for it. */19 export const TRIGGER =20 "tablet:text-ui tablet:h-9 h-11 w-full max-w-xs text-base";21 22 export const TerritorySelect = ({32 unmodified linesmodified:apps/web/src/features/today/read.ts+3 added-25 removed
1-/**2- * What Today's page reads, in a module with no view of its own: a route's3- * loader runs before its page's view loads, so the route reaches these4- * without carrying the page.5- *6- * - `TodayRead`: the reader's Today, or why there is none (a refusal, no7- * session, no answer from the platform), as the loader sends it.8- * - `readToday`: that read, made with whatever `Client` the caller gives9- * (the server's, carrying the reader's own session).10- * - The order a decider takes decisions in: due within the day first, then11- * by expiry.12- */1 import { Client } from "@repo/protocol/contracts";2 import { Today } from "@repo/protocol/domain/decision";3 import type { Decision } from "@repo/protocol/domain/decision";4 import type { DecisionId, ProjectName } from "@repo/protocol/ids";11 unmodified lines16 } from "effect";17 18 import { decisionKey } from "../decision/subject.ts";19 32-/** What the page read for its reader: their Today, or why there is none. */20 export const TodayRead = Schema.TaggedUnion({21 Read: { today: Today },22 Refused: { refusal: Refusal },23 SignedOut: {},1 unmodified line25 });26 27 export type TodayRead = typeof TodayRead.Type;28 42-/** What Today's loader sends: the read, and the instant it was made. */29 export const TodayPageData = Schema.Struct({30 now: Schema.DateTimeUtcFromString,31 read: TodayRead,32 });3 unmodified lines36 const isRefusal = Schema.is(Refusal);37 38 const isUnauthenticated = Schema.is(Unauthenticated);39 54-/** Whether a read failed because its reader is not signed in. */40 export const isSignedOut = (cause: Cause.Cause<unknown>) =>41 Option.exists(Cause.findErrorOption(cause), isUnauthenticated);42 58-/** A failed read of Today, as the page says it. */43 export const readOfCause = (cause: Cause.Cause<unknown>): TodayRead => {44 const error = Cause.findErrorOption(cause);45 46 if (Option.isSome(error) && isRefusal(error.value)) {4 unmodified lines51 ? TodayRead.cases.SignedOut.make({})52 : TodayRead.cases.Unreachable.make({});53 };54 71-/** Soonest to expire first, then oldest, then by project and id: one order every time. */55 export const expiryOrder: Order.Order<Decision> = Order.combineAll([56 Order.mapInput(DateTime.Order, ({ expiresAt }: Decision) => expiresAt),57 Order.mapInput(DateTime.Order, ({ openedAt }: Decision) => openedAt),58 Order.mapInput(Order.String, ({ project }: Decision) => project),59 Order.mapInput(Order.String, ({ id }: Decision) => id),60 ]);61 62 /**80- * The decisions `today.expiringSoon` names. Ids are minted per project, so a81- * Today across projects may hold two decisions with one id; where an id is82- * named `n` times, the `n` of its decisions that expire first are the ones83- * meant (a decision that expires within the day expires before any that84- * does not).63+ * Ids are minted per project, so a Today across projects may hold two decisions64+ * with one id; where an id is named `n` times, the `n` of its decisions that65+ * expire first are the ones meant.66 */67 export const expiringSoon = (today: Today): ReadonlySet<string> => {68 const named = Arr.groupBy(today.expiringSoon, (id) => id);69 const byExpiry = Arr.sort(today.decisions, expiryOrder);7 unmodified lines77 )78 );79 };80 100-/** Today's decisions in the order a decider takes them: expiring soon first, then by expiry. */81 export const orderDecisions = (today: Today): readonly Decision[] => {82 const soon = expiringSoon(today);83 84 return Arr.sort(7 unmodified lines92 )93 );94 };95 116-/** Where one decision stands on Today: listed (and whether it expires soon), or not there. */96 export const findDecision = (97 today: Today,98 project: ProjectName,99 id: DecisionId10 unmodified lines110 }))111 );112 };113 135-/** The reader's Today, or why there is none, encoded for the page. */114 export const readToday = ({ project }: { readonly project?: ProjectName }) =>115 Effect.gen(function* () {116 const client = yield* Client;117 12 unmodified linesmodified:apps/web/src/features/today/today-page.tsx+1 added-52 removed
1-/**2- * Today: a decider's day of decisions, not diffs, held to a budget said in3- * one sentence. The decisions sit in sections: those due within the day,4- * then the rest within the budget by expiry, then how many wait for5- * tomorrow (their ids are not in the read, so they have no rows). Below6- * them, the newcomers to welcome and a sample of landings that needed7- * nobody.8- *9- * Each row says its subject in plain words (the link to its page), its10- * project, kind and id, and when it expires over its default. From the11- * shell's width a row selects into the inspector, which holds the whole12- * decision: its evidence, a note, and its choices, each with what it does.13- * Below it a row opens in place, one at a time, its choices kept in sight14- * above the bottom bar while it is open.15- *16- * A choice taken leaves its row where it was, reading what it did; the17- * budget sentence moves with the next read. There is no toast.18- *19- * A failure reads as what it is: a refusal (`NotDecider` for a person who20- * decides nothing) through `RefusalView`, a missing sign-in as what Today21- * is and how to sign in, and an unreachable platform as that, never as an22- * empty day.23- */1 import { Brand } from "@repo/brand";2 import type { Decision, Today } from "@repo/protocol/domain/decision";3 import type { LandingView } from "@repo/protocol/domain/landing";4 import { Array as Arr, Option, Order } from "effect";42 unmodified lines47 } from "./read.ts";48 49 const counted = (count: number) => (count === 0 ? "none" : String(count));50 74-/** The day's budget, in one sentence: decisions taken and left, and the finishes apart. */51 export const budgetSentence = (budget: Today["budget"]) =>52 `Decisions: ${budget.used} taken, ${counted(Math.max(0, budget.total - budget.used))} left today. Finishes are counted apart: ${counted(budget.finishes)} taken.`;53 78-/** The budget for the context bar: what is left. */54 const budgetShort = (budget: Today["budget"]) =>55 `${counted(Math.max(0, budget.total - budget.used))} left today`;56 82-/** What Today is, for someone it does not hold decisions for yet. */57 const WHAT_TODAY_IS =58 "Today is a decider's page: the decisions you owe your projects each day, each with its evidence and a safe default if you leave it.";59 86-/** A decision on the page: listed, and whether it is due within the day. */60 interface Listed {61 readonly decision: Decision;62 readonly soon: boolean;63 }64 92-/** The choice a row's decision was taken with, when the decider took it here. */65 const choiceOf = (decision: Decision) => decision.decided?.choice;66 95-/** Its expiry over its default, at the row's end; muted when it is not due within the day. */67 const openState = (listed: Listed, now: DateTime.Utc) => ({68 mark: listed.soon ? ("waiting" as const) : ("notYet" as const),69 time: `default: ${listed.decision.default}`,70 word: distanceInWords(listed.decision.expiresAt, now),71 });72 102-/** The way to open a row in place, below the shell's width. */73 const OpenHere = ({74 decision,75 onToggle,76 open,25 unmodified lines102 readonly onSelect: ((key: string) => void) | undefined;103 readonly open: string | undefined;104 readonly onOpen: (key: string | undefined) => void;105 readonly selected: string | undefined;136- /** The decisions taken while the page was open, to stamp once. */106 readonly stamped: ReadonlySet<string>;107 }108 140-/** One decision's row: its subject, where it stands, and (below the shell's width) the whole of it in place. */109 const DecisionRow = ({110 listed,111 props,112 }: {96 unmodified lines209 210 const plural = (count: number, one: string, many: string) =>211 `${count} ${count === 1 ? one : many}`;212 245-/** The decisions, due today then within the budget, each section only when it holds one. */213 const DecisionSections = ({214 listed,215 props,216 }: {36 unmodified lines253 </>254 );255 };256 290-/** How many wait beyond the budget, as a sentence: their ids are not in the read. */257 const Tomorrow = ({ overflow }: { readonly overflow: number }) =>258 overflow === 0 ? null : (259 <Section name="Waits for tomorrow">260 <li62 unmodified lines323 ))}324 </Section>325 );326 361-/** The decision the inspector holds, whole. */327 const SelectedFacts = ({328 busy,329 listed,330 now,40 unmodified lines371 </FactBlock>372 </>373 );374 410-/** Signed out: what Today is, the way in, and the command. */375 const SignedOutNotice = ({ here }: { readonly here: string }) => (376 <div className="flex max-w-[70ch] flex-col items-start gap-3">377 <p className="text-body">{WHAT_TODAY_IS}</p>378 <p className="text-ui">8 unmodified lines387 <CommandLine command={`${Brand.cli} today`} />388 </div>389 );390 427-/** What a choice that failed came back with: the refusal, or why there is none. */391 const DecidedFailure = ({392 decided,393 }: {394 readonly decided: AsyncResult.AsyncResult<unknown, unknown>;11 unmodified lines406 Unreachable: () => <UnreachableNotice />,407 });408 };409 447-/** The page around a Today with no decisions to list: the reason, said whole. */410 const Unlisted = ({ children }: { readonly children: ReactNode }) => (411 <Workspace crumbs={[{ label: "Today" }]} title="Today" variant="list">412 {children}413 </Workspace>414 );415 454-/**455- * The decisions on the page: Today's, and any the decider took here that456- * the next read no longer lists, each where it was.457- */416 const listedOf = (417 today: Today,418 taken: ReadonlyMap<string, Listed>419 ): readonly Listed[] => {20 unmodified lines440 )441 );442 };443 486-/** `kept` with `decision`, taken, where it was listed. */444 const withTaken = (445 kept: ReadonlyMap<string, Listed>,446 decision: Decision,447 soon: ReadonlySet<string>5 unmodified lines453 [key, { decision, soon: kept.get(key)?.soon ?? soon.has(key) }],454 ]);455 };456 500-/** The decision a choice just came back with, when it was taken. */457 const takenNow = (458 decided: AsyncResult.AsyncResult<{ readonly decision: Decision }, unknown>459 ): Option.Option<Decision> =>460 Option.filter(23 unmodified lines484 const [open, setOpen] = useState<string>();485 const soon = expiringSoon(today);486 const fresh = takenNow(decided);487 532- // A choice taken stays on the page after the next read leaves it out:533- // kept as soon as it comes back, while this render draws it already.488+ // A choice taken stays on the page after the next read leaves it out.489 if (490 Option.isSome(fresh) &&491 kept.get(decisionKey(fresh.value))?.decision.decided === undefined492 ) {35 unmodified lines528 onDecide,529 onOpen: setOpen,530 onSelect,531 open,577- // A row is drawn selected only when the address names it; with none578- // named the inspector holds the first, and no row looks chosen.532 selected,533 stamped,534 };535 536 return (584- // Below the shell's width a row opens in place, so the inspector's585- // copy of the selected decision is not drawn in main as well.537 <div className="contents [&_[data-facts=inline]]:hidden">538 <Workspace539 count={budgetShort(today.budget)}540 crumbs={[{ label: "Today" }]}52 unmodified lines593 }: {594 readonly read: TodayRead;595 readonly now: DateTime.Utc;596 readonly onDecide: (input: DecideInput) => void;646- /** The decider's last choice, as `decide` answered it. */597 readonly decided?: AsyncResult.AsyncResult<598 { readonly decision: Decision },599 unknown600 >;651- /** The decision the inspector holds (`project/id`); the first listed when none. */601 readonly selected?: string | undefined;602 readonly onSelect?: ((key: string) => void) | undefined;603 }) =>604 TodayRead.match(read, {28 unmodified lines