Skip to content

feat: a design area where each bot's screens take shape live - #33

Merged
httpsphl merged 4 commits into
mainfrom
feat/screens
Sep 29, 2026
Merged

httpsphl merged 4 commits into
mainfrom
feat/screens

Conversation

@httpsphl

Copy link
Copy Markdown
Owner

What

The N4 from the browser work: a design area beside the chat where every HTML screen a bot makes shows up as an artboard and takes shape while the bot writes it (spec section 22).

Daemon (T1)

  • While the model writes a Write of an .html file, Claude Code streams the tool input (input_json_delta). The daemon reads the partial JSON (file_path, and content so far, unescaped), keeps a draft of the file and sends screen.draft to the apps, at most every 250 ms. When the tool result arrives (written, denied or failed), the draft ends and the address serves the file on disk again.
  • GET /view/<key>/<root>/<path> serves screens, drafts and the files next to them (CSS, images). The per-bot key is random, lives in memory only and goes only to the app. Paths must stay inside the crew's work folder or the bot's folder. Every response carries Content-Security-Policy: sandbox …, so pages run in an opaque origin, away from the daemon and the app.
  • screens.list returns the bot's HTML files, with their address and the device a file asks for (<meta name="botloft-device" content="mobile">). The bot's rules now describe its browser and the design area.

App (T2)

  • A Screens button in the bot's header opens a dotted board. Artboards are drawn at computer, tablet or phone size, scaled by a zoom (fit, minus, plus). The screen being written glows in the bot's color with "Writing… 7 KB". Each version loads behind the one on show and swaps in when ready, so there is no flicker. The area opens by itself when the bot starts drawing, if nothing else is open.
  • Clicking a screen opens it on its own, alive: scroll and click, pick the device, Open, Show in folder.
  • Write and Edit lines of HTML files in the chat get a "Show in screens" button.
  • The Tauri CSP allows frame-src http://127.0.0.1:*. Texts in English, Portuguese and Spanish. FakeBotloft has screens and drafts, and the dev preview has a Designer drawing a bakery page.

Tests

  • cargo test --workspace (245), clippy -D warnings, fmt, pnpm check (129).
  • New: the partial JSON reader (escapes cut anywhere, surrogate pairs), places and paths, device hints, and an integration test where a Write streamed by the FakeRuntime becomes a draft at /view and then the file. Another test checks that /view serves nothing outside the folders (.., hidden files, wrong key).

Tested with the real Claude Code (2.1.284, Haiku, Manual mode)

  1. Asked for a bakery landing page. The design area opened by itself, and the page built up version by version (about 70 versions of 8 KB), before the owner allowed the write.
  2. After allowing it, the screen came from disk.
  3. For a second page, a mid-stream capture shows the menu half built. Denying that write removed the screen.
  4. The debug log held only statuses and ids.

The Claude desktop app's browser pane blocks frames to 127.0.0.1 (ERR_BLOCKED_BY_CLIENT), so the preview was checked in a headless Edge instead.

Still to try by hand: the design area inside the Tauri window (pnpm tauri dev), which is the WebView2 CSP path.

Every .html file a bot makes in its folders is a screen. While the model
writes a Write of one, Claude Code streams its input; the daemon reads
the partial JSON, keeps a draft of the file and sends screen.draft to the
apps at most every 250 ms, until the tool result gives way to the file
on disk.

GET /view/<key>/<root>/<path> serves screens, drafts and the files next
to them, with a per-bot key that lives only in memory and a CSP sandbox
that gives every page an opaque origin. screens.list lists them with
their address and the device a file asks for. The bot's rules tell it
about its browser and the design area.

Spec: new section 22.
The app shows it next to "Writing…": a page's head and styles come
first and draw nothing, so the size says the bot is at work.
A Screens button in the bot's header opens a dotted board with every
HTML screen the bot made, drawn at a computer, tablet or phone size and
scaled by the board's zoom. The one being written glows in the bot's
color with its size so far, and each new version loads behind the one on
show and swaps in when ready, so it grows without flickering. The area
opens by itself when the bot starts drawing and nothing else is open.

A click opens a screen on its own, alive, with its device, Open and Show
in folder. Write and Edit lines of HTML files in the chat get a button
to it. Screens load in sandboxed frames from the daemon's /view, which
the Tauri CSP now allows. FakeBotloft has screens and drafts; the dev
preview has a Designer drawing a bakery page. Texts in English,
Portuguese and Spanish.
A Manual bot on Haiku drew a landing page that took shape before the
owner allowed the write, and a denied write left the design area.
@httpsphl
httpsphl merged commit dcc2af6 into main Sep 29, 2026
3 checks passed
@httpsphl httpsphl mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant