ui-canvas
UI Canvas
Approve-before-you-build loop for user interface work: you write a quick,
self-contained HTML mockup of the component, the human opens it in the
browser and adjusts it by hand like a website builder, and **Save and
Finish** hands you the exact result to wire into the real code. Nobody has to
rebuild and rerun the whole app to check a padding change.
Any component qualifies: a card, a sidebar, a modal, a settings pane, a
single button state, an animation, a page section. Any harness qualifies:
the loop is a CLI that prints JSON.
Shares its server, state, and hooks with plan-canvas (inspired by
lavish-axi by @kunchenguid).
Editing conventions follow
VisBug and
Onlook: Enter/Shift+Enter walk the
tree, Delete removes, an edit/interact mode switch.
When to Use
- The user asks to redesign, restyle, or add a UI component and wants to see
it before you commit, rerun, or rebuild.
- Feedback is visual ("make it tighter", "move that up", "lose the border")
and is faster done by hand than typed.
- Mobile and desktop both matter and the user wants to check the component
at exact dimensions.
- The user asks for
/ui-canvas, a preview, a mockup, "show me first".
Do NOT use for: plan or document review (/plan-canvas), running the real
app, remote URLs, or components you cannot render as plain HTML/CSS/JS in one
file. The canvas serves local files only.
How It Works
Invoke the CLI as ecc-ui-canvas (bin from the ecc-universal package, on
PATH after a global or plugin install; node "$CLAUDE_PLUGIN_ROOT/scripts/ui-canvas.js"
also works). It runs the same detached loopback server as plan-canvas
(127.0.0.1:4517), keyed by artifact path; there are no session ids.
1. Write the mockup
Write one self-contained .html file (for example .claude/previews/<name>.html
or next to the component): markup, a <style> block, and any <script> the
component needs to behave (tabs, toggles, open/close, animation). Rules:
- Use the project's real brand tokens, fonts, copy, and realistic data. Read
the existing CSS or theme file first; do not invent a palette.
- Give meaningful elements an
idor a distinctive class. The canvas records
every human edit against a CSS selector; stable names make the export map
cleanly back to your code.
- Keep it faithful to production: same breakpoints, same
max-width, same
states. The canvas renders at true CSS-pixel viewport sizes, so media
queries behave exactly as they would in the app.
- Sibling assets (images, fonts) may sit next to the file and be referenced by
relative path; a data: URI or an inline SVG also works.
- Inline only what the component needs. A mockup is a sketch, not the app.
2. Open and listen
ecc-ui-canvas open .claude/previews/pricing-card.html --viewport desktop --title "Pricing card"
ecc-ui-canvas await .claude/previews/pricing-card.html # run in the background; leave it running--viewport takes mobile (393×852), desktop (fills the window), custom,
or exact WxH such as 1024x768. Run await in the background if your
harness time-limits foreground commands; re-run it if interrupted, queued
feedback is never lost. While it runs, the canvas shows "<your harness>
listening" so the human knows you are connected.
3. Handle what comes back
await prints JSON when the human acts. Items:
{ "kind": "chat", "text": "change this to dark gray in the brand colors",
"anchor": { "selector": "#pricing-card", "tag": "article", "snippet": "Most popular Team plan…", "size": { "width": 720, "height": 388 } },
"pendingEdits": ["resized img.art to 220px wide, 220px tall (was 260×260)", "removed button.btn.secondary"] }chatis a request.anchoris the element the human had selected when
they sent it; pendingEdits summarizes hand edits they have made that are
not yet in your file. Make the requested change in the mockup file.
The preview reloads within a second and re-applies their pending edits on
top, so do not bake pendingEdits into the file yourself: they are
context, and doubling them up would misplace things. Answer in the canvas
and keep listening with one command:
```bash
ecc-ui-canvas await <file> --reply "Background is now var(--gray-800) from the brand tokens."
```
Speed matters here. Run ecc-ui-canvas typing <file> --state thinking
the moment you start, edit the file, then reply. Under two seconds from
request to repaint is the target for a one-property change.
{ "id": "fb-123", "kind": "edits", "editCount": 3, "edits": [ { "kind": "resize", "selector": "img.art", "width": 220, "height": 220, "before": { "width": 260, "height": 260 } } ],
"viewport": { "preset": "mobile", "width": 393, "height": 852 },
"exportPath": "/abs/.claude/previews/pricing-card.apply-mf3k2x-9a1c.edited.html", "editsPath": "/abs/.claude/previews/pricing-card.apply-mf3k2x-9a1c.edits.json" }editsmeans the human clicked Apply to file: they want their hand
edits written into the mockup now. Replace the mockup file with the
contents of exportPath (it is the full DOM they are looking at, with
their inline-style changes), tidy it into real CSS if it is messy, keep it
self-contained, and reply. Each Apply writes its own
<name>.apply-<batch>.* pair, so a queued earlier batch keeps its own
snapshot. The canvas keeps sh
