Prototype /demo route backed by an MSW-mocked agent#13
Draft
cooper (czxtm) wants to merge 3 commits intomainfrom
Draft
Prototype /demo route backed by an MSW-mocked agent#13cooper (czxtm) wants to merge 3 commits intomainfrom
cooper (czxtm) wants to merge 3 commits intomainfrom
Conversation
Adds a self-contained `apps/web/src/demo/` module: a frozen fixture (state.json shape, Nix config, entity tables), MSW handlers covering the high-traffic REST endpoints plus a Connect-RPC catch-all, a fake JWT for AgentProvider, and a lazy `setupWorker(...)` so the demo bundle only loads on `/demo`. The route mounts the studio sidebar/header against `demo-agent.stackpanel.local` with no real network involvement, so visitors to stackpanel.com can poke at the UI without pairing a real agent. Uses `onUnhandledRequest: "bypass"` so missing handlers surface as blank panels rather than errors; the README documents the one-time `bunx msw init public/` bootstrap and sketches the proto-driven mock generation plan.
Deploy CI runs `bun install --frozen-lockfile`; the previous commit added msw to apps/web/package.json without updating the lockfile, which failed the deploy job on PR #13.
Auto-generated by TanStack Router when the dev server picked up the new `apps/web/src/routes/demo.tsx` route.
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
Stands up a
/demoroute on the web app so visitors to stackpanel.com can play with the studio UI without pairing a real agent. All agent traffic is intercepted in-browser by MSW; nothing leaves the page.apps/web/src/demo/— fixture data (stack.jsonshape, Nix config, entity tables), MSW handlers for the high-traffic REST endpoints + Connect-RPC catch-all, lazysetupWorker(...), and a synthesised JWT.apps/web/src/routes/demo.tsx— boots the worker, mountsAgentProvider/ProjectProvider/ sidebar / header againstdemo-agent.stackpanel.local, rendersOverviewPanel. SSE provider is intentionally skipped for the prototype (handlers return 204, polling falls back).apps/web/package.json— addsmswto devDependencies.What's mocked
GET /health,GET /api/auth/validate,GET /api/events(204)GET|POST /api/nix/config,GET|POST /api/nix/data?entity=*GET /api/state,POST /api/exec(no-op echo)POST /<service>.<method>Connect-RPC catch-all →{}onUnhandledRequest: "bypass"keeps everything else passing through, so missing handlers surface as blank panels rather than thrown errors.Bootstrap
After
vp install, run once:cd apps/web bunx msw init public/ --saveThat writes
public/mockServiceWorker.js(commit it). Both dev and production builds load it from/mockServiceWorker.js.Next step
Generate the handler stubs from
packages/proto/(a buf plugin emittinghandlers.gen.ts) so the mock surface stays in sync with the Go agent automatically. Hand-writtenhandlers.tsthen becomes overrides on top of the generated defaults.Test plan
vp install,bunx msw init apps/web/public/ --savevp dev, navigate to/demo, confirm sidebar + overview render with demo datalocalhost:9876in DevToolsvp checkpasseshttps://claude.ai/code/session_015YfQqBnAi5QZonHdhQHDZG
Generated by Claude Code