feat: Shader Playground (Phase B, #52)#53
Conversation
Implements Phase B server infrastructure for the Shader Playground (#52): - Design spec with architecture, API contracts, and wireframes - PlaygroundSession types, SSE events, and API request/response types - SQLite session store (playground-db) following reviews-db pattern - In-memory SSE connection registry with screenshot wait queue - Catch-all API route handling create, update, state, screenshot, errors, SSE - 15 unit tests for session store CRUD operations (all passing) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Playground UI (SolidJS + Three.js + CodeMirror 6): - PlaygroundCanvas: reactive WebGL renderer with preserveDrawingBuffer, error extraction via getShaderInfoLog, auto screenshot capture - PlaygroundEditor: CodeMirror 6 with C++ syntax (GLSL-compatible), one-dark theme, external value sync without cursor loss - PlaygroundLayout: split editor/canvas layout, SSE connection for agent-driven updates, debounced manual edits, error display bar - /playground route with ?session= param, auto-creates new session MCP playground tools (4 new tools): - create_playground: creates session, returns URL - update_shader: updates GLSL, returns errors + screenshot as image content - get_preview: returns latest screenshot as MCP image content - get_errors: returns compilation error list - Handlers with dependency-injected fetch for testability - 8 handler tests (all passing) Polish: - Added "playground" link to Header navigation - Updated existing MCP tests for 7 tools (was 3) - All tests pass across 13 test files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Findings:
Checks run:
|
1. High: Fix SSR crash — move window.history.replaceState out of createResource fetcher into a client-only createEffect with isServer guard and useNavigate for URL updates. 2. Medium: Remove auth check from /update endpoint — the session UUID is the capability token. Both browser editor and MCP worker can update. Only /create requires PLAYGROUND_SECRET. 3. Medium: Add uniforms array to create_playground tool schema in both TOOLS and TOOLS_MCP_FORMAT so schema-driven MCP clients expose the parameter correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
All three findings addressed in 4f77b48. Here's the breakdown: 1. High — SSR crash from Fixed. Moved the URL update out of the 2. Medium — Browser editor blocked by auth on Fixed. Removed the 3. Medium — Fixed. Added the Re: what is In dev mode (no |
|
Follow-up fix pushed in I found one residual edge case after the earlier review fixes: when The change in
I also included the regenerated Verification:
|
Summary
Implements the Shader Playground — an agent-first shader editor where AI agents write GLSL via MCP tools and get visual feedback (screenshots), while humans see a live preview + code editor side-by-side.
docs/specs/playground.mdreviews-db.tspattern), in-memory SSE registry, screenshot wait queue/api/playground/*— create, update, state, screenshot, SSE events, errorscreate_playground,update_shader,get_preview,get_errors— screenshots returned as MCP image contentCloses #52
Test plan
bun testpasses (verified locally — 0 failures across 13 files)bun run dev:web→/playgroundloads with default shader renderingcreate_playground→ returns session ID + URLupdate_shader→ returns errors + screenshotget_errorswith invalid GLSL → returns compilation errors🤖 Generated with Claude Code