Skip to content
File

Blob: worker/AGENTS.md

Markdown39 lines

Exhibit application

This directory owns the React frontend and Cloudflare backend.

Use Tailwind v4 utilities for layout, typography, controls, and responsive behavior. Keep custom CSS focused on theme tokens and drawing effects. Run Prettier after edits. Use vercel-react-best-practices for React design choices; keep the high-frequency spectrum renderer outside full-page renders.

Organize exhibit components by responsibility under src/client/exhibit/. The exhibit maps radio state to narrow panel props; panels do not own or import RadioSession. Keep the board SVG separate from board layout, wire geometry separate from DOM measurement, and explanation copy separate from popover logic. src/client/radio/use-radio.ts is the React boundary for the session owner. Use named API operations with Zod-inferred outputs and direct module imports.

Use Hono for HTTP routing and cookie handling, shared Zod schemas for JSON boundaries, and typed RPC for Worker-to-Durable-Object operations. Generate Env with Wrangler; secret names belong in wrangler.jsonc's secrets.required, never in a duplicate handwritten Env interface. Keep RPC errors serializable.

RobotRoom owns one board's sessions, controller lease, and cleanup. Preserve its class name, persisted state shape, and migration history during compatible rollouts. Keep SFU mutations serialized across awaits, revoke canReply when a lease expires, and retain failed allocations and viewer cleanup within the current generation. Replacing or expiring the publisher discards its entire generation; old SFU sessions expire independently and must not block a new boot. Status polling must not postpone an existing alarm. Firmware API paths and data-channel formats must remain compatible with the connected board.

Check with make check, make test-worker and make test-worker-bundle from the root. Live tests in tests/live.mjs require the board, SFU, credentials, and a Chrome CDP endpoint. Document integration workarounds in ../ERRATA.md.

Use @/, @dev/ and @tests/ for imports across directories; the shared alias map and Node preload live in dev/. Worker runtime tests use Cloudflare Vitest with synthetic bindings and reset storage between cases. Keep the production-bundle smoke test independent of the runner's extra compatibility flags.