kevin-wiki / ui
Purpose
The web viewer. A Next.js (App Router) app that renders the wiki/ markdown
knowledge base as a browsable site, plus the private local /brief decision
surface. Wiki content remains read-only; /brief writes
only to the local Daily Brief event store through its gated API. Tailwind owns
styling; the public wiki is deployed on Vercel.
Mental model & key files
src/app/(wiki)/— the wiki reader (home,wiki/[...slug], packs, search), rendered statically for an anonymous viewer;src/app/unlocked/is its twin for unlocked viewers (see "Static rendering and the twin").src/app/(wiki)/system/— public brain/system projection.src/app/(wiki)/brief/— global-password-gated local Daily Brief client.src/app/api/—og(per-article OpenGraph images: title, subtitle and byline, with no eyebrow and no tagline, like home's card),search,assets,unlock, publicsystem, public OKF v0.2, privatebrief, and bearer-authenticated proposal-memory routes.src/components/atlas/SKILL.md— the Atlas map and the /graph cloud.src/components/,src/lib/,src/contexts/— shared UI, helpers, providers.src/lib/privacy-policy.json+src/lib/gating.ts— shared fail-closed public/private policy for runtime and bundling.scripts/— build-time content bundling + citation checks (seeui/scripts/SKILL.md).
Patterns to follow / invariants
- Tailwind +
cn()first; raw CSS only inglobals.css. No co-located CSS modules for ordinary UI (seewiki/style/css-ui-enforcement.md). - Follow
wiki/style/react.md+wiki/style/typescript.md; checkvercel-react-best-practicesfor data fetching / perf. - Package manager is pnpm here (the repo root is npm/tsx). Run from
ui/. - Keep the full-text search index out of server-rendered page props. Public
search loads the privacy-filtered
/search-index.jsonstatic asset; unlocked search uses the bounded/api/search?view=pageresponse.
Static rendering and the twin
- Every public page is static. The
(wiki)layout and pages read no cookie and render forANONYMOUS_ACCESS(src/lib/auth.ts): home,/packs(the gate), andwiki/[...slug], which prerenders every public page, every folder that holds one and every public README's redirect (getPublicWikiPaths). WithdynamicParams = false, every other path, a private slug included, is Next's one static 404: the same status, headers and body for every path, and no page code runs for it.packs/[pack]prerenders nothing and setsdynamicParams = falsetoo, so every anonymous/packs/<name>is that 404 (its unlock control opens the gate). wiki/[...slug]/page.tsxis a dispatcher: a page rendersArticleView(src/components/article-view.tsx), a category or folder with a page the viewer can open rendersCategoryIndex(src/components/category-index.tsx),/wiki/<folder>/README308s to the folder when the viewer can open that README, and everything else, a private slug included, is the one 404.CategoryIndexrenders the README as its lead throughArticleBody(the body and its enhancers: anchors, diagrams, charts, tweets, image guard), as articles and packs do, and leaves the Deprecated skills folder out of the skills index. It prints its own h1 only when the README's HTML does not open with one (HTML comments before it do not count;src/lib/readme-title.ts,scripts/test-readme-title.ts).- The twin,
src/app/unlocked/**, renders the same modules with the viewer's access (getGateAccess()). Its files only call the(wiki)exports (WikiLayoutView,HomeView,renderWikiPath,wikiPathMetadata,PacksView,PackDetailView,packMetadata) or re-export a page; they hold no markup, so a redesign of the(wiki)modules reaches unlocked viewers. Every twin response is dynamic and sends Cache-Controlprivate, no-cache, no-store; a direct request for/unlocked/**without a valid cookie gets the gate. - Why not Cache Components: it needs
cacheComponents: trueinnext.config.tsand changes route segment config across the app; the twin keeps every static page free of request data instead. /brief,/system/sessionsand/privacysit under the(wiki)layout and keep their own gates, so they show the shell's header.- On a case-insensitive disk, as on a Mac, a page and a folder whose paths
differ only in case (the SOUL page and the soul folder, and three more pairs)
prerender to one file, so a local
next startserves one of each pair for both URLs, and a localvercel build(or a--prebuiltdeploy from it) fails with EEXIST; run those on a case-sensitive volume. Vercel's own builds serve both.scripts/test-case-paths.tsnames the pairs in the prebuild and fails undervercel buildon such a disk. - Static pages do not know about an unlock in another tab.
PasswordGate(after an unlock) andWikiShell's lock post onBroadcastChannel("wiki-gate")(src/lib/gate-channel.ts), andWikiShellcallsrouter.refresh()when another tab posts, which reaches the twin. - Shell links (the mark, the index, the graph, breadcrumbs) and home's lists
set
prefetch={false}: a static target's prefetch carries its whole payload, on every page that shows the link. - Nothing fades in on load or on open: text painted at opacity 0 is no largest-paint candidate, so LCP waited for the next full repaint, and nothing moves unless the reader moved it. The one motion is the map's pan ("Shell, articles, gates and 404").
Proxy matcher
src/proxy.tsruns only where a job applies. Plain entries always run it:/briefand/system/sessions(global unlock or/locked) and the twin path. Every public entry (/,/wiki/...,/search,/packs,/packs/...,/api/search) carrieshas: [{ type: "cookie", key }], once for"wiki_unlock"(GATE_COOKIE) and once for"wiki_unlock_slugs"(GATE_SLUGS_COOKIE), so an anonymous view of a static page invokes no function. Matcher values must be literal constants; keep the plain entries first (test-route-surfacesreads them).- With a valid cookie the proxy rewrites to the twin, and
/api/searchto/api/search/private(the same handler,private, no-store); an invalid cookie falls through to the static page.
Category JSON
- The anonymous shell sends the index's category rows only (
category,label,count), fromgetPublicNav()in(wiki)/layout.tsx; the index loads a category's pages when the reader opens it, and the open page's category when the index opens (warmed on pointer or focus on Index). - Each category's pages are static JSON at
/nav/<version>/<category>.json(src/app/nav/[version]/[file]/route.ts, URL frompublicNavUrlinsrc/lib/public-nav-url.ts; data fromgetPublicNav()insrc/lib/wiki-navigation.ts).versionhashes the whole public index, so a URL never changes content. Fields:category,count,label,pages(eachprivate,slug,title) andfolders(eachpath,label,count,pages,children), sorted by label and title. Public pages only; the twin inlines a viewer's private entries. test-public-countsholds home's counts equal to the shell's rows and the sums of the JSON;test-public-independenceprojects it asnav.
Tokens
globals.css"Atlas tokens":--signal(text-signal,bg-signal; #b84019 on paper, #f06a3a on dark),focus-ring(2px solid ink, offset 2px),--measure30em (max-w-measure; about 64 characters at 17px, as 64ch measured 88 in PP Mori; 510px, whichmarkdown.ts'sTEXT_COLUMN_MAXrepeats),--motion-duration240ms with--motion-ease(duration-pan,ease-pan), type stepstext-meta13,text-ui15,text-body17 (1.6 line height),text-lead21,text-h327,text-h234,text-h142 andtext-display64 (1.15 to 1.25), andpage-grid(12 fluid columns, 24px gutters, 16px side gutters on mobile).src/lib/dates.tsformatDateprints a frontmatter date as YYYY-MM-DD, with no timezone conversion.node scripts/check-ui-tokens.mjsreports text below 13px (arbitrary px, rem or em sizes too), uppercase with tracking, negative tracking on headings and arbitrary tracking in.tsxundersrc;--failexits 1.- Theme: the root layout's
<head>runs a plain inline script (notnext/script, which runs after parsing) that sets.darkor.lighton<html>from the stored choice or the system preference before the body paints;theme-context.tsxkeeps both classes in step. Until a class is set,globals.cssgives:root:not(.light)the dark tokens underprefers-color-scheme: dark; keep that block in step with.dark.
Fonts
- PP Mori is the site font: woff2 subsets of the OTFs in
public/fonts/pp-mori(pyftsubset, no outline changed; a glyph-specimen pixel diff showed 0 changed glyphs), one family,ppMori, from four faces: a core file per weight (Latin, Latin-1, common punctuation, every character a public page title uses) and an extended file per weight that the browser fetches only for a page that uses one of its characters. The extended files go throughnext/font/local(_fonts/pp-mori.ts), never preloaded. - One URL per face:
src/app/_fonts/site-faces.tsdeclares the two PP Mori core files (with the metric-matched Arial fallback next/font computed for 400) and Geist Mono (OFL;public/fonts/site/OFL.txt) once, for every route, as content-hashed files inpublic/fonts/site; the root layout inlines the rules andglobals.csssets--font-pp-moriand--font-geist-mono.site-urls.tsholds the URLs alone, so client code that needs one does not ship the rules.vercel.jsonserves the folder as immutable (its other/fontsrule excludessite/). Geist Mono is two variable files:geist-mono-core, cut fromGeistMono[wght].ttfin the vercel/geist-font v1.7.2 release (Latin, Latin-1, common punctuation, arrows, every box-drawing and block character, and the geometric shapes and math signs code diagrams use), and Google Fonts' 1.701 latin-ext file. One file holds a code diagram's lines and letters, so they never come from different faces, and itsunicode-rangelists exactly the code points it holds. - To add characters to
geist-mono-core, edit the code-point list (src/app/_fonts/geist-mono-core.unicodes.txt, oneU+XXXXper line) and cut the file again from the same release with fontTools'pyftsubset, default options:pyftsubset 'GeistMono[wght].ttf' --unicodes-file=<list> --flavor=woff2 --output-file=<out>(on the current list it reproduces the current file byte for byte). Rename the file to the first 10 hex of its sha256, put that name on the list's first line, setGEIST_MONO_CORE_URLand setGEIST_MONO_CORE_RANGEto the list's range. The postbuild font check fails until the file's hash, the list and the range agree. - PP Mori 400 and 600 are preloaded only by the server render, through one
client component,
src/app/_fonts/font-preload.tsx:<FontPreload weight={400} />in the root layout's<head>(every route, the 404, the twin and dynamic routes included) and<FontPreload weight={600} />in the wiki shell, on/lockedand in the 404, outside any Suspense boundary and above everyawait: the shell (WikiLayoutView) renders it before the async view that reads the viewer's access and the index's data. It callsreact-dom'spreload()only whentypeof window === "undefined"and renders nothing, so React's server renderer emits each preload once and the client never inserts one, on a navigation or on Next's client-rendered error page. A prerendered page carries them in its head's font slot, ahead of the stylesheets and the logo's image preload. A page rendered per request (the twin, its 404 body included, and/search) carries those that render in React's first pass of work in the response'sLinkheader, which the browser reads before the HTML; React writes that header once, after the first pass. A preload that renders later goes to the head's font slot, and on the error page, whose head is empty, nowhere, so the 600 stays above everyawait, where a fresh instance's first request renders it in the first pass too. The logo's image preload renders in the shell after its data, so it reaches the header on a warm instance only. WebKit does not share a font preload added after the load event with the@font-faceload of the same file, so a preload the client adds downloads the face twice; and a<link>rendered in the head lands behind the logo's preload, which delays first paint on a slow connection. A navigation from a page without the 600 preload (/graph, say) into the shell loads the 600 through@font-facealone. A client component's server render never reaches an RSC payload; a<link>orpreload()in a server component becomes a font hint in every payload that carries it, and the root not-found page travels in every route's payload. Geist Mono is never preloaded. Next's own font preloads never reached the prerendered 404 or a dynamic route, and next/font names a preloaded file differently from the same file without a preload, so declaring a face there once per route group shipped it as two files. After changing a PP Mori file, rename it to its new hash and update its constant insite-urls.ts. - Accepted: Safari Private Browsing downloads the 600 a second time when a
soft navigation from
/graphor/dev/atlasinto the shell is followed by a new document: a reload, a typed URL or/graph's plain link list, prerendered or rendered per request (the twin, its 404 body included, through theLinkheader). Its memory cache does not reuse a no-cors font fetch for a cors preload. Do not preload the 600 on those pages to avoid it. - The font rules live in
scripts/lib/font-heads.ts: no payload carries a font hint and no RSC response a fontLinkheader; every font preload is in theLinkheader or<head>, before the first stylesheet and image preload, for a PP Mori core file on the page's own origin (the URL resolved against the page), once, in React's shape:rel="preload",as="font",type="font/woff2", an anonymouscrossorigin("",anonymousor any value butuse-credentials, in any case, as a browser reads it) and anhref, nothing else and none twice; the 400 on every page with the root layout; the 600 on the shell,/lockedand the 404 and nowhere else; no font preload on a page without the root layout, but for Next's error page rendered for the request (the document whose<html>hasid="__next_error__"; a build with a deployment id, as on Vercel, putsdata-dpl-idbefore it), which carries the 400 and the 600 in itsLinkheader and none in its HTML. A prerendered error shell has none wherever it is served from: Vercel serves/dev/atlas's 404 and a README's 308 from the edge with noLinkheader, and a redirect,x-nextjs-prerenderor anx-vercel-cacheof PRERENDER, HIT or STALE marks such a response. A document is UTF-8 with no byte order mark, and a served one is labeledtext/html; charset=utf-8. ALinkheader is in React's shape, which every engine splits alike:<url>entries with; name=valueparameters joined by,, names in lower case, each value a token or a quoted string with no quote, comma, semicolon, backslash,<or>(React percent-escapes the first three), and each URL with no<,>, quote, apostrophe or backslash. The reader errs toward red: it walks the head as every engine reads it (comments, the doctype, and thehtml,head,base,link,meta,script,styleandtitlestart tags, with script, style and title text skipped), and the walk ends at</head>,</body>,</html>or</br>, at text, at any other start tag, or at a script that holds<!--. Past that point browsers disagree (Chromium's preload scanner fetches a<link>inside<svg>or<math>), so every font preload after it, in foreign content, a comment, raw text or an attribute value included, is a finding. Past the walk it reads each tag from where the last one ended, so it stays linear in a page's length, and a<link,<baseor<htmlinside such a tag or still open at the page's end is a finding. So are a<base>, an<html>after the head, an attribute in a font preload or<html>with a named reference other thanamp,apos,gt,ltandquot, and a repeated attribute in a font preload. Like HTML's tokenizer, the reader lowers attribute names, turns U+0000 into U+FFFD and reads tab, line feed, form feed, carriage return and space as whitespace;asandtypemust befontandfont/woff2in lower case (WebKit reads them case-sensitively). A finding names a site font file by its file name and any other by its href's length and an 8-character hash, never its text, and the start tag that ended the head by name only from a fixed list (body,noscript,templateand the like), else as another start tag.pnpm test:font-heads(prebuild) holds the reader to hand-written documents, each red when any engine may fetch a font against the rules, and to malformed megabyte pages and long runs of whitespace in a Link header within a time bound.pnpm test:font-output(postbuild) holds every prerendered page to the rules, read from its bytes, checks the font files' hashes, that the Geist Mono file's cmap, list and range agree, and that no client chunk names a PP Mori core file or theppMori Fallbackface. The crawl mode oftest-public-build-outputholds every served answer a browser may render as a document to them, from its bytes andContent-Type(its document test errs red; scripts/SKILL.md), and the pages rendered per request for unlocked viewers (the twin, its 404 body included), so run it with the server'sWIKI_GATE_SECRET(scripts/SKILL.md). Without a local build it skips the 400 and 600 placement on crawled pages alone. - Geist Mono is never preloaded and uses
font-display: optionalwith the system monospace as its fallback: it never swaps in after first paint, so code never rewraps; a reader's first view of code may use the system monospace, and later views use Geist Mono from the cache. - The font switcher exists only in development: the shell loads it with
next/dynamic, and it injectspublic/fonts/switcher.css. Production never restores a switcher font..vercelignoreuploads onlypublic/fonts/siteand keepsswitcher.css, the switcher's font folders and the PP Mori OTFs out; check withgit -c core.excludesFile=.vercelignore check-ignore --no-index.
Diagrams and tweets
- Every public Mermaid diagram is drawn ahead of the build for both themes:
pnpm measure:diagrams(headless agent-browser, the site's fonts andsrc/components/article/mermaid-theme.ts) writessrc/generated/diagrams/<diagramKey>.light.svgand.dark.svgat natural size, andsrc/lib/diagram-sizes.json.markdown.tsinlines the pair (.mermaid-lightand.mermaid-dark, one shown per theme), so the page loads no mermaid. A diagram with no drawing (a private page's, in the twin, or one not drawn yet) keepsdata-source, reserves its measured height and draws on the client (mermaid-renderer.tsx, near the viewport). A diagram wider than the 510px column (.mermaid-wide, its natural width in--diagram-w) breaks out at lg over the two empty grid columns left of the text (the margin column holds the crop and contents) and shrinks to fit down to three quarters of its size, its labels to 12px. Past that, and below lg at natural size, it scrolls sideways with a visible scrollbar, a fade at its right edge and a "Scroll →" hint while more of it lies to the right. In print every diagram prints whole, in its light variant at its own width or the page's, with no fade or hint. After adding or editing a public diagram, runpnpm measure:diagrams. The folder is read at run time; where a deployment's function lacks it, diagrams fall back to the client. - A
::tweetis a one-line citation,@handle date, a native<details>that opens into the react-tweet card (markdown.ts,tweet-embeds.tsx). It takes its handle and date from the page's[Source: X/@handle, date](url)link to the same post, in the directive's block or after it (one before it cites an earlier claim and stays), and that link goes, so the post is cited once: the punctuation it leaves closes up, and a list item or list it empties goes; a link alone in a table cell stays. The citation sits just before the block that held the link, its handle set in ink with the links' underline. Opened, the card renders after the slot's "Open on X" link, which hides once the card draws and stays when it cannot load. It is built from the Markdown the viewer's mask produced. react-tweet and its stylesheet load only when a reader opens a citation (components/article/tweet-card.tsx). - An opened card's slot reserves its measured height (
src/lib/tweet-sizes.json, keyed by tweet id: the card at 550px, at a 430px screen and at a 360px screen), in three bands: under 440px the taller phone height, 440 to 639px the taller of the 430px and 550px heights, then the 550px height. After adding tweets to a public page, runpnpm measure:tweets --base <a running site> --missing. - The prebuild's
pnpm check:embed-sizeswarns about any public diagram with no drawing or no height and any public tweet with no size (--failexits 1), and fails on any key in those files, a drawing's file name included, that is no current public diagram or tweet.scripts/lib/public-embeds.tsreads diagrams from each exact public page slug's masked Markdown and tweets from its citations, never a folder path, which a case-insensitive disk could read as a private page's file.
Cache headers
vercel.jsongives/wiki-assets/*a day of browser cache with stale-while-revalidate and a year ofVercel-CDN-Cache-Control; their names are not content-hashed, so noimmutable./fonts/site/*is immutable (Fonts). Vercel purges its CDN on each deploy.next startignoresvercel.json. Imported images (the logo, category art) and/nav/**carry hashed or versioned URLs./fonts/site/*(vercel.json) and/atlas/*(next.config.ts) are immutable for a year: each name there is its file's content hash. Vercel applies header rules to every status, so a 404 under either path carries that header too. Accepted: a hashed name that answers 404 is one no page links to.- The graph's data file (
public/atlas/graph.<hash>.bin, 111,942 B) reaches browsers as brotli, 55,910 B on the wire, more than Vercel's gzip copy (50,434 B).
Retired routes
/embeds,/wiki/assetsand/auditwere retired (Decision 5, 2026-11-11); their code is in~/repos/_retired/ui-inventory-pages-20261104/. The bookmark images inpublic/wiki-assets,/api/assets/[...path]andwiki/meta/cursor-audit-data.jsonstay. Crawl mode asserts the three paths answer 404.- The
/meportfolio was retired on 2026-11-17: Kevin's own site, www.kevinliu.studio, holds his portfolio. Its code, images, CSS and the dialkit panel are in~/repos/_retired/ui-me-portfolio-20261117/.next.config.ts308s/meand/me/*to the site, and its eight font families moved toswitcher.cssfor the development switcher. Crawl mode asserts the redirect, and that the portfolio's old image URLs answer exactly like a missing image.
Shell, articles, gates and 404
- The shell (
(wiki)/layout.tsx,wiki-shell.tsx) is one thin header and a main landmark. The header (components/shell/site-header.tsx) holds the mark and "Kevin Liu's Wiki", the Cmd+K search, one theme control and Index, and no per-page state, so a client navigation never changes its DOM. A skip link to#contentis the first focusable element./lockedand the 404 render the same header without Index, so of the four gates only /packs, inside the shell, has Index; /locked, /brief and /system/sessions do not (accepted, 2026-11-18). Every focusable control uses thefocus-ringtoken. The ⌘K hint is set in the sans by name (font-sans; a kbd defaults to mono, a font the gate pages otherwise never load). In print the header keeps only the mark and title. - Cmd+K (
command-palette.tsx) is a native modal dialog: typeahead through/api/search, each hit linking tohit.href ?? /wiki/<slug>, and Index, theme, Open graph (/graph?focus=<slug>on an article), Ask Wikibot, the page's Markdown (copy, download, share; only on an article, which names its slug indata-markdown, fetched fresh per command so a lock never serves the unlocked text) and Lock for an unlocked viewer. Cmd+K closes an open dialog throughclose(), so focus returns to the control that opened it. The palette and Index load apart from the header (idle after load, or at the first approach or press; the Index only where the header has one) and are kept in a module store once loaded, so an open renders them directly and never suspends: a lazy component's first open waits out React's 300ms reveal throttle. Keys always go where focus is: nothing captures them, and the palette opens empty. A dialog asked for before its code arrives opens late only if focus is still exactly where it was, outside any field, and the reader did nothing in between: any key but a lone modifier or Cmd+K, input of any kind (typed, pasted, filled, dictated, composed), a submit, a click, a mouse press, a focus move, Back or Forward or a new page drops it, and so does a failed load. A touch that only scrolls drops nothing; a tap does. In a field, Cmd+K and Ctrl+K are the field's (Ctrl+K deletes to the line's end on a Mac), and nothing asked for from a field opens late, so a gate password never reaches search. Escape or a second Cmd+K cancels. Search is a link to /search that a hydrated page turns into the palette, so a press before hydration still navigates. The search field's row rule turns to a 2px ink line while the field has focus, inside the dialog's edge.SearchBarstays the inline field home and /search render. - Index (
site-index.tsx) is an off-canvas native dialog: reader categories, then the agent categories in one collapsed "Agent system" group, labels in sentence case at 15px with no counts, and "Packs" after "Agent system" for an unlocked viewer;skills/deprecatedis hidden. The open page's category opens with it, and the current page is marked in the signal color. A category whose list fails to load shows a link to its page, and retries only when the reader opens it again. Wikibot opens from the palette; the drawer loads on first use. - A child of
mainwithdata-bleed(an article, the 404) lays itself out onpage-grid; every other page sits in one centred column (PAGE_COLUMN). A wide surface's route wraps it inWideColumn(data-wide, from the layouts of /packs, /brief and /system, and in the twin's pack pages around a found pack only, so its missing pack's 404 sits straight inmainlike every 404), which takes the wider column; the route says so because the twin's server render sees the rewritten path. - An article (
article-view.tsx) sets its own#heading first at 42px (the heading is split from the body HTML; a page without one shows its title), then one 13px Geist Mono meta line (Breadcrumbs, the updated date), then the body at 17px/1.6 in full ink at a 30em measure (about 64 characters). On desktop the margin column holds the page's map crop at 240px, linking to/graph?focus=<slug>, and a plain contents list, read from the body's headings on the client (the build's privacy scan counts in-site link text as a page title, and a heading may name a page in prose); on a phone the crop follows the body. Related pages, backlinks and the tags as plain links end the page; the backlinks list every page that links here under a heading that counts them, and Related pages leaves those out. In print the article is one column at the page's width in light colors, its parts in order with the crop after the body and no contents list, and code wraps; the root's scheme and background follow the light tokens too, over the theme script's inline scheme, so the paper's margins print light with background graphics on. A project page shows its artifact screenshots as one full-bleed strip of square-cornered tiles under its title and their sites on one mono line. - A code block, table or diagram wider than the column scrolls sideways; once
hydrated, one that overflows gets a tab stop and the group name "Code",
"Table" or "Diagram" (
components/article/scroll-regions.tsx), and one that fits gets none, except a block with focus, which keeps its stop until it blurs. One ResizeObserver re-checks a block when its width changes (a resize, a rotation), and a MutationObserver when the content changes. - A click on a body link to a wiki page goes through the client router
(
components/article/body-links.tsx), so the shell stays mounted and the map pans; modified clicks and in-page links keep the browser's behaviour. - Hovering or focusing a wikilink lights its target's dot over the crop in
the same frame (
atlas-crop-frame.tsx, from points the server passes for the linked pages near the crop). - The one motion: the crop sits in
<ViewTransition name="atlas">withonShareandonUpdate. On a navigation between pages with a map, the departing map hands over its point, and the new map's view-transition group starts offset by the step from the old address to the new one, capped at 48px, and settles in 240ms, transform only. It plays only when the crop is on screen at the click (at 390px it sits below the body, so it never does): panning a map nobody can see is pointless. Any key, pointer press or wheel finishes it; reduced motion skips it.globals.cssturns off the browser's own animations foratlasandroot, so nothing else animates. Name one map per pageatlas; passtransition={false}to any other. - The gate (
password-gate.tsx) owns its layout: "Private page", a labelled Password field and an ink Unlock button; a reason shows only after a failed attempt. It submits through a form action, so before hydration React keeps the form from submitting natively and replays the submit once hydrated; the field is uncontrolled, so a password typed early stays in it. One attempt runs at a time: once hydrated, a second Enter or click does nothing while one runs (the button isaria-disabled), and of several submits made before hydration only the first is replayed as an attempt. React resets the form after each attempt to the action state'sretry, read from the field as the attempt returns: a network failure or a 5xx keeps what the field holds, and a wrong password (401) clears it unless the reader typed something new while the attempt ran. Each failure renders a newrole="alert"node, keyed by a count, so a screen reader announces every one; an Enter on the field a wrong password left empty keeps that reason and announces nothing new. /packs, /locked (which the proxy serves for /brief and /system/sessions) and the gate branches render it with no wrapper. The 404's Unlock is a native<details>around the same form, so it opens and takes a password before the page hydrates; the slug is read from the address at each attempt, and opening it moves focus to the field once hydrated. - The 404 (
not-found.tsx,components/shell/not-found-body.tsx) is the header, the whole map, "No page has this address.", the Unlock control and up to three nearest pages, found on the client from the address. The root 404 travels in every route's payload, so its map is a client component (not-found-map.tsx): other pages carry only its URL and frame, and its markup and image preload come from the 404's own server render, as FontPreload's do. In the twin, rendered per request, a notFound() reaches Next's client-rendered error page (an empty head: no theme, no title), sorenderWikiPathtakes the answer for a path the viewer cannot open: the static route keeps Next's 404, and the twin renders the 404's body in the viewer's shell, missing and private alike, with status 200 and robots noindex, nofollow (the response is also private and no-store); the twin's pack page does the same for a missing pack, for a viewer with everything unlocked (one with a page unlocked gets the password gate for every pack name). The served crawl holds each view to its status and to carrying this body or not, found by its heading,NOT_FOUND_SENTENCE(scripts/SKILL.md). - Media sizes (pending Lane 5: nothing writes the file yet, so images ship
without width and height until it lands):
bundle-wiki.mjswrites.content/media-dimensions.json,{ "/wiki-assets/<path>": { "width": <int>, "height": <int> } }, public media only.src/lib/media-dimensions.tsreads it once (node:fs; an empty map when it is missing) andmarkdown.tsgives each image it lists width and height, plussizes,decoding="async"and, below the first screen,loading="lazy". A failed image keeps its box (image-guard.tsx).
Common tasks → first action
- Dev server →
pnpm dev(from repo root:npm run dev). - Build →
npm run build(installs ui deps frozen, then builds). - Add a page → App Router segment under
src/app/, reusesrc/components/.
Gotchas
- The app reads bundled wiki content — re-run the bundler (
ui/scripts) after wiki changes that the viewer must reflect. scripts/export-okf.mjsowns the privacy-filtered.content/okfprojection;/api/okfonly serves that generated tree and never reads canonical private pages directly.- Never add a parallel privacy list. Runtime and
bundle-wiki.mjsmust read the shared privacy manifest, and protected slugs cannot be force-public through frontmatter. - Never expose
/api/briefwithout checking the global gate session. The local PGlite ledger is authoritative for the first Daily Brief slice and must not be serialized into public pages or generated assets. /api/memoryis a separate machine credential boundary: derive authority on the server, require idempotency and provenance, enforceKEVIN_WIKI_MEMORY_SOURCE_SCOPES, deny public writes unless explicitly enabled, and require a durable ledger path in production. It stores proposals, not canonical wiki truth.- This is a separate pnpm workspace from the tsx scripts at the repo root.