Add Studio: agent-rendered artifacts and design canvases - #458
Merged
Conversation
A side panel where agents render things that do not exist in the codebase yet — one HTML document (agenthub_artifact) or N variants of a component on an infinite canvas (agenthub_design) — and the user points, comments, crops, tweaks, edits, and picks one. Works for Claude and Codex. Nothing is written into the project: the agent renders into a scratch surface served from an in-process loopback server, and everything the user does becomes a panel-local edit or a prompt. - Tool boundary: per-variant CSS scoping (StudioCSSScoper), fragment normalization, payload limits, shared tweak props validated and required to be referenced. - Tweaks: one shared props schema per canvas exposed as CSS custom properties; Save defaults writes into the payload; agent actions re-file. - Edit mode bakes canvas edits into the variant (quiet, with Revert); documents keep the send-to-agent path. - Implement (header menu + per-artboard pill) is the only action that asks for code and always carries the edited variant; agenthub_get_artifact lets a variant chosen in chat resolve to the same content. - Agents are steered by a system-prompt nudge (default-on, Settings toggle) and a bundled agenthub-studio skill for both providers. - Codex 0.148 per-tool MCP approval: mark the bundled server auto, and XcodeBuildMCP auto under never/full-auto (own setting or global config); annotate every tool (readOnlyHint on list/get/planning). - SQLite v18 studio_artifacts; served documents are a cache reconciled on launch; SidePanelContent.artifact renamed .claudeArtifact. See AgentHubStudio.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Studio: a side panel where agents render things that do not exist in the codebase yet — one HTML document, or several variants of a component on an infinite canvas — and the user points, comments, tweaks, edits, and picks one. Works for Claude and Codex. Nothing is ever written into the project; everything the user does on the surface becomes either a panel-local edit or a prompt.
Full design, invariants, and remaining gaps:
AgentHubStudio.md.Agent-facing tools (bundled MCP server, both providers)
agenthub_artifact(title, html, id?)— one self-contained document, served verbatim.agenthub_design(component, variants[], props?, sourcePath?, id?)— N variants side by side. Each variant's CSS is scoped to its own artboard at the tool boundary (StudioCSSScoper):body,:rootvariables,@media,@keyframesall work per variant; scripts are stripped; unparseable CSS is rejected with a character offset.agenthub_list_artifacts/agenthub_get_artifact(id, variant?)— discovery and the current content of an artifact (including edits the user made in the panel), read from a JSON index + sidecar the app publishes. The CLI never opens SQLite.readOnlyHinton list/get/planning,destructiveHintonly on worktree deletion).Panel
NWListenerserver (GET/HEAD,127.0.0.1only, path-traversal guarded,no-store). Open in browser / Copy link / Export work; re-files reload in place; host-page changes regenerate canvases already on disk (hostVersionmarker).innerHTMLserialized into the payload, debounced, quiet — no reload) with Revert; documents keep the send-to-agent path.propsschema per canvas (sliders/colors/selects/toggles/text) exposed to every artboard as CSS custom properties — one control moves every variant. Save defaults writes back into the payload; Ideas/Custom/Delete go to the session agent as re-file prompts. Documents get the same panel by callingdc_set_props. A declared prop no variant references is a tool error.agenthub_get_artifact.Getting agents to use it
StudioAgentGuidancesystem-prompt line (Claude--append-system-prompt, Codexdeveloper_instructions), default-on, only when the bundled server is attached.agenthub-studioskill installed for both providers (model-invocable + explicit/agenthub-studio).Codex compatibility (surfaced while testing)
Codex 0.148 introduced per-tool MCP approval; under
approval_policy = neverevery AgentHub MCP call failed with "MCP tool call requires approval, but approval policy is never". The Codex bootstrap now setsmcp_servers.agenthub.default_tools_approval_mode = "auto", and XcodeBuildMCP toautowhen the effective policy (AgentHub's own, else the global~/.codex/config.tomlvalue via the new read-onlyCodexGlobalConfigReader) isnever/full-auto. Older Codex ignores the key.Storage
v18_create_studio_artifactsmigration (blob payload +payloadVersion); project-scoped with worktree rollup; served documents are a cache derived from SQLite, reconciled on launch.SidePanelContent.artifact(claude.ai artifacts) renamed.claudeArtifactso the two features are never confused.Test plan
cd app/modules/AgentHubCLI && swift test— 146 tests incl.StudioCSSScoperTests,StudioFragmentNormalizerTests,StudioTweakPropsTests,StudioArtifactQueueTests,StudioIndexStoreTests../scripts/test.sh core— incl.StudioDocumentWriterTests,StudioStaticServerTests(live socket),StudioLibraryTests,StudioArtifactStoreTests(v18 preserves the v17 baseline),StudioTweaksTests,StudioDesignEditStateTests,StudioPanelStateTests,StudioArtifactHandlerTests,CLISessionsViewModelStudioTests,CodexGlobalConfigReaderTests, launch-builder/config suites for the guidance + approval-mode args.neveraccepts the configured server.