# `ui/src/demo/` — Stage 1 Demo Mode

Runs the UI with no backend by intercepting `fetch` / `EventSource` via MSW.
Gated by `import.meta.env.VITE_DEMO_MODE`; tree-shaken in production builds.

## How

`ui/src/main.tsx` conditionally `await import('./demo')` before `createRoot`.
`./index.ts` starts the MSW service worker registered against
`ui/public/mockServiceWorker.js` (generated by `pnpm -F open-alice-ui msw:init`).

## Layout

- `handlers/` — one file per `ui/src/api/*.ts` domain. `catchAll.ts` MUST stay
  last in `handlers/index.ts`.
- `fixtures/` — typed const exports. Only non-trivial shapes get their own
  file; empty arrays / nulls live inline in handlers.
- `DemoTerminalStub.tsx` — rendered by `TerminalView` when the env flag is on
  (Terminal.tsx has a 1-line early-return guard).

## Running

```bash
pnpm -F open-alice-ui dev:demo    # vite dev server, demo mode
pnpm -F open-alice-ui build:demo  # static build
```

## Stage 2 backlog

Walk the `[demo] unmocked …` console.warn output from `catchAll` to find
endpoints that need real handlers. Then:

- Rich fixtures (multiple UTAs, varied positions, P&L, workspace sessions).
- Scripted SSE timelines for events + chat (multi-turn convos, tool calls).
- WebSocket PTY replay — waits for MSW v2 WS GA (currently `next` tag).
- In-memory mutation persistence (create-then-reload survives).
- Persistent "Demo Mode" UI banner.
