chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.6.0 Latest 5 packages
0
0
A playground at /playground writes a view beside what it draws
Merged Approved
This adds /playground, plus the anyone-callable getPlayground and previewView methods. It also lets an inline view name the origins and thumbnails that bundled views already name.
What I read. I read view.rs, tools.rs, xrpc.rs, playground.rs, lib.rs, playground.svelte.ts and share.ts in full, plus AGENTS.md on main. I did not read the rest of the web files (editors, preview, menus, CSS, package-lock.json), the lexicon files, the docs or harness/contrast.json. just check is the gate for those.
Trust change.
- Inline origins are restricted to
bundled_origins(), andparsechecks every one. view_ctxnow passes the origins through. The tests cover both the refusal and the accepted case.csp_origins(...)already puts these origins in every view's CSP inmcp.rsand in the workspace page's CSP inworkspace.rs. So an inline view's pictures gain no new origin to load from, which matches the PR's claim.AGENTS.mdis updated to match.
previewView.
- It is open to anyone, but a cookie caller must pass
from_page(X-HUD: 1and same origin), the same check the other procedures use. A bad or missing session falls back to no account, never to someone else's. - The tool is limited to the three that draw views, and an invalid view returns every problem before anything is read.
- Replaying a client-supplied
answerthroughredrawreads nothing from the answer's own source. Handle lookups are capped at 50 DIDs (HANDLES_MAX) and a short deadline, so the 4 MiB body does not become unbounded outbound work. - The
answercomes from the caller and is drawn only back to them. - With sign-in off, the workspace's methods answer
MethodNotImplemented, and the test covers that.
Non-blocking.
- Without an
answer,previewruns the tool as/mcpdoes, so an unauthenticated caller gets the same reads and any rate limits/mcphas. Confirm the deployment's limits cover/xrpc/place.hud.previewViewas well, if they are per route. fromLinkinflates a#v=payload with no size cap. That only affects the person who opens the link, so it is minor.
No changes needed.
Merged as fb3a956
A playground at
/playground: a view's JSON on the right, what it draws from live data on the left, redrawn as you type, shareable as a link. It works signed out and with sign-in off, and it lets an inline view name the origins bundled views already name, so its pictures load.Claude Opus 5.5 · high
What changes
The page (
web/playground.html,web/workspace/Playground.svelte,PlaygroundPage,PlaygroundEditor,PlaygroundPreview,TemplateMenu,CodeEditor,lib/playground/): CodeMirror 6 editors for the call (tool and arguments) and the view, the preview drawn byshared/Result.svelteas a tile draws it, at a column's, a wide, a phone's or the full width, in light, dark or any of HUD's themes, with Tree and Data tabs. The server's problems are marked where each is in the editor and listed under it; the catalog completes component and prop names. It starts from any bundled view (its call fromexamples.ts) or a blank one. Copy link puts the call and view, compressed, in#v=; the work is kept in localStorage. What a drawing opens is shown, not followed, with a button to load the call; actions and forms don't write here. On a phone, Edit and Preview are tabs.Two methods, anyone's (
schemas/place.hud.getPlayground.json,place.hud.previewView.json,crates/hud-server/src/xrpc.rs):getPlaygroundgives the bundled views a read tool draws, each as an inline view may be (view::inline_copy), with its app, the catalog and HUD's themes.previewViewtakes a tool, its arguments with the view, and optionally the answer read before: an invalid view answers every problem by where it is; with an answer it redraws over it (Hud::redraw, sharingdrawn_queryanddrawn_recordswith the tools, so the drawing is the tool's own); without, it makes the call, as the account where a session is good, else as no one. The page edits a layout by redrawing and reads afresh only when the call or anything else in the view changes. Its input may be 4 MiB.Served with sign-in off too:
/playground(playground.rs),/favicon.svg, and/xrpc, where the workspace's methods then answerMethodNotImplemented.Inline views' origins: an inline view may name
origins(andthumbnailson them) that some bundled view names, and draws from them. Any other origin is refused, naming those allowed. The CSPs already allow exactly the bundled views' origins, so none widens. The catalog's grammar says so to models.Why
Writing a view meant a model or a person sending inline views through
/mcpand reading errors back. The playground shows the drawing and every problem at once. Redrawing over the answer read keeps typing off the PDSes and AppViews, and drawing through the tools' own code means the preview is what a tile shows. A subdomain was considered and dropped: the same origin needs no CORS or second cookie.Inline views named no origins, so every AppView picture (Bluesky's avatars and images, Grain's photos) was missing from anything a model or the playground wrote. Allowing the bundled views' own origins fixes that without loading anything the page could not already load.
How it was checked
just checkpasses (100% lines and functions). Tests:a_view_drawn_again_over_its_answer(a redraw equals the call made afresh with that view, for a page, a record and a query, nothing read again),the_playground_draws_a_viewandthe_playground_with_sign_in_offthrough the router, every answer held to its lexicon,bundled_views_copied_to_draw_inline, and the inline-origin cases indocumentsandviews_chosen. In Chromium against a localhud serve: the Bluesky profile, Grain gallery and plyr.fm templates read and draw with their pictures; a layout edit redraws withanswer(one request, no read); a broken component is marked and listed; a copied link restores the view in a fresh tab; Paper theme, phone width, light desktop and dark phone looked at and critiqued by a reviewer agent, its findings fixed.Shortcomings
bsky-chat,bsky-chat-with,bsky-chatscall procedures andbsky-feedsends interactions in their layouts, which only a bundled view may, so those templates start with their problems shown. Actions and forms don't write from the playground. Nojust lookstate or e2e covers the page. The page is 739 KB (221 KB gzipped), CodeMirror most of it. Saving a view as a record isn't built: sharing is the link.Review
The trust change first:
view::originsandview_ctx. ThenHud::redrawandpreviewinxrpc.rs; the page last.