#34
Add isolated public demo sandbox
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.appRailway 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 lintstill reports the existingno-require-importserrors inbabel.config.jsandpostcss.config.js; all files changed by this PR pass ESLint.
Activity
9mikeyreviewed2mo 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 passedpnpm 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 existingno-require-importserrors inbabel.config.jsandpostcss.config.js, both unchanged frommain
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 withCache-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
2f48341 into main2mo 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 (getEnabledAiCredentialshort-circuits tonullin sandbox mode, and/api/mail/focusreturns the mock result before reachingclassifyFocusThreads). 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). Becauseproxy.tsauto-issues a freshsandbox_<uuid>cookie to any request lacking a valid one, and that cookie is live beforegetSessionUser()runs on the same request, every cookie-less hit (bots, crawlers, health scanners,curlin 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 (theseed()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 nomaxAge(session-only), while/api/auth/demo's cookie setsmaxAge: 14 days(route.ts:16). Not a bug, just an inconsistency worth a comment if intentional..trylle/workflows/railway.yml: the newdeploy-demojob reusesRAILWAY_PRODUCTION_TOKENto 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
isDemoSandboxMode()through every call site to confirm no production (DEMO_MODE=false) code path is affected.lib/data/ai-settings.tsandapp/api/mail/focus/route.tsnever construct a real AI credential or callclassifyFocusThreadswhenisDemoSandboxMode()is true.lib/demo/store.tsin full for the sandbox user lifecycle (ensureDemoSandboxUser,resetDemoSandboxUser,seedWorkspace,persist)..data/(the non-sandbox demo persistence file) is gitignored and unaffected by this change.