Add the `clai2` web UI: a sessions sidebar, streaming chat, tool cards, and a composer with `/` completion

Merged
MP
2mo ago
+5200-6

Part 3 of 3 of a browser UI for clai2 (stack: #10261 โ†’ #10262 โ†’ this PR). Based on #10262. No linked issue: built at the CLAI maintainer's request.

Why. The web plugin needs a UI that feels like a desktop coding agent (Codex app style), with no Node needed to run it.

What it is. React 19 + TypeScript + Vite in src/pydantic_clai2/web-ui/, built into builtin_plugins/web/static/ (about 126 KB gzipped). Small dependency set: react, marked, dompurify, highlight.js (core, 13 languages).

  • Sidebar: sessions grouped by project, search, new, switch, rename, fork, delete, live running state.
  • Chat: streaming sanitized Markdown with highlighted code and copy buttons. Thinking and tool calls are quiet collapsible rows. Shell rows show live output and exit codes, edit and write rows show diffs (rebuilt from arguments in replayed history), and run_code rows show their code and printed output.
  • Composer: / completion from CLAI's own registry, a saved-model picker, Stop, and ask_user question cards.
  • Keys: Enter, Shift+Enter, Esc to interrupt (only from the composer or the page), Cmd/Ctrl+K, Cmd/Ctrl+Shift+O, Cmd/Ctrl+B.
  • Dark first, with a light mode that follows the OS.

Built bundle is committed rather than built at package time. uvx pydantic-clai2 --web and the bleeding-edge sdist installs then need no Node. The cost is a generated diff whenever the UI changes. It is marked linguist-generated and excluded from the text-rewriting pre-commit hooks, which would corrupt it. Rebuild with npm ci && npm run build in web-ui/. A CI freshness check is a good follow-up.

Verification. npm run build typechecks (tsc --noEmit, strict) and builds cleanly. Exercised in headed Playwright against clai2 --web with claude-code:claude-haiku-4-5: streaming, tool cards and diffs, /cost, interrupt, a question answered in the browser, new session, switching, rename, fork, light mode. No page or console errors.

What changes for existing users. Nothing until they enable web.

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.