Skip to content

fix(playground): client-side session loading#55

Open
devallibus wants to merge 1 commit intodevelopmentfrom
fix/playground-client-side-session
Open

fix(playground): client-side session loading#55
devallibus wants to merge 1 commit intodevelopmentfrom
fix/playground-client-side-session

Conversation

@devallibus
Copy link
Owner

Summary

  • Replace createServerFn/useServerFn with direct API calls for session loading
  • The playground doesn't need SSR — editor + canvas are purely client-side
  • Eliminates hydration timing issues where useSearch reactive values aren't available when onMount fires
  • Remove auth requirement from POST /api/playground/create (creating an empty session is harmless — the UUID is the capability token)

What was wrong

  1. createResource doesn't integrate with TanStack Router SSR streaming → blank page
  2. useServerFn + onMount worked but useSearch reactive value isn't hydrated at mount time → session ID always undefined → MCP-created sessions ignored, new session created instead
  3. Server function serialization (seroval) was sending undefined for the session ID

How it works now

  • onMount reads ?session= from window.location.search directly
  • Calls /api/playground/:id/state to load existing session, or /api/playground/create for new ones
  • SSE push from MCP → browser already works (unchanged)

Test plan

  • Visit /playground → new session created, editor + canvas render
  • MCP create_playground → get session URL → open in browser → same session loads (not a new one)
  • MCP update_shader with browser open → canvas updates live via SSE
  • MCP get_errors with broken GLSL → returns compilation errors

🤖 Generated with Claude Code

Replace createServerFn/useServerFn with direct API calls. The
playground doesn't need SSR — the editor and canvas are purely
client-side. This eliminates hydration timing issues where useSearch
reactive values aren't available when onMount fires.

Changes:
- playground.tsx: fetch session via /api/playground/create and
  /api/playground/:id/state instead of server functions
- $.ts: remove auth requirement from POST /api/playground/create
  (creating an empty session is harmless — the UUID is the capability
  token)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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