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
Provenance
- Commit
88206c4- Tree
1f20802- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
a257688
42 files changed+63 added−975 removed
modified:apps/web/src/features/shared/shell/app-shell.tsx+2 added-19 removed
12345678910111213141512347 unmodified lines12131415311617181936202122237 unmodified lines31323334525335363738394052 unmodified lines/** * The shell every page sits in: the rail (where you are), main (what is * waiting) and, when a page has typed facts, the inspector (the thing in * hand), on one paper ground parted by hairlines. From 1120 px the three * are columns, each scrolling on its own; below it a top bar holds the way * around, and on a phone a bottom bar holds the sections. The page's own * panes come from its `Workspace`. * * The shell owns the overlays (the rail as a sheet, More, Projects, the * keys dialog), loaded once the page is up and closed whenever the reader * moves, and the keyboard's one listener. * * One page is drawn outside it: the landing, whose route names * `staticData: { shell: "bare" }`. There the shell gives the page alone. */import { useHydrated, useLocation, useMatches } from "@tanstack/react-router";import { Suspense, useCallback, useMemo, useState } from "react";import type { ReactNode } from "react";
7 unmodified linesimport { TopBar } from "./top-bar.tsx";
declare module "@tanstack/react-router" { interface StaticDataRouteOption { /** `"bare"`: the page is drawn alone, with no rail, bars or overlays. */ readonly shell?: "bare"; }}
/** Whether the address's page is drawn outside the shell. */const useBare = () => useMatches({ select: (matches) => matches.some(({ staticData }) => staticData.shell === "bare"),7 unmodified lines const pathname = useLocation({ select: (location) => location.pathname }); const hydrated = useHydrated(); const bare = useBare();
// An overlay belongs to the address it opened on: a link inside it moves // the reader on, and it is gone from the next page. // An overlay belongs to the address it opened on: it is gone from the next // page. const [opened, setOpened] = useState<{ readonly at: string; readonly overlay: Overlay; }>();52 unmodified linesmodified:apps/web/src/features/shared/shell/bottom-bar.tsx-7 removed
1234567123464 unmodified lines/** * The phone's bottom bar, fixed above the home indicator: Home, Asks, * Today, Projects (the switcher, as a sheet) and More (Docs, For agents, the project's * sections, the keys and the session), each a mark over its word. The * current page's item is ink at 600 with a rule on its top edge; the rest * are muted. */import { CalendarCheck, Ellipsis, Folders, House, List } from "lucide-react";import type { LucideIcon } from "lucide-react";
import { AppLink } from "../link.tsx";64 unmodified linesmodified: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- */1 import { Check, Copy } from "lucide-react";2 import type { ReactNode } from "react";3 4 import { Button } from "../../../components/ui/button.tsx";1 unmodified line6 import { useNumberedCommand } from "../keys.tsx";7 import { AppLink } from "../link.tsx";8 import type { Crumb } from "./sections.ts";9 17-/** The trail to the page, as a breadcrumb: each step a link but the page itself. */10 export const Breadcrumb = ({11 crumbs,12 }: {13 readonly crumbs: readonly Crumb[];4 unmodified lines18 const last = index === crumbs.length - 1;19 const face = mono ? "text-mono font-mono" : "";20 21 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 lines55 </ol>56 </nav>57 );58 69-/**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- */59 export const CopyCommand = ({ command }: { readonly command: string }) => {60 const { copied, copy } = useCopy(command);61 const number = useNumberedCommand(command);62 29 unmodified lines92 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 linesmodified: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- */1 import type { ProjectListing } from "@repo/protocol/domain/front-page";2 import { ProjectName } from "@repo/protocol/ids";3 import { useMatch } from "@tanstack/react-router";4 import { Schema } from "effect";5 import { createContext, useContext } from "react";6 import type { ReactNode } from "react";7 15-/** One of the shell's overlays. */8 export type Overlay = "keys" | "menu" | "more" | "projects";9 10 export interface Shell {11 readonly open: (overlay: Overlay) => void;4 unmodified lines16 // Outside the shell (a view's own test) there is nothing to open.17 },18 });19 28-/** The shell's overlays, from inside it. */20 export const useShell = (): Shell => useContext(ShellContext);21 22 const isProjectName = Schema.is(ProjectName);23 33-/**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- */24 export const useCurrentProject = (): ProjectName | undefined =>25 useMatch({26 from: "/$owner/$project",27 select: ({ params }) =>28 isProjectName(params.project) ? params.project : undefined,29 shouldThrow: false,30 });31 46-/** What the root route read for the rail. */32 export 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 }36 37 export const ShellReadsContext = createContext<ShellReads>({});38 56-/**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- */39 export const useProjectList = (): readonly ProjectListing[] | undefined =>40 useContext(ShellReadsContext).projects;41 64-/** Today's count for the rail, when there is one. */42 export 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- */1 import type { ReactNode } from "react";2 3 import { Sheet, SheetContent } from "../../../components/ui/sheet.tsx";4 import { CommandSlotProvider } from "../keys.tsx";22 unmodified linesmodified:apps/web/src/features/shared/shell/lazy-overlays.ts+2 added-4 removed
123452345676 unmodified lines/** * The shell's overlays (`overlays.tsx`) and a code page's facts sheet * (`facts-sheet.tsx`), fetched once the page is up: the Worker never * renders one (an overlay opens on a press), and no page's first load * carries their dialog, sheet and combobox code. * Fetched once the page is up: the Worker never renders one, and no page's * first load carries their dialog, sheet and combobox code. */import { lazy } from "react";
export const LazyOverlays = import.meta.env.SSR6 unmodified linesmodified: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- */1 import { Brand } from "@repo/brand";2 import { useRouter } from "@tanstack/react-router";3 import { BookOpen, Bot, FolderInput, Keyboard } from "lucide-react";4 import { useRef } from "react";28 unmodified lines33 RailFoot,34 } from "./rail.tsx";35 36 export interface OverlayProps {45- /** The overlay open now; none when all are closed. */37 readonly overlay: Overlay | undefined;38 readonly onClose: () => void;39 }40 50-/** A sheet's or dialog's open state, as the shell holds it. */41 const openState = (open: boolean, onClose: () => void) => ({42 onOpenChange: (next: boolean) => {43 if (!next) {44 onClose();1 unmodified line46 },47 open,48 });49 60-/** Whether the screen is at least a tablet's width, read when an overlay opens. */50 const atLeastTablet = () => globalThis.matchMedia("(min-width: 40rem)").matches;51 63-/**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- */52 const 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 lines100 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 lines117 </Combobox>118 );119 };120 140-/** The Projects sheet's body: the switcher, and the way to import a repo at its foot. */121 export const ProjectsSheetBody = ({122 input,123 onChosen,124 }: {14 unmodified lines139 </div>140 </>141 );142 163-/** The phone's More: Docs, For agents, the project's sections, the keys, the session. */143 const More = () => {144 const project = useCurrentProject();145 const listed = useProjectList();146 const { open } = useShell();87 unmodified lines234 </Dialog>235 );236 };237 259-/**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. */239 const ShellOverlays = ({ onClose, overlay }: OverlayProps) => {240 const filter = useRef<HTMLInputElement>(null);241 242 return (31 unmodified linesmodified: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- */1 import { useMatches } from "@tanstack/react-router";2 import { createElement } from "react";3 import type { ComponentType, ReactNode } from "react";4 5 declare 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 }10 29-/** The slot's frame: the rest of the rail's height, scrolling on its own. */11 export 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 lines23 {children}24 </section>25 );26 47-/** The component the deepest matched route puts in the slot, when one does. */27 export const useRailContent = (): ComponentType | undefined =>28 useMatches({29 select: (matches) =>30 matches.findLast(({ staticData }) => staticData.rail !== undefined)31 ?.staticData.rail,32 });33 55-/** The slot's content for the address, or nothing. */34 export const RailSlotOutlet = (): ReactNode => {35 const Content = useRailContent();36 37 return Content === undefined ? null : createElement(Content);1 unmodified linemodified: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- */1 import { Brand } from "@repo/brand";2 import type { ProjectListing } from "@repo/protocol/domain/front-page";3 import type { ProjectName } from "@repo/protocol/ids";4 import type { Posture } from "@repo/protocol/posture";28 unmodified lines33 } from "./context.ts";34 import { RailSlotOutlet, useRailContent } from "./rail-slot.tsx";35 import { projectSections, sectionOf } from "./sections.ts";36 52-/** A row of the rail, before the fill that marks the current one. */37 const 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";39 56-/** A row of the rail: a word (and its mark), 32 px, filled when current. */40 export const RAIL_ROW = `${RAIL_BASE} [&[aria-current]]:bg-surface`;41 59-/** A row's mark: 16 px at the marks' stroke, muted until the row is current. */42 const MARK = "text-muted-foreground size-4 shrink-0";43 44 const SITE = [45 { icon: House, label: "Home", to: HOME_PATH },6 unmodified lines52 readonly label: string;53 readonly to: string;54 }[];55 74-/** Only the page itself is current; its search (a filter, a selection) does not count. */56 const EXACT = { exact: true, includeSearch: false } as const;57 77-/** A count of things at a rail row's end, in tabular figures, with what it counts for a screen reader. */58 export const RailCount = ({59 count,60 of,61 }: {5 unmodified lines67 <span className="sr-only"> {of}</span>68 </span>69 );70 91-/** Today's count, as the root route read it. */71 const TodayCount = () => useTodayCount() ?? null;72 94-/** The wordmark, leading to the landing (which sends a signed-in reader home). */73 export const Wordmark = ({74 className = "",75 }: {76 readonly className?: string;6 unmodified lines83 {Brand.name}84 </AppLink>85 );86 109-/** Home, Asks, Today, Docs and For agents. */87 const SiteSections = () => (88 <ul className="flex flex-col gap-px">89 {SITE.map(({ icon: Icon, label, to }) => (90 <li key={to}>6 unmodified lines97 ))}98 </ul>99 );100 124-/** 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. */101 export const PostureMark = ({ posture }: { readonly posture: Posture }) => {102 const { icon: Icon, tone } = POSTURE_MARKS[posture];103 104 return (12 unmodified lines117 </span>118 );119 };120 145-/**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- */121 const ProjectRow = ({122 current,123 listing,124 project,13 unmodified lines138 {listing === undefined ? null : <PostureMark posture={listing.posture} />}139 </AppLink>140 );141 171-/** The current project's sections, indented under it, the open asks counted beside Asks. */142 export const ProjectSectionList = ({143 openAsks,144 project,145 }: {27 unmodified lines173 </ul>174 );175 };176 207-/** The list's place while it is read: three rows of the rail's height. */177 const PLACEHOLDERS = ["w-24", "w-20", "w-28"] as const;178 179 const PlaceholderRows = () => (180 <li aria-hidden="true" className="flex flex-col gap-px">5 unmodified lines186 </li>187 );188 189 /**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 */193 const Projects = () => {194 const current = useCurrentProject();195 const listed = useProjectList();58 unmodified lines254 );255 };256 257 /**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 */261 const Quiet = ({ children }: { readonly children: ReactNode }) => (262 <span className="text-muted-foreground flex shrink-0">{children}</span>263 );264 300-/** The rail's foot: the session, and the Keys button that opens the `?` dialog. */265 export const RailFoot = () => {266 const { open } = useShell();267 268 return (14 unmodified lines283 </div>284 );285 };286 323-/** The rail's sections and projects: the column's middle, and the Menu sheet's body. */287 export const RailContent = (): ReactNode => (288 <div className="flex flex-col gap-2 px-2 py-2">289 <SiteSections />290 <Projects />291 </div>292 );293 331-/**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- */294 const ProjectLine = ({ project }: { readonly project: ProjectName }) => {295 const listed = useProjectList();296 297 const section = useLocation({28 unmodified lines326 </details>327 );328 };329 372-/**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- */330 export const Rail = () => {331 const slotted = useRailContent() !== undefined;332 const project = useCurrentProject();333 const { open } = useShell();37 unmodified linesmodified: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- */1 import { projectAddressOf } from "@repo/protocol/ids";2 import { Option } from "effect";3 4 import { segmentsOf } from "../paths.ts";5 12-/** Which of a project's pages is being read. */6 export type ProjectTab =7 | "code"8 | "env"9 | "landings"1 unmodified line11 | "overview"12 | "people"13 | "refs";14 22-/** One of a project's sections: its word, its page, and the tab it is. */15 export interface Section {16 readonly label: string;17 readonly tab: ProjectTab;18 readonly to: string;19 }20 29-/**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- */21 export 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 lines27 { label: "Ledger", tab: "ledger", to: `/${project}/ledger` },28 { label: "Env shape", tab: "env", to: `/${project}/env` },29 ];30 45-/** The first segment of each of a project's pages, by the section it sits in. */31 const SECTION_OF = {32 answers: "overview",33 asks: "overview",34 blob: "code",6 unmodified lines41 tree: "code",42 why: "code",43 } as const satisfies Record<string, ProjectTab>;44 60-/** The site's own first segments: every other one starts a project's address. */45 const SITE = new Set([46 "agents",47 "asks",48 "docs",2 unmodified lines51 "people",52 "today",53 ]);54 71-/**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- */55 const addressOf = (pathname: string) => {56 const segments = segmentsOf(pathname);57 const [first] = segments;58 1 unmodified line60 ? undefined61 : Option.getOrUndefined(projectAddressOf(segments));62 };63 87-/** The project an address is in; none on the site's own pages. */64 export const projectOf = (pathname: string): string | undefined =>65 addressOf(pathname)?.spelled;66 91-/** The project section an address sits in; none for a page under none (a decision, a proposal). */67 export const sectionOf = (pathname: string): ProjectTab | undefined => {68 const address = addressOf(pathname);69 70 if (address === undefined) {6 unmodified lines77 ? "overview"78 : Object.entries(SECTION_OF).find(([segment]) => segment === page)?.[1];79 };80 106-/** One step of the trail to a page: its word, its page (none for the page itself), and whether it is an id. */81 export interface Crumb {82 readonly label: string;83 readonly mono?: boolean;84 readonly to?: string;8 unmodified lines93 people: "Policy",94 refs: "Refs",95 } as const satisfies Record<ProjectTab, string>;96 123-/** A section's crumb, linked to its page when a page sits below it. */97 const sectionCrumb = (98 project: string,99 tab: ProjectTab,100 below: boolean3 unmodified lines104 105 return below && section !== undefined ? { label, to: section.to } : { label };106 };107 135-/** A project's crumb, then its section's. */108 const projectCrumbs = (109 project: string,110 tab: ProjectTab,111 below: boolean1 unmodified line113 { label: project, to: `/${project}` },114 sectionCrumb(project, tab, below),115 ];116 145-/** A code page's trail: Code, then the path in hand (none at the root). */117 const pathCrumbs = (project: string, path: string): readonly Crumb[] =>118 path === ""119 ? projectCrumbs(project, "code", false)120 : [...projectCrumbs(project, "code", true), { label: path, mono: true }];121 151-/** The site's own pages' trails, by first segment. */122 const SITE_CRUMBS = {123 agents: () => [{ label: "For agents" }],124 asks: () => [{ label: "Asks" }],125 docs: (page: string | undefined) =>7 unmodified lines133 string,134 (second: string | undefined) => readonly Crumb[]135 >;136 167-/** A project's subject pages' trails (an ask, an answer, a commit, a path…), by second segment. */137 const SUBJECT_CRUMBS = {138 answers: (project: string, ask: string) => [139 ...projectCrumbs(project, "overview", true),140 { label: ask, mono: true, to: `/${project}/asks/${ask}` },26 unmodified lines167 string,168 (project: string, third: string, rest: string) => readonly Crumb[]169 >;170 202-/**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- */171 export const crumbsFor = (pathname: string): readonly Crumb[] => {172 const [first, second] = segmentsOf(pathname);173 174 if (first === undefined) {35 unmodified linesmodified: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 */5 import {6 defaultStringifySearch,7 useLocation,3 unmodified lines11 import { useCallback } from "react";12 13 import { useEscapeClears } from "../keys.tsx";14 29-/** The search params a list selects by. */15 export type SelectionParam = "ask" | "decision";16 32-/** A selection as an address's search carries it. */17 const Selection = Schema.Struct({18 ask: Schema.optionalKey(Schema.String),19 decision: Schema.optionalKey(Schema.String),20 });21 22 const decodeSelection = Schema.decodeUnknownOption(Selection);23 40-/**41- * `searchStr` (`?filter=…&ask=…`) with `param` set to `id`, or without it,42- * each value written as the router writes it.43- */24 export const searchWith = (25 searchStr: string,26 param: SelectionParam,27 id?: string53 unmodified lines81 82 return { clear, select, selected };83 };84 105-/**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- */85 export 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- */1 import { useLocation } from "@tanstack/react-router";2 import { ChevronLeft, ChevronsUpDown, Menu } from "lucide-react";3 4 import { Button } from "../../../components/ui/button.tsx";2 unmodified lines7 import { useCurrentProject, useShell } from "./context.ts";8 import { Wordmark } from "./rail.tsx";9 import { crumbsFor } from "./sections.ts";10 19-/** The page above a subject page (its crumb before last), when the address is one. */11 const parentOf = (pathname: string) => {12 const crumbs = crumbsFor(pathname);13 const parent = crumbs.at(-2);14 65 unmodified linesmodified: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- */1 import { useHydrated, useLocation, useRouter } from "@tanstack/react-router";2 import { Predicate } from "effect";3 import { ChevronDown, PanelRight } from "lucide-react";4 import { Suspense, useState } from "react";7 unmodified lines12 import { crumbsFor } from "./sections.ts";13 import type { Crumb } from "./sections.ts";14 15 export 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 }32 64-/** Main's side padding at each width. */33 export const GUTTER = "px-4 tablet:px-5 shell:px-6";34 67-/** How wide rows and the head run: 56 rem, from the left. */35 export const MEASURE = "max-w-[56rem]";36 70-/** Past this many characters a title is set a step down, to stay within three lines. */37 const LONG_TITLE = 80;38 39 const PageHead = ({40 meta,18 unmodified lines59 )}60 </div>61 );62 97-/** The inspector's heading row: names what the facts describe, and announces it when it changes. */63 const 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 line68 <h2 className="text-ui font-semibold">{heading}</h2>69 </div>70 );71 107-/** The facts settling in when their subject changes: 120 ms of opacity, nothing that moves. */72 const Settling = ({73 children,74 id,75 }: {4 unmodified lines80 {children}81 </div>82 );83 120-/** The facts in main, after the head, below the shell's width. */84 const InlineFacts = ({85 facts,86 heading,87 list,34 unmodified lines122 <div className="flex flex-col">{facts}</div>123 </section>124 );125 163-/** A code page's Facts button, and its facts as a sheet from the right. */126 const FactsSheet = ({127 facts,128 heading,129 }: {48 unmodified lines178 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 lines198 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 lines275 pathname={useLocation({ select: (location) => location.pathname })}276 />277 );278 319-/**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- */279 export const Workspace = (props: WorkspaceProps) =>280 Predicate.isNotNullish(useRouter({ warn: false })) ? (281 <AtAddress {...props} />282 ) : (2 unmodified linesmodified: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- */1 import type { Ask } from "@repo/protocol/domain/ask";2 import { ProjectEvent } from "@repo/protocol/domain/event";3 import { Outcome } from "@repo/protocol/domain/outcome";4 import type { AskId, CommitSha, Handle, LandedSha } from "@repo/protocol/ids";5 import type { DateTime } from "effect";6 import { constVoid, identity } from "effect/Function";7 18-/** One answer checked: the commit pushed, what the gate said, and when. */8 export interface Round {9 readonly at: DateTime.Utc;10 readonly head: CommitSha;11 readonly outcome: Outcome;12 readonly seq: number;13 }14 26-/** Where one ask stands, as its events tell it. */15 export 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 }28 47-/** One child's place in its family. */29 export type Mark =30 | "checking"31 | "claimed"32 | "landed"33 | "open"34 | "refused"35 | "waiting";36 56-/** A family's progress: each stored child's mark, in order, and how many landed of how many. */37 export interface Family {38 readonly children: readonly { readonly ask: AskId; readonly mark: Mark }[];39 readonly landed: number;40 readonly total: number;41 }42 63-/** Who acts next on an ask. */43 export type Move = "answerer" | "decider" | "none" | "parent" | "platform";44 66-/** The highest event number among `events`; 0 when there are none. */45 export const lastSeq = (events: readonly ProjectEvent[]): number => {46 let highest = 0;47 48 for (const { seq } of events) {4 unmodified lines53 };54 55 const fresh: AskProgress = { lastSeq: 0, rounds: [] };56 79-/** `progress` with nobody holding the ask. */57 const unclaimed = ({ claimant: _held, ...rest }: AskProgress): AskProgress =>58 rest;59 83-/** `progress` started over: nobody holds the ask, and no outcome speaks for it. */60 const startedOver = ({61 claimant: _held,62 latest: _said,63 ...rest64 }: AskProgress): AskProgress => rest;65 90-/** `event` applied to `states`, when it is about one ask. */66 const apply = (states: Map<AskId, AskProgress>, event: ProjectEvent): void => {67 const change = (68 ask: AskId,69 step: (progress: AskProgress) => AskProgress44 unmodified lines114 });115 };116 117 /**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 */121 export const askStates = (122 events: readonly ProjectEvent[]123 ): ReadonlyMap<AskId, AskProgress> => {9 unmodified lines133 134 return states;135 };136 163-/**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- */137 export const whoseMove = (latest?: Outcome, claimant?: Handle): Move => {138 if (latest === undefined) {139 return claimant === undefined ? "none" : "answerer";140 }7 unmodified lines148 WaitingOnParent: (): Move => "parent",149 });150 };151 185-/** One child's mark: landed first, then what its latest outcome says, then whether someone holds it. */152 export const markOf = (progress: AskProgress | undefined): Mark => {153 if (progress === undefined) {154 return "open";155 }18 unmodified lines174 return claimant === undefined ? "open" : "claimed";175 };176 177 /**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 */181 export const familyMarks = (182 parent: Ask,183 states: ReadonlyMap<AskId, AskProgress>10 unmodified lines194 };195 };196 197 /**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 */201 export const stampsFrom = (202 previous: ReadonlyMap<AskId, AskProgress> | undefined,203 next: ReadonlyMap<AskId, AskProgress>,11 unmodified linesmodified: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 */5 7-/** A section's heading, the "title" step of the type scale. */6 export const SECTION = "text-lg font-semibold tracking-[-0.01em]";7 10-/** The mono face for names a terminal prints: ids, kinds, territories. */8 export const ID = "font-mono text-mono";9 13-/** Text that is code: an id, a path, a SHA, a command's name; it wraps anywhere. */10 export const CODE = "font-mono text-mono [overflow-wrap:anywhere]";11 16-/** A link in running text: underlined in the rule colour, darker on hover. */12 export const LINK = "decoration-rule underline hover:decoration-current";13 19-/** A field's label: small, muted, above or beside its value. */14 export 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).1 import { Check, Copy } from "lucide-react";2 import { createContext, useContext } from "react";3 import type { ReactNode } from "react";4 5 import { Button } from "../../components/ui/button.tsx";6 import { useCopy } from "./copy-action.tsx";7 import { useNumberedCommand } from "./keys.tsx";8 16-/**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- */9 type Form = "bleed" | "box";10 11 const FormContext = createContext<Form>("box");12 25-/** Command lines under it take the inspector's bleed form. */13 export const InspectorCommands = ({14 children,15 }: {16 readonly children: ReactNode;17 }) => <FormContext value="bleed">{children}</FormContext>;18 32-/** How far a line of the command hangs, in ch, when the column breaks it: less in the inspector's narrow column. */19 const HANGS = { bleed: 2, box: 6 } as const satisfies Record<Form, number>;20 35-/** The box around the command, in each form. */21 const 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>;26 27 /**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 */31 const hangOf = (hang: number, words: readonly string[], line: string) =>32 Math.min(33 hang,34 line.length - Math.max(0, ...words.map(({ length }) => length))35 );36 55-// 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 ` \`.39 const wordsOf = (command: string, form: Form) =>40 command.split("\n").map((line, at, lines) => {41 const parts = line.split(/(?<space>\s+)(?!\\$)/u);42 83 unmodified lines126 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 linesmodified: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 */5 import { Brand } from "@repo/brand";6 import { Effect, Option } from "effect";7 import { Check, Copy } from "lucide-react";8 import { useState } from "react";9 10 import { useCopiedCommand, useNumberedCommand } from "./keys.tsx";11 23-/** Copy `command`, then show it copied for two seconds. */12 const copyFor = (command: string, shown: (copied: boolean) => void) =>13 Effect.tryPromise(() => navigator.clipboard.writeText(command)).pipe(14 Effect.andThen(15 Effect.sync(() => {8 unmodified lines24 ),25 Effect.ignore26 );27 40-/**41- * Copying `command`: whether it was just copied (by this control, or by its42- * number key), and the press that copies it.43- */28 export const useCopy = (command: string) => {29 const [pressed, setPressed] = useState(false);30 const byKey = useCopiedCommand();31 6 unmodified lines38 };39 40 interface 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 }45 46 const ActionButton = ({35 unmodified lines82 const NumberedAction = (props: Omit<CopyProps, "numbered">) => (83 <ActionButton {...props} number={useNumberedCommand(props.command)} />84 );85 104-/** A row's copy button: the icon in sight, the command in the text. */86 export const CopyAction = ({ numbered = false, ...props }: CopyProps) =>87 numbered ? (88 <NumberedAction {...props} />89 ) : (90 <ActionButton {...props} number={undefined} />91 );92 112-/** An open ask's claim command, as a row's copy button. */93 export const ClaimAction = ({94 ask,95 project,96 }: {5 unmodified lines102 label="Copy claim command"103 />104 );105 126-/** A command shown whole and small (a status line's next step); pressing it copies it. */106 export const CommandChip = ({ command }: { readonly command: string }) => {107 const { copied, copy } = useCopy(command);108 const Icon = copied ? Check : Copy;109 22 unmodified linesmodified: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. */2 import { CreditRole } from "@repo/protocol/domain/credit";3 import type { AgentTrailer, Credit } from "@repo/protocol/domain/credit";4 import { LockKeyhole } from "lucide-react";5 import { Fragment } from "react";1 unmodified line7 import { HandleLink } from "./handle.tsx";8 9 const rank = (credit: Credit) => CreditRole.literals.indexOf(credit.role);10 22-/** Credits in trailer order; people in one role keep the order given. */11 export const inTrailerOrder = (credits: readonly Credit[]) =>12 credits.toSorted((one, other) => rank(one) - rank(other));13 26-/** An `Assisted-by:` value as the landing's trailer spells it: `pi:opus-4 (claimed)`. */14 export const assistedValue = ({ harness, model, verified }: AgentTrailer) =>15 `${harness}${model === undefined ? "" : `:${model}`} (${verified ? "verified" : "claimed"})`;16 17 const LINES = "flex flex-col gap-1 font-mono text-mono leading-terminal";8 unmodified lines26 }: {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 lines65 )}66 </div>67 );68 83-/** Each role as a row's line says it: the trailer, in words. */69 const roleWords = {70 "Advised-by": "advised by",71 "Asked-by": "asked by",72 "Decided-by": "decided by",2 unmodified lines75 "Released-by": "released by",76 "Signed-off-by": "answered by",77 } as const satisfies Record<CreditRole, string>;78 94-/** A sentence's first word with its first letter raised. */79 const raised = (words: string) =>80 `${words.slice(0, 1).toUpperCase()}${words.slice(1)}`;81 98-/** What comes before the `index`th of `count` people in a list of words. */82 const before = (index: number, count: number) => {83 if (index === 0) {84 return "";85 }86 87 return index === count - 1 ? " and " : ", ";88 };89 107-/** People in a list of words: "bram", "bram and tamsin", "bram, ines and tamsin". */90 const 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 ));97 116-/** A landing's credit in one line: each role once, in trailer order, its people linked. */98 export 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 linesmodified: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- */1 import type { Disclosure } from "@repo/protocol/domain/visibility";2 3 export const disclosureWords = {4 counted: "counted: how many it holds, and when they open",8 unmodified linesmodified: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- */1 import type { ReactNode } from "react";2 3 import { CommandLine } from "./command.tsx";4 1 unmodified line6 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 linesmodified: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- */1 import { Brand } from "@repo/brand";2 import type { Verdict } from "@repo/protocol/domain/answer";3 import type { Ask } from "@repo/protocol/domain/ask";4 import { CheckSpec } from "@repo/protocol/domain/check";26 unmodified lines31 import { StatusLine, readStatus, stageNames } from "./status-line.tsx";32 import type { StatusSubject } from "./status-line.tsx";33 import { When } from "./time.tsx";34 46-/** A block's frame: a hairline above every block but the first. */35 const 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";37 38 const LINK = "decoration-rule underline hover:decoration-current";39 52-/** One block: its label, then its facts. */40 export const FactBlock = ({41 children,42 label,43 }: {5 unmodified lines49 {children}50 </section>51 );52 66-/**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- */53 export const shortValue = (value: string) => {54 if (/^[0-9a-f]{40,64}$/u.test(value)) {55 return shortSha(value);56 }7 unmodified lines64 ? value65 : `${algorithm}:${hex.slice(0, 6)}…`;66 };67 86-/** A value that is code: shortened, whole in its title. */68 export const CodeValue = ({ value }: { readonly value: string }) => (69 <code className="text-mono font-mono [overflow-wrap:anywhere]" title={value}>70 {shortValue(value)}71 </code>72 );73 93-/** The status line whole, and the command that runs next, numbered first. */74 export 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 lines87 </FactBlock>88 );89 };90 112-/** One numbered step: what it does, then its command. */91 const Step = ({92 command,93 label,94 }: {5 unmodified lines100 <CommandLine command={command} numbered />101 </div>102 );103 126-/** Who may take an ask, in a sentence. */104 const whoMayTake = (ask: Ask) => {105 if (ask.reserve === "newcomers") {106 return ask.mentor === undefined107 ? "Held for newcomers"4 unmodified lines112 ? "Held for people, not agents"113 : `Anyone vouched in ${ask.project}, or with a record in its area`;114 };115 139-/** Who may take an open ask, then the three commands that start an answer. */116 export 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 lines133 <Step command={`${Brand.cli} check`} label="Check before you push" />134 </FactBlock>135 );136 162-/** Who holds a claim, in words: the viewer, someone, or nobody. */137 const Holder = ({138 claimant,139 yours,140 }: {12 unmodified lines153 </>154 );155 };156 183-/**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. */158 export const ClaimFacts = ({159 claimant,160 lastPush,161 now,1 unmodified line163 }: {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 lines188 </FactBlock>189 );190 };191 222-/** What each stage runs, in one line. */192 const runs = Match.type<StageName>().pipe(193 Match.when(194 "parse",195 () => "Who may push what: the branch, the pusher and their claim."22 unmodified lines218 ),219 Match.exhaustive220 );221 253-/** Each stage's state as a mark and a word. */222 const stageMarks = {223 current: { mark: "now", word: "now" },224 passed: { mark: "passed", word: "passed" },225 pending: { mark: "notYet", word: "not yet" },3 unmodified lines229 StageState,230 { readonly mark: StateMark; readonly word: string }231 >;232 265-/**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- */233 export const GateFacts = (234 props:235 | { readonly outcome?: undefined }236 | {74 unmodified lines311 </FactBlock>312 );313 };314 352-/** What each posture means, in one line. */315 const 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 lines321 "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>;324 363-/** A project's posture as the platform labels it, what it means, and its ledger. */325 export const PostureFacts = ({326 label,327 posture,328 project,10 unmodified lines339 </AppLink>340 </FactBlock>341 );342 382-/** What a project holds back: one sealed line per area, or that nothing is. */343 export 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 lines373 )}374 </FactBlock>375 );376 418-/** The family a member belongs to, drawn top to bottom. */377 export const FamilyFacts = (props: Parameters<typeof FamilyTree>[0]) => (378 <FactBlock label="Family">379 <FamilyTree {...props} />380 </FactBlock>381 );382 425-/** The folder a territory's first path names, when it names one plainly. */383 const folderOf = (ask: Ask) => {384 const [first] = ask.territory.paths;385 const folder = first.replace(/\/\*\*$|\/\*$|^\*\*$/u, "");386 387 return /[*?[{]/u.test(folder) ? undefined : folder;388 };389 433-/**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- */390 const TerritoryLine = ({ ask }: { readonly ask: Ask }) => {391 const folder = folderOf(ask);392 const { module, paths } = ask.territory;393 24 unmodified lines418 </AppLink>419 );420 };421 470-/** What judges an answer, by the check's kind. */422 const CheckLine = ({ ask }: { readonly ask: Ask }) =>423 CheckSpec.match(ask.check, {424 LintToZero: ({ rule }) => (425 <p className="text-ui">35 unmodified lines461 </p>462 ),463 });464 514-/** Where an answer may change things, and what judges it. */465 export const TerritoryFacts = ({ ask }: { readonly ask: Ask }) => (466 <FactBlock label="Territory and check">467 <TerritoryLine ask={ask} />468 <CheckLine ask={ask} />469 </FactBlock>470 );471 522-/** A landing's credit as the commit carries it, the agents apart. */472 export const CreditFacts = (props: {473 readonly assisted: readonly AgentTrailer[];474 readonly credits: readonly Credit[];475 readonly heldBack?: string | undefined;6 unmodified lines482 />483 </div>484 );485 537-/** One fact of provenance: its label, its whole value, and how it reads. */486 export 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 }491 545-/** What a verdict judged: the commits, the tree, the patch, the check, who judged it and when. */492 export const verdictProvenance = (493 verdict: Verdict,494 now: DateTime.Utc495 ): readonly ProvenanceEntry[] => [9 unmodified lines505 value: DateTime.formatIso(verdict.at),506 },507 ];508 563-/** Where a landing comes from: its author, its parent, and the request that landed it. */509 export const landingProvenance = (510 landing: LandingView511 ): readonly ProvenanceEntry[] => [512 { label: "Author", value: landing.author },7 unmodified lines520 ? []521 : [{ label: "Request-Id", value: landing.requestId }]),522 ];523 579-/**580- * The plumbing, last: each value shortened, whole in its title and on581- * copy. Below the shell's width it starts folded.582- */524 export const ProvenanceFacts = ({525 entries,526 }: {527 readonly entries: readonly ProvenanceEntry[];21 unmodified lines549 />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 lines562 </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 linesmodified: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- */1 import type { Ask } from "@repo/protocol/domain/ask";2 import type { AskId, ProjectName } from "@repo/protocol/ids";3 import { ArrowRight, ChevronDown } from "lucide-react";4 import { useId, useState } from "react";5 unmodified lines10 import { StateMarkIcon } from "./marks.tsx";11 import type { StateMark } from "./marks.tsx";12 import { askPath } from "./paths.ts";13 33-/** Each child's state in the words its node is read by. */14 const words = {15 checking: "checking",16 claimed: "claimed",17 landed: "landed",1 unmodified line19 refused: "refused",20 waiting: "waiting",21 } as const satisfies Record<Mark, string>;22 43-/** The fold's marks are named as the marks are. */23 const markFor = (mark: Mark): StateMark => mark;24 46-/** The words of `id` after `prefix` and its dash, or `id` when it does not start so. */25 const after = (id: string, prefix: string) =>26 id.startsWith(`${prefix}-`) ? id.slice(prefix.length + 1) : id;27 50-/**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- */28 export const shortNames = (29 parent: AskId,30 children: readonly AskId[]31 ): ReadonlyMap<AskId, string> => {16 unmodified lines48 })49 );50 };51 79-/** A family's children (the delete child apart), their marks and what the delete child waits on. */52 const familyOf = (53 parent: Ask,54 states: ReadonlyMap<AskId, AskProgress>,55 finale: AskId | undefined17 unmodified lines73 total: children.length,74 };75 };76 105-/** Where the delete child stands: its mark, and its state in words. */77 interface FinaleState {78 readonly mark: StateMark;79 readonly words: string;80 }81 111-/** The delete child's state: it waits until every child lands, then opens, then lands. */82 const finaleOf = (83 finale: AskId,84 states: ReadonlyMap<AskId, AskProgress>,85 remaining: number16 unmodified lines102 103 const NODE =104 "text-label relative z-10 inline-flex min-w-0 items-center gap-1 no-underline hover:underline decoration-rule";105 136-/** A row's third line: the fan, the count, and the children as rows on demand. */106 export const FamilyStrip = ({107 expanded,108 finale,109 parent,3 unmodified lines113 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 lines205 {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 lines252 </div>253 );254 };255 292-/** One member in the vertical form: its mark, its name, its state's word; the member being read filled. */256 const Member = ({257 current,258 label,259 mark,23 unmodified lines283 </span>284 </AppLink>285 );286 324-/** The family read top to bottom: the parent, its children on a bus, then the delete child. */287 export const FamilyTree = ({288 current,289 finale,290 parent,2 unmodified lines293 }: {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));302 342- // 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 linesmodified: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- */1 import type { Handle } from "@repo/protocol/ids";2 3 import { AppLink } from "./link.tsx";4 import { personPath } from "./paths.ts";9 unmodified linesmodified: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- */1 import { Brand } from "@repo/brand";2 7-/** A page's `<title>`: the page, then the product. */3 export const pageTitle = (title: string) => `${title} · ${Brand.name}`;4 5 /**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 */9 export const pageHead = ({10 description,11 title,18 unmodified linesmodified: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 */5 import { Effect, Option, Result } from "effect";6 import {7 createContext,8 unmodified lines16 import type { ReactNode } from "react";17 18 import { Kbd } from "../../components/ui/kbd.tsx";19 35-/** A key pressed, as the listener reads it. */20 export 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 }27 45-/** What a key asks for. */28 export type KeyIntent =29 | { readonly index: number; readonly kind: "copy" }30 | {31 readonly kind:13 unmodified lines45 } as const satisfies Record<string, KeyIntent["kind"]>;46 47 const DIGIT = /^[1-9]$/u;48 67-/** The shell's width, from which the rail and the inspector are columns. */49 const SHELL_WIDTH = "(min-width: 70rem)";50 70-/**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- */51 export const intentOf = (52 press: KeyPress,53 on: boolean54 ): KeyIntent | undefined => {21 unmodified lines76 77 return move === undefined ? undefined : { kind: move[1] };78 };79 103-/** Where the switch is kept, in the browser's storage. */80 const SWITCH = "keys.single";81 106-/** Whether the single keys are on: on unless `storage` says off, or cannot say. */82 export const readShortcuts = (storage?: Storage): boolean =>83 storage === undefined ||84 Result.getOrElse(85 Result.try(() => storage.getItem(SWITCH) !== "off"),86 () => true87 );88 114-/** Keep the switch as `on` says; a storage that refuses keeps nothing. */89 export const writeShortcuts = (storage: Storage | undefined, on: boolean) => {90 Result.try(() => storage?.setItem(SWITCH, on ? "on" : "off"));91 };92 119-/** The browser's storage, when there is one this page may use. */93 const localStorageOf = (): Storage | undefined =>94 Result.getOrUndefined(Result.try(() => globalThis.localStorage));95 123-/** The keys and what each does, as the dialog lists them. */96 const 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 line101 { does: "Copy the page's numbered command", keys: ["1", "…", "9"] },102 { does: "Close, or clear the selection", keys: ["Esc"] },103 ] as const;104 133-/** The switch's two settings, each a button that says whether it is pressed. */105 const SETTINGS = [106 { label: "On", on: true },107 { label: "Off", on: false },108 ] as const;109 139-/**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- */110 export const KeysHelp = ({111 on,112 onChange,113 }: {44 unmodified lines158 </p>159 </div>160 );161 195-/** Which part of the page a command sits in: the inspector's are numbered first. */162 export type CommandSlot = "facts" | "main";163 164 const SlotContext = createContext<CommandSlot>("main");165 200-/** Commands under `slot` number as the inspector's or main's. */166 export const CommandSlotProvider = ({167 children,168 slot,169 }: {170 readonly children: ReactNode;171 readonly slot: CommandSlot;172 }) => <SlotContext value={slot}>{children}</SlotContext>;173 209-/** A list the page lets `j` and `k` move through. */174 interface ListRegistration {175 readonly focus: (id: string) => void;176 readonly read: () => {177 readonly ids: readonly string[];1 unmodified line179 };180 focused?: string;181 }182 219-/** The files a page lets `J` and `K` move between. */183 interface FileRegistration {184 readonly read: () => {185 readonly onMove: (path: string) => void;186 readonly paths: readonly string[];6 unmodified lines193 readonly id: string;194 readonly slot: CommandSlot;195 }196 234-/** What the page registers with the listener; one for the shell's life. */197 interface Registry {198 readonly clearers: Set<() => void>;199 readonly files: Set<FileRegistration>;200 readonly lists: Set<ListRegistration>;201 readonly register: (command: Command) => () => void;202 }203 242-/** What the keys show: whether they are on, the numbers, the last copy. */204 interface KeysState {205 readonly copied: string | undefined;206 readonly numbered: ReadonlyMap<string, number>;207 readonly on: boolean;3 unmodified lines211 const RegistryContext = createContext<Registry | undefined>(undefined);212 213 const StateContext = createContext<KeysState | undefined>(undefined);214 254-/** The keys' state, for the dialog. */215 export const useKeys = () => useContext(StateContext);216 257-/** `item` in `set` until the returned function takes it out. */217 const held = <A,>(set: Set<A>, item: A) => {218 set.add(item);219 220 return () => {221 set.delete(item);222 };223 };224 266-/** The last registered of `set`: the page's own, over any that left late. */225+/** The page's own, over any that left late. */226 const lastOf = <A,>(set: ReadonlySet<A>): A | undefined => [...set].at(-1);227 269-/** Whether `event` was pressed inside something that takes typing. */228 export const inField = (event: KeyboardEvent) => {229 const [target] = event.composedPath();230 231 return (4 unmodified lines236 ) !== null)237 );238 };239 282-/** Numbers commands 1 to 9: the inspector's first, each command once. */240 const numberOf = (241 commands: readonly Command[]242 ): ReadonlyMap<string, number> => {243 const ordered = [7 unmodified lines251 unique.slice(0, 9).map((command, index) => [command, index + 1])252 );253 };254 298-/** Copy `command`, then mark it copied for two seconds. */255 const copyNumbered = (command: string, shown: (copied?: string) => void) =>256 Effect.tryPromise(() => navigator.clipboard.writeText(command)).pipe(257 Effect.andThen(258 Effect.sync(() => {8 unmodified lines267 ),268 Effect.ignore269 );270 315-/** The row a key moved to: focused, scrolled to, and selected at the shell's width. */271 const 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 lines293 row.focus({ preventScroll: true });294 row.scrollIntoView({ block: "nearest" });295 }296 342- // 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 lines309 onMove(next);310 }311 };312 359-/** What the listener reads when a key is pressed. */313 interface 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 }320 368-/** Do what `intent` asks; whether it did anything (so the browser does not too). */321 const act = (intent: KeyIntent, now: Pressing): boolean => {322 const { registry } = now;323 324 if (intent.kind === "keys") {41 unmodified lines366 367 return files !== undefined;368 };369 418-/**419- * The shell's one listener and the state behind it. `openDialog` opens the420- * keys dialog (the shell draws it).421- */370 export 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 lines402 }, []);403 404 const numbered = useMemo(() => numberOf(commands), [commands]);405 458- // The listener reads the latest of these, kept here after each render.406 const pressing = useRef<Pressing | null>(null);407 408 useEffect(() => {409 pressing.current = {54 unmodified lines464 </RegistryContext>465 );466 };467 521-/** `value`, kept current in a ref after each render, for a handler to read later. */468 const useLatest = <A,>(value: A) => {469 const latest = useRef(value);470 471 useEffect(() => {2 unmodified lines474 475 return latest;476 };477 532-/**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- */478 export const useListKeys = (479 ids: readonly string[],480 onSelect: (id: string) => void481 ): { readonly focused?: string } => {14 unmodified lines496 497 return focused === undefined ? {} : { focused };498 };499 560-/** Let `J` and `K` move between `paths` (the page's files, in order), each move calling `onMove`. */500 export const useFileKeys = (501 paths: readonly string[],502 onMove: (path: string) => void503 ): void => {8 unmodified lines512 [latest, registry]513 );514 };515 577-/**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- */516 export const useNumberedCommand = (command: string): number | undefined => {517 const registry = useContext(RegistryContext);518 const state = useContext(StateContext);519 const slot = useContext(SlotContext);6 unmodified lines526 527 return state?.on === true ? state.numbered.get(command) : undefined;528 };529 596-/** The command a number key copied in the last two seconds, to show as copied. */530 export const useCopiedCommand = (): Option.Option<string> =>531 Option.fromUndefinedOr(useContext(StateContext)?.copied);532 600-/** Let `Escape` call `clear` while the caller is on the page (the selection's). */533 export const useEscapeClears = (clear: () => void): void => {534 const registry = useContext(RegistryContext);535 const latest = useLatest(clear);536 10 unmodified linesmodified: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- */1 import type { ReactNode } from "react";2 3 import { Workspace } from "./shell/workspace.tsx";4 4 unmodified lines9 readonly children: ReactNode;10 readonly title: string;11 }) => <Workspace title={title}>{children}</Workspace>;12 20-/** The first stop of a keyboard on every page: straight to main, past the rail. */13 export 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 linesmodified: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 */5 import {6 defaultStringifySearch,7 Link,3 unmodified lines11 import { Predicate } from "effect";12 import { createElement } from "react";13 import type { AnchorHTMLAttributes, ReactNode } from "react";14 31-/** An `AppLink`'s props: an anchor's, with the address as `to`. */15 export 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 }27 28 /**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 */33 export const literalPath = (path: string): string =>34 path.replaceAll("$", "%24").replaceAll("{", "%7B").replaceAll("}", "%7D");35 62-/** The address an `AppLink` names, as the router would write it. */36 export const hrefOf = ({37 hash,38 search,39 to,3 unmodified lines43 ? ""44 : defaultStringifySearch(search)45 }${hash === undefined ? "" : `#${hash}`}`;46 74-/**75- * `Link` over any router, whose `to` is any path: the router reads a path76- * built whole as it reads a typed address.77- */47 const PathLink = Link<AnyRouter, string, string>;48 49 export const AppLink = (props: AppLinkProps): ReactNode => {50 const router = useRouter({ warn: false });1 unmodified line52 if (Predicate.isNotNullish(router)) {53 return <PathLink {...props} to={literalPath(props.to)} />;54 }55 87- // 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 linesmodified: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 */5 import type { Posture } from "@repo/protocol/posture";6 import { Eye, LockKeyhole, LockKeyholeOpen } from "lucide-react";7 import type { LucideIcon } from "lucide-react";8 10-/** How a mark is drawn: its icon, its role's colour, and whether its icon is filled. */9 export 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 }14 19-/** A project's posture as a mark: a lock in the sealed role when something is kept sealed. */15 export 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 linesmodified: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- */1 import {2 Check,3 CircleSmall,4 Circle,8 unmodified lines13 } from "lucide-react";14 15 import type { MarkLook } from "./mark-look.ts";16 32-/** Every state a mark is drawn for. */17 export const STATE_MARK_NAMES = [18 "landed",19 "passed",20 "checking",11 unmodified lines32 ] as const;33 34 export type StateMark = (typeof STATE_MARK_NAMES)[number];35 52-/** Each state's mark and its word, as it reads on its own. */36 export const STATE_MARKS = {37 checking: {38 fill: true,39 icon: CircleSmall,19 unmodified lines59 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 }>;62 80-/** A mark's size beside 14 and 16 px text, and one a step down for 13 px lines. */63 const SIZES = { md: "size-4", sm: "size-3.5" } as const;64 83-/**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- */65 export const Mark = ({66 className = "",67 look,68 size = "md",18 unmodified lines87 />88 );89 };90 114-/** The mark of a named state. */91 export const StateMarkIcon = ({92 mark,93 ...rest94 }: {5 unmodified linesmodified: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- */1 import { Outcome, StageName } from "@repo/protocol/domain/outcome";2 import type { Handle, ProjectName } from "@repo/protocol/ids";3 4 import { StateMarkIcon } from "./marks.tsx";10 unmodified lines15 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 lines56 </div>57 );58 };59 78-/** A stage's place in the strip. */60 export type StageState =61 | "passed"62 | "current"63 | "refused"64 | "pending"65 | "skipped";66 86-/** What a verdict holds beyond its stage: a decider's decision, and held-back results. */67 export interface StageHolds {68 readonly decided: boolean;69 readonly heldBack: boolean;70 }71 72 /**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 */77 export const stageStates = (78 reached: StageName,79 outcome: Outcome,37 unmodified lines117 ] as const;118 });119 };120 148-/** Each state's mark and word in a cell; the current one's mark follows the outcome. */121 const cellMarks = (outcome: Outcome) =>122 ({123 current: {124 mark: Outcome.isAnyOf(["Checking"])(outcome) ? "now" : "waiting",7 unmodified lines132 StageState,133 { readonly mark: StateMark; readonly word: string }134 >;135 164-/** A cell's word in its state's role; not yet and not needed stay muted. */136 const wordTones = {137 current: "",138 passed: "text-landed",139 pending: "text-muted-foreground",5 unmodified lines145 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 linesmodified: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- */1 import type {2 AskId,3 DecisionId,4 Handle,5 ProjectName,6 } from "@repo/protocol/ids";7 import { Result } from "effect";8 13-/** The front page: every open ask, across every project. */9 export const ASKS_PATH = "/asks";10 16-/** A signed-in reader's own page. */11 export const HOME_PATH = "/home";12 19-/** The import page: a public repo made a project. */13 export const IMPORT_PATH = "/import";14 22-/** The docs' index, or one of its pages. */15 export const docsPath = (page?: string) =>16 page === undefined ? "/docs" : `/docs/${page}`;17 26-/** A project's page. */18 export const projectPath = (project: ProjectName) => `/${project}`;19 29-/** An ask's page. */20 export const askPath = (project: ProjectName, ask: AskId) =>21 `/${project}/asks/${ask}`;22 33-/** The page of the verdict on an ask's latest answer. */23 export const answerPath = (project: ProjectName, ask: AskId) =>24 `/${project}/answers/${ask}`;25 37-/** A person's page: `/people/<handle>` (a handle is URL-safe by its schema). */26+/** A handle is URL-safe by its schema. */27 export const personPath = (handle: Handle) => `/people/${handle}`;28 40-/** A project's ledger. */29 export const ledgerPath = (project: ProjectName) => `/${project}/ledger`;30 43-/** A project's env shape. */31 export const envPath = (project: ProjectName) => `/${project}/env`;32 46-/** A decision's page. */33 export const decisionPath = (project: ProjectName, decision: DecisionId) =>34 `/${project}/decisions/${decision}`;35 50-/** `segment` decoded, or as it came when it does not decode. */36 const decoded = (segment: string) =>37 Result.getOrElse(38 Result.try(() => decodeURIComponent(segment)),39 () => segment40 );41 57-/** A pathname's segments, decoded, the empty ones dropped. */42 export const segmentsOf = (pathname: string) =>43 pathname44 .split("/")45 .filter((segment) => segment !== "")1 unmodified linemodified: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- */1 import type { ErrorComponentProps } from "@tanstack/react-router";2 import { useLocation } from "@tanstack/react-router";3 import { Unplug } from "lucide-react";4 6 unmodified lines11 import { RowSkeleton } from "./skeleton.tsx";12 13 const ROWS = ["first", "second", "third"] as const;14 28-/** Rows that hold a list's place while the platform answers: a row's height, two bars each. */15 export 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 lines30 const reload = () => {31 globalThis.location.reload();32 };33 48-/** 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+ */38 export const UnreachableNotice = () => (39 <div40 className="border-rule-strong flex max-w-[40rem] items-start gap-3 border p-4"41 role="alert"21 unmodified lines63 <UnreachableNotice />64 </PageShell>65 );66 78-/** The page's name as its address gives it: the last step of its trail. */67 const useAddressTitle = () =>68 useLocation({69 select: ({ pathname }) => crumbsFor(pathname).at(-1)?.label ?? "",70 });71 84-/**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- */72 export const PendingPage = () => (73 <PageShell title={useAddressTitle()}>74 <ReadingRows />75 </PageShell>76 );77 95-/**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- */78 export const RouteError = (_props: ErrorComponentProps) => (79 <PageShell title={useAddressTitle()}>80 <UnreachableNotice />81 </PageShell>82 );83 105-/** An address no page serves: the trail up to what exists, and the ways onward. */84 export const NotFoundPage = () => {85 const pathname = useLocation({ select: (location) => location.pathname });86 const project = projectOf(pathname);87 40 unmodified linesmodified: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 */5 import type { Posture } from "@repo/protocol/posture";6 7 import { POSTURE_MARKS } from "./mark-look.ts";8 import { StateBadge } from "./state-badge.tsx";9 13-/** The label's colour: sealed when something is kept sealed, ink when nothing is, muted for a licence that is not open. */10 const wordTone = {11 open: "text-foreground",12 openCore: "text-sealed",13 openOnSchedule: "text-sealed",7 unmodified lines21 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 linesmodified: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- */1 import type { ProjectListing } from "@repo/protocol/domain/front-page";2 import { Array as Arr, Order } from "effect";3 10-/** How many projects the rail and the landing name; the rest are a step away. */4 export const PROJECTS_SHOWN = 8;5 13-/** The most open asks first, then by name. */6 const leading = Order.combine(7 Order.mapInput(8 Order.flip(Order.Number),9 ({ openAsks }: ProjectListing) => openAsks10 ),11 Order.mapInput(Order.String, ({ project }: ProjectListing) => project)12 );13 22-/** The `n` projects that lead: the most open asks first, a tie by name. */14 export 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 */5 import type { Refusal } from "@repo/protocol/refusal";6 import { explain, headline } from "@repo/protocol/render";7 import type { Array } from "effect";8 import { OctagonX, RotateCcw } from "lucide-react";9 10 import { CommandLine } from "./command.tsx";11 15-/** One refusal's lines, with its tag set apart on the first. */12 const Lines = ({ refusal }: { readonly refusal: Refusal }) => {13 const prefix = `${refusal._tag}:`;14 15 return (55 unmodified linesmodified: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- */1 import { Refusal } from "@repo/protocol/refusal";2 import { notFound } from "@tanstack/react-router";3 import { Effect, Schema } from "effect";4 12-/** Refusals as a not-found carries them. */5 export const Refusals = Schema.NonEmptyArray(Refusal);6 15-/** A loader's 404 for `refusal`: a not-found that carries it, encoded, to the page. */7 export 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- */1 import type { AskListing } from "@repo/protocol/domain/ask";2 import type { ClaimState } from "@repo/protocol/domain/claim";3 import { Outcome } from "@repo/protocol/domain/outcome";4 import type { ProjectName } from "@repo/protocol/ids";11 unmodified lines16 import { useSelection } from "./shell/selection.ts";17 import type { SelectionParam } from "./shell/selection.ts";18 import { When } from "./time.tsx";19 43-/** A row's state: its mark, its word, and when (a `When`, or words). */20 export 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 }26 27 export 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 }44 84-/** The shell's width, from which a row selects rather than opens. */45 const SHELL_WIDTH = "(min-width: 70rem)";46 47 /**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 */51 export const wordTone = (mark: StateMark) => {52 if (mark === "refused" || mark === "retry") {53 return STATE_MARKS.refused.tone;1 unmodified line55 56 return mark === "landed" ? STATE_MARKS.landed.tone : "text-foreground";57 };58 102-/** Whether a press on `target` was meant for a link or a control in the row. */59 const onControl = (target: EventTarget) =>60 target instanceof Element &&61 target.closest("a, button, summary, input, select, textarea") !== null;62 107-/** Metadata parted by ` · `, with every empty part left out. */63 export const MetaLine = ({64 parts,65 }: {66 readonly parts: readonly (ReactNode | false | null | undefined)[];10 unmodified lines77 </Fragment>78 ));79 };80 126-/** Code in a row's metadata: an id, a territory, a SHA. */81 export const MetaCode = ({ children }: { readonly children: ReactNode }) => (82 <code className="text-mono font-mono">{children}</code>83 );84 131-/** A territory as a row shows it: nothing for the whole repo. */85 export const territoryPart = (territory: string) =>86 territory === "." || territory === "" ? undefined : (87 <MetaCode>{territory}</MetaCode>88 );89 90 const 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";92 140-/** From the shell's width a row that selects lets a press off its link through to the row. */93 const SELECTS = "shell:after:pointer-events-none";94 143-/** A press on the row, off its link and its controls, selects it from the shell's width. */95 const selectOnPress =96 (id: string, onSelect: ((id: string) => void) | undefined) =>97 (event: MouseEvent<HTMLLIElement>) => {98 if (4 unmodified lines103 onSelect(id);104 }105 };106 156-/** The row's state at its end: the word in its role, over (or beside) its time. */107 const StateEnd = ({108 state,109 stacked,110 }: {43 unmodified lines154 <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 lines168 state === undefined ? null : (169 <StateMarkIcon mark={state.mark} stamp={state.stamp === true} />170 );171 223- // `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 lines212 </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 lines238 </li>239 );240 };241 294-/** Where a group's header sticks: under the toolbar, or under the context bar when the list has none. */242 const 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;246 300-/** A list's group: a sticky header (its name as a link, its facts, its counts), then its rows. */247 export const RowGroup = ({248 children,249 counts,250 facts,1 unmodified line252 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 lines280 <ul className="flex flex-col">{children}</ul>281 </section>282 );283 344-/** A list of rows with no groups. */284 export 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 );298 362-/**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- */299 export const useRowSelection = (300 ids: readonly string[],301 param: SelectionParam302 ) => {2 unmodified lines305 306 return { clear, focused, select, selected };307 };308 376-/** An answer's latest outcome as a row's state: a retryable refusal turns back. */309 export 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 lines318 }),319 WaitingOnParent: (): RowState => ({ mark: "waiting", word: "Waiting" }),320 });321 390-/** Each claim state as a row says it: its mark and its word. */322 export 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>;329 399-/** Who an ask is held for, as its state word. */330 const reserveWords = {331 newcomers: "Held for newcomers",332 people: "Held for people",333 } as const;334 405-/** Where an open ask stands for its reader, as a row's state. */335 const askState = (336 listing: AskListing,337 takeable: boolean | undefined,338 progress: AskProgress | undefined13 unmodified lines352 if (listing.blockedBy.length > 0) {353 return { mark: "waiting", word: "Waiting" };354 }355 427- // 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 line361 ? { mark: "notYet", word: "Not open to you" }362 : { mark: "open", word: "Open to take" };363 };364 438-/**439- * The time an ask row shows: its last push, else its last round, else its440- * opening, so a list scans by recency.441- */365 const askTime = (progress: AskProgress | undefined) =>366 progress?.lastPush?.at ?? progress?.rounds.at(-1)?.at ?? progress?.opened;367 445-/**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- */368 export const AskRow = ({369 listing,370 now,371 onSelect,5 unmodified lines377 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 linesmodified: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- */1 import { Skeleton } from "../../components/ui/skeleton.tsx";2 10-/** A two-line row's place: 64 px, the want's bar over the metadata's. */3 export 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 lines9 <Skeleton className="h-2.5 w-full max-w-[14rem]" />10 </div>11 );12 21-/** The inspector's place: each block's label as it will read, its values as bars. */13 export const FactsSkeleton = ({14 labels,15 }: {16 readonly labels: readonly string[];15 unmodified linesmodified: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- */1 import { Predicate } from "effect";2 import type { ReactNode } from "react";3 4 import type { MarkLook } from "./mark-look.ts";5 import { Mark, STATE_MARKS } from "./marks.tsx";6 import type { StateMark } from "./marks.tsx";7 8 export 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 }17 18 export const StateBadge = ({23 unmodified linesmodified: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 */5 import type { Ask } from "@repo/protocol/domain/ask";6 import type { Choice, Decision } from "@repo/protocol/domain/decision";7 import { Outcome } from "@repo/protocol/domain/outcome";16 unmodified lines24 import type { StateMark } from "./marks.tsx";25 import { askPath, decisionPath } from "./paths.ts";26 import { distanceInWords } from "./time.tsx";27 41-/** Each stage as a cell heads it (`label`) and as a sentence names it (`words`). */28 export 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 lines38 Match.when("human", () => ({ label: "Decider", words: "decider" })),39 Match.exhaustive40 );41 56-/** What a status line is about. */42 export 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 };65 88-/** The role a line is drawn in; `ink` and `muted` are no state's colour. */66 export type StatusTone =67 | "checking"68 | "ink"69 | "landed"9 unmodified lines79 refused: "text-refused",80 waiting: "text-waiting",81 } as const satisfies Record<StatusTone, string>;82 106-/** A status line, read from its subject. */83 interface 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 }91 92 const Code = ({ children }: { readonly children: ReactNode }) => (1 unmodified line94 {children}95 </code>96 );97 124-/** `children` as a link to `to` when the project is known, as plain code when not. */98 const CodeLink = ({99 children,100 to,101 }: {10 unmodified lines112 {children}113 </AppLink>114 );115 143-/** Whose move, in words; nothing when it is no one's. */116 const moveWords = (117 move: Move,118 {119 claimant,10 unmodified lines130 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 );138 168-/** An answer's outcome as a line. */139 const answerReading = ({140 claimant,141 outcome,142 project,116 unmodified lines259 }),260 });261 };262 293-/** Who an ask is held for, when it is held for someone. */263 const heldFor = (ask: Ask): readonly string[] => {264 if (ask.reserve === "newcomers") {265 return [266 ask.mentor === undefined4 unmodified lines271 272 return ask.reserve === "people" ? ["held for people, not agents"] : [];273 };274 306-/** What an ask that waits on others waits for, in its family's terms when the caller counted them. */275 const waitingReading = (ask: Ask, blockers: Family | undefined): Reading => {276 if (blockers !== undefined && blockers.total > 0) {277 const remaining = blockers.total - blockers.landed;278 79 unmodified lines358 tone: "ink",359 };360 }361 394- // 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 lines368 tone: "muted",369 };370 };371 405-/** A decider's choice in the past tense, and whether it took effect. */372 const chosen = {373 accept: { effect: true, word: "Accepted" },374 adopt: { effect: true, word: "Adopted" },375 decline: { effect: false, word: "Declined" },2 unmodified lines378 Choice,379 { readonly effect: boolean; readonly word: string }380 >;381 416-/** Whose move an open decision is: the viewer's, its one decider's, or any of its deciders'. */382 const deciderMove = (decision: Decision, viewerDecides: boolean) => {383 if (viewerDecides) {384 return "your move";385 }100 unmodified lines486 }),487 });488 };489 525-/** The line its subject reads as. */490 export const readStatus: (subject: StatusSubject) => Reading =491 Match.type<StatusSubject>().pipe(492 Match.discriminator("kind")("answer", answerReading),493 Match.discriminator("kind")("ask", askReading),10 unmodified lines504 } as const;505 506 export 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 }513 514 export const StatusLine = ({60 unmodified linesmodified: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 */5 export const themeColors = {6 dark: "#0e1114",7 light: "#f5f8fa",1 unmodified linemodified: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- */1 import { DateTime } from "effect";2 3 const MINUTE = 60_000;4 5 const HOUR = 60 * MINUTE;6 7 const DAY = 24 * HOUR;8 14-/** The largest whole unit in `millis`, as "5 min", "3 h" or "2 d". */9 const span = (millis: number) => {10 if (millis < HOUR) {11 return `${Math.floor(millis / MINUTE)} min`;12 }2 unmodified lines15 ? `${Math.floor(millis / HOUR)} h`16 : `${Math.floor(millis / DAY)} d`;17 };18 25-/** How far `at` is from `now`, in words. */19 export const distanceInWords = (at: DateTime.Utc, now: DateTime.Utc) => {20 const millis = DateTime.toEpochMillis(at) - DateTime.toEpochMillis(now);21 22 if (Math.abs(millis) < MINUTE) {21 unmodified lines