Skip to content
Myr

Strip non-essential comments from the web's shared 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 a257688 · Browse files · 42 files+63 added−975 removed
This commit

State

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

Diff stats

42 files+63 added−975 removed

  • other:+63 added−975 removed

42 files+63 added−975 removed

modified:apps/web/src/features/shared/shell/app-shell.tsx+2 added-19 removed
modified:apps/web/src/features/shared/shell/bottom-bar.tsx-7 removed
modified:apps/web/src/features/shared/shell/context-bar.tsx-16 removed
1/**2 * Main's context bar, 44 px, on the same line as the rail's wordmark: the3 * trail to the page on the left (the project first, ids in mono, each a4 * link but the last), and on the right what the page is in a word (its5 * state, or a list's count) and its one command to copy. From the shell's6 * width it stays at the top of main while main scrolls.7 */1import { Check, Copy } from "lucide-react";2import type { ReactNode } from "react";34import { Button } from "../../../components/ui/button.tsx";
1 unmodified line
6import { useNumberedCommand } from "../keys.tsx";7import { AppLink } from "../link.tsx";8import type { Crumb } from "./sections.ts";917/** The trail to the page, as a breadcrumb: each step a link but the page itself. */10export const Breadcrumb = ({11 crumbs,12}: {13 readonly crumbs: readonly Crumb[];
4 unmodified lines
18 const last = index === crumbs.length - 1;19 const face = mono ? "text-mono font-mono" : "";2021 return (30 // On a phone the top bar's Back link names the page above, so31 // the trail keeps only the page itself, whole rather than cut.22 <li23 className={`${last ? "flex" : "tablet:flex hidden"} min-w-0 items-center gap-1.5`}24 key={`${index}:${label}`}25 >
29 unmodified lines
55 </ol>56 </nav>57);5869/**70 * The page's one command, as a copy button: the command itself is the71 * button's text for a screen reader and a crawler, and its number (when the72 * single keys are on) is in its title.73 */59export const CopyCommand = ({ command }: { readonly command: string }) => {60 const { copied, copy } = useCopy(command);61 const number = useNumberedCommand(command);62
29 unmodified lines
92 state,93}: {94 readonly count?: string | undefined;95 readonly crumbs: readonly Crumb[];111 /** Anything else the page's bar holds at its end (the code pages' Facts button). */96 readonly end?: ReactNode;97 readonly primaryCommand?: string | undefined;98 readonly state?: ReactNode;99}) => (
18 unmodified lines
modified:apps/web/src/features/shared/shell/context.ts-23 removed
1/**2 * What the shell lends the parts inside it: a way to open its overlays (the3 * rail as a sheet, the phone's More and Projects sheets, the keys dialog),4 * the project the address is in, and what the root route read for the rail5 * (the list of projects, the count on Today). The shell's parts are views:6 * the root route wires the reads (`src/routes/__root.tsx`).7 */1import type { ProjectListing } from "@repo/protocol/domain/front-page";2import { ProjectName } from "@repo/protocol/ids";3import { useMatch } from "@tanstack/react-router";4import { Schema } from "effect";5import { createContext, useContext } from "react";6import type { ReactNode } from "react";715/** One of the shell's overlays. */8export type Overlay = "keys" | "menu" | "more" | "projects";910export interface Shell {11 readonly open: (overlay: Overlay) => void;
4 unmodified lines
16 // Outside the shell (a view's own test) there is nothing to open.17 },18});1928/** The shell's overlays, from inside it. */20export const useShell = (): Shell => useContext(ShellContext);2122const isProjectName = Schema.is(ProjectName);2333/**34 * The project the address is in: the `$project` route's name, when it is35 * one a project could have. None on the site's own pages, and none for a36 * name no project may take (the page says so itself).37 */24export const useCurrentProject = (): ProjectName | undefined =>25 useMatch({26 from: "/$owner/$project",27 select: ({ params }) =>28 isProjectName(params.project) ? params.project : undefined,29 shouldThrow: false,30 });3146/** What the root route read for the rail. */32export interface ShellReads {48 /** Every listed project, once the list has arrived in the browser; nothing before. */33 readonly projects?: readonly ProjectListing[] | undefined;50 /** Today's count, drawn at the end of its row (`RailCount`); nothing for a reader who decides nothing. */34 readonly todayCount?: ReactNode;35}3637export const ShellReadsContext = createContext<ShellReads>({});3856/**57 * Every listed project, once the list has arrived: the server renders the58 * rail without them (the current project's name comes from the address),59 * and nothing on a page waits on the list.60 */39export const useProjectList = (): readonly ProjectListing[] | undefined =>40 useContext(ShellReadsContext).projects;4164/** Today's count for the rail, when there is one. */42export const useTodayCount = (): ReactNode =>43 useContext(ShellReadsContext).todayCount;
modified:apps/web/src/features/shared/shell/facts-sheet.tsx-5 removed
1/**2 * A code page's facts as a sheet from the right, where the code keeps the3 * width (below 1440 px). Loaded once the page is up, and mounted closed so4 * it slides in when the Facts button opens it.5 */1import type { ReactNode } from "react";23import { Sheet, SheetContent } from "../../../components/ui/sheet.tsx";4import { CommandSlotProvider } from "../keys.tsx";
22 unmodified lines
modified:apps/web/src/features/shared/shell/lazy-overlays.ts+2 added-4 removed
modified:apps/web/src/features/shared/shell/overlays.tsx+1 added-25 removed
1/**2 * The shell's overlays, loaded once the page is up, so no page's first load3 * carries them: the rail as a sheet (Menu, below the shell's width), the4 * phone's More and Projects sheets, and the keys dialog. Each opens on a5 * press, slides in over 200 ms, traps focus, and closes on Escape, a press6 * outside or Close; following a link inside closes it too (the shell's open7 * overlay belongs to the address it opened on).8 */1import { Brand } from "@repo/brand";2import { useRouter } from "@tanstack/react-router";3import { BookOpen, Bot, FolderInput, Keyboard } from "lucide-react";4import { useRef } from "react";
28 unmodified lines
33 RailFoot,34} from "./rail.tsx";3536export interface OverlayProps {45 /** The overlay open now; none when all are closed. */37 readonly overlay: Overlay | undefined;38 readonly onClose: () => void;39}4050/** A sheet's or dialog's open state, as the shell holds it. */41const openState = (open: boolean, onClose: () => void) => ({42 onOpenChange: (next: boolean) => {43 if (!next) {44 onClose();
1 unmodified line
46 },47 open,48});4960/** Whether the screen is at least a tablet's width, read when an overlay opens. */50const atLeastTablet = () => globalThis.matchMedia("(min-width: 40rem)").matches;5163/**64 * Every project, with a typed filter: choosing one opens its asks. The65 * names, their posture and their open asks come from the list the rail66 * reads.67 */52const ProjectSwitcher = ({53 input,54 onChosen,55}: {72 /** The filter, which takes focus when the sheet opens. */56 readonly input: RefObject<HTMLInputElement | null>;57 readonly onChosen: () => void;58}) => {59 const listed = useProjectList();
40 unmodified lines
100 return (101 <ComboboxItem className="h-10 gap-3" key={name} value={name}>102 <span className="min-w-0 truncate font-medium">{name}</span>103 {listing === undefined ? null : (121 // One group at the row's end, so the count sits beside122 // the posture rather than midway along the row.104 <span className="ml-auto flex shrink-0 items-center gap-3">105 <span className="text-muted-foreground text-label tabular-nums">106 {listing.openAsks} open107 </span>
9 unmodified lines
117 </Combobox>118 );119};120140/** The Projects sheet's body: the switcher, and the way to import a repo at its foot. */121export const ProjectsSheetBody = ({122 input,123 onChosen,124}: {
14 unmodified lines
139 </div>140 </>141);142163/** The phone's More: Docs, For agents, the project's sections, the keys, the session. */143const More = () => {144 const project = useCurrentProject();145 const listed = useProjectList();146 const { open } = useShell();
87 unmodified lines
234 </Dialog>235 );236};237259/**260 * Every overlay the shell has, each closed until the shell opens it. They261 * stay mounted once loaded, so each one slides in from closed.262 */238/** They stay mounted once loaded, so each one slides in from closed. */239const ShellOverlays = ({ onClose, overlay }: OverlayProps) => {240 const filter = useRef<HTMLInputElement>(null);241242 return (
31 unmodified lines
modified:apps/web/src/features/shared/shell/rail-slot.tsx-22 removed
1/**2 * The rail's slot: room under the project's line for what a page keeps3 * beside it while the reader moves between its siblings (the code pages'4 * file tree). A route names the component that fills it in its5 * `staticData.rail`; the shell draws the deepest one the address matches,6 * on the server too. Sibling routes that name the same component keep one7 * mounted instance as the reader moves between them, since the rail itself8 * never leaves the page.9 *10 * ```tsx11 * const CodeRail = () => <RailSlot label="Files"><ProjectTree /></RailSlot>;12 *13 * export const Route = createFileRoute("/$owner/$project/blob/$rev/$")({14 * staticData: { rail: CodeRail },15 * });16 * ```17 */1import { useMatches } from "@tanstack/react-router";2import { createElement } from "react";3import type { ComponentType, ReactNode } from "react";45declare module "@tanstack/react-router" {6 interface StaticDataRouteOption {24 /** What fills the rail's slot on this route's pages, and on its children's. */7 readonly rail?: ComponentType;8 }9}1029/** The slot's frame: the rest of the rail's height, scrolling on its own. */11export const RailSlot = ({12 children,13 label = "Files",14}: {15 readonly children: ReactNode;35 /** What the slot holds, for a screen reader moving by region. */16 readonly label?: string;17}) => (18 <section19 aria-label={label}
3 unmodified lines
23 {children}24 </section>25);2647/** The component the deepest matched route puts in the slot, when one does. */27export const useRailContent = (): ComponentType | undefined =>28 useMatches({29 select: (matches) =>30 matches.findLast(({ staticData }) => staticData.rail !== undefined)31 ?.staticData.rail,32 });3355/** The slot's content for the address, or nothing. */34export const RailSlotOutlet = (): ReactNode => {35 const Content = useRailContent();3637 return Content === undefined ? null : createElement(Content);
1 unmodified line
modified:apps/web/src/features/shared/shell/rail.tsx+4 added-52 removed
1/**2 * The rail: where the reader is. Top to bottom, the wordmark, which leads3 * to the landing; the site's sections (Home, Asks, Today, Docs, For4 * agents), each a word beside its mark; the5 * projects, the current one first with its own sections under it; the6 * rail's slot on pages that fill it (the code pages' tree); and the session7 * with the Keys button at the foot.8 *9 * From the shell's width it is a column beside main; below it, the same10 * content opens as a sheet from the top bar's Menu (`RailContent`). The11 * current item is filled with the surface and set in ink at 600, never12 * coloured; the router marks a link to the page being read13 * `aria-current="page"`, and a section holding the page is marked14 * `aria-current="true"`.15 */1import { Brand } from "@repo/brand";2import type { ProjectListing } from "@repo/protocol/domain/front-page";3import type { ProjectName } from "@repo/protocol/ids";4import type { Posture } from "@repo/protocol/posture";
28 unmodified lines
33} from "./context.ts";34import { RailSlotOutlet, useRailContent } from "./rail-slot.tsx";35import { projectSections, sectionOf } from "./sections.ts";3652/** A row of the rail, before the fill that marks the current one. */37const RAIL_BASE =38 "text-ui text-foreground hover:bg-surface flex h-8 min-w-0 items-center gap-2.5 px-2 no-underline transition-colors duration-[120ms] focus-visible:outline-offset-[-2px] [&[aria-current]]:font-semibold [&[aria-current]>svg]:text-foreground";3956/** A row of the rail: a word (and its mark), 32 px, filled when current. */40export const RAIL_ROW = `${RAIL_BASE} [&[aria-current]]:bg-surface`;4159/** A row's mark: 16 px at the marks' stroke, muted until the row is current. */42const MARK = "text-muted-foreground size-4 shrink-0";4344const SITE = [45 { icon: House, label: "Home", to: HOME_PATH },
6 unmodified lines
52 readonly label: string;53 readonly to: string;54}[];5574/** Only the page itself is current; its search (a filter, a selection) does not count. */56const EXACT = { exact: true, includeSearch: false } as const;5777/** A count of things at a rail row's end, in tabular figures, with what it counts for a screen reader. */58export const RailCount = ({59 count,60 of,61}: {
5 unmodified lines
67 <span className="sr-only"> {of}</span>68 </span>69);7091/** Today's count, as the root route read it. */71const TodayCount = () => useTodayCount() ?? null;7294/** The wordmark, leading to the landing (which sends a signed-in reader home). */73export const Wordmark = ({74 className = "",75}: {76 readonly className?: string;
6 unmodified lines
83 {Brand.name}84 </AppLink>85);86109/** Home, Asks, Today, Docs and For agents. */87const SiteSections = () => (88 <ul className="flex flex-col gap-px">89 {SITE.map(({ icon: Icon, label, to }) => (90 <li key={to}>
6 unmodified lines
97 ))}98 </ul>99);100124/** A project's posture at its row's end: the mark in its role, its short form muted (the head's), the full label as its title. */101export const PostureMark = ({ posture }: { readonly posture: Posture }) => {102 const { icon: Icon, tone } = POSTURE_MARKS[posture];103104 return (
12 unmodified lines
117 </span>118 );119};120145/**146 * A project's row: its name, and its posture once the list has it. The147 * current project's is in ink at 600 but unfilled, so the page being read148 * (a section under it) is the one filled row.149 */121const ProjectRow = ({122 current,123 listing,124 project,
13 unmodified lines
138 {listing === undefined ? null : <PostureMark posture={listing.posture} />}139 </AppLink>140);141171/** The current project's sections, indented under it, the open asks counted beside Asks. */142export const ProjectSectionList = ({143 openAsks,144 project,145}: {
27 unmodified lines
173 </ul>174 );175};176207/** The list's place while it is read: three rows of the rail's height. */177const PLACEHOLDERS = ["w-24", "w-20", "w-28"] as const;178179const PlaceholderRows = () => (180 <li aria-hidden="true" className="flex flex-col gap-px">
5 unmodified lines
186 </li>187);188189/**221 * The projects: the current one first, its sections under it, so the list222 * arriving after the page moves nothing above it; then the others that223 * lead (the most open asks first, a tie by name), up to eight in all, and224 * the switcher for the rest.190 * The current one first, so the list arriving after the page moves nothing191 * above it.192 */193const Projects = () => {194 const current = useCurrentProject();195 const listed = useProjectList();
58 unmodified lines
254 );255};256257/**291 * A ghost button set in muted text, ink on hover. The colour comes from292 * around the button, not through its `className`: the kit merges classes,293 * reads an unknown `text-*` as a colour, and would drop the button's294 * `text-ui` size for a colour given there.258 * The colour comes from around the button: the kit merges classes, reads an259 * unknown `text-*` as a colour, and would drop the button's `text-ui` size.260 */261const Quiet = ({ children }: { readonly children: ReactNode }) => (262 <span className="text-muted-foreground flex shrink-0">{children}</span>263);264300/** The rail's foot: the session, and the Keys button that opens the `?` dialog. */265export const RailFoot = () => {266 const { open } = useShell();267268 return (
14 unmodified lines
283 </div>284 );285};286323/** The rail's sections and projects: the column's middle, and the Menu sheet's body. */287export const RailContent = (): ReactNode => (288 <div className="flex flex-col gap-2 px-2 py-2">289 <SiteSections />290 <Projects />291 </div>292);293331/**332 * The project's line in the code pages' rail: its name and the section333 * being read, opening to the project's sections, so the tree below gets334 * the height.335 */294const ProjectLine = ({ project }: { readonly project: ProjectName }) => {295 const listed = useProjectList();296297 const section = useLocation({
28 unmodified lines
326 </details>327 );328};329372/**373 * The rail as a column, from the shell's width. On a page that fills the374 * slot (the code pages) it gives the slot the height: the site's sections375 * and the projects fold into the wordmark row's Menu, and the project's376 * sections into its line.377 */330export const Rail = () => {331 const slotted = useRailContent() !== undefined;332 const project = useCurrentProject();333 const { open } = useShell();
37 unmodified lines
modified:apps/web/src/features/shared/shell/sections.ts-36 removed
1/**2 * Where a reader can be: the site's sections, a project's, and the trail of3 * crumbs from the site to the page at an address. The rail, the top bar,4 * the bottom bar, the section row and the context bar all read them here,5 * so one address names one place everywhere.6 */1import { projectAddressOf } from "@repo/protocol/ids";2import { Option } from "effect";34import { segmentsOf } from "../paths.ts";512/** Which of a project's pages is being read. */6export type ProjectTab =7 | "code"8 | "env"9 | "landings"
1 unmodified line
11 | "overview"12 | "people"13 | "refs";1422/** One of a project's sections: its word, its page, and the tab it is. */15export interface Section {16 readonly label: string;17 readonly tab: ProjectTab;18 readonly to: string;19}2029/**30 * A project's sections (`project` as the address names it), in the order31 * every list of them shows. The project's32 * home is its asks; its `people` page is its policy (who decides, vouches,33 * budgets), and reads so, at the address it has always had.34 */21export const projectSections = (project: string): readonly Section[] => [22 { label: "Asks", tab: "overview", to: `/${project}` },23 { label: "Code", tab: "code", to: `/${project}/tree/main` },24 { label: "Landings", tab: "landings", to: `/${project}/commits/main` },
2 unmodified lines
27 { label: "Ledger", tab: "ledger", to: `/${project}/ledger` },28 { label: "Env shape", tab: "env", to: `/${project}/env` },29];3045/** The first segment of each of a project's pages, by the section it sits in. */31const SECTION_OF = {32 answers: "overview",33 asks: "overview",34 blob: "code",
6 unmodified lines
41 tree: "code",42 why: "code",43} as const satisfies Record<string, ProjectTab>;4460/** The site's own first segments: every other one starts a project's address. */45const SITE = new Set([46 "agents",47 "asks",48 "docs",
2 unmodified lines
51 "people",52 "today",53]);5471/**72 * The project an address is in, as the address spells it, and the73 * segments of its page after the name; none on the site's own pages. The74 * name is read by the protocol's one reader of addresses, so75 * `/oscabriel/datekit/ledger` and `/github.com/pallets/click/tree/main` (or76 * the router's own `/github.com%2Fpallets/click/…`) each find theirs.77 */55const addressOf = (pathname: string) => {56 const segments = segmentsOf(pathname);57 const [first] = segments;58
1 unmodified line
60 ? undefined61 : Option.getOrUndefined(projectAddressOf(segments));62};6387/** The project an address is in; none on the site's own pages. */64export const projectOf = (pathname: string): string | undefined =>65 addressOf(pathname)?.spelled;6691/** The project section an address sits in; none for a page under none (a decision, a proposal). */67export const sectionOf = (pathname: string): ProjectTab | undefined => {68 const address = addressOf(pathname);6970 if (address === undefined) {
6 unmodified lines
77 ? "overview"78 : Object.entries(SECTION_OF).find(([segment]) => segment === page)?.[1];79};80106/** One step of the trail to a page: its word, its page (none for the page itself), and whether it is an id. */81export interface Crumb {82 readonly label: string;83 readonly mono?: boolean;84 readonly to?: string;
8 unmodified lines
93 people: "Policy",94 refs: "Refs",95} as const satisfies Record<ProjectTab, string>;96123/** A section's crumb, linked to its page when a page sits below it. */97const sectionCrumb = (98 project: string,99 tab: ProjectTab,100 below: boolean
3 unmodified lines
104105 return below && section !== undefined ? { label, to: section.to } : { label };106};107135/** A project's crumb, then its section's. */108const projectCrumbs = (109 project: string,110 tab: ProjectTab,111 below: boolean
1 unmodified line
113 { label: project, to: `/${project}` },114 sectionCrumb(project, tab, below),115];116145/** A code page's trail: Code, then the path in hand (none at the root). */117const pathCrumbs = (project: string, path: string): readonly Crumb[] =>118 path === ""119 ? projectCrumbs(project, "code", false)120 : [...projectCrumbs(project, "code", true), { label: path, mono: true }];121151/** The site's own pages' trails, by first segment. */122const SITE_CRUMBS = {123 agents: () => [{ label: "For agents" }],124 asks: () => [{ label: "Asks" }],125 docs: (page: string | undefined) =>
7 unmodified lines
133 string,134 (second: string | undefined) => readonly Crumb[]135>;136167/** A project's subject pages' trails (an ask, an answer, a commit, a path…), by second segment. */137const SUBJECT_CRUMBS = {138 answers: (project: string, ask: string) => [139 ...projectCrumbs(project, "overview", true),140 { label: ask, mono: true, to: `/${project}/asks/${ask}` },
26 unmodified lines
167 string,168 (project: string, third: string, rest: string) => readonly Crumb[]169>;170202/**203 * The trail from the site to the page at `pathname`: the project first, then204 * its section, then the thing in hand (an ask, a commit, a path), each a205 * link but the last. A page that knows better gives `Workspace` its own.206 */171export const crumbsFor = (pathname: string): readonly Crumb[] => {172 const [first, second] = segmentsOf(pathname);173174 if (first === undefined) {
35 unmodified lines
modified:apps/web/src/features/shared/shell/selection.ts+2 added-27 removed
1/**2 * A list's selected row, kept in the address's search (`?ask=format-ordinal`,3 * `?decision=dec-000001`), so the server renders the row selected with its4 * facts in the inspector, and a link to them can be shared. Selecting5 * replaces the history entry and keeps every pane's scroll; `Escape` clears6 * it (`useEscapeClears`).7 *8 * A route whose list selects keeps the param out of its loader: `loaderDeps`9 * leaves it out, so a selection never reads the list again, and10 * `shouldReload: reloadOnEnter` keeps a list from reading again on every11 * selection once it is stale.12 *13 * ```tsx14 * const { selected, select } = useSelection("ask");15 * const { focused } = useListKeys(ids, select);16 * <Workspace facts={selected === undefined ? <ProjectFacts /> : <AskFacts ask={selected} />} factsKey={selected} … />17 * ```2 * A route whose list selects leaves the param out of `loaderDeps`, so a3 * selection never reads the list again.4 */5import {6 defaultStringifySearch,7 useLocation,
3 unmodified lines
11import { useCallback } from "react";1213import { useEscapeClears } from "../keys.tsx";1429/** The search params a list selects by. */15export type SelectionParam = "ask" | "decision";1632/** A selection as an address's search carries it. */17const Selection = Schema.Struct({18 ask: Schema.optionalKey(Schema.String),19 decision: Schema.optionalKey(Schema.String),20});2122const decodeSelection = Schema.decodeUnknownOption(Selection);2340/**41 * `searchStr` (`?filter=…&ask=…`) with `param` set to `id`, or without it,42 * each value written as the router writes it.43 */24export const searchWith = (25 searchStr: string,26 param: SelectionParam,27 id?: string
53 unmodified lines
8182 return { clear, select, selected };83};84105/**106 * A route's `shouldReload` for a list that selects: read the list when the107 * reader comes to it (or a link to it is preloaded), not again on each108 * selection; its atoms keep it live.109 */85export const reloadOnEnter = ({ cause }: { readonly cause: string }) =>86 cause !== "stay";
modified:apps/web/src/features/shared/shell/top-bar.tsx-9 removed
1/**2 * The top bar, below the shell's width, where the rail is not drawn. On a3 * tablet (48 px): Menu (the rail as a sheet), the wordmark, the current4 * project as a switcher, and the session at the end. On a phone (44 px):5 * Back to the page above on a subject page (an ask, an answer, a commit),6 * else the wordmark, then the project's switcher; the bottom bar holds the7 * rest.8 */1import { useLocation } from "@tanstack/react-router";2import { ChevronLeft, ChevronsUpDown, Menu } from "lucide-react";34import { Button } from "../../../components/ui/button.tsx";
2 unmodified lines
7import { useCurrentProject, useShell } from "./context.ts";8import { Wordmark } from "./rail.tsx";9import { crumbsFor } from "./sections.ts";1019/** The page above a subject page (its crumb before last), when the address is one. */11const parentOf = (pathname: string) => {12 const crumbs = crumbsFor(pathname);13 const parent = crumbs.at(-2);14
65 unmodified lines
modified:apps/web/src/features/shared/shell/workspace.tsx-45 removed
1/**2 * One page's panes: main (the context bar, the page's head, its toolbar and3 * its content) and, when the page has typed facts, the inspector, both4 * rendered in one pass on the server. Every page renders one `Workspace`.5 *6 * From the shell's width main scrolls on its own and the inspector is a7 * column of its own scroll on the right, its heading announcing what it8 * describes as it changes. Below it, the facts sit in one slot after the9 * page's head: open on a subject's page, a disclosure on a list's (whose10 * summary keeps one fact in sight). Code pages keep the width for the code:11 * the inspector is a column from 1440 px and a sheet below, behind a Facts12 * button in the context bar.13 *14 * Rows and the head stop at 56 rem, left-aligned; prose at 70 ch is the15 * page's; code takes the whole pane.16 */1import { useHydrated, useLocation, useRouter } from "@tanstack/react-router";2import { Predicate } from "effect";3import { ChevronDown, PanelRight } from "lucide-react";4import { Suspense, useState } from "react";
7 unmodified lines
12import { crumbsFor } from "./sections.ts";13import type { Crumb } from "./sections.ts";1415export interface WorkspaceProps {32 /** The trail to the page; the address's when left out. */16 readonly crumbs?: readonly Crumb[];34 /** The page head's title: the headline, or a title when it runs long. */17 readonly title: ReactNode;36 /** The title is someone's own words (a want), shown as they wrote it. */18 readonly said?: boolean | undefined;38 /** A status line under the title. */19 readonly status?: ReactNode;40 /** A 14 px muted line under the status: kind, asker, age. */20 readonly meta?: ReactNode;42 /** The subject's state in a word and a mark, at the context bar's end. */21 readonly state?: ReactNode;44 /** A list's count, at the context bar's end ("10 open asks, 8 open to take"). */22 readonly count?: string;46 /** The page's one command, copied from the context bar. */23 readonly primaryCommand?: string;48 /** Filters, view toggles, sort: a bar that stays under the context bar. */24 readonly toolbar?: ReactNode;50 /** The inspector's fact blocks; inline below the shell's width. */25 readonly facts?: ReactNode;52 /** What the facts describe: "This ask", "Selected ask", "How a change lands here". */26 readonly factsHeading?: string;54 /** The one fact a list keeps in sight below the shell's width (its posture). */27 readonly factsSummary?: ReactNode;56 /** The facts' subject (a selected row's id): a new one settles in. */28 readonly factsKey?: string;58 /** A document (the default), a list, or code. */29 readonly variant?: "code" | "document" | "list";60 /** Main's content. */30 readonly children: ReactNode;31}3264/** Main's side padding at each width. */33export const GUTTER = "px-4 tablet:px-5 shell:px-6";3467/** How wide rows and the head run: 56 rem, from the left. */35export const MEASURE = "max-w-[56rem]";3670/** Past this many characters a title is set a step down, to stay within three lines. */37const LONG_TITLE = 80;3839const PageHead = ({40 meta,
18 unmodified lines
59 )}60 </div>61);6297/** The inspector's heading row: names what the facts describe, and announces it when it changes. */63const FactsHeading = ({ heading }: { readonly heading: string }) => (64 <div65 aria-live="polite"66 className="border-rule bg-background sticky top-0 z-10 flex h-11 shrink-0 items-center border-b px-4"
1 unmodified line
68 <h2 className="text-ui font-semibold">{heading}</h2>69 </div>70);71107/** The facts settling in when their subject changes: 120 ms of opacity, nothing that moves. */72const Settling = ({73 children,74 id,75}: {
4 unmodified lines
80 {children}81 </div>82);83120/** The facts in main, after the head, below the shell's width. */84const InlineFacts = ({85 facts,86 heading,87 list,
34 unmodified lines
122 <div className="flex flex-col">{facts}</div>123 </section>124 );125163/** A code page's Facts button, and its facts as a sheet from the right. */126const FactsSheet = ({127 facts,128 heading,129}: {
48 unmodified lines
178 toolbar,179 pathname,180 variant = "document",181}: WorkspaceProps & {220 /** The address, for the default trail; none outside a router. */182 readonly pathname: string;183}) => {184 const hasFacts = facts !== undefined && facts !== null;185 const code = variant === "code";
12 unmodified lines
198 count={count}199 crumbs={crumbs ?? crumbsFor(pathname)}200 end={201 code && hasFacts ? (241 // The sheet belongs to the page it opened on.202 <FactsSheet203 facts={facts}204 heading={factsHeading}205 key={pathname}
69 unmodified lines
275 pathname={useLocation({ select: (location) => location.pathname })}276 />277);278319/**320 * A page's panes. Inside the router its trail defaults to its address's; a321 * view rendered alone (its own test) draws the same panes with the trail322 * it is given.323 */279export const Workspace = (props: WorkspaceProps) =>280 Predicate.isNotNullish(useRouter({ warn: false })) ? (281 <AtAddress {...props} />282 ) : (
2 unmodified lines
modified:apps/web/src/features/shared/ask-progress.ts+8 added-47 removed
1/**2 * Where each ask of a project stands, folded from the project's events (the3 * `watch` replay its page already reads): who holds it, its rounds, its4 * latest outcome, whether it landed; whose move that leaves; a family's5 * marks against the parent's stored children; and which landings a page6 * that is open should stamp.7 *8 * Pure functions over events, with no transport, so a view can take what9 * they return (and their types) as props.10 */1import type { Ask } from "@repo/protocol/domain/ask";2import { ProjectEvent } from "@repo/protocol/domain/event";3import { Outcome } from "@repo/protocol/domain/outcome";4import type { AskId, CommitSha, Handle, LandedSha } from "@repo/protocol/ids";5import type { DateTime } from "effect";6import { constVoid, identity } from "effect/Function";718/** One answer checked: the commit pushed, what the gate said, and when. */8export interface Round {9 readonly at: DateTime.Utc;10 readonly head: CommitSha;11 readonly outcome: Outcome;12 readonly seq: number;13}1426/** Where one ask stands, as its events tell it. */15export interface AskProgress {28 /** Who holds it now: the last claim, until it is released, lapses or the ask closes. */16 readonly claimant?: Handle;30 /** The landing that closed it, and that event's number. */17 readonly landed?: { readonly sha: LandedSha; readonly seq: number };18 readonly lastPush?: { readonly at: DateTime.Utc; readonly head: CommitSha };33 /** The number of the last event about it. */19 readonly lastSeq: number;20 /**36 * The last outcome of the current attempt: a new claim, a release or a37 * lapse starts the ask over, so an earlier answerer's refusal no longer38 * speaks for it (its round stays in `rounds`).21 * A new claim, a release or a lapse starts the ask over, so an earlier22 * answerer's refusal no longer speaks for it.23 */24 readonly latest?: Outcome;41 /** When it was opened, once the events say so. */25 readonly opened?: DateTime.Utc;43 /** Every answer checked, oldest first. */26 readonly rounds: readonly Round[];27}2847/** One child's place in its family. */29export type Mark =30 | "checking"31 | "claimed"32 | "landed"33 | "open"34 | "refused"35 | "waiting";3656/** A family's progress: each stored child's mark, in order, and how many landed of how many. */37export interface Family {38 readonly children: readonly { readonly ask: AskId; readonly mark: Mark }[];39 readonly landed: number;40 readonly total: number;41}4263/** Who acts next on an ask. */43export type Move = "answerer" | "decider" | "none" | "parent" | "platform";4466/** The highest event number among `events`; 0 when there are none. */45export const lastSeq = (events: readonly ProjectEvent[]): number => {46 let highest = 0;4748 for (const { seq } of events) {
4 unmodified lines
53};5455const fresh: AskProgress = { lastSeq: 0, rounds: [] };5679/** `progress` with nobody holding the ask. */57const unclaimed = ({ claimant: _held, ...rest }: AskProgress): AskProgress =>58 rest;5983/** `progress` started over: nobody holds the ask, and no outcome speaks for it. */60const startedOver = ({61 claimant: _held,62 latest: _said,63 ...rest64}: AskProgress): AskProgress => rest;6590/** `event` applied to `states`, when it is about one ask. */66const apply = (states: Map<AskId, AskProgress>, event: ProjectEvent): void => {67 const change = (68 ask: AskId,69 step: (progress: AskProgress) => AskProgress
44 unmodified lines
114 });115};116117/**143 * Where each ask stands, from a project's events: applied in their number's144 * order, each number once, so a replay heard twice or out of order folds to145 * the same map.118 * Applied in their number's order, each number once, so a replay heard twice or119 * out of order folds to the same map.120 */121export const askStates = (122 events: readonly ProjectEvent[]123): ReadonlyMap<AskId, AskProgress> => {
9 unmodified lines
133134 return states;135};136163/**164 * Who acts next, from the latest outcome alone: a refusal leaves it to the165 * answerer, a wait on a decision or a finish to a decider, a check under166 * way to the platform, a wait on the parent to the rest of its family. With167 * nothing judged yet, a claimed ask is its answerer's to push and an open168 * one nobody's in particular.169 */137export const whoseMove = (latest?: Outcome, claimant?: Handle): Move => {138 if (latest === undefined) {139 return claimant === undefined ? "none" : "answerer";140 }
7 unmodified lines
148 WaitingOnParent: (): Move => "parent",149 });150};151185/** One child's mark: landed first, then what its latest outcome says, then whether someone holds it. */152export const markOf = (progress: AskProgress | undefined): Mark => {153 if (progress === undefined) {154 return "open";155 }
18 unmodified lines
174 return claimant === undefined ? "open" : "claimed";175};176177/**212 * A family's marks: one per child the parent stores (`showAsk(parent)`'s213 * `blockedBy`, in its order), and how many of them landed. A listing's214 * `blockedBy` names only the children still open, so it cannot count them.178 * A listing's `blockedBy` names only the children still open, so it cannot179 * count them.180 */181export const familyMarks = (182 parent: Ask,183 states: ReadonlyMap<AskId, AskProgress>
10 unmodified lines
194 };195};196197/**233 * The asks whose landing a page that is open should stamp: landed in234 * `next`, not in `previous` (the read before; none for the first read), and235 * closed by an event after the highest number of the first read the page236 * settled on (`mountSeq`). A replay that already held a landing never237 * stamps it, and a landing stamps once, whether the stream or the poll238 * brought it.198 * A replay that already held a landing never stamps it, and a landing stamps199 * once, whether the stream or the poll brought it.200 */201export const stampsFrom = (202 previous: ReadonlyMap<AskId, AskProgress> | undefined,203 next: ReadonlyMap<AskId, AskProgress>,
11 unmodified lines
modified:apps/web/src/features/shared/classes.ts+2 added-8 removed
1/**2 * The class strings many views share, in a module with no view of its own,3 * so a route that needs one never pulls a view (and what that view4 * imports) into the code every page loads.2 * A module with no view, so a route that needs a class never pulls a view into3 * the code every page loads.4 */57/** A section's heading, the "title" step of the type scale. */6export const SECTION = "text-lg font-semibold tracking-[-0.01em]";710/** The mono face for names a terminal prints: ids, kinds, territories. */8export const ID = "font-mono text-mono";913/** Text that is code: an id, a path, a SHA, a command's name; it wraps anywhere. */10export const CODE = "font-mono text-mono [overflow-wrap:anywhere]";1116/** A link in running text: underlined in the rule colour, darker on hover. */12export const LINK = "decoration-rule underline hover:decoration-current";1319/** A field's label: small, muted, above or beside its value. */14export const LABEL = "text-muted-foreground text-label font-medium";
modified:apps/web/src/features/shared/command.tsx+4 added-27 removed
1// A shell line a reader runs next: a refusal's `next`, a clone URL, the2// install line. The terminal is where work happens, so every page that3// suggests an action shows its command, whole and copyable, never a form.4//5// A page marks its main commands `numbered`: while the single keys are on,6// each shows its number before the `$`, and that number key copies it7// ("Copy (1)" in the button's title).1import { Check, Copy } from "lucide-react";2import { createContext, useContext } from "react";3import type { ReactNode } from "react";45import { Button } from "../../components/ui/button.tsx";6import { useCopy } from "./copy-action.tsx";7import { useNumberedCommand } from "./keys.tsx";816/**17 * Where a command line is drawn: a box hugging its command in main, or18 * the inspector's bleed form, pane-wide between two hairlines, where the19 * column is narrow and every character of the line counts.20 */9type Form = "bleed" | "box";1011const FormContext = createContext<Form>("box");1225/** Command lines under it take the inspector's bleed form. */13export const InspectorCommands = ({14 children,15}: {16 readonly children: ReactNode;17}) => <FormContext value="bleed">{children}</FormContext>;1832/** How far a line of the command hangs, in ch, when the column breaks it: less in the inspector's narrow column. */19const HANGS = { bleed: 2, box: 6 } as const satisfies Record<Form, number>;2035/** The box around the command, in each form. */21const BOXES = {22 bleed:23 "border-rule bg-surface text-mono leading-terminal -mx-4 flex min-w-0 items-start gap-2 border-y py-1 pr-1 pl-4 font-mono",24 box: "border-rule bg-surface text-mono leading-terminal flex w-fit max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3 font-mono",25} as const satisfies Record<Form, string>;2627/**43 * A line's hang: `hang` ch, or less on a line so short that its longest word44 * would not fit beside the hang. The box hugs its longest line, so a line's45 * room beside its hang is its own length less the hang; a word wider than46 * that room is broken in two (`<cli> today` read "tod" / "<cli> ay"). Such a47 * line fits whole wherever its box does, so its hang never shows.28 * The box hugs its longest line, so a word wider than the room beside the hang29 * would be broken in two; such a line fits whole wherever its box does.30 */31const hangOf = (hang: number, words: readonly string[], line: string) =>32 Math.min(33 hang,34 line.length - Math.max(0, ...words.map(({ length }) => length))35 );3655// The command's words, each kept whole on its line: a narrow column breaks56// the line between words, never after a word's own hyphen57// (`lint-heading-levels`, `--project`) nor before a closing ` \`; a word58// longer than the line (a URL) still breaks, anywhere. Each of the59// command's own lines hangs, so a line the column breaks reads as one line60// going on. The text is the command's, space for space.37// Breaks between words, never after a word's own hyphen (`--project`) nor38// before a closing ` \`.39const wordsOf = (command: string, form: Form) =>40 command.split("\n").map((line, at, lines) => {41 const parts = line.split(/(?<space>\s+)(?!\\$)/u);42
83 unmodified lines
126 command,127 numbered = false,128}: {129 readonly command: string;152 /** One of the page's main commands, which a number key copies. */130 readonly numbered?: boolean;131}) =>132 numbered ? (133 <NumberedLine command={command} />
3 unmodified lines
modified:apps/web/src/features/shared/copy-action.tsx+2 added-23 removed
1/**2 * A command copied with one press. The command itself is always text in3 * the page (inside the button, visually hidden where only the icon shows),4 * so an agent reading the HTML and a screen reader both get it, never only5 * a clipboard payload. After a copy the button shows a check and says6 * "Copied" for two seconds, once, in a polite live region.7 *8 * - `CopyAction`: a row's ghost button, 32 px square, named for what it9 * copies ("Copy claim command").10 * - `CommandChip`: the command shown whole, small, at the end of a status11 * line; pressing it copies it.12 *13 * Either can be numbered: while the single keys are on, its number copies14 * it, and shows in its title ("Copy claim command (1)").2 * The command is always text in the page, so an agent reading the HTML and a3 * screen reader both get it, never only a clipboard payload.4 */5import { Brand } from "@repo/brand";6import { Effect, Option } from "effect";7import { Check, Copy } from "lucide-react";8import { useState } from "react";910import { useCopiedCommand, useNumberedCommand } from "./keys.tsx";1123/** Copy `command`, then show it copied for two seconds. */12const copyFor = (command: string, shown: (copied: boolean) => void) =>13 Effect.tryPromise(() => navigator.clipboard.writeText(command)).pipe(14 Effect.andThen(15 Effect.sync(() => {
8 unmodified lines
24 ),25 Effect.ignore26 );2740/**41 * Copying `command`: whether it was just copied (by this control, or by its42 * number key), and the press that copies it.43 */28export const useCopy = (command: string) => {29 const [pressed, setPressed] = useState(false);30 const byKey = useCopiedCommand();31
6 unmodified lines
38};3940interface CopyProps {41 readonly command: string;58 /** What the button copies, as its accessible name: "Copy claim command". */42 readonly label: string;60 /** Whether the page's number keys reach it. */43 readonly numbered?: boolean;44}4546const ActionButton = ({
35 unmodified lines
82const NumberedAction = (props: Omit<CopyProps, "numbered">) => (83 <ActionButton {...props} number={useNumberedCommand(props.command)} />84);85104/** A row's copy button: the icon in sight, the command in the text. */86export const CopyAction = ({ numbered = false, ...props }: CopyProps) =>87 numbered ? (88 <NumberedAction {...props} />89 ) : (90 <ActionButton {...props} number={undefined} />91 );92112/** An open ask's claim command, as a row's copy button. */93export const ClaimAction = ({94 ask,95 project,96}: {
5 unmodified lines
102 label="Copy claim command"103 />104);105126/** A command shown whole and small (a status line's next step); pressing it copies it. */106export const CommandChip = ({ command }: { readonly command: string }) => {107 const { copied, copy } = useCopy(command);108 const Icon = copied ? Check : Copy;109
22 unmodified lines
modified:apps/web/src/features/shared/credits.tsx+1 added-21 removed
1/**2 * A landing's trailers, as the commit carries them: credit first, in the3 * order of `CreditRole`'s literals (`Asked-by` before `Signed-off-by`), one4 * `Role: handle` line per person; then the `Held-back:` commitment, if the5 * landing was judged by held-back checks; then, apart and labelled, the6 * agents people worked through. `Assisted-by` is a disclosure, never credit7 * (GLOSSARY.md "Credit").8 *9 * `CompactCredit` is the same credit in one line for a row ("Asked by10 * ines-v · answered by tamsin"): the roles in the same order, each person11 * linked, and never an agent.12 */1/** `Assisted-by` is a disclosure, never credit. */2import { CreditRole } from "@repo/protocol/domain/credit";3import type { AgentTrailer, Credit } from "@repo/protocol/domain/credit";4import { LockKeyhole } from "lucide-react";5import { Fragment } from "react";
1 unmodified line
7import { HandleLink } from "./handle.tsx";89const rank = (credit: Credit) => CreditRole.literals.indexOf(credit.role);1022/** Credits in trailer order; people in one role keep the order given. */11export const inTrailerOrder = (credits: readonly Credit[]) =>12 credits.toSorted((one, other) => rank(one) - rank(other));1326/** An `Assisted-by:` value as the landing's trailer spells it: `pi:opus-4 (claimed)`. */14export const assistedValue = ({ harness, model, verified }: AgentTrailer) =>15 `${harness}${model === undefined ? "" : `:${model}`} (${verified ? "verified" : "claimed"})`;1617const LINES = "flex flex-col gap-1 font-mono text-mono leading-terminal";
8 unmodified lines
26}: {27 readonly assisted: readonly AgentTrailer[];28 readonly credits: readonly Credit[];29 readonly heldBack?: string;43 /** "Credit" as a fact's label, or at Title weight, a region's own head (the Landed page). */30 readonly label?: "fact" | "title";31}) => (32 <div className="flex flex-col gap-4">33 {credits.length === 0 ? null : (
31 unmodified lines
65 )}66 </div>67);6883/** Each role as a row's line says it: the trailer, in words. */69const roleWords = {70 "Advised-by": "advised by",71 "Asked-by": "asked by",72 "Decided-by": "decided by",
2 unmodified lines
75 "Released-by": "released by",76 "Signed-off-by": "answered by",77} as const satisfies Record<CreditRole, string>;7894/** A sentence's first word with its first letter raised. */79const raised = (words: string) =>80 `${words.slice(0, 1).toUpperCase()}${words.slice(1)}`;8198/** What comes before the `index`th of `count` people in a list of words. */82const before = (index: number, count: number) => {83 if (index === 0) {84 return "";85 }8687 return index === count - 1 ? " and " : ", ";88};89107/** People in a list of words: "bram", "bram and tamsin", "bram, ines and tamsin". */90const Joined = ({ people }: { readonly people: readonly Credit[] }) =>91 people.map(({ handle }, index) => (92 <Fragment key={handle}>93 {before(index, people.length)}94 <HandleLink handle={handle} />95 </Fragment>96 ));97116/** A landing's credit in one line: each role once, in trailer order, its people linked. */98export const CompactCredit = ({99 credits,100 within = false,101}: {102 readonly credits: readonly Credit[];122 /** Inside a sentence, after a ` · `: its first word stays lower case. */103 readonly within?: boolean;104}) => {105 const roles = CreditRole.literals.flatMap((role) => {106 const people = credits.filter((credit) => credit.role === role);
17 unmodified lines
modified:apps/web/src/features/shared/disclosure.ts-5 removed
1/**2 * What people outside a layer's audience learn about what it holds, in3 * one set of words for every page that shows a layer (the ledger, the4 * people page).5 */1import type { Disclosure } from "@repo/protocol/domain/visibility";23export const disclosureWords = {4 counted: "counted: how many it holds, and when they open",
8 unmodified lines
modified:apps/web/src/features/shared/empty.tsx-8 removed
1/**2 * An empty list, said plainly, with the way onward: the command that would3 * fill it, or a link to where to go instead. A dashed hairline marks the4 * place the rows would be, an unfilled field rather than a dead end.5 */1import type { ReactNode } from "react";23import { CommandLine } from "./command.tsx";4
1 unmodified line
6 command,7 onward,8 title,9}: {15 /** The command that changes what is empty. */10 readonly command?: string;17 /** Where to go instead, when no command changes it: a link or two. */11 readonly onward?: ReactNode;19 /** One sentence saying what is empty. */12 readonly title: string;13}) => (14 <div className="border-rule flex flex-col items-start gap-3 border border-dashed px-4 py-5">15 <p className="text-ui text-foreground max-w-[70ch]">{title}</p>
6 unmodified lines
modified:apps/web/src/features/shared/facts.tsx+1 added-64 removed
1/**2 * The inspector's fact blocks: the typed facts of the thing in hand, each3 * under a label, in a fixed order per page. A block holds no box; a value4 * that is code is mono and wraps anywhere; a long SHA or root is shortened5 * (`7fbe4b2`, `sha256:7fbe4b…`), its whole value in its title and on copy.6 * Blocks never repeat the page's prose: they hold the facts it refers to.7 *8 * The blocks every page shares are here (State, Take it, Claim, Gate,9 * Posture, Held back, Family, Territory and check, Credit,10 * Provenance); a block only one page has is that page's own.11 */1import { Brand } from "@repo/brand";2import type { Verdict } from "@repo/protocol/domain/answer";3import type { Ask } from "@repo/protocol/domain/ask";4import { CheckSpec } from "@repo/protocol/domain/check";
26 unmodified lines
31import { StatusLine, readStatus, stageNames } from "./status-line.tsx";32import type { StatusSubject } from "./status-line.tsx";33import { When } from "./time.tsx";3446/** A block's frame: a hairline above every block but the first. */35const BLOCK =36 "@container border-rule flex min-w-0 flex-col gap-2.5 border-t py-3 first:border-t-0 first:pt-0";3738const LINK = "decoration-rule underline hover:decoration-current";3952/** One block: its label, then its facts. */40export const FactBlock = ({41 children,42 label,43}: {
5 unmodified lines
49 {children}50 </section>51);5266/**67 * A long hash as a person reads it: a 40- or 64-hex SHA to its first68 * seven, an `algorithm:hex` root to the algorithm and six; anything else as69 * it is.70 */53export const shortValue = (value: string) => {54 if (/^[0-9a-f]{40,64}$/u.test(value)) {55 return shortSha(value);56 }
7 unmodified lines
64 ? value65 : `${algorithm}:${hex.slice(0, 6)}…`;66};6786/** A value that is code: shortened, whole in its title. */68export const CodeValue = ({ value }: { readonly value: string }) => (69 <code className="text-mono font-mono [overflow-wrap:anywhere]" title={value}>70 {shortValue(value)}71 </code>72);7393/** The status line whole, and the command that runs next, numbered first. */74export const StateFacts = ({75 command,76 subject,77}: {78 readonly subject: StatusSubject;99 /** What runs next; a refusal's own `next` when left out. */79 readonly command?: string;80}) => {81 const next = command ?? readStatus(subject).next;82
4 unmodified lines
87 </FactBlock>88 );89};90112/** One numbered step: what it does, then its command. */91const Step = ({92 command,93 label,94}: {
5 unmodified lines
100 <CommandLine command={command} numbered />101 </div>102);103126/** Who may take an ask, in a sentence. */104const whoMayTake = (ask: Ask) => {105 if (ask.reserve === "newcomers") {106 return ask.mentor === undefined107 ? "Held for newcomers"
4 unmodified lines
112 ? "Held for people, not agents"113 : `Anyone vouched in ${ask.project}, or with a record in its area`;114};115139/** Who may take an open ask, then the three commands that start an answer. */116export const TakeItFacts = ({117 ask,118 platformUrl,119}: {120 readonly ask: Ask;145 /** Where the project is cloned from. */121 readonly platformUrl: string;122}) => (123 <FactBlock label="Take it">124 <p className="text-ui">{whoMayTake(ask)}</p>
8 unmodified lines
133 <Step command={`${Brand.cli} check`} label="Check before you push" />134 </FactBlock>135);136162/** Who holds a claim, in words: the viewer, someone, or nobody. */137const Holder = ({138 claimant,139 yours,140}: {
12 unmodified lines
153 </>154 );155};156183/**184 * Who holds a claim and when they last pushed. No read carries a claim's185 * deadline, so none is shown.186 */157/** No read carries a claim's deadline, so none is shown. */158export const ClaimFacts = ({159 claimant,160 lastPush,161 now,
1 unmodified line
163}: {164 readonly claimant?: Handle;165 readonly lastPush?: AskProgress["lastPush"];166 readonly now: DateTime.Utc;196 /** Who is reading, to tell the claimant it is theirs. */167 readonly viewer?: Handle;168}) => {169 const yours = claimant !== undefined && claimant === viewer;170
17 unmodified lines
188 </FactBlock>189 );190};191222/** What each stage runs, in one line. */192const runs = Match.type<StageName>().pipe(193 Match.when(194 "parse",195 () => "Who may push what: the branch, the pusher and their claim."
22 unmodified lines
218 ),219 Match.exhaustive220);221253/** Each stage's state as a mark and a word. */222const stageMarks = {223 current: { mark: "now", word: "now" },224 passed: { mark: "passed", word: "passed" },225 pending: { mark: "notYet", word: "not yet" },
3 unmodified lines
229 StageState,230 { readonly mark: StateMark; readonly word: string }231>;232265/**266 * The gate. On a project: the seven stages in the order of their cost, on267 * one line, and what each runs behind a disclosure. On an answer: each268 * stage's state, the one it stands at marked as the current step.269 */233export const GateFacts = (234 props:235 | { readonly outcome?: undefined }236 | {
74 unmodified lines
311 </FactBlock>312 );313};314352/** What each posture means, in one line. */315const glosses = {316 open: "Everything it ships is public.",317 openCore: "Some files it ships are kept in a layer, with no date to open.",318 openOnSchedule:
2 unmodified lines
321 "Everything it ships is public; some checks are kept in a layer and judge answers unseen.",322 sourceAvailable: "Its licence is not an open-source one.",323} as const satisfies Record<Posture, string>;324363/** A project's posture as the platform labels it, what it means, and its ledger. */325export const PostureFacts = ({326 label,327 posture,328 project,
10 unmodified lines
339 </AppLink>340 </FactBlock>341);342382/** What a project holds back: one sealed line per area, or that nothing is. */343export const HeldBackFacts = ({344 areas,345}: {346 readonly areas: readonly {347 readonly area: AreaName;388 /** What the area holds, in words: "7 sealed checks". */348 readonly detail: string;349 }[];350}) => (351 <FactBlock label="Held back">
21 unmodified lines
373 )}374 </FactBlock>375);376418/** The family a member belongs to, drawn top to bottom. */377export const FamilyFacts = (props: Parameters<typeof FamilyTree>[0]) => (378 <FactBlock label="Family">379 <FamilyTree {...props} />380 </FactBlock>381);382425/** The folder a territory's first path names, when it names one plainly. */383const folderOf = (ask: Ask) => {384 const [first] = ask.territory.paths;385 const folder = first.replace(/\/\*\*$|\/\*$|^\*\*$/u, "");386387 return /[*?[{]/u.test(folder) ? undefined : folder;388};389433/**434 * A territory: a module by name, linked to its folder when its first path435 * names one plainly; the whole project when it covers every path; or, in436 * a repo of one package, the paths themselves.437 */390const TerritoryLine = ({ ask }: { readonly ask: Ask }) => {391 const folder = folderOf(ask);392 const { module, paths } = ask.territory;393
24 unmodified lines
418 </AppLink>419 );420};421470/** What judges an answer, by the check's kind. */422const CheckLine = ({ ask }: { readonly ask: Ask }) =>423 CheckSpec.match(ask.check, {424 LintToZero: ({ rule }) => (425 <p className="text-ui">
35 unmodified lines
461 </p>462 ),463 });464514/** Where an answer may change things, and what judges it. */465export const TerritoryFacts = ({ ask }: { readonly ask: Ask }) => (466 <FactBlock label="Territory and check">467 <TerritoryLine ask={ask} />468 <CheckLine ask={ask} />469 </FactBlock>470);471522/** A landing's credit as the commit carries it, the agents apart. */472export const CreditFacts = (props: {473 readonly assisted: readonly AgentTrailer[];474 readonly credits: readonly Credit[];475 readonly heldBack?: string | undefined;
6 unmodified lines
482 />483 </div>484);485537/** One fact of provenance: its label, its whole value, and how it reads. */486export interface ProvenanceEntry {487 readonly label: string;488 readonly value: string;541 /** How it reads, when not as its shortened value (a time). */489 readonly shown?: ReactNode;490}491545/** What a verdict judged: the commits, the tree, the patch, the check, who judged it and when. */492export const verdictProvenance = (493 verdict: Verdict,494 now: DateTime.Utc495): readonly ProvenanceEntry[] => [
9 unmodified lines
505 value: DateTime.formatIso(verdict.at),506 },507];508563/** Where a landing comes from: its author, its parent, and the request that landed it. */509export const landingProvenance = (510 landing: LandingView511): readonly ProvenanceEntry[] => [512 { label: "Author", value: landing.author },
7 unmodified lines
520 ? []521 : [{ label: "Request-Id", value: landing.requestId }]),522];523579/**580 * The plumbing, last: each value shortened, whole in its title and on581 * copy. Below the shell's width it starts folded.582 */524export const ProvenanceFacts = ({525 entries,526}: {527 readonly entries: readonly ProvenanceEntry[];
21 unmodified lines
549 />550 </button>551 <dl className={`${open ? "flex" : "shell:flex hidden"} flex-col gap-1.5`}>552 {entries.map(({ label, shown, value }) => (612 // A label over its value, as every block is: never a key and613 // value grid.553 <div554 className="flex min-w-0 flex-col"555 data-provenance={label}556 key={label}
5 unmodified lines
562 </span>563 {shown === undefined ? (564 <CopyAction command={value} label={`Copy ${label}`} />565 ) : (627 // A time reads as words, its exact instant in its own628 // title: nothing here to paste into a terminal.566 <span aria-hidden="true" className="size-8 shrink-0" />567 )}568 </dd>569 </div>
5 unmodified lines
modified:apps/web/src/features/shared/family.tsx+1 added-41 removed
1/**2 * A family as a fan: a parent ask split into sibling children, one per3 * module, and a delete child that waits for all of them. The children are4 * siblings, so they are drawn side by side on one bus, never as a ladder,5 * with an arrow to the delete child at the end.6 *7 * - `FamilyStrip` is a parent row's third line: each child's mark and its8 * short name, the arrow to the delete child, "n of N landed", and a9 * button that lists the children as rows beneath. N is the children the10 * parent stores, never the listing's remaining blockers (a listing drops11 * the ones that landed).12 * - `FamilyTree` is the vertical form, for the inspector and the top of a13 * member's page: the parent, its children on a left bus, then the delete14 * child, the member being read marked.15 *16 * A child that lands while the page is open settles with the stamp, once17 * (the caller's `stamps`, from `stampsFrom`); the count changes with no18 * motion of its own, and with reduced motion nothing moves.19 */1import type { Ask } from "@repo/protocol/domain/ask";2import type { AskId, ProjectName } from "@repo/protocol/ids";3import { ArrowRight, ChevronDown } from "lucide-react";4import { useId, useState } from "react";
5 unmodified lines
10import { StateMarkIcon } from "./marks.tsx";11import type { StateMark } from "./marks.tsx";12import { askPath } from "./paths.ts";1333/** Each child's state in the words its node is read by. */14const words = {15 checking: "checking",16 claimed: "claimed",17 landed: "landed",
1 unmodified line
19 refused: "refused",20 waiting: "waiting",21} as const satisfies Record<Mark, string>;2243/** The fold's marks are named as the marks are. */23const markFor = (mark: Mark): StateMark => mark;2446/** The words of `id` after `prefix` and its dash, or `id` when it does not start so. */25const after = (id: string, prefix: string) =>26 id.startsWith(`${prefix}-`) ? id.slice(prefix.length + 1) : id;2750/**51 * Each child's short name: its id after the parent's, and after any word52 * every sibling shares ("drop-legacy-fetch-burrow-auth" reads "auth" when53 * every child is a burrow module).54 */28export const shortNames = (29 parent: AskId,30 children: readonly AskId[]31): ReadonlyMap<AskId, string> => {
16 unmodified lines
48 })49 );50};5179/** A family's children (the delete child apart), their marks and what the delete child waits on. */52const familyOf = (53 parent: Ask,54 states: ReadonlyMap<AskId, AskProgress>,55 finale: AskId | undefined
17 unmodified lines
73 total: children.length,74 };75};76105/** Where the delete child stands: its mark, and its state in words. */77interface FinaleState {78 readonly mark: StateMark;79 readonly words: string;80}81111/** The delete child's state: it waits until every child lands, then opens, then lands. */82const finaleOf = (83 finale: AskId,84 states: ReadonlyMap<AskId, AskProgress>,85 remaining: number
16 unmodified lines
102103const NODE =104 "text-label relative z-10 inline-flex min-w-0 items-center gap-1 no-underline hover:underline decoration-rule";105136/** A row's third line: the fan, the count, and the children as rows on demand. */106export const FamilyStrip = ({107 expanded,108 finale,109 parent,
3 unmodified lines
113 wants,114}: {115 readonly parent: Ask;116 readonly states: ReadonlyMap<AskId, AskProgress>;148 /** The delete child, when the family has one. */117 readonly finale?: AskId;150 /** Children that landed while the page was open. */118 readonly stamps: ReadonlySet<AskId>;119 readonly project: ProjectName;153 /** Whether the children start listed as rows. */120 readonly expanded: boolean;155 /** Each child's want, when the page has it, for the listed rows. */121 readonly wants?: ReadonlyMap<AskId, string>;122}) => {123 const [open, setOpen] = useState(expanded);124 const rowsId = useId();
80 unmodified lines
205 {open ? "Hide" : "Show"} {family.total} {plural}206 </span>207 </button>208 </div>244 {/* Folded, the rows stay in the page, hidden: each open child's245 claim command is text an agent reading the page still finds. */}209 {/* Folded, the rows stay in the page: each open child's claim command is text an agent still finds. */}210 <ul211 className="border-rule mt-1 ml-[0.4375rem] flex flex-col border-l pl-3"212 hidden={!open}213 id={rowsId}
38 unmodified lines
252 </div>253 );254};255292/** One member in the vertical form: its mark, its name, its state's word; the member being read filled. */256const Member = ({257 current,258 label,259 mark,
23 unmodified lines
283 </span>284 </AppLink>285);286324/** The family read top to bottom: the parent, its children on a bus, then the delete child. */287export const FamilyTree = ({288 current,289 finale,290 parent,
2 unmodified lines
293}: {294 readonly parent: Ask;295 readonly states: ReadonlyMap<AskId, AskProgress>;296 readonly finale?: AskId;335 /** The member whose page this is. */297 readonly current?: AskId;298 readonly project: ProjectName;299}) => {300 const family = familyOf(parent, states, finale);301 const progress = markOf(states.get(parent.id));302342 // An open parent waits while anything it waits on has not landed.303 const own =304 progress === "open" &&305 parent.blockedBy.some((ask) => states.get(ask)?.landed === undefined)306 ? "waiting"
49 unmodified lines
modified:apps/web/src/features/shared/handle.tsx-4 removed
1/**2 * A person, by handle, linking to their page of credits. People appear by3 * handle and role only: nothing here ranks or scores them.4 */1import type { Handle } from "@repo/protocol/ids";23import { AppLink } from "./link.tsx";4import { personPath } from "./paths.ts";
9 unmodified lines
modified:apps/web/src/features/shared/head.ts+2 added-14 removed
1/**2 * What a page puts in the document's head, in a module with no view of its3 * own: a route's `head` runs with the route, before its page's view loads.4 */1import { Brand } from "@repo/brand";27/** A page's `<title>`: the page, then the product. */3export const pageTitle = (title: string) => `${title} · ${Brand.name}`;45/**11 * A page's head: its `<title>`, and what a shared link unfurls with (the12 * description and the Open Graph title, description and type; no image).13 * The router keeps one meta per name or Open Graph property, the last a14 * route gives, so a page's replace the root's, and a page with no15 * description of its own unfurls with the root's.16 *17 * ```ts18 * head: ({ params }) => pageHead({ title: `${params.ask} · ${params.project}`, description: want }),19 * ```6 * The router keeps one meta per name or Open Graph property, the last a route7 * gives, so a page's replace the root's.8 */9export const pageHead = ({10 description,11 title,
18 unmodified lines
modified:apps/web/src/features/shared/keys.tsx+4 added-72 removed
1/**2 * The keyboard's single keys, one listener for the whole shell:3 *4 * - `?` opens the keys dialog, which lists them and holds the switch;5 * - `j` / `k` move through the page's list (its rows, `useListKeys`), and at6 * the shell's width select the row, so the inspector follows; `Enter`7 * opens the focused row, as a link does;8 * - `J` / `K` move between the page's files (`useFileKeys`);9 * - `1` to `9` copy the page's numbered commands, the inspector's first10 * (`useNumberedCommand`);11 * - `Escape` clears the selection (a sheet or a dialog closes itself).12 *13 * No key acts while focus is in a text field, a combobox or the tree's14 * search, or with Ctrl, Alt or Meta held. Every key has a twin a pointer15 * reaches: rows are links, files are the tree's rows, commands have their16 * copy buttons. The switch turns every key but `?` off (WCAG 2.2 SC 2.1.4)17 * and is the viewer's own: kept in this browser's storage, on until turned18 * off, and on whenever the storage cannot be read.2 * The switch turns every key but `?` off (WCAG 2.2 SC 2.1.4), and is on3 * whenever the storage cannot be read.4 */5import { Effect, Option, Result } from "effect";6import {7 createContext,
8 unmodified lines
16import type { ReactNode } from "react";1718import { Kbd } from "../../components/ui/kbd.tsx";1935/** A key pressed, as the listener reads it. */20export interface KeyPress {21 readonly altKey: boolean;22 readonly ctrlKey: boolean;39 /** Whether focus is in a text field, a combobox or a search. */23 readonly inField: boolean;24 readonly key: string;25 readonly metaKey: boolean;26}2745/** What a key asks for. */28export type KeyIntent =29 | { readonly index: number; readonly kind: "copy" }30 | {31 readonly kind:
13 unmodified lines
45} as const satisfies Record<string, KeyIntent["kind"]>;4647const DIGIT = /^[1-9]$/u;4867/** The shell's width, from which the rail and the inspector are columns. */49const SHELL_WIDTH = "(min-width: 70rem)";5070/**71 * What `press` asks for, with the single keys `on` or off; nothing for a72 * press in a text field, with a modifier held, or with no meaning here.73 */51export const intentOf = (52 press: KeyPress,53 on: boolean54): KeyIntent | undefined => {
21 unmodified lines
7677 return move === undefined ? undefined : { kind: move[1] };78};79103/** Where the switch is kept, in the browser's storage. */80const SWITCH = "keys.single";81106/** Whether the single keys are on: on unless `storage` says off, or cannot say. */82export const readShortcuts = (storage?: Storage): boolean =>83 storage === undefined ||84 Result.getOrElse(85 Result.try(() => storage.getItem(SWITCH) !== "off"),86 () => true87 );88114/** Keep the switch as `on` says; a storage that refuses keeps nothing. */89export const writeShortcuts = (storage: Storage | undefined, on: boolean) => {90 Result.try(() => storage?.setItem(SWITCH, on ? "on" : "off"));91};92119/** The browser's storage, when there is one this page may use. */93const localStorageOf = (): Storage | undefined =>94 Result.getOrUndefined(Result.try(() => globalThis.localStorage));95123/** The keys and what each does, as the dialog lists them. */96const KEYS = [97 { does: "Show these keys", keys: ["?"] },98 { does: "Next or previous row", keys: ["j", "k"] },99 { does: "Open the focused row", keys: ["Enter"] },
1 unmodified line
101 { does: "Copy the page's numbered command", keys: ["1", "…", "9"] },102 { does: "Close, or clear the selection", keys: ["Esc"] },103] as const;104133/** The switch's two settings, each a button that says whether it is pressed. */105const SETTINGS = [106 { label: "On", on: true },107 { label: "Off", on: false },108] as const;109139/**140 * The keys dialog's body: every key with what it does, and the switch. `?`141 * opens it even with the switch off, so the switch is always in reach.142 */110export const KeysHelp = ({111 on,112 onChange,113}: {
44 unmodified lines
158 </p>159 </div>160);161195/** Which part of the page a command sits in: the inspector's are numbered first. */162export type CommandSlot = "facts" | "main";163164const SlotContext = createContext<CommandSlot>("main");165200/** Commands under `slot` number as the inspector's or main's. */166export const CommandSlotProvider = ({167 children,168 slot,169}: {170 readonly children: ReactNode;171 readonly slot: CommandSlot;172}) => <SlotContext value={slot}>{children}</SlotContext>;173209/** A list the page lets `j` and `k` move through. */174interface ListRegistration {175 readonly focus: (id: string) => void;176 readonly read: () => {177 readonly ids: readonly string[];
1 unmodified line
179 };180 focused?: string;181}182219/** The files a page lets `J` and `K` move between. */183interface FileRegistration {184 readonly read: () => {185 readonly onMove: (path: string) => void;186 readonly paths: readonly string[];
6 unmodified lines
193 readonly id: string;194 readonly slot: CommandSlot;195}196234/** What the page registers with the listener; one for the shell's life. */197interface Registry {198 readonly clearers: Set<() => void>;199 readonly files: Set<FileRegistration>;200 readonly lists: Set<ListRegistration>;201 readonly register: (command: Command) => () => void;202}203242/** What the keys show: whether they are on, the numbers, the last copy. */204interface KeysState {205 readonly copied: string | undefined;206 readonly numbered: ReadonlyMap<string, number>;207 readonly on: boolean;
3 unmodified lines
211const RegistryContext = createContext<Registry | undefined>(undefined);212213const StateContext = createContext<KeysState | undefined>(undefined);214254/** The keys' state, for the dialog. */215export const useKeys = () => useContext(StateContext);216257/** `item` in `set` until the returned function takes it out. */217const held = <A,>(set: Set<A>, item: A) => {218 set.add(item);219220 return () => {221 set.delete(item);222 };223};224266/** The last registered of `set`: the page's own, over any that left late. */225/** The page's own, over any that left late. */226const lastOf = <A,>(set: ReadonlySet<A>): A | undefined => [...set].at(-1);227269/** Whether `event` was pressed inside something that takes typing. */228export const inField = (event: KeyboardEvent) => {229 const [target] = event.composedPath();230231 return (
4 unmodified lines
236 ) !== null)237 );238};239282/** Numbers commands 1 to 9: the inspector's first, each command once. */240const numberOf = (241 commands: readonly Command[]242): ReadonlyMap<string, number> => {243 const ordered = [
7 unmodified lines
251 unique.slice(0, 9).map((command, index) => [command, index + 1])252 );253};254298/** Copy `command`, then mark it copied for two seconds. */255const copyNumbered = (command: string, shown: (copied?: string) => void) =>256 Effect.tryPromise(() => navigator.clipboard.writeText(command)).pipe(257 Effect.andThen(258 Effect.sync(() => {
8 unmodified lines
267 ),268 Effect.ignore269 );270315/** The row a key moved to: focused, scrolled to, and selected at the shell's width. */271const moveTo = (list: ListRegistration, step: 1 | -1) => {272 const { ids, onSelect } = list.read();273 const at = list.focused === undefined ? -1 : ids.indexOf(list.focused);274
18 unmodified lines
293 row.focus({ preventScroll: true });294 row.scrollIntoView({ block: "nearest" });295 }296342 // The inspector is a column at the shell's width, so a move selects there.297 if (globalThis.matchMedia(SHELL_WIDTH).matches) {298 onSelect(next);299 }300};
8 unmodified lines
309 onMove(next);310 }311};312359/** What the listener reads when a key is pressed. */313interface Pressing {314 readonly copy: (command: string) => void;315 readonly numbered: ReadonlyMap<string, number>;316 readonly on: boolean;317 readonly openDialog: () => void;318 readonly registry: Registry;319}320368/** Do what `intent` asks; whether it did anything (so the browser does not too). */321const act = (intent: KeyIntent, now: Pressing): boolean => {322 const { registry } = now;323324 if (intent.kind === "keys") {
41 unmodified lines
366367 return files !== undefined;368};369418/**419 * The shell's one listener and the state behind it. `openDialog` opens the420 * keys dialog (the shell draws it).421 */370export const KeysProvider = ({371 children,372 openDialog,373}: {374 readonly children: ReactNode;375 readonly openDialog: () => void;376}) => {377 // The server has no storage and renders the keys on; nothing it renders430 // depends on them (a command's number comes once the page has run).378 // depends on them.379 const [on, setOn] = useState(() => readShortcuts(localStorageOf()));380 const [commands, setCommands] = useState<readonly Command[]>([]);381 const [copied, setCopied] = useState<string>();382
19 unmodified lines
402 }, []);403404 const numbered = useMemo(() => numberOf(commands), [commands]);405458 // The listener reads the latest of these, kept here after each render.406 const pressing = useRef<Pressing | null>(null);407408 useEffect(() => {409 pressing.current = {
54 unmodified lines
464 </RegistryContext>465 );466};467521/** `value`, kept current in a ref after each render, for a handler to read later. */468const useLatest = <A,>(value: A) => {469 const latest = useRef(value);470471 useEffect(() => {
2 unmodified lines
474475 return latest;476};477532/**533 * Let `j` and `k` move through `ids` (the page's rows, in order); at the534 * shell's width each move also selects the row (`onSelect`). Give each row's535 * link `data-list-key={id}` so the move focuses it and `Enter` opens it.536 * Returns the row the keys rest on, to draw as focused.537 */478export const useListKeys = (479 ids: readonly string[],480 onSelect: (id: string) => void481): { readonly focused?: string } => {
14 unmodified lines
496497 return focused === undefined ? {} : { focused };498};499560/** Let `J` and `K` move between `paths` (the page's files, in order), each move calling `onMove`. */500export const useFileKeys = (501 paths: readonly string[],502 onMove: (path: string) => void503): void => {
8 unmodified lines
512 [latest, registry]513 );514};515577/**578 * Number `command` among the page's commands: the digit that copies it, while579 * the single keys are on, to show before it ("Copy (1)"); nothing when they580 * are off or it is past the ninth.581 */516export const useNumberedCommand = (command: string): number | undefined => {517 const registry = useContext(RegistryContext);518 const state = useContext(StateContext);519 const slot = useContext(SlotContext);
6 unmodified lines
526527 return state?.on === true ? state.numbered.get(command) : undefined;528};529596/** The command a number key copied in the last two seconds, to show as copied. */530export const useCopiedCommand = (): Option.Option<string> =>531 Option.fromUndefinedOr(useContext(StateContext)?.copied);532600/** Let `Escape` call `clear` while the caller is on the page (the selection's). */533export const useEscapeClears = (clear: () => void): void => {534 const registry = useContext(RegistryContext);535 const latest = useLatest(clear);536
10 unmodified lines
modified:apps/web/src/features/shared/layout.tsx-8 removed
1/**2 * What every page renders inside the shell (`shell/app-shell.tsx`):3 * `PageShell`, a page with a title and no facts, drawn by the shell's4 * `Workspace` (its context bar names the page from its address), for the5 * pages that have not yet come to `Workspace` themselves; and the skip link6 * the shell puts first, so a keyboard passes the rail to the page.7 */1import type { ReactNode } from "react";23import { Workspace } from "./shell/workspace.tsx";4
4 unmodified lines
9 readonly children: ReactNode;10 readonly title: string;11}) => <Workspace title={title}>{children}</Workspace>;1220/** The first stop of a keyboard on every page: straight to main, past the rail. */13export const SkipLink = () => (14 <a15 className="bg-background text-ui sr-only z-50 px-3 py-2 font-medium focus:not-sr-only focus:fixed focus:top-2 focus:left-2"16 href="#main"
4 unmodified lines
modified:apps/web/src/features/shared/link.tsx+5 added-37 removed
1/**2 * The one link between the web's pages: the router's `Link`, so a click3 * moves without reloading the document, and a hover or focus fetches the4 * page's code and loader data first (the router's `defaultPreload` is5 * "intent", `src/router.tsx`). The router marks the link to the page being6 * read with `aria-current="page"` and `data-status="active"`.7 *8 * `to` is a path built whole, as `paths.ts` builds them (`askPath(project,9 * ask)`), with its search as `search`; the router reads its params from it10 * as it reads them from a typed address.11 *12 * A view rendered with no router around it (its own test, with13 * `renderToStaticMarkup`) draws the same address as a plain anchor, so its14 * markup reads the same either way; the shell's own test renders inside a15 * router (`test/render.tsx`) and checks its links are the router's.16 *17 * Only pages the router serves take an `AppLink`. A server route (sign-in,18 * a raw file, a `.md` twin, `llms.txt`) is a plain `<a>`, or the router would19 * look for a page that is not there.2 * A server route (sign-in, a raw file, a `.md` twin, `llms.txt`) is a plain3 * `<a>`, or the router would look for a page that is not there.4 */5import {6 defaultStringifySearch,7 Link,
3 unmodified lines
11import { Predicate } from "effect";12import { createElement } from "react";13import type { AnchorHTMLAttributes, ReactNode } from "react";1431/** An `AppLink`'s props: an anchor's, with the address as `to`. */15export interface AppLinkProps extends Omit<16 AnchorHTMLAttributes<HTMLAnchorElement>,17 "href" | "target"18> {36 /** The path, built whole: `/datekit/ledger`. */19 readonly to: string;38 /** The address's search, each value a string. */20 readonly search?: Readonly<Record<string, string>> | undefined;40 /** The fragment, without its `#`. */21 readonly hash?: string;42 /** How the router decides the link leads to the page being read. */22 readonly activeOptions?: ActiveOptions;44 /** `false` keeps the router from fetching the page ahead of a click. */23 readonly preload?: false;46 /** Replace the history entry rather than push one (a selection). */24 readonly replace?: boolean;48 /** Keep each pane's scroll where it is (a selection in a list). */25 readonly resetScroll?: boolean;26}2728/**53 * `path` with the router's own marks escaped: a `$` (a param, or the splat)54 * and the braces of an optional segment are, in a path built whole, part of55 * a name (a file at `routes/$project/$.tsx`), never a param for the router56 * to fill from the page being read. Escaped, they reach the address as57 * written, and the router decodes them back when it reads the page's params.29 * `$` and the braces of an optional segment are, in a path built whole, part of30 * a name (`routes/$project/$.tsx`), never a param for the router to fill.31 * Escaped, they reach the address as written.32 */33export const literalPath = (path: string): string =>34 path.replaceAll("$", "%24").replaceAll("{", "%7B").replaceAll("}", "%7D");3562/** The address an `AppLink` names, as the router would write it. */36export const hrefOf = ({37 hash,38 search,39 to,
3 unmodified lines
43 ? ""44 : defaultStringifySearch(search)45 }${hash === undefined ? "" : `#${hash}`}`;4674/**75 * `Link` over any router, whose `to` is any path: the router reads a path76 * built whole as it reads a typed address.77 */47const PathLink = Link<AnyRouter, string, string>;4849export const AppLink = (props: AppLinkProps): ReactNode => {50 const router = useRouter({ warn: false });
1 unmodified line
52 if (Predicate.isNotNullish(router)) {53 return <PathLink {...props} to={literalPath(props.to)} />;54 }5587 // A router is always there in the app; only a view rendered alone has none.56 const {57 activeOptions: _active,58 hash: _hash,59 preload: _preload,
9 unmodified lines
modified:apps/web/src/features/shared/mark-look.ts+2 added-7 removed
1/**2 * How a mark is drawn, and a posture's mark: kept apart from the states'3 * marks (`marks.tsx`) so the rail, on every page, carries only the three4 * icons a posture needs.2 * Kept apart from `marks.tsx` so the rail, on every page, carries only the3 * three icons a posture needs.4 */5import type { Posture } from "@repo/protocol/posture";6import { Eye, LockKeyhole, LockKeyholeOpen } from "lucide-react";7import type { LucideIcon } from "lucide-react";810/** How a mark is drawn: its icon, its role's colour, and whether its icon is filled. */9export interface MarkLook {10 readonly icon: LucideIcon;13 /** The role's colour, as a text class. */11 readonly tone: string;15 /** The icon's inner shape is filled (the checking dot, the claimed half). */12 readonly fill?: true;13}1419/** A project's posture as a mark: a lock in the sealed role when something is kept sealed. */15export const POSTURE_MARKS = {16 open: { icon: LockKeyholeOpen, tone: "text-muted-foreground" },17 openCore: { icon: LockKeyhole, tone: "text-sealed" },18 openOnSchedule: { icon: LockKeyhole, tone: "text-sealed" },
3 unmodified lines
modified:apps/web/src/features/shared/marks.tsx-24 removed
1/**2 * Every state the web draws, as one mark and one word: the same mark means3 * the same thing on every page. Marks are lucide's, 16 px at a 1.754 * stroke; the word always renders beside the mark or in its row, so the5 * mark is hidden from screen readers and a page read in grayscale says the6 * same thing. Colour is the state's role, and only for state:7 *8 * - landed green: on main (a landing, a stage that passed);9 * - checking blue: running now;10 * - waiting ochre: paused on a person, a parent or a retry;11 * - refused red: a refusal, and nothing else;12 * - sealed violet: held back;13 * - ink and muted for the rest (claimed, open, not needed, a default, and14 * a failure that is not a refusal, such as a draft that did not come).15 */1import {2 Check,3 CircleSmall,4 Circle,
8 unmodified lines
13} from "lucide-react";1415import type { MarkLook } from "./mark-look.ts";1632/** Every state a mark is drawn for. */17export const STATE_MARK_NAMES = [18 "landed",19 "passed",20 "checking",
11 unmodified lines
32] as const;3334export type StateMark = (typeof STATE_MARK_NAMES)[number];3552/** Each state's mark and its word, as it reads on its own. */36export const STATE_MARKS = {37 checking: {38 fill: true,39 icon: CircleSmall,
19 unmodified lines
59 sealed: { icon: LockKeyhole, tone: "text-sealed", word: "Sealed" },60 waiting: { icon: Hourglass, tone: "text-waiting", word: "Waiting" },61} as const satisfies Record<StateMark, MarkLook & { readonly word: string }>;6280/** A mark's size beside 14 and 16 px text, and one a step down for 13 px lines. */63const SIZES = { md: "size-4", sm: "size-3.5" } as const;6483/**84 * One mark, hidden from screen readers (its word is beside it). `stamp`85 * settles it once, as a landing's stamp does, when the viewer allows86 * motion.87 */65export const Mark = ({66 className = "",67 look,68 size = "md",
18 unmodified lines
87 />88 );89};90114/** The mark of a named state. */91export const StateMarkIcon = ({92 mark,93 ...rest94}: {
5 unmodified lines
modified:apps/web/src/features/shared/outcome.tsx+3 added-33 removed
1/**2 * Where an answer stands, read the same on every page that shows one.3 *4 * `OutcomeView` gives the outcome as the status line (`StatusLine`):5 * checking, waiting (on a decision, a finish or a parent ask) or landed,6 * each with its state as `data-state` ("waiting" or "final"); a refusal's7 * line is followed by the refusal itself, drawn whole by `RefusalView`.8 * Waiting is never shown as refusing.9 *10 * `StageStrip` is the gate's results row: one cell per stage, in the order11 * of cost, each marked passed, current, refused, pending or not needed by12 * a mark and a word, colour only third.13 */1import { Outcome, StageName } from "@repo/protocol/domain/outcome";2import type { Handle, ProjectName } from "@repo/protocol/ids";34import { StateMarkIcon } from "./marks.tsx";
10 unmodified lines
15 stage,16 stamp = false,17}: {18 readonly outcome: Outcome;32 /** Who holds the ask, to name whose move a refusal leaves. */19 readonly claimant?: Handle;34 /** The stage the verdict reached, to say where a refusal came from. */20 readonly stage?: StageName;36 /** The project, to link the landing or what the answer waits on. */21 readonly project?: ProjectName;38 /** The answer page's hero is a step up. */22 readonly size?: "body" | "title";40 /** Settle a landing's mark once: it landed while the page was open. */23 readonly stamp?: boolean;24}) => {25 const subject: StatusSubject = {26 claimant,
29 unmodified lines
56 </div>57 );58};5978/** A stage's place in the strip. */60export type StageState =61 | "passed"62 | "current"63 | "refused"64 | "pending"65 | "skipped";6686/** What a verdict holds beyond its stage: a decider's decision, and held-back results. */67export interface StageHolds {68 readonly decided: boolean;69 readonly heldBack: boolean;70}7172/**93 * Each stage's state, given the furthest stage the answer reached and its94 * outcome: stages before it passed; at it, current (checking or waiting),95 * refused, or passed (landed or waiting on its parent); after it, pending,96 * or skipped once the answer landed without them.97 *98 * A passing verdict reaches the decider stage whether or not a decider99 * took part, so with `holds` (what the verdict holds) a held-back or100 * decider stage that would read passed reads not needed when the verdict101 * holds no held-back results or no decision. Without it, every stage102 * before the reached one reads passed.73 * A passing verdict reaches the decider stage whether or not a decider took74 * part, so with `holds` a held-back or decider stage it never needed reads not75 * needed.76 */77export const stageStates = (78 reached: StageName,79 outcome: Outcome,
37 unmodified lines
117 ] as const;118 });119};120148/** Each state's mark and word in a cell; the current one's mark follows the outcome. */121const cellMarks = (outcome: Outcome) =>122 ({123 current: {124 mark: Outcome.isAnyOf(["Checking"])(outcome) ? "now" : "waiting",
7 unmodified lines
132 StageState,133 { readonly mark: StateMark; readonly word: string }134 >;135164/** A cell's word in its state's role; not yet and not needed stay muted. */136const wordTones = {137 current: "",138 passed: "text-landed",139 pending: "text-muted-foreground",
5 unmodified lines
145 holds,146 outcome,147 stage,148}: {178 /** What the verdict holds, so a stage it never needed reads not needed. */149 readonly holds?: StageHolds;150 readonly outcome: Outcome;151 readonly stage: StageName;152}) => {
51 unmodified lines
modified:apps/web/src/features/shared/paths.ts+1 added-17 removed
1/**2 * The site's addresses, in a module with no view of its own, so a route or3 * a view links to a page without carrying that page's view.4 */1import type {2 AskId,3 DecisionId,4 Handle,5 ProjectName,6} from "@repo/protocol/ids";7import { Result } from "effect";813/** The front page: every open ask, across every project. */9export const ASKS_PATH = "/asks";1016/** A signed-in reader's own page. */11export const HOME_PATH = "/home";1219/** The import page: a public repo made a project. */13export const IMPORT_PATH = "/import";1422/** The docs' index, or one of its pages. */15export const docsPath = (page?: string) =>16 page === undefined ? "/docs" : `/docs/${page}`;1726/** A project's page. */18export const projectPath = (project: ProjectName) => `/${project}`;1929/** An ask's page. */20export const askPath = (project: ProjectName, ask: AskId) =>21 `/${project}/asks/${ask}`;2233/** The page of the verdict on an ask's latest answer. */23export const answerPath = (project: ProjectName, ask: AskId) =>24 `/${project}/answers/${ask}`;2537/** A person's page: `/people/<handle>` (a handle is URL-safe by its schema). */26/** A handle is URL-safe by its schema. */27export const personPath = (handle: Handle) => `/people/${handle}`;2840/** A project's ledger. */29export const ledgerPath = (project: ProjectName) => `/${project}/ledger`;3043/** A project's env shape. */31export const envPath = (project: ProjectName) => `/${project}/env`;3246/** A decision's page. */33export const decisionPath = (project: ProjectName, decision: DecisionId) =>34 `/${project}/decisions/${decision}`;3550/** `segment` decoded, or as it came when it does not decode. */36const decoded = (segment: string) =>37 Result.getOrElse(38 Result.try(() => decodeURIComponent(segment)),39 () => segment40 );4157/** A pathname's segments, decoded, the empty ones dropped. */42export const segmentsOf = (pathname: string) =>43 pathname44 .split("/")45 .filter((segment) => segment !== "")
1 unmodified line
modified:apps/web/src/features/shared/pending.tsx+4 added-26 removed
1/**2 * What a page shows while its reads are on their way, when the platform3 * did not answer, and when nothing is at an address, each inside the shell4 * (the rail, the bars and the context bar stay):5 *6 * - `ReadingRows`: rows of a list's own height (64 px), each two hairline7 * bars, with no shimmer; `Reading` is a page of them under its title;8 * - `Unreachable`: the platform did not answer, said in ink with a way to9 * ask again. It is not a refusal (a refusal is the platform's answer, and10 * this is the absence of one), so it is never drawn in the refusal's red;11 * - `PendingPage`, `RouteError` and `NotFoundPage`: the router's own pending,12 * failure and missing pages (`src/router.tsx`).13 */1import type { ErrorComponentProps } from "@tanstack/react-router";2import { useLocation } from "@tanstack/react-router";3import { Unplug } from "lucide-react";4
6 unmodified lines
11import { RowSkeleton } from "./skeleton.tsx";1213const ROWS = ["first", "second", "third"] as const;1428/** Rows that hold a list's place while the platform answers: a row's height, two bars each. */15export const ReadingRows = () => (16 <div aria-busy="true" className="flex flex-col">17 <output className="sr-only">Reading from the platform</output>18 {ROWS.map((row) => (
11 unmodified lines
30const reload = () => {31 globalThis.location.reload();32};3348/** The platform did not answer: in ink, with a way to ask again. */34/**35 * Not a refusal (it is the absence of the platform's answer), so never in the36 * refused red.37 */38export const UnreachableNotice = () => (39 <div40 className="border-rule-strong flex max-w-[40rem] items-start gap-3 border p-4"41 role="alert"
21 unmodified lines
63 <UnreachableNotice />64 </PageShell>65);6678/** The page's name as its address gives it: the last step of its trail. */67const useAddressTitle = () =>68 useLocation({69 select: ({ pathname }) => crumbsFor(pathname).at(-1)?.label ?? "",70 });7184/**85 * A page the router is still loading, after 300 ms: its name from the86 * address over rows that hold its place, so a quick move never flashes and87 * a slow one keeps the shell where it is.88 */72export const PendingPage = () => (73 <PageShell title={useAddressTitle()}>74 <ReadingRows />75 </PageShell>76);7795/**96 * A page whose read failed on its way (the platform did not answer, or97 * answered with nothing the page could read), inside the shell.98 */78export const RouteError = (_props: ErrorComponentProps) => (79 <PageShell title={useAddressTitle()}>80 <UnreachableNotice />81 </PageShell>82);83105/** An address no page serves: the trail up to what exists, and the ways onward. */84export const NotFoundPage = () => {85 const pathname = useLocation({ select: (location) => location.pathname });86 const project = projectOf(pathname);87
40 unmodified lines
modified:apps/web/src/features/shared/posture.tsx+2 added-7 removed
1/**2 * A project's posture, as the honest label the platform computes from its3 * visibility config. The posture literal rides as `data-posture`, so tests4 * and styles key on it; the words are the label, never rewritten here.5 * It is a state badge: a lock in the sealed role when something is kept6 * sealed, then the label.2 * The posture literal rides as `data-posture`, so tests and styles key on it;3 * the words are the platform's label, never rewritten here.4 */5import type { Posture } from "@repo/protocol/posture";67import { POSTURE_MARKS } from "./mark-look.ts";8import { StateBadge } from "./state-badge.tsx";913/** The label's colour: sealed when something is kept sealed, ink when nothing is, muted for a licence that is not open. */10const wordTone = {11 open: "text-foreground",12 openCore: "text-sealed",13 openOnSchedule: "text-sealed",
7 unmodified lines
21 title,22}: {23 readonly label: string;24 readonly posture: Posture;29 /** The platform's full label, when the badge says a short form. */25 readonly title?: string | undefined;26}) => (27 <StateBadge28 className="text-ui items-start [&>svg]:mt-0.5"
9 unmodified lines
modified:apps/web/src/features/shared/project-order.ts-9 removed
1/**2 * Which projects a short list names: the rail's and the3 * landing's. The ones with the most open asks lead, a tie by name, so a4 * reader meets first the projects with work to take. The platform's own5 * list keeps its order; this is the web's.6 */1import type { ProjectListing } from "@repo/protocol/domain/front-page";2import { Array as Arr, Order } from "effect";310/** How many projects the rail and the landing name; the rest are a step away. */4export const PROJECTS_SHOWN = 8;513/** The most open asks first, then by name. */6const leading = Order.combine(7 Order.mapInput(8 Order.flip(Order.Number),9 ({ openAsks }: ProjectListing) => openAsks10 ),11 Order.mapInput(Order.String, ({ project }: ProjectListing) => project)12);1322/** The `n` projects that lead: the most open asks first, a tie by name. */14export const leadingProjects = (15 projects: readonly ProjectListing[],16 n: number17): readonly ProjectListing[] => Arr.take(Arr.sort(projects, leading), n);
modified:apps/web/src/features/shared/refusal.tsx+2 added-6 removed
1/**2 * A refusal, as `git push` printed it. The words are `@repo/protocol/render`'s3 * (`headline` and `explain`, the one renderer for git, the CLI, MCP and the4 * web, AGENTS.md principle 3); this view only sets them: each refusal's lines5 * verbatim, its tag in the rubric colour, then its `next` command to copy.6 * Whether retrying can help picks the mark, never the words.2 * The words are `@repo/protocol/render`'s; this view only sets them. Whether3 * retrying can help picks the mark, never the words.4 */5import type { Refusal } from "@repo/protocol/refusal";6import { explain, headline } from "@repo/protocol/render";7import type { Array } from "effect";8import { OctagonX, RotateCcw } from "lucide-react";910import { CommandLine } from "./command.tsx";1115/** One refusal's lines, with its tag set apart on the first. */12const Lines = ({ refusal }: { readonly refusal: Refusal }) => {13 const prefix = `${refusal._tag}:`;1415 return (
55 unmodified lines
modified:apps/web/src/features/shared/refusals.ts-9 removed
1/**2 * A loader's 404 that carries the platform's refusal to the page, in a3 * module with no view of its own: a route's loader runs before its page's4 * view loads. The refusals travel in a not-found's data, encoded as5 * `Refusals`; the page decodes them where they arrive (AGENTS.md6 * principle 2).7 */1import { Refusal } from "@repo/protocol/refusal";2import { notFound } from "@tanstack/react-router";3import { Effect, Schema } from "effect";412/** Refusals as a not-found carries them. */5export const Refusals = Schema.NonEmptyArray(Refusal);615/** A loader's 404 for `refusal`: a not-found that carries it, encoded, to the page. */7export const notFoundFor = (refusal: Refusal) =>8 Effect.flatMap(Schema.encodeEffect(Refusals)([refusal]), (data) =>9 Effect.fail(notFound({ data }))10 );
modified:apps/web/src/features/shared/row.tsx+4 added-91 removed
1/**2 * One row for every list: asks, decisions, landings, commits, refs, forks,3 * credits, rounds, history. Two lines, the thing first and its state at4 * the right:5 *6 * [mark] the want or subject, the link [state word] [copy]7 * kind · territory · id (metadata) [time]8 *9 * - Line 1 is the thing in its own words, one line, ellipsised, the whole10 * text its `title`; it is the link, never the id.11 * - Line 2 is metadata, parted by ` · `; a value that means nothing (the12 * whole repo's territory, ".") is left out (`MetaLine`).13 * - The state's mark sits in its own column, in its role's colour, and its14 * word at the right in ink (Refused and Landed keep theirs: DESIGN.md's15 * Mark Carries Rule); the mark is hidden from screen readers, the word16 * is not.17 * - A row with a command has one copy action, the command as text inside it.18 *19 * From the shell's width a click anywhere off the link selects the row20 * (its facts fill the inspector); below it the whole row is the link's to21 * press. `j` and `k` reach each row's link (`data-list-key`). Every22 * `data-*` a list carries sits on the row's `<li>`.23 */1import type { AskListing } from "@repo/protocol/domain/ask";2import type { ClaimState } from "@repo/protocol/domain/claim";3import { Outcome } from "@repo/protocol/domain/outcome";4import type { ProjectName } from "@repo/protocol/ids";
11 unmodified lines
16import { useSelection } from "./shell/selection.ts";17import type { SelectionParam } from "./shell/selection.ts";18import { When } from "./time.tsx";1943/** A row's state: its mark, its word, and when (a `When`, or words). */20export interface RowState {21 readonly mark: StateMark;22 readonly word: string;23 readonly time?: ReactNode;48 /** Settle the mark once: it landed while the page was open. */24 readonly stamp?: boolean;25}2627export interface RowProps {53 /** The thing's id: what selection and `j`/`k` name it by. */28 readonly id: string;55 /** Its page. */29 readonly href: string;57 /** The page's search, when the row names one state of it (`?head=`). */30 readonly search?: Readonly<Record<string, string>> | undefined;59 /** Line 1: the want, the subject, the commit's first line. */31 readonly title: string;61 /** Line 2 (or, one-line, after the title): metadata (`MetaLine`). */32 readonly meta?: ReactNode;33 readonly state?: RowState | undefined;64 /** A `CopyAction`, at the row's end. */34 readonly action?: ReactNode;66 /** A third line under the two: a family's fan. */35 readonly strip?: ReactNode;68 /**69 * What the row stands for, on its `<li>` (`data-ask`, `data-takeable`, …);70 * an attribute left undefined is left out.71 */36 readonly data?: Readonly<37 Record<`data-${string}`, string | boolean | undefined>38 >;39 readonly size?: "two-line" | "one-line";76 /** The row whose facts the inspector shows. */40 readonly selected?: boolean | undefined;78 /** Select the row, from the shell's width (`useRowSelection`). */41 readonly onSelect?: ((id: string) => void) | undefined;80 /** Line 1 is code (a ref, a fork's name): set it in mono. */42 readonly mono?: boolean;43}4484/** The shell's width, from which a row selects rather than opens. */45const SHELL_WIDTH = "(min-width: 70rem)";4647/**88 * The word's colour (DESIGN.md's Mark Carries Rule): ink, its role's colour89 * left to the mark, so a list of waiting asks is not an ochre stripe; a90 * refusal keeps red and a landing green. A refusal that can be retried91 * keeps its ochre mark, but its word is a refusal's, as the status line92 * says it.48 * Ink, the role's colour left to the mark, so a list of waiting asks is not an49 * ochre stripe; a refusal keeps red and a landing green.50 */51export const wordTone = (mark: StateMark) => {52 if (mark === "refused" || mark === "retry") {53 return STATE_MARKS.refused.tone;
1 unmodified line
5556 return mark === "landed" ? STATE_MARKS.landed.tone : "text-foreground";57};58102/** Whether a press on `target` was meant for a link or a control in the row. */59const onControl = (target: EventTarget) =>60 target instanceof Element &&61 target.closest("a, button, summary, input, select, textarea") !== null;62107/** Metadata parted by ` · `, with every empty part left out. */63export const MetaLine = ({64 parts,65}: {66 readonly parts: readonly (ReactNode | false | null | undefined)[];
10 unmodified lines
77 </Fragment>78 ));79};80126/** Code in a row's metadata: an id, a territory, a SHA. */81export const MetaCode = ({ children }: { readonly children: ReactNode }) => (82 <code className="text-mono font-mono">{children}</code>83);84131/** A territory as a row shows it: nothing for the whole repo. */85export const territoryPart = (territory: string) =>86 territory === "." || territory === "" ? undefined : (87 <MetaCode>{territory}</MetaCode>88 );8990const LINK =91 "text-foreground no-underline outline-none after:absolute after:inset-0 after:content-[''] focus-visible:after:outline-2 focus-visible:after:-outline-offset-2 focus-visible:after:outline-ring focus-visible:after:outline-solid";92140/** From the shell's width a row that selects lets a press off its link through to the row. */93const SELECTS = "shell:after:pointer-events-none";94143/** A press on the row, off its link and its controls, selects it from the shell's width. */95const selectOnPress =96 (id: string, onSelect: ((id: string) => void) | undefined) =>97 (event: MouseEvent<HTMLLIElement>) => {98 if (
4 unmodified lines
103 onSelect(id);104 }105 };106156/** The row's state at its end: the word in its role, over (or beside) its time. */107const StateEnd = ({108 state,109 stacked,110}: {
43 unmodified lines
154 <AppLink155 aria-current={selected ? "true" : undefined}156 className={onSelect === undefined ? LINK : `${LINK} ${SELECTS}`}157 data-list-key={id}208 // The thing in its own words: a want, a subject, a commit's line.158 data-said=""159 search={search}160 title={title}161 to={href}
6 unmodified lines
168 state === undefined ? null : (169 <StateMarkIcon mark={state.mark} stamp={state.stamp === true} />170 );171223 // `isolate` keeps the row's raised controls (its copy button, a fan's224 // nodes) inside the row, so a sticky header passes over them.172 // `isolate` keeps the row's raised controls inside the row, so a sticky173 // header passes over them.174 const rowClass = `group/row border-rule relative isolate -mx-2 border-b px-2 transition-colors duration-[120ms] ${175 selected ? "bg-surface hover:bg-surface-2" : "hover:bg-surface/50"176 }`;177
34 unmodified lines
212 </p>213 {meta === undefined && state === undefined ? null : (214 <p className="text-ui text-muted-foreground truncate leading-5">215 {state === undefined ? null : (267 // On a phone the want takes the width; its state leads line 2.216 <span217 className={`tablet:hidden font-medium ${wordTone(state.mark)}`}218 >219 {state.word}
18 unmodified lines
238 </li>239 );240};241294/** Where a group's header sticks: under the toolbar, or under the context bar when the list has none. */242const STICK = {243 bar: "top-[2.6875rem] tablet:top-[2.9375rem] shell:top-[2.6875rem]",244 toolbar: "top-[5.1875rem] tablet:top-[5.4375rem] shell:top-[5.1875rem]",245} as const;246300/** A list's group: a sticky header (its name as a link, its facts, its counts), then its rows. */247export const RowGroup = ({248 children,249 counts,250 facts,
1 unmodified line
252 name,253 under = "toolbar",254}: {255 readonly name: ReactNode;310 /** The group's facts after its name: a project's posture. */256 readonly facts?: ReactNode;312 /** Its counts at the end, in words: "7 open · 6 to take". */257 readonly counts?: string | undefined;314 /** The group's name in words, for its list (the name may be a link). */258 readonly label?: string;316 /** What the header sticks under. */259 readonly under?: keyof typeof STICK;260 readonly children: ReactNode;261}) => (262 <section aria-label={label} className="flex min-w-0 flex-col">263 <div322 // On a phone a long posture wraps under the name rather than losing323 // its last word; from a tablet the header is one 32 px line.264 className={`border-rule bg-background tablet:h-8 tablet:flex-nowrap tablet:py-0 sticky z-[5] -mx-2 flex min-h-8 min-w-0 flex-wrap items-center gap-x-3 gap-y-0.5 border-b px-2 py-1 ${STICK[under]}`}265 >266 <h2 className="text-ui shrink-0 font-semibold [&_a]:no-underline [&_a:hover]:underline">267 {name}
12 unmodified lines
280 <ul className="flex flex-col">{children}</ul>281 </section>282);283344/** A list of rows with no groups. */284export const RowList = ({285 children,286 label,287}: {288 readonly children: ReactNode;289 readonly label: string;290}) => (352 // The top hairline runs as wide as the rows' own (each row reaches 8 px353 // past the list on either side, for its fill).291 <ul292 aria-label={label}293 className="border-rule -mx-2 flex flex-col border-t px-2"294 >295 {children}296 </ul>297);298362/**363 * A list's selection and keys together: the row selected (from the364 * address), the one `j`/`k` rest on, and the select to hand each row.365 */299export const useRowSelection = (300 ids: readonly string[],301 param: SelectionParam302) => {
2 unmodified lines
305306 return { clear, focused, select, selected };307};308376/** An answer's latest outcome as a row's state: a retryable refusal turns back. */309export const outcomeState = (outcome: Outcome): RowState =>310 Outcome.match(outcome, {311 AwaitingDecision: (): RowState => ({ mark: "waiting", word: "Waiting" }),312 AwaitingFinish: (): RowState => ({ mark: "waiting", word: "Waiting" }),
5 unmodified lines
318 }),319 WaitingOnParent: (): RowState => ({ mark: "waiting", word: "Waiting" }),320 });321390/** Each claim state as a row says it: its mark and its word. */322export const CLAIM_STATES = {323 answered: { mark: "landed", word: "Answered" },324 lapsed: { mark: "notNeeded", word: "Lapsed" },325 live: { mark: "claimed", word: "Claimed" },326 released: { mark: "notNeeded", word: "Given up" },327 warned: { mark: "waiting", word: "Warned, no push lately" },328} as const satisfies Record<ClaimState, RowState>;329399/** Who an ask is held for, as its state word. */330const reserveWords = {331 newcomers: "Held for newcomers",332 people: "Held for people",333} as const;334405/** Where an open ask stands for its reader, as a row's state. */335const askState = (336 listing: AskListing,337 takeable: boolean | undefined,338 progress: AskProgress | undefined
13 unmodified lines
352 if (listing.blockedBy.length > 0) {353 return { mark: "waiting", word: "Waiting" };354 }355427 // An ask held for someone says so wherever it is listed and whoever428 // reads it, before whether this reader may take it.356 if (listing.reserve !== undefined) {357 return { mark: "open", word: reserveWords[listing.reserve] };358 }359
1 unmodified line
361 ? { mark: "notYet", word: "Not open to you" }362 : { mark: "open", word: "Open to take" };363};364438/**439 * The time an ask row shows: its last push, else its last round, else its440 * opening, so a list scans by recency.441 */365const askTime = (progress: AskProgress | undefined) =>366 progress?.lastPush?.at ?? progress?.rounds.at(-1)?.at ?? progress?.opened;367445/**446 * An open ask as a row: its want, its kind, territory and id, where it447 * stands (from the listing, and the event fold when the page has it), and448 * the claim command when the reader may take it.449 */368export const AskRow = ({369 listing,370 now,371 onSelect,
5 unmodified lines
377 takeable,378}: {379 readonly listing: AskListing;380 readonly project: ProjectName;463 /** Whether the viewer may take it (the front page knows); a project's page does not say. */381 readonly takeable?: boolean | undefined;465 /** The ask's progress from the project's events, when the page folds them. */382 readonly progress?: AskProgress | undefined;383 readonly selected?: boolean | undefined;384 readonly onSelect?: ((id: string) => void) | undefined;469 /** Name the project in the metadata: a list across projects with no groups. */385 readonly showProject?: boolean;471 /** A family's fan, when the ask is a parent. */386 readonly strip?: ReactNode;473 /** The page's now, which the row's time is told against. */387 readonly now?: DateTime.Utc | undefined;388}) => {389 const at = askTime(progress);390 const standing = askState(listing, takeable, progress);
44 unmodified lines
modified:apps/web/src/features/shared/skeleton.tsx-9 removed
1/**2 * What holds a row's or a fact block's place while it is read in the3 * browser (a selection's facts, a live fold, a route change): the same4 * size as what replaces it, drawn as hairline bars at 1.5:1 or more, still.5 * No shimmer: the wait is a fact, not a show. The lists themselves arrive6 * with the page, so these are only for what the browser reads after it.7 */1import { Skeleton } from "../../components/ui/skeleton.tsx";210/** A two-line row's place: 64 px, the want's bar over the metadata's. */3export const RowSkeleton = () => (4 <div5 aria-hidden="true"6 className="border-rule flex h-16 flex-col justify-center gap-2.5 border-b pl-8"
2 unmodified lines
9 <Skeleton className="h-2.5 w-full max-w-[14rem]" />10 </div>11);1221/** The inspector's place: each block's label as it will read, its values as bars. */13export const FactsSkeleton = ({14 labels,15}: {16 readonly labels: readonly string[];
15 unmodified lines
modified:apps/web/src/features/shared/state-badge.tsx-12 removed
1/**2 * The one way the web shows a state in a word: its mark, then its word in3 * the state's role, at the size of the line it sits in. No pill, no fill,4 * no box: the mark and the word are the badge. A posture, a stage, an5 * ask's standing and a decision's default all draw through it.6 */1import { Predicate } from "effect";2import type { ReactNode } from "react";34import type { MarkLook } from "./mark-look.ts";5import { Mark, STATE_MARKS } from "./marks.tsx";6import type { StateMark } from "./marks.tsx";78export interface StateBadgeProps {15 /** A named state, or a look of its own (a posture's). */9 readonly mark: StateMark | MarkLook;17 /** The word, when the state's own word is not the one to say. */10 readonly word?: ReactNode;19 /** The word's colour, when it is not the mark's role (a posture's word is muted). */11 readonly wordTone?: string;21 /** A step down, for 13 px lines (a stage's cell). */12 readonly small?: boolean;23 /** Settle the mark once, as a landing's stamp does. */13 readonly stamp?: boolean;14 readonly className?: string;26 /** What the badge stands for, for tests and styles (`data-posture`, `data-state`). */15 readonly data?: Readonly<Record<`data-${string}`, string>>;16}1718export const StateBadge = ({
23 unmodified lines
modified:apps/web/src/features/shared/status-line.tsx+2 added-46 removed
1/**2 * Where a subject stands, in one sentence, the same on every page: under a3 * title, in the inspector's State block, and (compact: the mark and the4 * lead word) in the context bar.5 *6 * [mark] [Lead, in its role] [the rest, in ink] · [whose move] · [next command]7 *8 * A subject is an answer (its outcome), an ask (its state, who holds it and9 * its latest outcome), a decision or a proposal. Whose move it is comes10 * from the outcome alone (`whoseMove`): a refusal leaves it to the11 * answerer, a wait on a decision or a finish to a decider, a check under12 * way to the platform, a wait on a parent ask to the family.13 *14 * Two rules hold everywhere: waiting is never drawn in the refused role,15 * and a refusal is named by its tag (`headline`, the renderer git and the16 * CLI use) and never paraphrased; the refusal itself is `RefusalView`'s.2 * Waiting is never drawn in the refused role, and a refusal is named by its3 * tag, never paraphrased.4 */5import type { Ask } from "@repo/protocol/domain/ask";6import type { Choice, Decision } from "@repo/protocol/domain/decision";7import { Outcome } from "@repo/protocol/domain/outcome";
16 unmodified lines
24import type { StateMark } from "./marks.tsx";25import { askPath, decisionPath } from "./paths.ts";26import { distanceInWords } from "./time.tsx";2741/** Each stage as a cell heads it (`label`) and as a sentence names it (`words`). */28export const stageNames = Match.type<StageName>().pipe(29 Match.when("parse", () => ({ label: "Parse", words: "parse" })),30 Match.when("shape", () => ({ label: "Shape", words: "shape" })),31 Match.when("merge", () => ({ label: "Merge", words: "merge" })),
6 unmodified lines
38 Match.when("human", () => ({ label: "Decider", words: "decider" })),39 Match.exhaustive40);4156/** What a status line is about. */42export type StatusSubject =43 | {44 readonly kind: "answer";45 readonly outcome: Outcome;61 /** Who holds the ask, to name whose move a refusal leaves. */46 readonly claimant?: Handle | undefined;63 /** The stage the verdict reached, to say where a refusal came from. */47 readonly stage?: StageName | undefined;65 /** The project, to link the landing, the decision or the parent named. */48 readonly project?: ProjectName | undefined;49 }50 | {51 readonly kind: "ask";52 readonly ask: Ask;71 /** Whether the viewer may take it now. */53 readonly takeable: boolean;54 readonly claimant?: Handle | undefined;74 /** The current attempt's latest outcome, from the event fold. */55 readonly latest?: Outcome | undefined;76 /** The asks it waits on, as a family counts them (`familyMarks(ask, states)`). */56 readonly blockers?: Family | undefined;57 }58 | {59 readonly kind: "decision";60 readonly decision: Decision;61 readonly now: DateTime.Utc;83 /** Whether the viewer is one of its deciders. */62 readonly viewerDecides: boolean;63 }64 | { readonly kind: "proposal"; readonly proposal: Proposal };6588/** The role a line is drawn in; `ink` and `muted` are no state's colour. */66export type StatusTone =67 | "checking"68 | "ink"69 | "landed"
9 unmodified lines
79 refused: "text-refused",80 waiting: "text-waiting",81} as const satisfies Record<StatusTone, string>;82106/** A status line, read from its subject. */83interface Reading {84 readonly mark: StateMark;85 readonly tone: StatusTone;86 readonly lead: string;87 readonly rest?: ReactNode;112 /** Muted parts after the sentence: who it is held for, a default, whose move. */88 readonly after: readonly string[];114 /** The command that runs next, when the subject itself names one (a refusal's `next`). */89 readonly next?: string;90}9192const Code = ({ children }: { readonly children: ReactNode }) => (
1 unmodified line
94 {children}95 </code>96);97124/** `children` as a link to `to` when the project is known, as plain code when not. */98const CodeLink = ({99 children,100 to,101}: {
10 unmodified lines
112 {children}113 </AppLink>114 );115143/** Whose move, in words; nothing when it is no one's. */116const moveWords = (117 move: Move,118 {119 claimant,
10 unmodified lines
130 Match.when("decider", () => [131 decider === undefined ? "a decider's move" : `${decider}'s move`,132 ]),133 Match.when("platform", () => ["the platform's move"]),162 // The ask it waits on may be a family's or a lone one: its move.134 Match.when("parent", () => ["that ask's move"]),135 Match.when("none", () => []),136 Match.exhaustive137 );138168/** An answer's outcome as a line. */139const answerReading = ({140 claimant,141 outcome,142 project,
116 unmodified lines
259 }),260 });261};262293/** Who an ask is held for, when it is held for someone. */263const heldFor = (ask: Ask): readonly string[] => {264 if (ask.reserve === "newcomers") {265 return [266 ask.mentor === undefined
4 unmodified lines
271272 return ask.reserve === "people" ? ["held for people, not agents"] : [];273};274306/** What an ask that waits on others waits for, in its family's terms when the caller counted them. */275const waitingReading = (ask: Ask, blockers: Family | undefined): Reading => {276 if (blockers !== undefined && blockers.total > 0) {277 const remaining = blockers.total - blockers.landed;278
79 unmodified lines
358 tone: "ink",359 };360 }361394 // Not takeable while it waits on others: waiting, as its row says.362 return !takeable && ask.blockedBy.length > 0363 ? { after: [], lead: "Waiting", mark: "waiting", tone: "waiting" }364 : {365 after: heldFor(ask),
2 unmodified lines
368 tone: "muted",369 };370};371405/** A decider's choice in the past tense, and whether it took effect. */372const chosen = {373 accept: { effect: true, word: "Accepted" },374 adopt: { effect: true, word: "Adopted" },375 decline: { effect: false, word: "Declined" },
2 unmodified lines
378 Choice,379 { readonly effect: boolean; readonly word: string }380>;381416/** Whose move an open decision is: the viewer's, its one decider's, or any of its deciders'. */382const deciderMove = (decision: Decision, viewerDecides: boolean) => {383 if (viewerDecides) {384 return "your move";385 }
100 unmodified lines
486 }),487 });488};489525/** The line its subject reads as. */490export const readStatus: (subject: StatusSubject) => Reading =491 Match.type<StatusSubject>().pipe(492 Match.discriminator("kind")("answer", answerReading),493 Match.discriminator("kind")("ask", askReading),
10 unmodified lines
504} as const;505506export interface StatusLineProps {507 readonly subject: StatusSubject;544 /**545 * The command that runs next; a refusal's own `next` when left out, and546 * none at all with `false` (a refusal drawn whole below the line shows547 * its own).548 */508 readonly command?: string | false;550 /** Only the mark and the lead word (the context bar's). */509 readonly compact?: boolean;552 /** The outcome hero of an answer is a step up. */510 readonly size?: keyof typeof SIZE;554 /** Settle the mark once: a landing that happened while the page was open. */511 readonly stamp?: boolean;512}513514export const StatusLine = ({
60 unmodified lines
modified:apps/web/src/features/shared/theme.ts+2 added-3 removed
1/**2 * The paper colour of each theme, as hex for the places that cannot read a3 * CSS variable: the document's `theme-color` meta and the web app manifest.4 * They equal `--background` in `src/styles.css`.2 * For the places that cannot read a CSS variable (the `theme-color` meta, the3 * manifest). They equal `--background` in `src/styles.css`.4 */5export const themeColors = {6 dark: "#0e1114",7 light: "#f5f8fa",
1 unmodified line
modified:apps/web/src/features/shared/time.tsx-7 removed
1/**2 * A time as a short distance from now: "in 3 h", "2 d ago". `now` is a prop,3 * so a page and its test say the same thing; the exact time is the4 * element's `dateTime` and its tooltip.5 */1import { DateTime } from "effect";23const MINUTE = 60_000;45const HOUR = 60 * MINUTE;67const DAY = 24 * HOUR;814/** The largest whole unit in `millis`, as "5 min", "3 h" or "2 d". */9const span = (millis: number) => {10 if (millis < HOUR) {11 return `${Math.floor(millis / MINUTE)} min`;12 }
2 unmodified lines
15 ? `${Math.floor(millis / HOUR)} h`16 : `${Math.floor(millis / DAY)} d`;17};1825/** How far `at` is from `now`, in words. */19export const distanceInWords = (at: DateTime.Utc, now: DateTime.Utc) => {20 const millis = DateTime.toEpochMillis(at) - DateTime.toEpochMillis(now);2122 if (Math.abs(millis) < MINUTE) {
21 unmodified lines