PaprikaPaprikaDocs
HomeGitHubPortuguês

Reference

ADR 0009: The web app on TanStack Start and the UI SDK

#Context

ADR 0003 and ADR 0005 describe web-legacy, a Vite + React app with hand-rolled state, Tailwind without Preflight and shadcn primitives copied over Radix. On 2026-11-26 the maintainer asked for a new app instead of another migration: written from the new interface drawn in Paprika (phases 1 to 4 of the "App · nova interface" workspace), with no code ported from the old one, and with one goal that the old app never had: an agent should be able to operate the UI the way a person does (roles, names and keyboard paths that hold up without the mouse). #259 built the new apps/web next to the old one; #262 made the Go server serve it, ported the canvas and the E2E suites to it and removed web-legacy.

Nothing recorded the decisions behind the new app. ADR 0003 still says "no Preflight", which is no longer true, and ADR 0005 describes a component layer that no longer exists.

#Decision

  1. TanStack Start in SPA mode. apps/web is a TanStack Start app with spa.enabled (vite.config.ts). The build writes static files to apps/web/dist/client, with the shell at _shell.html; the Go server serves that folder by default (webEntries in http.go), so there is still one binary and no Node process at run time. Routes are files under src/routes/ (/ for the overview and /w/$workspaceId for the editor), typed by TanStack Router.

  2. Data goes through src/data/ only. data/api.ts is the HTTP client and data/live/ is the /ws client (a client without React, made once by LiveProvider, read with useLive(selector) and written with useLiveActions().apply(ops, label), settled by the server's ack or error; nothing is applied optimistically). The ack can arrive before the delta it announces, so the editor's useApplyOps resolves only once the page shows that version (untilShown): code that reads the document after its own write never sees the state from before it. Server state that is not the live document goes through TanStack Query (data/query-client.ts, data/queries/). TanStack DB is installed and allowed only inside data/, but nothing uses it yet. src/adapters/ are pure functions from server shapes to component props. src/test/architecture.ts keeps the network, stores and sockets out of every other layer.

  3. State: TanStack Store, per instance. The editor's shared state is a store made per editor (src/editor/editor-store.ts), and regional state inside a complex component uses createRegion from frontends/_shared. No store, socket or client is created at module scope. The app's keys (undo, history, pins) use TanStack Hotkeys; the keys that act on the selection live in editor/shortcuts.ts and only fire with the focus on the page, the stage, the layers tree or the stage toolbar.

  4. Components: the UI SDK, headless, on Paprika's tokens. Every interactive primitive comes from the UI SDK (@ui-sdk/core and @ui-sdk/react, vercel-labs/ui), which handles roles, focus and keyboard behavior. It is used headless: its default theme (@ui-sdk/core/web.css) is not imported, and there is no shadcn or Radix. Styling is Tailwind classes on the brand tokens. Two layers:

    • src/components/ui/: simple components that only render. Data comes in by props and events go out by callbacks; all visible text and aria-labels arrive by props; no i18n, router, Query or store.
    • src/components/frontends/<name>/: complex components (canvas, inspector, layers, overview…) that take external state by props, emit callbacks, may use i18n and a short list of libraries, and never touch the network.

    src/components/architecture.test.ts enforces both layers on every pnpm test. The UI SDK skill is vendored in .claude/skills/ui-sdk/, and AGENTS.md rule 8 says where it yields to the project's rules.

  5. Tailwind 4 with Preflight, and a canvas world that does not depend on the chrome. This amends ADR 0003. src/styles.css declares the ui-sdk cascade layer first, imports all of Tailwind (Preflight included) and defines the brand tokens in @theme static with light-dark() pairs, so one set of names covers both themes. The canvas world (data-canvas-world in frontends/canvas/canvas.tsx) undoes what the chrome would leak into the user's document: it sets line-height: normal and color-scheme: light, and every node paints from the inline styles of nodeStyle, which set what the document needs instead of relying on the page's defaults. The guarantee that ADR 0003 drew from "no Preflight" now comes from tests: canvas.test.tsx checks the world's classes, wasm.e2e compares the DOM and the WASM renderer pixel by pixel, and the server's render parity tests (render_parity_test.go) compare the export with render_screenshot.

  6. i18n with i18next. The UI and the default names follow the language (en and pt-BR, in src/i18n/), detected by i18next-browser-languagedetector; keys are typed (i18next.d.ts). The HTTP API stays in English. A complex component uses frontends.<name>.* keys with complete labels, never a noun interpolated from its owner.

#Consequences

Edit this page on GitHub