feat: public Vercel demo via NEXT_PUBLIC_DEMO_MODE#20
Open
kleopasevan wants to merge 4 commits into
Open
Conversation
Wires apps/ui to run as a public, fully-mocked demo when NEXT_PUBLIC_DEMO_MODE=true so the same codebase can ship to a Vercel demo URL without a manager/agent behind it. When the flag is on: - DemoBootstrap is mounted in place of the License/EULA/Auth guards and seeds the auth store with a demo admin so the dashboard renders immediately. - apiClient.request, window.fetch (for the few direct calls), and window.WebSocket are all patched to route through a mock router with realistic in-memory state (VMs, containers, networks, volumes, images, templates, hosts, functions, users, snapshots, audit). - Mutations (create/start/stop/delete/attach/…) update the store and persist to localStorage so refreshes keep state. A floating "Demo mode" banner exposes a Reset button. Also wraps two pages in Suspense to unblock the production build (useSearchParams + Next 15 prerender), and makes output: "standalone" conditional on VERCEL=0 so Vercel doesn't warn. Includes vercel.json + .vercelignore for the Vercel project. Demo data is updated on each release by re-deploying apps/ui with the env var set; no separate demo app to maintain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds .github/workflows/deploy-demo.yml that builds and ships apps/ui to https://nqr-microvm-demo.vercel.app whenever a release tag (vX.Y.Z) is pushed, plus a workflow_dispatch entry for ad-hoc refreshes (with a production/preview target toggle). The workflow uses Vercel CLI's --prebuilt pipeline so the bundle is built inside CI rather than re-uploaded; org + project IDs are inlined (they aren't secrets), only VERCEL_TOKEN must be added as a repository secret. One-time setup for the maintainer: 1. Create a token at https://vercel.com/account/tokens scoped to the kleopasevans-projects team. 2. gh secret set VERCEL_TOKEN --body <token> Also bumps next 15.5.6 → 15.5.18 — Vercel rejected the initial deploy because 15.5.6 has a known CVE; 15.5.18 is the security backport on the 15.x track. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previously DemoBootstrap auto-seeded the auth store and redirected the landing page to /dashboard, so visitors never saw the login screen. Putting it back in the demo flow: - DemoBootstrap no longer touches auth state or routing — it just installs the request/WS interceptors and renders the floating banner (which now also clears the auth-storage key on Reset so visitors get kicked back to the sign-in page). - Providers wraps everything in the real LicenseGuard / EulaGuard / AuthGuard again. The license + EULA endpoints stay mocked as permissive, so the only thing standing between a visitor and the dashboard is the login form. - Mock /auth/login validates admin/admin and rejects anything else with a 401 + "Use admin / admin" suggestion, so the failure mode surfaces a useful hint. - Landing page shows a Demo-mode hint card above the form with a one-click "Fill credentials" button. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The mock router was already answering /admin/license/status and /admin/eula/status with permissive responses, but the guards still mounted, fetched, and showed a brief loading state. In demo mode we just want the login → dashboard flow, so the License and EULA guards are now bypassed entirely and only AuthGuard wraps the children. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Ships a public, fully-mocked demo of
apps/uito https://nqr-microvm-demo.vercel.app driven by a single env var, plus the GitHub workflow that keeps it in sync on every release.apps/uiitself runs in demo mode whenNEXT_PUBLIC_DEMO_MODE=true. Everything else stays untouched.apps/ui/lib/demo/:flag.ts— env detection.state.ts— in-memory seed (VMs, containers, networks, volumes, images, templates, hosts, functions, users, snapshots, audit logs, backup targets) with localStorage persistence.router.ts— pattern-matched mock handler for ~80 manager endpoints (auth, EULA, license, dashboard, VM/container lifecycle, snapshots, networks, volumes, functions, users, audit, backups). Unmatched routes return safe{ items: [] }defaults.install.ts— patchesapiClient.request,window.fetch(for the few direct calls), andwindow.WebSocketso live metric / log / shell streams emit fake events.components/demo/demo-bootstrap.tsxseeds the auth store, bypasses License/EULA/Auth guards (only in demo mode), redirects/→/dashboard, and shows a floating "Demo mode" pill with a Reset button.templates/page.tsxandsso/callback/page.tsxso production builds prerender..github/workflows/deploy-demo.ymltriggers onv*.*.*tags + manual dispatch, runsvercel build --prodandvercel deploy --prebuilt --prodagainst the existing project (nqr-microvm-demo).One-time setup
Add a Vercel token as a repo secret so the workflow can deploy:
The org/project IDs are inlined in the workflow — they aren't secrets.
Test plan
pnpm buildsucceeds locally with and withoutNEXT_PUBLIC_DEMO_MODE=truepnpm startreturns 200 for/,/dashboard,/vms🤖 Generated with Claude Code