The web client (packages/client) is a single-page interactive fiction reader, workbench, and harness inspector built on Solid 2.0 and UI SDK (@ui-sdk/solid + @ui-sdk/core). It runs identically against the Vite+ dev server (bun --bun vp run dev) and the single-port standalone server (tavern start).
1. Three-Layer Spatial Shell & Page Stack
On desktop viewports (≥ 72rem), shell.tsx organizes the workspace into three spatial planes without unmounting active streams:
| Plane | Modules | Responsibility |
|---|---|---|
| Ground Chrome & Sidebar | shell.tsx, side.tsx, tabs.ts, edge.tsx, fold.ts |
Top strip (card › story multi-tab bar with live/unread dots, Settings, Theme, Language) and a two-layer left sidebar (Shelf across all cards ↔ Workspace for the focused card’s stories, persona, writing switches, and tags). |
| Stage Card | App.tsx, pages.ts |
Central card hosting the Reader permanently at the bottom of the stack while full-stage views (Card Page, Timeline, Inspector, Writing, Readings, Workshop, Settings) push and pop above it—keeping any turn in flight streaming underneath. |
| Overlays & Sheets | dialogs.tsx, readings.tsx, manager.tsx |
Story manager, persona picker, tag manager, delete confirmations, and per-turn Record / Readings sheets. |
- Spring-settled sidebar edge (
edge.tsx,fold.ts): Dragging the Stage Card’s left separator resizes the sidebar within a200–320pxband with rubber-band resistance past bounds, velocity-aware flick-to-fold, and spring settle on release. When folded to zero width, bringing the pointer to the left screen edge floats the sidebar over the stage without shifting prose layout. - Mobile layout (
< 72rem): Collapses the outer canvas so the Stage Card fills the screen; the sidebar becomes a touchDrawerand popups adapt into bottom sheets without duplicating state logic.
2. Reader, Composer & Turn Surfaces
- Non-jumping streaming (
App.tsx): Sending pins the new turn to the top of the viewport above a full-screen runway, trading runway whitespace line-by-line asnarratestreams. Scrolling upward detaches follow mode cleanly without yanking the viewport back. - Zero-auto-send Composer (
composer.tsx,invocation-menu.tsx,ime.ts): Nothing in the interface sends behind the player’s back—optionschips, quicksnippets, and punctuationformatkeys (「」,『』) only populate the input box, with full CJK IME composition protection. Players toggle betweenactandnotechannels (or revise past lines in place), while pressing/or+opens aPopover+ multi-pageCommandpalette searching across snippets, mounted packentries, and unlockedplayer: truecardlore. - Readings, Ledger & Theater (
readings.tsx,record.ts): Theater products arrive through parallelrecordcalls; post-turn deltas condense into a one-line Record pill that opens into a detailed sheet;demand-triggeredtheaterblocks are requested from the turn’s menu; and scalar meters (steps,gauge,scale,value) plusworldtables render on the Readings view.
3. Timeline, Inspector & Workshop
- Timeline (
timeline.tsx): Projects the immutableLogtree across branches—distinguishingswipe,reword,edit, post-recordpassageepoch boundaries, andoverleaves—with instantcheckoutand subtreedrop. - Turn Inspector (
inspector.tsx,inspect.ts): Inspects any node from the harness’s point of view ([/]to walk the path) across two side-by-side panes:- Pipeline pane: Lists only the calls that ran—including
DecisionModelpre-check passes forlookupandcheck—with aligned metric columns (latency,↑input tokens,↓output tokens, and↻/+KV cache reads/writes). Expanding a row offers Result (verdicts, tool steps, and probability bars againstLO/HI/LOOKUPthresholds), Prompt (assembled messages with KV cache breakpoints marked as hairlines whenTAVERN_INSPECT=1/tavern start --inspectis active), and JSON. - Node pane: Displays input channel, untold lore hooks, state deltas against the parent node, and shaped
world/chronicle/theaterproducts.
- Pipeline pane: Lists only the calls that ran—including
- Card Page (
card.tsx): Previews card modules and token budgets, and configuresField.startparameters and dynamic opening notes beforegreet. - Workshop (
workshop.tsx,manuscript.ts): Its own list of the install’s cards with New, and one card open as plain text: always-on setting sections, openings, and single-layer entries read on demand. There is no draft: New is a card on the shelf at once, and edits autosave to the card through the install gate. Anything the editor does not show (rules, conditions, layered entries) is carried through untouched.
4. Solid 2.0 + UI SDK (@ui-sdk) Behavioral Substrate
- Run-once reactivity & root atoms (
atom.ts,bridge.ts): Components execute once with zero virtual-DOM re-renders. Shared state lives in root-owned Solid 2.0 signals and memos behind anAtom/AtomRegistrysurface, paired with incremental per-paragraph Markdown rendering (markdown.ts). - Unified control & gesture primitives (
controls.tsx,edge.tsx):Select(presentation="auto", rendering a positioned list on desktop and a bottom sheet on small touch screens),Switch,Dialog(createDialogControllerfor modals, prompts, and full-page sheets),AlertDialog(createConfirmfor destructive actions),Drawer,Popover,Menu, andCommand.- Custom controls not shipped by
@ui-sdk—such as the stage’sEdgeseparator—are authored viadefinePrimitive,createParts,bindDrag,rubberBand,createVelocityTracker, andsolveSpring(@ui-sdk/core/gesture).
- Five-layer CSS cascade (
app.css): Declared in strict priority order—@layer ui-sdk, tokens, components, card, user—so@ui-sdk’s minimal popup positioning rules sit at the bottom, design tokens (tokens.csswithlight-dark()) and component stylesheets override cleanly without!important, and card/reader themes sit on top. - Agent Bridge & headless browser verification (
test/controls.tsx,test/ui.ts,test/imports.ts):- Every interactive control is a named
@ui-sdkpart reachable via@ui-sdk/solid/agent(createAgentsnapshotandact, enforcing confirmation gates on destructiveAlertDialogbuttons). - Running
cd packages/client && vp run verify:uibundlestest/controls.tsxwithout a backend server, drives every control and gesture in headless Chrome, and asserts zero unnamed parts, zero failed interactions, and zero@solidjs/diagnosticswarnings. test/imports.ts(invp run verify) statically walks all value imports reachable frompackages/client/src/to guarantee nonode:*module or server AI-SDK barrel ever enters the browser bundle.
- Every interactive control is a named