# Surfaces: component map and views The map of where each surface's code lives and what each view is for. Moved here from `CLAUDE.md` when that file became a pointer to `AGENTS.md`; the rules these surfaces follow are in `AGENTS.md`. When a component or route moves, update this file in the same change. ## Component map ``` src/ ├── app/ → Pages + API routes (thin, delegate to queries/components) ├── components/ │ ├── ui/ → Shared primitives (Card, Modal, Drawer, Field, PageLayout) │ ├── public/ → The signed-out site. PublicSurface = the shell every │ │ public and auth page renders in: a skip link, the sticky │ │ header (brand, PublicNav, PublicHeaderActions), the page, │ │ PublicFooter (four groups). PublicNav = the Product menu │ │ (opens on a press, never on hover) and, below 1120px, the │ │ menu button and its full-screen drawer (focus enters, │ │ Tab stays inside, closing hands focus back). │ │ HeroComposer = the homepage's ONE action: the shared │ │ composer (never a second message box); what a signed-out │ │ visitor says is kept in the tab (lib/first-words), shown │ │ back on sign-up (auth/FirstWordsNote) and handed to the │ │ new-project form at the end of onboarding or sign-in. │ │ Its microphone is the browser's own recogniser │ │ (composer/voice.ts VISITOR_VOICE): the server leg needs │ │ a session. LoopFigure = the three drawn figures on the │ │ homepage's steps, in tokens, hidden from assistive tech. │ │ ProblemsSection = three rows on the homepage, all of │ │ them on /why. One label per destination: sign-up is │ │ "Start a project" wherever it is a button or a row link. │ ├── shell/ → AppShell, Sidebar, AppTopBar + AccountMenu, MobileNav, │ │ AskLokiButton → /loki. │ │ The sidebar NAVIGATES; the account menu acts on the │ │ ACCOUNT. Nothing appears in both — that split is what │ │ stopped the sidebar footer becoming a second settings │ │ page. Sign out, Settings, appearance and the private-zone │ │ lock live in AccountMenu (top bar, every viewport). │ │ Sections are SSOT in config/navigation.ts: THREE WORDS │ │ bare at the top — Loki (the default screen, say it) · │ │ Home (what now) · Projects (what am I building) — then │ │ folded groups that each say their question (Waiting │ │ for you · Your day · Other ways to talk · Across your │ │ projects · Under the hood) + PIN-gated Private; every line says what it is │ │ for on hover. They were Build / Loki / To review / The │ │ fleet, by kind of thing, until 2026-11-01 (AGENTS.md, │ │ "Why Loki exists"). The phone's bottom bar is the bare │ │ three + More (the folded groups as a sheet). │ ├── control/ → ControlPanel = HOME (/control, labelled "Home" since │ │ 2026-10-19), ProjectCard, ProjectProfile. │ │ There is no ProjectTile. HomeComposer = the top: what to │ │ build + a project chip, sent via /api/inject — the one │ │ place work starts (no "Start something" card). │ │ Under it, three sections of ListRows answer, in order: │ │ "Needs you" (AttentionBar + ControlInbox + the hero, │ │ heading hidden when all are quiet), "Being built" │ │ (ControlNow: one row per job, live step from the │ │ runner's beat via lib/run-step, opening the live │ │ session) and "Done" (ControlDone). ControlFoot = two │ │ rows: builder (opens settings) + New project. │ │ ControlFleetStatus = the hero, shown ONLY for alarms the │ │ rows do not already name: ONE question, one button. │ │ ControlInbox = one collapsed queue for every small task │ │ (feedback triage + widget coverage) — add a group, never a │ │ new full-width strip. ControlSettingsSheet = autopilot, │ │ refresh, builder detail (settings, not state). │ │ See docs/development/responsive-design.md. │ ├── composer/ → Composer — THE composer (text, attach, voice, model, │ │ Send/Stop, optional modes). Loki chat (loki/Composer → │ │ LokiComposer), the terminal's Loki rail + Control's quick send │ │ (terminal/TerminalComposer) and the session box │ │ (terminal/SessionComposer) all render it. Never add a second message box — add a prop. │ ├── loki/ → LokiWorkspace, Thread, LokiComposer (Composer.tsx), ThreadRail (conversation list) (chat assistant) │ ├── terminal/ → TerminalSurface (the ONE shell: tab strip + session bar + │ │ session + session box), TerminalTabStrip, TerminalModeBar, │ │ TerminalComposer, ShellWorkspace (server-owned bash PTYs, │ │ local/sandbox only), TerminalView (the one xterm), │ │ terminal-transport (substrate seam). │ │ SessionComposer = THE box for the agent in a session, │ │ in the terminal view AND the conversation view, at │ │ every width: microphone, screenshots, prompt library │ │ ("/"), "What's going on?" + held-still next steps above │ │ it. It picks the path: a live session is typed into │ │ (bracketed paste + Enter), a screenshot goes via │ │ chat-send, nothing running → tab-inject (starts/queues). │ │ There is no Type / Prompt / Voice switch — never add one. │ │ The box's row is + · model · mic · send, nothing else. │ │ "+" (or "/") opens SessionPicker, a bottom SHEET (photo │ │ or screenshot, Keys on a phone, agent commands, Loki's │ │ records, the prompt library); chatkit's paperclip is │ │ hidden there but mounted — "Photo or screenshot" presses │ │ it, so paste and Camera/Photos/Files stay chatkit's. In │ │ the conversation view next steps are reply rows under │ │ the answer (ReplySteps → the box's sendRequest), never │ │ chips over the box. A panel pinned above the box ran off the │ │ screen once its search raised the keyboard. Nothing in │ │ it takes the keyboard on a touch screen. The agent │ │ cannot read Loki's database, so │ │ Loki's records reach it only as a VISIBLE file on the box │ │ (LokiFiles; feedback via /api/feedback/export, fenced as │ │ untrusted) — a library prompt that needs one declares │ │ `attach` and gets it; the box agents' contract │ │ (scripts/hetzner/box-agent-claude.md, re-applied on every │ │ deploy) tells them to ask for it in one line. SessionInfo │ │ (the model chip, in BOTH views: TerminalSessionInfo │ │ reads the log itself in the terminal view, and the box's │ │ row is identical in both) names the model, effort and mode │ │ READ from the session log, in words, and changes them │ │ in place: each row lists its choices and a tap sends │ │ the agent's own command with the choice named │ │ (`/model sonnet`, `/effort high`). Never type a bare │ │ `/model` from a sheet: the picker opens in the terminal │ │ behind it and nothing visible happens (2026-10-18). │ │ Models are FAMILIES by Claude Code's own aliases │ │ (fable/opus/sonnet/haiku, config/agent-commands.ts), │ │ never versions; the row settles on Claude Code's own │ │ "Set model to …" (a `setting` transcript item) │ │ or shows its refusal in its words. │ │ Modes are SSOT in config/terminal-modes.ts; never add a │ │ second terminal shell — add a transport. │ │ TerminalActions = what the screen needs TYPED (signed │ │ out → /login, a menu → Enter), one click from the │ │ session. The agent CLIs' own commands are SSOT in │ │ config/agent-commands.ts; they are typed as keys, never │ │ injected (inject wraps text in project context). │ │ A press on the read-only screen puts the cursor in the box. │ │ Below md the same state drives phone chrome: │ │ TerminalMobileHeader (a chat app's: back to Control · │ │ the session's name, "Claude · 2 sessions · cloud │ │ builder" under it · ⋮, and the Chat | Terminal pill │ │ centred below; no row of tabs) + TerminalSessionSheet │ │ (the name: sessions, New session, where it runs, agent) │ │ + TerminalMoreSheet (⋮: What's going on?, full screen, │ │ text size, live keystrokes). An open session hides the │ │ app bars below md (useImmersiveChat), so back is the way │ │ out + TerminalMobileDock = TerminalKeyDeck │ │ (the arrows/Esc/Tab/Ctrl a soft keyboard lacks — bytes are │ │ SSOT in config/terminal-keys.ts), opened by the Keys │ │ button on the terminal's corner — never a second text │ │ box. While the phone keyboard is up, the app bar and the │ │ view switch step aside and next steps go to one row │ │ (`fc-keyboard-open` in globals.css). Keys open hides │ │ the next-step row. A command button anywhere TYPES its │ │ words, then Enter as its own keystroke (lib/session- │ │ keystrokes typeCommand) — in one write Claude Code reads │ │ "/model opus\r" as a paste and the CR as a newline. │ │ Three surfaces talk, on purpose, and only three: the │ │ session box (the agent), TerminalLokiRail (Loki about │ │ this session — beside it on a wide screen; on a phone │ │ "What's going on?" opens it as a SHEET showing the │ │ answer and its steps, with no composer and no model │ │ picker, `presentation="sheet"`), and /loki (Loki chat). │ │ Two "models" exist and are named apart: the agent's │ │ (the SessionInfo chip, named by model family) and the one answering │ │ Loki (loki/ModelPicker, "Loki answers with"). │ │ See docs/development/responsive-design.md. │ ├── workbench/ → WorkbenchView (/projects/[id]/workbench): one project on │ │ one screen, ONE box. Two windows of one desk, each a │ │ WorkbenchFrame (a title bar: dot · sentence · one link, │ │ over a body). Left, the site as Loki's browser sees it │ │ (WorkbenchSiteView: the bar is the address and what │ │ Loki is doing there, the body the review worker's frame │ │ — the robot's walk while it reviews; a tap opens the │ │ real site in its own window). Right, the robot: the bar │ │ is the build's state (hooks/use-run-state: the Watch │ │ track's sentence, lib/workbench/state-line) over │ │ TerminalSurface in its quiet shape (`quiet`: no │ │ builder picker, no tab strip, no shell rows, no agent │ │ switch) with its own box. A FOCUS screen: the sidebar, │ │ top bar and project strip leave while it is open │ │ (hooks/use-workbench-focus.ts). WorkbenchStrip = back, title, Open the site, │ │ and ONE "⋯" (the robot in its own window / on the other │ │ screen, the site on the other screen, full screen). │ │ Loki's chat is NOT here (a second box), Watch's card is │ │ NOT here (a second surface). A solo window │ │ (`?pane=session`) is the robot's frame with Close; │ │ WorkbenchNarrow = the phone's │ │ rows. Panes are SSOT in config/workbench.ts; whether the │ │ robot is in this window is the window's own │ │ (lib/workbench/layout.ts) and the project's windows on │ │ one machine talk over a BroadcastChannel │ │ (lib/workbench/bus.ts). The site is a PICTURE, not a │ │ frame: fleet sites forbid framing and sever │ │ window.opener (docs/architecture/workbench.md). │ ├── inspection/ → InspectionWorkspace (/projects/[id]/review), ReviewBrowser, │ │ and RobotBrowser — Loki's browser WATCHED, the one view │ │ the workbench and Review share: the pointer glides to │ │ each press (ReviewFrame.target), the press lights up │ │ while live, the picture fills its box and slides to │ │ keep the press in sight (lib/inspection/robot-view │ │ viewOf). RobotEnding = the warm end of a walk watched. │ ├── activity/ → ActivityView (scope menus, the answer as a sentence, NeedsYouCard │ │ and EventStream as ListRows), ActivityReport (the written │ │ report, the page's one action, in a sheet) │ ├── today/ → Greeting, SummaryBar (the day in one sentence), StickyNoteCard (captures; Loki "add X to my list"), CalendarCard, WeatherCard (one line), CommitmentsCard, HabitsList — sections of rows, no cards │ ├── people/ → PeopleList (ListRows + Show/Sort menus; import/merge in a │ │ sheet, PeopleBookPanel), PersonDetail (the person page) │ ├── crew/ → CrewWorkspace (asks + roster as ListRows), AssignmentSheet, │ │ NewAssignmentButton, AddCrewButton, SharedTaskView. │ │ Work for HUMANS: an assignment is a draft until the │ │ operator hands it over, and the assignee answers through │ │ a share link with no account. Who may move a task is │ │ SSOT in config/crew.ts (OPERATOR_MOVES vs ASSIGNEE_MOVES) │ │ — never widen one to "fix" a stuck row. │ ├── projects/ → ProjectsWorkspace + ProjectRow (list), ProjectWorkspaceView + │ │ ProjectWorkspaceHeader (detail). ProjectGrid/ProjectDetail │ │ survive only as TYPE names (project-grid-row.ts, │ │ project-detail-types.ts) — there are no such components │ ├── goals/ → GoalsList (ListRows, progress ring), GoalDetail (/goals/[id]), │ │ NewGoalButton │ ├── money/ → SubscriptionsList, SubscriptionSheet, NewSubscriptionButton │ ├── habits/ → HabitsList (check off from the row; heatmap + settings in a │ │ sheet), HabitHeatmap, NewHabitButton │ ├── events/ → EventsList (by date: deadline, else the day it happens), │ │ EventSheet, NewEventButton │ ├── prompts/ → PromptLibraryClient (ListRows: yours, then Loki's by group), │ │ RunModal (THE Run sheet: one Run button — a project's │ │ agent for project work, Loki for personal prompts, │ │ lib/prompt-run), ScheduleModal, PromptForm, PromptPreview │ ├── settings/ → SettingsTabs (a list of sections on a phone, a rail from lg), │ │ one component per section (TeamSettings = invite flow) │ └── system/ → JobDetail, SystemStats, FleetDoctorCard, ScheduledJobsCard, │ │ RecentFailuresCard, HetznerCapacityCard (no AutopilotCard) ├── config/ → SSOT for navigation, channels, prompt-library, subscriptions, │ actors (who may be listed vs delegated to) and crew (who │ may move an assignment, and to where) ├── db/ │ ├── schema/ → Drizzle tables (SSOT for all types) │ └── queries/ → Data access functions (one file per domain) ├── hooks/ → useFetch, useCreateMutation, useInlineEdit └── lib/ → constants, dates, tools, utils, api/* wrappers home/ → Agent orchestration library. Pure pieces that tail one append-only JSONL event log: watcher.ts (Bridge — emits worker.idle when ~/.loki/sessions/*.md changes), plus decide/render/state/emit/log/projects/calendar-drain. The worker (zellij consumer) was deleted 2026-09-11. The standalone Brain (home/server.ts, port 3001) and its scripts/home-start.sh launcher were RETIRED in a3f470d. These pieces are a LIBRARY, not a process — three different executors embed them via startWatcher(): • scripts/box-runner.ts — systemd on the box. The DEFAULT. Exists precisely to delete the "laptop must be on" dependency (b62e3aeb, 2026-06-26). • desktop/ (Fleet Runner) — the user's own machine, for work that must touch local files or a local checkout. • scripts/hosted-runner.ts — ephemeral hosted runs. Do NOT describe any one of them as the sole executor; which one serves a given workflow is SSOT in docs/development/cloud-local-workflows.md. Dispatch goes through /api/inject → pending_command → an authorized runner. Project-owned sessions are the execution identity; Tabs are owned PTYs keyed by project; there is no multiplexer to guess. Which builder runs a project is a STORED decision (locus lock → `builder_pref` → cloud floor, src/lib/execution-access.ts), never presence. To iterate on a single piece, run it directly (`pnpm exec tsx home/watcher.ts --start`); test the whole library with `pnpm run test:home`. Full docs: home/README.md. widget/ → The embeddable feedback widget customer sites load as