dx-playground cockpit: embedded UI + approval gate, runtime registry, themeable proposals, freeform screens

dx-playground cockpit: embedded UI + approval gate, runtime registry, themeable proposals, freeform screens

#1 in tonybierman/dioxus-mcp — merged 2026-05-27

Summary

Builds out the dx-playground cockpit — a wasm DSL editor + live preview that the stdio MCP server embeds and serves — and the substrate underneath it. Five threads of work:

Cockpit + human approval gate (M5–M7)

  • The stdio MCP server now also serves the cockpit (UI + HTTP MCP) on --bind (default 127.0.0.1:8731) unless --no-cockpit, sharing one Arc<State> — nothing extra to run.
  • propose_scaffold / resolve_proposal / check_proposal: submit a DSL doc as a proposal (preview/edit/approve in the cockpit) instead of writing files. Proposals persist to <root>/target/dioxus-mcp/proposals.json.
  • Cockpit UI: Author + Proposals modes, screen navigator, debounced dry-run preview.

String-keyed runtime registry (themes / components / layouts)

  • New wasm-safe crate dioxus-mcp-registry holding the descriptor schema + the generic-preview vocabulary (RenderNode/Slot/Behavior); RenderModel/RenderField moved here (server + playground re-export the one definition).
  • Descriptors loaded from disk (embedded built-ins < global ~/.config/dioxus-mcp/registry/ < project <root>/.dioxus-mcp/registry/), hot-reloaded on every access. get_registry MCP tool serves the merged registry to the cockpit (re-fetched on window focus).
  • Wired into: the component catalog, layout codegen dispatch, the cockpit theme selector, and a generic node-walker preview for runtime layouts. Built-ins unchanged (no codegen drift).

Themeable proposals

  • A doc-level theme: field flows to both the preview (--p-* CSS vars, overridable per-review) and generated code (assets/theme.css token block + baseline rules).

freeform screen kind (greenfield non-CRUD apps)

  • The escape hatch for UIs the closed CRUD template set can't express (markdown editor, dashboard, canvas): with template.body set it splices the full component body into a #[component]; with none it emits a titled shell. Preview shows a static shell so it stays in the navigator.
  • Spec + tool-description guidance steers the agent to freeform for non-CRUD requests, and documents that freeform bodies are prelude-only — use document::eval for browser capabilities (file save/clipboard), not native crates.

Packaging

  • scripts/build-ui.sh bakes the built cockpit into crates/dioxus-mcp/ui-dist/ so the bare-registered MCP serves the real UI via include_dir!.

Test plan

  • cargo test -p dioxus-mcp — 453 lib tests pass (codegen byte-for-byte stable; new freeform + registry + theme tests).
  • cd playground && cargo check --target wasm32-unknown-unknown clean.
  • End-to-end: scaffolded a working markdown editor via propose_scaffold + kind: freeform; verified the embedded cockpit serves the real UI and the approval round-trip writes files. Manual prompts in TODO_TEST_PROMPT.md (untracked).

🤖 Generated with Claude Code

Last updated 2026-05-28