Skip to content

feat: public Vercel demo via NEXT_PUBLIC_DEMO_MODE#20

Open
kleopasevan wants to merge 4 commits into
mainfrom
feat/demo-mode
Open

feat: public Vercel demo via NEXT_PUBLIC_DEMO_MODE#20
kleopasevan wants to merge 4 commits into
mainfrom
feat/demo-mode

Conversation

@kleopasevan
Copy link
Copy Markdown
Contributor

Summary

Ships a public, fully-mocked demo of apps/ui to https://nqr-microvm-demo.vercel.app driven by a single env var, plus the GitHub workflow that keeps it in sync on every release.

  • No separate demo app. apps/ui itself runs in demo mode when NEXT_PUBLIC_DEMO_MODE=true. Everything else stays untouched.
  • Self-contained shim under 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 — patches apiClient.request, window.fetch (for the few direct calls), and window.WebSocket so live metric / log / shell streams emit fake events.
  • components/demo/demo-bootstrap.tsx seeds 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.
  • Two small Suspense fixes in templates/page.tsx and sso/callback/page.tsx so production builds prerender.
  • Next.js bump 15.5.6 → 15.5.18 because Vercel rejected the initial deploy on the CVE in 15.5.6.
  • .github/workflows/deploy-demo.yml triggers on v*.*.* tags + manual dispatch, runs vercel build --prod and vercel deploy --prebuilt --prod against the existing project (nqr-microvm-demo).

One-time setup

Add a Vercel token as a repo secret so the workflow can deploy:

gh secret set VERCEL_TOKEN --body "$(token from https://vercel.com/account/tokens)"

The org/project IDs are inlined in the workflow — they aren't secrets.

Test plan

  • pnpm build succeeds locally with and without NEXT_PUBLIC_DEMO_MODE=true
  • pnpm start returns 200 for /, /dashboard, /vms
  • Initial Vercel deploy live at https://nqr-microvm-demo.vercel.app (HTTP 200)
  • Workflow run after VERCEL_TOKEN is set (push a tag or trigger workflow_dispatch)
  • Spot-check demo dashboard interactivity in a real browser (create/start/stop a VM, add a network, add a volume) — values should persist across reload and Reset clears them

🤖 Generated with Claude Code

kleopasevan and others added 4 commits May 24, 2026 00:32
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>
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