#34

Add isolated public demo sandbox

MergedstylesshOwnermerged intofrom

Summary

  • add a public, automatically signed-in demo sandbox that isolates each browser session and never connects to production mail, databases, or external AI providers
  • simulate mail, account, settings, domain, compose, Focus, and reset flows in memory, with explicit demo-only environment guards
  • seed 92 varied conversations across Projects, Finance, Travel, Reading, People, Security & Ops, and Personal folders, plus populated system views and realistic message states
  • add deployment configuration for the dedicated demo.redakt.app Railway service while keeping the production deployment path unchanged

Validation

  • pnpm test (156 passed)
  • pnpm exec tsc --noEmit
  • ESLint on every changed TypeScript, TSX, and MJS file
  • DEMO_MODE=true DEMO_SANDBOX_MODE=true BETTER_AUTH_URL=https://demo.redakt.app pnpm build
  • desktop and 390px mobile browser QA for automatic sign-in, folder navigation/counts, Starred, Focus, compose, settings, reset, and hard-refresh isolation
  • live demo health, TLS, seeded Finance/Starred API data, and Railway deployment verified at https://demo.redakt.app

Notes

  • Repository-wide pnpm lint still reports the existing no-require-imports errors in babel.config.js and postcss.config.js; all files changed by this PR pass ESLint.

Activity

9
mikeyreviewed2mo ago
mikey2mo ago

Summary

Reviewed the demo-sandbox isolation work end-to-end (proxy.ts, lib/demo/session-cookie.ts, lib/demo/store.ts, lib/session.ts, lib/data/ai-settings.ts, app/api/mail/focus/route.ts, app/api/auth/demo/route.ts, app/api/settings/account/route.ts, and the Railway/CI deployment config). The env-flag gating (isDemoSandboxMode = isDemoMode() && DEMO_SANDBOX_MODE === "true") correctly confines this to a dedicated, database-less Railway service, and the Focus/AI-settings sandbox paths correctly avoid ever calling an external AI provider (getEnabledAiCredential short-circuits to null in sandbox mode, and /api/mail/focus returns the mock result before reaching classifyFocusThreads). No production data path or credential appears reachable from sandbox mode.

Blocking: the sandbox session store has no bound on the number of sessions it will hold in memory (see inline comment on lib/demo/store.ts). Because proxy.ts auto-issues a fresh sandbox_<uuid> cookie to any request lacking a valid one, and that cookie is live before getSessionUser() runs on the same request, every cookie-less hit (bots, crawlers, health scanners, curl in a loop) permanently allocates a new seeded workspace in the process's global store — persist() is intentionally disabled in sandbox mode, so nothing is ever evicted short of a restart. For a service explicitly meant to be publicly reachable, this is a practical way to grow memory and per-request latency unboundedly (the seed() loop walks the full user list on every store read/write). I'd want to see a cap/eviction strategy (or a proof-of-cookie-retention gate before seeding) before this goes live.

Non-blocking notes

  • proxy.ts:28-33: the middleware-issued sandbox cookie has no maxAge (session-only), while /api/auth/demo's cookie sets maxAge: 14 days (route.ts:16). Not a bug, just an inconsistency worth a comment if intentional.
  • .trylle/workflows/railway.yml: the new deploy-demo job reuses RAILWAY_PRODUCTION_TOKEN to deploy the public demo service. Given the demo runs in the same Railway project, this seems intentional, but flagging in case a scoped-down token was intended for the public-facing deploy path.

Verification performed

  • Traced isDemoSandboxMode() through every call site to confirm no production (DEMO_MODE=false) code path is affected.
  • Verified lib/data/ai-settings.ts and app/api/mail/focus/route.ts never construct a real AI credential or call classifyFocusThreads when isDemoSandboxMode() is true.
  • Read lib/demo/store.ts in full for the sandbox user lifecycle (ensureDemoSandboxUser, resetDemoSandboxUser, seedWorkspace, persist).
  • Confirmed .data/ (the non-sandbox demo persistence file) is gitignored and unaffected by this change.
stylessh force-pushed the stylessh/demo-sandbox branch from c7c983a to a4c1eca2mo ago
stylesshOwner2mo ago

Addressed the blocking sandbox-retention feedback in a4c1eca and rebased onto current main (d35ec66).

  • Caps active anonymous demo workspaces at 128, expires sessions after six idle hours, and evicts least-recently-used sessions before admitting another visitor.
  • Purges all workspace, settings, and rate-limit state associated with an evicted session.
  • Removes the repeated whole-user seed() scan from the cached store path.
  • Documents why the proxy cookie is intentionally browser-session scoped.
  • Preserves the newly merged Smart Compose feature with deterministic, provider-free demo suggestions.

Local verification on a4c1eca:

  • pnpm test: 172 passed
  • pnpm exec tsc --noEmit: passed
  • focused ESLint for all touched/conflict-resolved files: passed
  • demo-mode production build: passed
  • API smoke test: anonymous cookie issued, AI settings enabled without a real key, simulated Smart Compose returned a valid suggestion
  • full pnpm lint: only the two existing no-require-imports errors in babel.config.js and postcss.config.js, both unchanged from main
stylesshOwner2mo ago

Live demo verification for a4c1eca:

  • Railway deployment f8cdee4d-37bc-4d5a-a80a-1bff1e05663d: SUCCESS
  • https://demo.redakt.app/api/health: 200 {"status":"ok"}
  • Fresh cookie-less request received an isolated sandbox_<uuid> session with Cache-Control: private, no-store
  • Live sandbox enabled Focus and Smart Compose without a submitted provider key
  • Live Smart Compose proofread returned a deterministic local suggestion
stylessh merged commit 2f48341 into main2mo ago

Branch stylessh/demo-sandbox has been merged.

Checking branch