Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

dashboard-next: scaffold prototype shell + auto-discovered sub-pages

nirholaseaecaf9761f0
diff --git a/api/_lib/migrations/2026-05-25-knowledge-async-ingest.sql b/api/_lib/migrations/2026-05-25-knowledge-async-ingest.sql
new file mode 100644
index 000000000..3f1c83b10
--- /dev/null
+++ b/api/_lib/migrations/2026-05-25-knowledge-async-ingest.sql
@@ -0,0 +1,38 @@
+-- Migration: knowledge async ingest — adds support for QStash-backed
+-- background embedding. Large PDFs blow Vercel's 60s function cap during
+-- inline embedding; queueing the work to a separate worker invocation makes
+-- ingest reliable regardless of doc size.
+--
+-- source_text: raw extracted text held server-side until the worker
+-- consumes it (then cleared to free row space).
+-- status: adds 'queued' as a pre-processing state.
+--
+-- Apply: npm run db:migrate -- --apply --file 2026-05-25-knowledge-async-ingest.sql
+-- Idempotent.
+
+begin;
+
+alter table widget_knowledge_docs
+ add column if not exists source_text text;
+
+-- Drop+recreate the status check so 'queued' is allowed alongside the
+-- existing states. PostgreSQL has no way to add a value to a CHECK
+-- constraint in place.
+do $$
+declare cname text;
+begin
+ select conname into cname
+ from pg_constraint
+ where conrelid = 'widget_knowledge_docs'::regclass
+ and contype = 'c'
+ and pg_get_constraintdef(oid) ilike '%status%';
+ if cname is not null then
+ execute format('alter table widget_knowledge_docs drop constraint %I', cname);
+ end if;
+end $$;
+
+alter table widget_knowledge_docs
+ add constraint widget_knowledge_docs_status_check
+ check (status in ('queued', 'processing', 'ready', 'failed'));
+
+commit;
diff --git a/api/_lib/qstash.js b/api/_lib/qstash.js
new file mode 100644
index 000000000..bac24c168
--- /dev/null
+++ b/api/_lib/qstash.js
@@ -0,0 +1,83 @@
+// Upstash QStash adapter — publish background jobs + verify inbound webhook
+// signatures. Used for any work that may exceed Vercel's per-request execution
+// cap (currently 60s on Hobby, 300s on Pro): knowledge embedding for large
+// PDFs, scheduled refreshes, batch mint metadata pre-warming, etc.
+//
+// Env:
+// QSTASH_TOKEN — REST API token for publishing
+// QSTASH_CURRENT_SIGNING_KEY — current verification key (always required)
+// QSTASH_NEXT_SIGNING_KEY — rotation key (verified as a fallback)
+//
+// If QSTASH_TOKEN is unset, qstashEnabled() returns false and callers should
+// fall back to synchronous execution.
+
+import { Client } from '@upstash/qstash';
+import { Receiver } from '@upstash/qstash';
+
+let _client = null;
+let _receiver = null;
+
+export function qstashEnabled() {
+ return Boolean(process.env.QSTASH_TOKEN);
+}
+
+function client() {
+ if (!process.env.QSTASH_TOKEN) {
+ throw new Error('qstash: QSTASH_TOKEN not set');
+ }
+ if (!_client) {
+ _client = new Client({ token: process.env.QSTASH_TOKEN });
+ }
+ return _client;
+}
+
+function receiver() {
+ if (!process.env.QSTASH_CURRENT_SIGNING_KEY) {
+ throw new Error('qstash: QSTASH_CURRENT_SIGNING_KEY not set');
+ }
+ if (!_receiver) {
+ _receiver = new Receiver({
+ currentSigningKey: process.env.QSTASH_CURRENT_SIGNING_KEY,
+ nextSigningKey: process.env.QSTASH_NEXT_SIGNING_KEY || process.env.QSTASH_CURRENT_SIGNING_KEY,
+ });
+ }
+ return _receiver;
+}
+
+/**
+ * Publish a JSON job to QStash. Returns the message ID.
+ * @param {{
+ * url: string, // public HTTPS endpoint QStash will POST to
+ * body: any, // JSON-serializable payload
+ * delaySeconds?: number, // optional delay before delivery
+ * retries?: number, // default 3
+ * deduplicationId?: string,
+ * }} opts
+ */
+export async function publishJob({ url, body, delaySeconds, retries = 3, deduplicationId } = {}) {
+ if (!url) throw new Error('qstash.publishJob: url required');
+ const c = client();
+ const opts = {
+ url,
+ body: JSON.stringify(body || {}),
+ headers: { 'content-type': 'application/json' },
+ retries,
+ };
+ if (delaySeconds && delaySeconds > 0) opts.delay = delaySeconds;
+ if (deduplicationId) opts.deduplicationId = deduplicationId;
+ const r = await c.publishJSON(opts);
+ return r?.messageId || r?.id || null;
+}
+
+/**
+ * Verify that an inbound request was signed by QStash. Pass the raw body string
+ * (NOT a parsed object) and the value of the 'upstash-signature' header.
+ * Throws on failure so handlers can surface 401 immediately.
+ */
+export async function verifyQstashSignature({ signature, body, url }) {
+ if (!signature) throw new Error('qstash: missing signature header');
+ const r = receiver();
+ const ok = await r.verify({ signature, body, url });
+ if (!ok) throw new Error('qstash: signature verification failed');
+ return true;
+}
diff --git a/package-lock.json b/package-lock.json
index f414972e0..a1fc3d180 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -68,6 +68,7 @@
"@tetsuo-ai/protocol": "^0.2.0",
"@tetsuo-ai/sdk": "^1.4.0",
"@three-ws/solana-agent": "file:solana-agent-sdk",
+ "@upstash/qstash": "^2.11.0",
"@upstash/ratelimit": "^2.0.5",
"@upstash/redis": "^1.34.3",
"@vercel/og": "^0.11.1",
@@ -21396,6 +21397,17 @@
"node": ">=16.0.0"
}
},
+ "node_modules/@upstash/qstash": {
+ "version": "2.11.0",
+ "resolved": "https://registry.npmjs.org/@upstash/qstash/-/qstash-2.11.0.tgz",
+ "integrity": "sha512-AfPPxsUeOJCrxMQ9dkh1RZL40wgxCsUNFkxrbBSomC3U4j4qKFRawU8sDK+dqqH+sZFUS1biVM4GK46d5Tg2Vg==",
+ "license": "MIT",
+ "dependencies": {
+ "crypto-js": ">=4.2.0",
+ "jose": "^5.2.3",
+ "neverthrow": "^7.0.1"
+ }
+ },
"node_modules/@upstash/ratelimit": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/@upstash/ratelimit/-/ratelimit-2.0.8.tgz",
@@ -39223,6 +39235,15 @@
"node": ">= 0.4.0"
}
},
+ "node_modules/neverthrow": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/neverthrow/-/neverthrow-7.2.0.tgz",
+ "integrity": "sha512-iGBUfFB7yPczHHtA8dksKTJ9E8TESNTAx1UQWW6TzMF280vo9jdPYpLUXrMN1BCkPdHFdNG3fxOt2CUad8KhAw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/nipplejs": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/nipplejs/-/nipplejs-1.0.2.tgz",
diff --git a/package.json b/package.json
index 679b443a8..ae4b41ad3 100644
--- a/package.json
+++ b/package.json
@@ -148,6 +148,7 @@
"@tetsuo-ai/protocol": "^0.2.0",
"@tetsuo-ai/sdk": "^1.4.0",
"@three-ws/solana-agent": "file:solana-agent-sdk",
+ "@upstash/qstash": "^2.11.0",
"@upstash/ratelimit": "^2.0.5",
"@upstash/redis": "^1.34.3",
"@vercel/og": "^0.11.1",
diff --git a/pages/dashboard-next/index.html b/pages/dashboard-next/index.html
new file mode 100644
index 000000000..bf0ef8cb1
--- /dev/null
+++ b/pages/dashboard-next/index.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Overview · Dashboard · three.ws</title>
+ <meta name="robots" content="noindex" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/dashboard-next/shell.css" />
+ </head>
+ <body>
+ <script type="module" src="/src/dashboard-next/pages/home.js"></script>
+ </body>
+</html>
diff --git a/prompts/dashboard-next/01-home-overview.md b/prompts/dashboard-next/01-home-overview.md
new file mode 100644
index 000000000..60fec15d6
--- /dev/null
+++ b/prompts/dashboard-next/01-home-overview.md
@@ -0,0 +1,80 @@
+# dashboard-next 01 — Home / Overview
+
+**First**: read `prompts/dashboard-next/_shared.md`. It has the rules, foundation paths, helpers, smoke-test script, and commit guidance. Don't skip it.
+
+## Your slice
+
+The landing page at `/dashboard-next`. Replace the placeholder rendered by `src/dashboard-next/pages/home.js` with the real overview.
+
+## Files you own
+
+- `src/dashboard-next/pages/home.js` (overwrite the placeholder)
+- `pages/dashboard-next/index.html` (already exists — only touch it if you need to add an extra `<link>` for `/embed.js` to use `<threews-avatar>`)
+
+Do **not** touch any other file.
+
+## What the page shows
+
+**Hero strip — live 3D**
+The user's 3 most recently updated avatars rendered with `<threews-avatar avatar-id="…" bg="transparent" hide-chrome>` in 240×320 portrait cards. Each card has a hover lift and a hover overlay revealing "Open", "Embed", "Edit" links. If the user has zero avatars, replace the strip with one big "Create your first avatar" CTA card linking to `/create`.
+
+**KPI row — 4 cards**
+- This week's revenue (`/api/billing/revenue?from=<7 days ago>&granularity=day`, sum `usd_total`)
+- Widget views in the last 7 days (`/api/widgets` then sum `widgetStats(id)` for each; cache per session)
+- New transcripts to review (`/api/widgets` then sum unread counts; if endpoint doesn't expose unread, sum the 7-day count)
+- Active avatars (count from `/api/avatars`)
+
+Each card: small label, big number, sparkline (inline SVG, no library — draw the trend across the same window). Use the `--nxt-accent` for the sparkline stroke.
+
+**Recent activity — right column on lg+, full-width on md-**
+Last 8 events across the account. Pull from `/api/events?limit=8` if it exists, else stitch from `/api/widgets/:id/transcripts?limit=2` for each widget. Each row: icon (use a Unicode glyph or a tiny SVG), single-line description, `relTime(iso)`. Click → navigate to the relevant entity.
+
+**Quick actions — 2x2 grid below the hero**
+Big tappable cards (use `.dn-panel` with `cursor:pointer`): "Create avatar from selfie → /create", "Embed an agent → /dashboard-next/widgets", "View revenue → /dashboard-next/monetize", "Open API keys → /dashboard-next/api".
+
+## Layout (1440 viewport)
+
+```
+┌─────────────────────────────────────────────────────────────────────┐
+│ "Welcome back, <name>." + sub │
+├──────────────────────────────────┬──────────────────────────────────┤
+│ [avatar] [avatar] [avatar] │ Recent activity │
+│ hero strip — live 3D │ · widget view 3m ago │
+│ │ · payment 18m ago │
+├──────────────────────────────────┤ · transcript 1h ago │
+│ KPI · KPI · KPI · KPI │ · … │
+├──────────────────────────────────┤ │
+│ Quick actions (2x2) │ │
+│ · Create from selfie │ │
+│ · Embed an agent │ │
+│ · View revenue │ │
+│ · Open API keys │ │
+└──────────────────────────────────┴──────────────────────────────────┘
+```
+
+Below 1100px, stack the activity column under the main column.
+
+## States
+
+- **Loading** — every section starts with `.dn-skeleton` blocks matching its final shape. Don't render an empty page then pop content in.
+- **Empty** — if the user has 0 avatars / 0 widgets / 0 revenue, swap the corresponding card body for a `.dn-empty` block with a single CTA.
+- **Error** — if any fetch throws an `ApiError` other than 401 (which `requireUser` already handles), surface `err.message` in that section's panel as a small red note. Do not blank the whole page.
+
+## Real-time touch
+
+Once the page is mounted, set up a 30s `setInterval` that re-fetches the KPI row and the activity feed. Clear it on `beforeunload`. Animate any KPI number change with a 400ms tween from old → new (CSS counter or rAF). The setInterval is fine — it's real polling, not fake loading.
+
+## Smoke test
+
+Hit `/dashboard-next` on the dev server, capture `/tmp/dn-home.png`, `Read` it, confirm:
+- Hero strip shows 3 spinning avatars (or the create CTA if user has none)
+- KPI numbers are real (not `0` from a failed fetch)
+- Activity feed has real entries (or empty state)
+- No console errors
+- Sidebar shows "Overview" highlighted
+
+## Done = reply with
+
+1. `/tmp/dn-home.png`
+2. Commit SHA (pushed to `origin` AND `threeD`)
+3. Any endpoint that didn't exist and forced a workaround
diff --git a/prompts/dashboard-next/01-home.md b/prompts/dashboard-next/01-home.md
new file mode 100644
index 000000000..271417c42
--- /dev/null
+++ b/prompts/dashboard-next/01-home.md
@@ -0,0 +1,66 @@
+# 01 — Home / Overview page
+
+**Read `prompts/dashboard-next/_shared.md` first.** It contains the project rules, foundation paths, atomic classes, smoke-test recipe, and commit instructions. Then build the slice below.
+
+## Your slice
+
+Build the Overview page at **`/dashboard-next/`**. This replaces the placeholder at [src/dashboard-next/pages/home.js](src/dashboard-next/pages/home.js) with the real product.
+
+This is the page users land on when they hit `/dashboard-next`. It is the hero of the redesign — it must feel premium and 3D-native, not like a generic admin panel.
+
+## Layout (top to bottom)
+
+1. **Hero heading row** — `<h1 class="dn-h1">` with the user's first name + greeting that varies by time-of-day ("Good morning, …", "Good evening, …"). One-line subheading underneath.
+
+2. **3D avatar strip** — horizontally-scrolling rail of the user's most-recent **5–8 avatars**, each rendered as a live `<threews-avatar avatar-id="…" hide-chrome bg="transparent">` web component inside a 240×320 portrait card. The web component is loaded by including `<script src="/embed.js"></script>` once in the page HTML. Each card shows the avatar name underneath and is clickable → navigates to `/avatars/<id>` (the existing avatar-page route, not `/dashboard-next/avatars/<id>`). Empty state: the `.dn-empty` block with CTA "Create your first avatar" → `/create`.
+
+3. **KPI row** — four `.dn-panel` cards in a CSS grid (`repeat(auto-fit, minmax(180px, 1fr))`):
+ - **Avatars** (count) — `/api/avatars?limit=1` returns `total` or count the page; fall back to length
+ - **Widgets** (count) — `/api/widgets`
+ - **30-day revenue** (`formatUsdc`) — `/api/billing/revenue?from=<30d ago iso>&to=<now iso>&granularity=day`, sum the points
+ - **Active subscriptions** (count) — pick the cheapest endpoint that returns this; if none exists, leave the KPI labelled "Subscriptions" with `—` and a tooltip explaining no endpoint yet
+ Each card has a tiny sparkline at the bottom built from the relevant series (revenue card uses the revenue series directly; counts can show a 7-bar microbar from past activity — if no per-day series exists, omit the sparkline rather than fake one).
+
+4. **Quick actions grid** — six small cards in two rows, each a CSS-grid item:
+ - "Create avatar from selfie" → `/create/selfie`
+ - "Upload a GLB" → `/create` (or `/dashboard-next/avatars` once that lands)
+ - "Make a widget" → `/widget-studio`
+ - "Issue an API key" → `/dashboard-next/api`
+ - "Set up an agent" → `/dashboard-next/account`
+ - "View revenue" → `/dashboard-next/monetize`
+ Use the inline-SVG icons already in `src/dashboard-next/nav.js` (`ICONS`).
+
+5. **Recent activity preview** — a `.dn-panel` showing the **last 6 events** from `/api/events?limit=6` (or the dashboard.js endpoint that already powers Activity). Each row: icon, plain-English summary, `relTime(iso)`. Empty state inside the panel says "No activity yet — your first widget view will show up here." Link at the bottom: "Open full activity →" which dispatches `window.dispatchEvent(new CustomEvent('dn:drawer:toggled', { detail: { open: true } }))` *and* sets the topbar drawer toggle. Simpler: read `localStorage.setItem('dn:drawer:open', '1')` then click the toggle button programmatically.
+
+## Files you create / modify
+
+- **Replace** `src/dashboard-next/pages/home.js` (already exists as placeholder)
+- **Modify** `pages/dashboard-next/index.html` — add `<script src="/embed.js"></script>` before the home.js module script
+- That's it. Do not touch any other file.
+
+## Data wiring rules
+
+- Use `requireUser()` first. If the user has zero avatars, render the empty-state CTA in the 3D strip rather than empty cards.
+- KPI cards each fetch independently and show their own `.dn-skeleton` until data lands.
+- A single failed KPI fetch must not break the others — wrap each in `try/catch` and show `—` with a tiny "couldn't load" tooltip via `title="…"`.
+- Hide the activity panel entirely (don't show an error) if `/api/events` returns 404 — that's a known unbuilt endpoint, not an error worth surfacing.
+
+## Visual quality bar
+
+- The hero 3D strip is the visual signature of the page. Each card should have a soft inner glow (`box-shadow: inset 0 -40px 60px -30px var(--nxt-accent-soft)`) and a 1px stroke (`--nxt-stroke`). Rounded corners `var(--nxt-radius)`. On hover, scale to 1.02 over 200ms.
+- KPI numbers in `--nxt-ink`, 28px, font-weight 600, letter-spacing -0.02em. The label above in `--nxt-ink-dim`, 11.5px, uppercase, letter-spacing 0.08em.
+- Quick-action cards have a subtle hover treatment (`background: rgba(255,255,255,0.04)` → `0.07` on hover). Icon left-aligned in `--nxt-accent`, label right.
+
+## Verification
+
+Smoke-test screenshot at `/tmp/dn-home.png` per the recipe in `_shared.md`. Open the image and verify:
+- 3D avatars actually render (you'll see faces / models, not just empty cards)
+- KPIs show real numbers (or `—` if no data, never `NaN` or `undefined`)
+- Quick-action grid is six items, no broken icons
+- Activity panel either shows real events or is hidden
+
+Then `npx vite build` must succeed, and `npx vitest run tests/api/widgets.test.js tests/api/widget-knowledge-helpers.test.js` must pass (defensive check that you didn't break anything).
+
+## Commit message
+
+`dashboard-next: overview page — 3D avatar strip + KPIs + activity preview`
diff --git a/prompts/dashboard-next/_shared.md b/prompts/dashboard-next/_shared.md
new file mode 100644
index 000000000..3aed9f1ec
--- /dev/null
+++ b/prompts/dashboard-next/_shared.md
@@ -0,0 +1,172 @@
+# dashboard-next — shared briefing
+
+You're a senior engineer working in the **three.ws** monorepo (Vite + vanilla JS + Vercel serverless). Read `/CLAUDE.md` before you touch any code — the project rules below are non-negotiable.
+
+## Project rules (hard, non-negotiable)
+
+1. **No mocks, no fake data, no placeholder arrays.** Use real `/api/*` endpoints. Real APIs, real data.
+2. **No TODO / FIXME / XXX / commented-out code.** Finish what you start.
+3. **No `throw new Error("not implemented")`, no fake `setTimeout` progress bars.**
+4. **Definition of done:** code written, wired, exercised in a real browser (`npx vite --port 3010`), no console errors, screenshot captured and verified, `npx vite build` green, `npx vitest run` passes.
+5. **Push to BOTH remotes when you commit.** `origin` (canonical) AND `threeD` (mirror). See the "Commit + push" section below.
+6. **Tone:** professional, terse. No emojis in code or commits.
+
+## What you're building
+
+A new dashboard prototype at `/dashboard-next`. The shell, design tokens, sidebar, topbar, drawer stub, palette stub, and route registry are already on disk. You build **exactly one self-contained slice** end-to-end. Other slices are being built by other agents in parallel — stay in your lane and you'll never conflict.
+
+## Foundation already committed
+
+- `pages/dashboard-next/index.html` — page template (overview page entry, JS at `src/dashboard-next/pages/home.js`)
+- `public/dashboard-next/tokens.css` — `--nxt-*` design tokens
+- `public/dashboard-next/shell.css` — layout grid + atomic classes
+- `src/dashboard-next/shell.js` — exports `mountShell()` which renders chrome and returns the `<main>` content slot
+- `src/dashboard-next/api.js` — exports `get/post/put/del/patch`, `requireUser`, `getMe`, `initialsOf`, `relTime`, `formatUsdc`, `esc`, `ApiError`
+- `src/dashboard-next/nav.js` — sidebar route registry (treat as read-only)
+- `src/dashboard-next/components/{sidebar,topbar,drawer,palette}.js` — read-only unless your prompt explicitly tells you to replace one
+- `src/dashboard-next/pages/home.js` — minimal placeholder home page
+
+Vite's input list auto-discovers any `pages/dashboard-next/*.html` you add — no central registry to update.
+
+## Atomic classes (reuse, don't reinvent)
+
+| Class | Purpose |
+|---|---|
+| `.dn-panel` | Bordered glass card |
+| `.dn-panel-title` / `.dn-panel-sub` | Card title + subtitle |
+| `.dn-h1` / `.dn-h1-sub` | Page hero heading + subheading |
+| `.dn-btn` + `.primary` / `.ghost` / `.danger` | Button variants |
+| `.dn-tag` + `.success` / `.warn` / `.danger` | Pill labels |
+| `.dn-skeleton` | Loading shimmer — set width/height inline |
+| `.dn-empty` | Centered empty-state block (use child `<h3>` + `<p>`) |
+
+## Page boilerplate
+
+Every new page goes in two files:
+
+`pages/dashboard-next/<slug>.html`:
+```html
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>… · Dashboard · three.ws</title>
+ <meta name="robots" content="noindex" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/dashboard-next/shell.css" />
+ </head>
+ <body>
+ <script type="module" src="/src/dashboard-next/pages/<slug>.js"></script>
+ </body>
+</html>
+```
+
+`src/dashboard-next/pages/<slug>.js`:
+```js
+import { mountShell } from '../shell.js';
+import { requireUser, get, esc, relTime } from '../api.js';
+
+(async function boot() {
+ const main = await mountShell();
+ const me = await requireUser(); // redirects if signed out
+
+ main.innerHTML = `
+ <h1 class="dn-h1">…</h1>
+ <p class="dn-h1-sub">…</p>
+ <div data-slot="content"></div>
+ `;
+
+ await renderContent(main.querySelector('[data-slot="content"]'), me);
+})();
+
+async function renderContent(host, me) {
+ // skeleton first, then real fetch, then render
+}
+```
+
+## Real-data sources
+
+Read `/src/dashboard/dashboard.js` for the canonical API patterns this repo uses (cursor pagination, error envelopes, CSRF). Endpoints you'll likely touch:
+
+- `/api/auth/me`
+- `/api/avatars` (list with `cursor`, `limit`), `/api/avatars/:id` (GET/PATCH/DELETE)
+- `/api/widgets`, `/api/widgets/:id`, `/api/widgets/:id/stats`, `/api/widgets/:id/transcripts`
+- `/api/agents`, `/api/agents/:id`, `/api/agents/me`
+- `/api/keys` (GET/POST/DELETE)
+- `/api/billing/revenue?from=…&to=…&granularity=day`
+- `/api/billing/usage`
+- `/api/animations`, `/api/animations/presign`
+- Activity / events: `/api/events?since=…` (poll) or `/api/events/stream` (SSE) — check existing dashboard.js for the actual path
+
+If an endpoint doesn't exist yet, prefer extending an existing endpoint to inventing a new one. Open an issue mentally and DM the user before adding new server routes.
+
+## Live 3D previews
+
+The web component `<threews-avatar>` is loaded automatically when you do `<script src="/embed.js"></script>` on the page. Use:
+
+```html
+<threews-avatar avatar-id="abc..." bg="transparent" hide-chrome></threews-avatar>
+```
+
+It renders a live GLB at the user's avatar with built-in idle anim. Use it for hero thumbnails on the home page and avatars grid.
+
+## Smoke-test (mandatory before reporting done)
+
+```bash
+# Start dev server (skip if already running)
+nohup npx vite --port 3010 --host 127.0.0.1 > /tmp/dn-dev.log 2>&1 &
+
+# Wait for it
+until curl -sf -o /dev/null http://127.0.0.1:3010/dashboard-next; do sleep 2; done
+
+# Headless screenshot script
+cat > scripts/_dn-shot.mjs <<'EOF'
+import { chromium } from 'playwright';
+const url = process.argv[2]; const out = process.argv[3];
+const b = await chromium.launch({ args: ['--use-gl=swiftshader','--no-sandbox'] });
+const p = await (await b.newContext({ viewport: { width: 1440, height: 900 } })).newPage();
+const errs = [];
+p.on('pageerror', e => errs.push('PAGEERROR ' + e.message.slice(0, 200)));
+p.on('console', m => { if (m.type() === 'error') errs.push('[err] ' + m.text().slice(0, 200)); });
+p.on('requestfailed', r => errs.push('REQ FAIL ' + r.url() + ' ' + r.failure()?.errorText));
+await p.goto(url, { waitUntil: 'networkidle', timeout: 60000 });
+await p.waitForSelector('.dn-shell .dn-rail-item', { timeout: 20000 });
+await p.screenshot({ path: out, fullPage: false });
+console.log('saved', out);
+if (errs.length) { console.log('errors:'); for (const e of errs) console.log(' ' + e); process.exit(1); }
+await b.close();
+EOF
+
+node scripts/_dn-shot.mjs http://127.0.0.1:3010/dashboard-next/<your-page> /tmp/dn-<name>.png
+rm scripts/_dn-shot.mjs
+```
+
+Then `Read /tmp/dn-<name>.png` so you actually see what you shipped. If something looks wrong, fix it before claiming done. Zero console errors required.
+
+## Commit + push (both remotes — per CLAUDE.md)
+
+```bash
+git add -A
+git status # double-check you only touched your slice
+git diff --cached | head -200
+
+git commit -m "$(cat <<'EOF'
+dashboard-next: <one-line title>
+
+<2-3 lines: what + why>
+
+Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
+EOF
+)"
+
+git push origin main
+git push threeD main
+```
+
+Do **not** force-push. Do **not** skip hooks. If a push to `threeD` is rejected because someone else's commit landed first, `git pull --rebase origin main` then push both again.
+
+## When you're done
+
+Reply with: (1) the screenshot path, (2) the commit SHA, (3) any endpoints you hit that didn't exist (so the user can decide whether to add them later). Nothing else.
diff --git a/public/dashboard-next/shell.css b/public/dashboard-next/shell.css
new file mode 100644
index 000000000..c9b196dbf
--- /dev/null
+++ b/public/dashboard-next/shell.css
@@ -0,0 +1,455 @@
+/* ==========================================================================
+ dashboard-next — shell layout
+ Three-column grid: [sidebar | main | drawer] on xl, [sidebar | main]
+ on lg, single-column with bottom tab on sm. Topbar is sticky.
+ Pages render into <main id="dn-main"> via their own module.
+ ========================================================================== */
+
+@import url('/dashboard-next/tokens.css');
+
+* { box-sizing: border-box; }
+
+html, body {
+ margin: 0;
+ height: 100%;
+ color: var(--nxt-ink);
+ background: var(--nxt-bg-0);
+ font: 14px/1.5 'Inter', system-ui, -apple-system, sans-serif;
+}
+
+body {
+ background:
+ radial-gradient(ellipse 70% 50% at 12% 0%, rgba(154, 124, 255, 0.06) 0%, transparent 65%),
+ radial-gradient(ellipse 50% 40% at 100% 100%, rgba(109, 193, 255, 0.04) 0%, transparent 60%),
+ var(--nxt-bg-0);
+ min-height: 100vh;
+ overflow-x: hidden;
+}
+
+a { color: inherit; text-decoration: none; }
+button { font: inherit; }
+
+/* ── Shell grid ─────────────────────────────────────────────────────────── */
+
+.dn-shell {
+ display: grid;
+ grid-template-columns: var(--dn-rail-w) minmax(0, 1fr);
+ grid-template-rows: var(--dn-topbar-h) 1fr;
+ grid-template-areas:
+ 'rail topbar'
+ 'rail main';
+ min-height: 100vh;
+}
+
+.dn-shell[data-drawer-open='true'] {
+ grid-template-columns: var(--dn-rail-w) minmax(0, 1fr) var(--dn-drawer-w);
+ grid-template-areas:
+ 'rail topbar topbar'
+ 'rail main drawer';
+}
+
+.dn-shell[data-rail-collapsed='true'] {
+ grid-template-columns: var(--dn-rail-w-collapsed) minmax(0, 1fr);
+}
+
+.dn-shell[data-rail-collapsed='true'][data-drawer-open='true'] {
+ grid-template-columns: var(--dn-rail-w-collapsed) minmax(0, 1fr) var(--dn-drawer-w);
+}
+
+/* ── Sidebar rail ───────────────────────────────────────────────────────── */
+
+.dn-rail {
+ grid-area: rail;
+ border-right: 1px solid var(--nxt-stroke);
+ background: linear-gradient(180deg, rgba(20, 21, 28, 0.6), rgba(12, 13, 18, 0.4));
+ backdrop-filter: blur(20px);
+ -webkit-backdrop-filter: blur(20px);
+ display: flex;
+ flex-direction: column;
+ position: sticky;
+ top: 0;
+ height: 100vh;
+ overflow: hidden;
+}
+
+.dn-rail-head {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ height: var(--dn-topbar-h);
+ padding: 0 16px;
+ border-bottom: 1px solid var(--nxt-stroke);
+ flex-shrink: 0;
+}
+
+.dn-rail-head img { height: 22px; width: auto; display: block; }
+.dn-rail-head .dn-rail-mark { display: none; }
+[data-rail-collapsed='true'] .dn-rail-head .dn-rail-full { display: none; }
+[data-rail-collapsed='true'] .dn-rail-head .dn-rail-mark { display: block; }
+
+.dn-rail-scroll {
+ flex: 1;
+ overflow-y: auto;
+ padding: 14px 10px;
+ scrollbar-width: thin;
+ scrollbar-color: var(--nxt-stroke-strong) transparent;
+}
+.dn-rail-scroll::-webkit-scrollbar { width: 6px; }
+.dn-rail-scroll::-webkit-scrollbar-thumb {
+ background: var(--nxt-stroke-strong);
+ border-radius: 999px;
+}
+
+.dn-rail-group { margin-bottom: 18px; }
+.dn-rail-group-label {
+ font-size: 11px;
+ font-weight: 600;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--nxt-ink-fade);
+ padding: 0 10px 6px;
+}
+[data-rail-collapsed='true'] .dn-rail-group-label { opacity: 0; pointer-events: none; }
+
+.dn-rail-item {
+ display: flex;
+ align-items: center;
+ gap: 11px;
+ padding: 8px 10px;
+ border-radius: 9px;
+ color: var(--nxt-ink-dim);
+ font-size: 13.5px;
+ transition: background 0.12s ease, color 0.12s ease;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.dn-rail-item:hover { color: var(--nxt-ink); background: rgba(255, 255, 255, 0.04); }
+.dn-rail-item[aria-current='page'] {
+ color: var(--nxt-ink);
+ background: var(--nxt-accent-soft);
+ box-shadow: inset 2px 0 0 var(--nxt-accent);
+}
+.dn-rail-item-icon {
+ width: 18px;
+ height: 18px;
+ flex-shrink: 0;
+ display: grid;
+ place-items: center;
+ color: var(--nxt-ink-fade);
+}
+.dn-rail-item[aria-current='page'] .dn-rail-item-icon { color: var(--nxt-accent-strong); }
+[data-rail-collapsed='true'] .dn-rail-item-text { display: none; }
+[data-rail-collapsed='true'] .dn-rail-item { justify-content: center; padding: 10px; }
+
+.dn-rail-foot {
+ padding: 12px 10px;
+ border-top: 1px solid var(--nxt-stroke);
+ flex-shrink: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+/* ── Topbar ─────────────────────────────────────────────────────────────── */
+
+.dn-topbar {
+ grid-area: topbar;
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ display: flex;
+ align-items: center;
+ gap: 14px;
+ padding: 0 var(--dn-gutter);
+ border-bottom: 1px solid var(--nxt-stroke);
+ background: var(--nxt-glass-strong);
+ backdrop-filter: blur(20px);
+ -webkit-backdrop-filter: blur(20px);
+}
+
+.dn-topbar-crumb {
+ font-size: 14px;
+ color: var(--nxt-ink-dim);
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+.dn-topbar-crumb strong { color: var(--nxt-ink); font-weight: 600; }
+
+.dn-topbar-spacer { flex: 1; }
+
+.dn-topbar-search {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 7px 12px;
+ border-radius: var(--nxt-radius-pill);
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid var(--nxt-stroke);
+ color: var(--nxt-ink-dim);
+ cursor: pointer;
+ font-size: 13px;
+ transition: background 0.12s ease;
+ min-width: 200px;
+ justify-content: space-between;
+}
+.dn-topbar-search:hover { background: rgba(255, 255, 255, 0.07); color: var(--nxt-ink); }
+.dn-topbar-search kbd {
+ font-family: 'JetBrains Mono', ui-monospace, monospace;
+ font-size: 11px;
+ padding: 1px 6px;
+ border-radius: 4px;
+ background: rgba(255, 255, 255, 0.07);
+ border: 1px solid var(--nxt-stroke);
+ color: var(--nxt-ink-fade);
+}
+
+.dn-topbar-btn {
+ background: transparent;
+ border: 1px solid transparent;
+ color: var(--nxt-ink-dim);
+ cursor: pointer;
+ padding: 7px 9px;
+ border-radius: var(--nxt-radius-sm);
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ font-size: 13px;
+ transition: all 0.12s ease;
+}
+.dn-topbar-btn:hover { color: var(--nxt-ink); background: rgba(255, 255, 255, 0.04); }
+.dn-topbar-btn[aria-pressed='true'] {
+ color: var(--nxt-ink);
+ background: var(--nxt-accent-soft);
+ border-color: var(--nxt-accent-soft);
+}
+
+.dn-topbar-user {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ padding: 4px 10px 4px 4px;
+ border-radius: var(--nxt-radius-pill);
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid var(--nxt-stroke);
+ cursor: pointer;
+ color: var(--nxt-ink);
+ font-size: 13px;
+}
+.dn-topbar-user:hover { background: rgba(255, 255, 255, 0.07); }
+.dn-topbar-user-avatar {
+ width: 26px;
+ height: 26px;
+ border-radius: 999px;
+ background: linear-gradient(135deg, var(--nxt-accent), #ff7ab8);
+ display: grid;
+ place-items: center;
+ color: #fff;
+ font-size: 12px;
+ font-weight: 600;
+}
+
+/* ── Main content area ─────────────────────────────────────────────────── */
+
+.dn-main {
+ grid-area: main;
+ overflow-y: auto;
+ overflow-x: hidden;
+ scroll-behavior: smooth;
+}
+.dn-main-inner {
+ max-width: var(--dn-content-max);
+ margin: 0 auto;
+ padding: 28px var(--dn-gutter) 80px;
+}
+
+/* ── Drawer (right rail) ───────────────────────────────────────────────── */
+
+.dn-drawer {
+ grid-area: drawer;
+ border-left: 1px solid var(--nxt-stroke);
+ background: rgba(20, 21, 28, 0.55);
+ backdrop-filter: blur(20px);
+ -webkit-backdrop-filter: blur(20px);
+ overflow-y: auto;
+ display: none;
+}
+.dn-shell[data-drawer-open='true'] .dn-drawer { display: block; }
+
+/* ── Cards / panels — shared atoms ─────────────────────────────────────── */
+
+.dn-panel {
+ background: linear-gradient(180deg, rgba(20, 21, 28, 0.7), rgba(14, 15, 22, 0.5));
+ border: 1px solid var(--nxt-stroke);
+ border-radius: var(--nxt-radius);
+ padding: 18px;
+}
+.dn-panel-title {
+ margin: 0 0 4px;
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--nxt-ink);
+ letter-spacing: -0.005em;
+}
+.dn-panel-sub {
+ margin: 0 0 14px;
+ font-size: 12.5px;
+ color: var(--nxt-ink-dim);
+}
+
+.dn-h1 {
+ font-size: 26px;
+ font-weight: 600;
+ letter-spacing: -0.02em;
+ margin: 0 0 6px;
+ color: var(--nxt-ink);
+}
+.dn-h1-sub {
+ color: var(--nxt-ink-dim);
+ font-size: 14px;
+ margin: 0 0 22px;
+}
+
+.dn-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ padding: 8px 14px;
+ font-size: 13px;
+ font-weight: 500;
+ border-radius: var(--nxt-radius-sm);
+ border: 1px solid var(--nxt-stroke);
+ background: rgba(255, 255, 255, 0.04);
+ color: var(--nxt-ink);
+ cursor: pointer;
+ transition: all 0.12s ease;
+}
+.dn-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--nxt-stroke-strong); }
+.dn-btn.primary {
+ background: var(--nxt-accent);
+ border-color: var(--nxt-accent);
+ color: #0c0512;
+ font-weight: 600;
+}
+.dn-btn.primary:hover { background: var(--nxt-accent-strong); border-color: var(--nxt-accent-strong); }
+.dn-btn.ghost { background: transparent; border-color: transparent; }
+.dn-btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }
+.dn-btn.danger {
+ border-color: rgba(255, 107, 138, 0.25);
+ color: var(--nxt-danger);
+ background: rgba(255, 107, 138, 0.08);
+}
+.dn-btn.danger:hover { background: rgba(255, 107, 138, 0.16); }
+
+.dn-tag {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 9px;
+ border-radius: var(--nxt-radius-pill);
+ font-size: 11.5px;
+ font-weight: 500;
+ background: rgba(255, 255, 255, 0.05);
+ border: 1px solid var(--nxt-stroke);
+ color: var(--nxt-ink-dim);
+}
+.dn-tag.success { background: rgba(78, 195, 138, 0.12); color: var(--nxt-success); border-color: rgba(78, 195, 138, 0.2); }
+.dn-tag.warn { background: rgba(255, 180, 84, 0.12); color: var(--nxt-warn); border-color: rgba(255, 180, 84, 0.2); }
+.dn-tag.danger { background: rgba(255, 107, 138, 0.12); color: var(--nxt-danger); border-color: rgba(255, 107, 138, 0.2); }
+
+.dn-skeleton {
+ background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.03) 100%);
+ background-size: 200% 100%;
+ animation: dn-shimmer 1.4s ease-in-out infinite;
+ border-radius: var(--nxt-radius-sm);
+}
+@keyframes dn-shimmer {
+ 0% { background-position: 200% 0; }
+ 100% { background-position: -200% 0; }
+}
+
+/* ── Empty states ──────────────────────────────────────────────────────── */
+
+.dn-empty {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 14px;
+ padding: 48px 24px;
+ border: 1px dashed var(--nxt-stroke);
+ border-radius: var(--nxt-radius);
+ text-align: center;
+ color: var(--nxt-ink-dim);
+}
+.dn-empty h3 {
+ margin: 0;
+ color: var(--nxt-ink);
+ font-size: 16px;
+ font-weight: 600;
+ letter-spacing: -0.005em;
+}
+.dn-empty p { margin: 0; max-width: 380px; font-size: 13.5px; }
+
+/* ── Responsive ────────────────────────────────────────────────────────── */
+
+@media (max-width: 1280px) {
+ .dn-shell[data-drawer-open='true'] {
+ grid-template-columns: var(--dn-rail-w) minmax(0, 1fr);
+ grid-template-areas:
+ 'rail topbar'
+ 'rail main';
+ }
+ .dn-drawer {
+ position: fixed;
+ top: var(--dn-topbar-h);
+ right: 0;
+ bottom: 0;
+ width: var(--dn-drawer-w);
+ max-width: 92vw;
+ z-index: 50;
+ }
+}
+
+@media (max-width: 880px) {
+ .dn-shell, .dn-shell[data-rail-collapsed='true'] {
+ grid-template-columns: 1fr;
+ grid-template-rows: var(--dn-topbar-h) 1fr 64px;
+ grid-template-areas:
+ 'topbar'
+ 'main'
+ 'rail';
+ }
+ .dn-rail {
+ flex-direction: row;
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ height: 64px;
+ border-right: none;
+ border-top: 1px solid var(--nxt-stroke);
+ z-index: 20;
+ }
+ .dn-rail-head, .dn-rail-foot { display: none; }
+ .dn-rail-scroll {
+ display: flex;
+ flex-direction: row;
+ padding: 6px 8px;
+ gap: 4px;
+ justify-content: space-around;
+ overflow-x: auto;
+ }
+ .dn-rail-group { display: contents; }
+ .dn-rail-group-label { display: none; }
+ .dn-rail-item {
+ flex-direction: column;
+ font-size: 10.5px;
+ padding: 6px 8px;
+ gap: 3px;
+ min-width: 56px;
+ justify-content: center;
+ }
+ .dn-rail-item[aria-current='page'] { box-shadow: none; background: var(--nxt-accent-soft); }
+ .dn-rail-item-text { display: block !important; }
+ .dn-main-inner { padding: 18px 16px 24px; }
+}
diff --git a/public/dashboard-next/tokens.css b/public/dashboard-next/tokens.css
new file mode 100644
index 000000000..8611daebb
--- /dev/null
+++ b/public/dashboard-next/tokens.css
@@ -0,0 +1,39 @@
+/* ==========================================================================
+ dashboard-next — design tokens
+ Reuses the --nxt-* palette established by /app-next so the prototype
+ feels like one product. Anything dashboard-shell specific (rail widths,
+ drawer width, content gutters) lives here.
+ ========================================================================== */
+
+:root {
+ /* Palette — mirrors app-next.css. Edit there first if it's a global change. */
+ --nxt-bg-0: #050608;
+ --nxt-bg-1: #0c0d12;
+ --nxt-bg-2: #14151c;
+ --nxt-bg-3: #1c1d27;
+ --nxt-ink: #e7e8ec;
+ --nxt-ink-dim: #9ca0aa;
+ --nxt-ink-fade: #6b6f78;
+ --nxt-accent: #9a7cff;
+ --nxt-accent-soft: rgba(154, 124, 255, 0.18);
+ --nxt-accent-strong: #b39bff;
+ --nxt-glass: rgba(14, 15, 22, 0.55);
+ --nxt-glass-strong: rgba(14, 15, 22, 0.82);
+ --nxt-stroke: rgba(255, 255, 255, 0.08);
+ --nxt-stroke-strong: rgba(255, 255, 255, 0.14);
+ --nxt-success: #4ec38a;
+ --nxt-warn: #ffb454;
+ --nxt-danger: #ff6b8a;
+
+ --nxt-radius: 14px;
+ --nxt-radius-sm: 10px;
+ --nxt-radius-pill: 999px;
+
+ /* Dashboard chrome dimensions */
+ --dn-rail-w: 232px; /* sidebar width on >= md */
+ --dn-rail-w-collapsed: 64px; /* sidebar width when user collapses it */
+ --dn-drawer-w: 360px; /* right drawer width on >= xl */
+ --dn-topbar-h: 56px;
+ --dn-content-max: 1280px;
+ --dn-gutter: 24px;
+}
diff --git a/src/dashboard-next/api.js b/src/dashboard-next/api.js
new file mode 100644
index 000000000..93f803f72
--- /dev/null
+++ b/src/dashboard-next/api.js
@@ -0,0 +1,131 @@
+// dashboard-next — minimal JSON fetch helper.
+//
+// Wraps fetch with credentials, JSON encode/decode, CSRF token, and a typed
+// error class so page modules can `try { ... } catch (err) { if (err.code === 'unauthorized') ... }`.
+//
+// Stays small on purpose. The page modules import this for their CRUD calls.
+
+let csrfPromise = null;
+
+async function getCsrf() {
+ if (!csrfPromise) {
+ csrfPromise = fetch('/api/csrf-token', { credentials: 'include' })
+ .then((r) => (r.ok ? r.json() : null))
+ .then((j) => j?.token || null)
+ .catch(() => null);
+ }
+ return csrfPromise;
+}
+
+export class ApiError extends Error {
+ constructor(status, code, message, body) {
+ super(message || code || `HTTP ${status}`);
+ this.name = 'ApiError';
+ this.status = status;
+ this.code = code;
+ this.body = body;
+ }
+}
+
+export async function api(method, path, body) {
+ const headers = { accept: 'application/json' };
+ let payload;
+ if (body !== undefined) {
+ headers['content-type'] = 'application/json';
+ payload = JSON.stringify(body);
+ }
+ if (method !== 'GET' && method !== 'HEAD') {
+ const csrf = await getCsrf();
+ if (csrf) headers['x-csrf-token'] = csrf;
+ }
+ const res = await fetch(path, {
+ method,
+ headers,
+ body: payload,
+ credentials: 'include',
+ });
+ const text = await res.text();
+ let data = null;
+ if (text) {
+ try { data = JSON.parse(text); }
+ catch { data = text; }
+ }
+ if (!res.ok) {
+ const code = (data && typeof data === 'object' && data.error) || `http_${res.status}`;
+ const message = (data && typeof data === 'object' && (data.error_description || data.message)) || res.statusText;
+ throw new ApiError(res.status, code, message, data);
+ }
+ return data;
+}
+
+export const get = (path) => api('GET', path);
+export const post = (path, body) => api('POST', path, body);
+export const put = (path, body) => api('PUT', path, body);
+export const del = (path) => api('DELETE', path);
+export const patch = (path, body) => api('PATCH', path, body);
+
+// ── User session ───────────────────────────────────────────────────────────
+
+let mePromise = null;
+export function getMe() {
+ if (!mePromise) {
+ mePromise = get('/api/auth/me').catch((err) => {
+ if (err.status === 401) return null;
+ throw err;
+ });
+ }
+ return mePromise;
+}
+
+/** Redirect to /login if the user isn't signed in. Returns the user record. */
+export async function requireUser() {
+ const me = await getMe();
+ if (!me) {
+ const ret = encodeURIComponent(location.pathname + location.search);
+ location.href = `/login?return=${ret}`;
+ throw new Error('redirecting');
+ }
+ return me;
+}
+
+// ── Small UI helpers used across pages ────────────────────────────────────
+
+/** Display name → 1-2 letter avatar initials. */
+export function initialsOf(user) {
+ if (!user) return '?';
+ const src = user.display_name || user.handle || user.email || '?';
+ const parts = String(src).split(/\s+|@/).filter(Boolean);
+ const first = parts[0]?.[0] || '?';
+ const second = parts[1]?.[0] || '';
+ return (first + second).toUpperCase().slice(0, 2);
+}
+
+/** Format an atomics (6-decimal USDC) integer as "$1,234.56". */
+export function formatUsdc(atomics) {
+ const n = Number(atomics) / 1_000_000;
+ if (!Number.isFinite(n)) return '$0.00';
+ return n.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
+}
+
+/** Relative time formatter — "3m ago", "2d ago", etc. */
+export function relTime(iso) {
+ const t = new Date(iso).getTime();
+ if (!Number.isFinite(t)) return '';
+ const diff = Date.now() - t;
+ const s = Math.round(diff / 1000);
+ if (s < 60) return `${s}s ago`;
+ const m = Math.round(s / 60);
+ if (m < 60) return `${m}m ago`;
+ const h = Math.round(m / 60);
+ if (h < 48) return `${h}h ago`;
+ const d = Math.round(h / 24);
+ if (d < 14) return `${d}d ago`;
+ return new Date(iso).toLocaleDateString();
+}
+
+/** Escape arbitrary text for safe innerHTML insertion. */
+export function esc(s) {
+ return String(s ?? '').replace(/[&<>"']/g, (c) => ({
+ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;',
+ })[c]);
+}
diff --git a/src/dashboard-next/components/drawer.js b/src/dashboard-next/components/drawer.js
new file mode 100644
index 000000000..7123e29b9
--- /dev/null
+++ b/src/dashboard-next/components/drawer.js
@@ -0,0 +1,34 @@
+// dashboard-next — activity drawer slot (foundation skeleton).
+//
+// This file ships the markup + open/close plumbing only. Prompt #9 replaces
+// the empty body with a live activity feed (server events / polling, real
+// data). Until then the drawer renders a "Coming soon" placeholder so the
+// shell layout is testable end-to-end.
+
+import { esc } from '../api.js';
+
+export function renderDrawer() {
+ return `
+ <aside class="dn-drawer" data-component="drawer" aria-label="Activity">
+ <div style="padding:18px 18px 12px;border-bottom:1px solid var(--nxt-stroke);display:flex;align-items:center;justify-content:space-between">
+ <div>
+ <div style="font-size:13px;font-weight:600;color:var(--nxt-ink)">Activity</div>
+ <div style="font-size:12px;color:var(--nxt-ink-dim);margin-top:2px">Recent events across your account</div>
+ </div>
+ <button type="button" class="dn-btn ghost" data-action="toggle-drawer" aria-label="Close activity drawer" style="padding:5px 8px">
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"><path d="M3 3l8 8M11 3l-8 8"/></svg>
+ </button>
+ </div>
+ <div data-slot="drawer-body" style="padding:14px 16px">
+ ${esc('')}
+ <div class="dn-empty" style="padding:36px 12px">
+ <h3>Activity is on the way</h3>
+ <p>Webhooks for widget views, transcript turns, and payments will flow in here as they arrive.</p>
+ </div>
+ </div>
+ </aside>`;
+}
+
+export function mountDrawerBehavior(/* shellEl */) {
+ /* No additional wiring at foundation level — topbar toggle drives open/close. */
+}
diff --git a/src/dashboard-next/components/palette.js b/src/dashboard-next/components/palette.js
new file mode 100644
index 000000000..53d3107eb
--- /dev/null
+++ b/src/dashboard-next/components/palette.js
@@ -0,0 +1,143 @@
+// dashboard-next — command palette (foundation stub).
+//
+// Listens for the global 'dn:palette:open' event and shows a minimal
+// navigable list of every route in nav.js. Prompt #8 replaces this with
+// a full fuzzy-search palette (recent items, action handlers, keyboard
+// navigation). This stub guarantees the ⌘K key works from day one.
+
+import { NAV } from '../nav.js';
+import { esc } from '../api.js';
+
+let overlayEl = null;
+
+function ensureOverlay() {
+ if (overlayEl) return overlayEl;
+ overlayEl = document.createElement('div');
+ overlayEl.id = 'dn-palette';
+ overlayEl.setAttribute('role', 'dialog');
+ overlayEl.setAttribute('aria-modal', 'true');
+ overlayEl.setAttribute('aria-label', 'Command palette');
+ overlayEl.style.cssText = `
+ position: fixed; inset: 0; z-index: 100;
+ background: rgba(2, 3, 6, 0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
+ display: none; align-items: flex-start; justify-content: center;
+ padding-top: 12vh;
+ `;
+ overlayEl.innerHTML = `
+ <div style="
+ width: min(560px, 92vw);
+ background: linear-gradient(180deg, rgba(28,29,39,0.95), rgba(20,21,28,0.95));
+ border: 1px solid var(--nxt-stroke-strong);
+ border-radius: var(--nxt-radius);
+ box-shadow: 0 30px 80px rgba(0,0,0,0.6);
+ overflow: hidden;
+ ">
+ <input type="text" autocomplete="off" autocapitalize="off" spellcheck="false"
+ placeholder="Jump to a page or run a command…"
+ data-role="palette-input"
+ style="
+ width: 100%;
+ background: transparent; border: 0; outline: none;
+ padding: 16px 18px;
+ font: 15px/1.4 'Inter', system-ui, sans-serif;
+ color: var(--nxt-ink);
+ border-bottom: 1px solid var(--nxt-stroke);
+ " />
+ <div data-role="palette-list" style="max-height: 56vh; overflow-y: auto; padding: 6px;"></div>
+ </div>`;
+ document.body.appendChild(overlayEl);
+ overlayEl.addEventListener('click', (e) => {
+ if (e.target === overlayEl) close();
+ });
+ overlayEl.querySelector('[data-role="palette-input"]').addEventListener('input', (e) => {
+ render(e.target.value);
+ });
+ overlayEl.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') { e.preventDefault(); close(); return; }
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
+ e.preventDefault();
+ moveActive(e.key === 'ArrowDown' ? 1 : -1);
+ return;
+ }
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ const active = overlayEl.querySelector('[data-active="true"]');
+ if (active) activate(active);
+ }
+ });
+ return overlayEl;
+}
+
+function render(query) {
+ const list = overlayEl.querySelector('[data-role="palette-list"]');
+ const q = String(query || '').trim().toLowerCase();
+ const items = !q
+ ? NAV
+ : NAV.filter((r) => {
+ const hay = [r.label, r.group, ...(r.tags || [])].join(' ').toLowerCase();
+ return hay.includes(q);
+ });
+ if (!items.length) {
+ list.innerHTML = `<div style="padding:18px;color:var(--nxt-ink-dim);font-size:13px">No matches.</div>`;
+ return;
+ }
+ list.innerHTML = items.map((r, i) => `
+ <button type="button" data-path="${esc(r.path)}" data-active="${i === 0 ? 'true' : 'false'}" style="
+ display: flex; align-items: center; justify-content: space-between;
+ width: 100%; text-align: left; border: 0; cursor: pointer;
+ padding: 10px 12px; border-radius: 8px; gap: 12px;
+ color: var(--nxt-ink); font-size: 13.5px;
+ background: ${i === 0 ? 'rgba(154,124,255,0.12)' : 'transparent'};
+ ">
+ <span>${esc(r.label)}</span>
+ <span style="font-size:11.5px;color:var(--nxt-ink-fade)">${esc(r.group)}</span>
+ </button>
+ `).join('');
+ list.querySelectorAll('button[data-path]').forEach((btn) => {
+ btn.addEventListener('mouseenter', () => {
+ list.querySelectorAll('[data-active="true"]').forEach((el) => {
+ el.setAttribute('data-active', 'false');
+ el.style.background = 'transparent';
+ });
+ btn.setAttribute('data-active', 'true');
+ btn.style.background = 'rgba(154,124,255,0.12)';
+ });
+ btn.addEventListener('click', () => activate(btn));
+ });
+}
+
+function moveActive(delta) {
+ const list = overlayEl.querySelector('[data-role="palette-list"]');
+ const btns = [...list.querySelectorAll('button[data-path]')];
+ if (!btns.length) return;
+ let idx = btns.findIndex((b) => b.getAttribute('data-active') === 'true');
+ idx = (idx + delta + btns.length) % btns.length;
+ btns.forEach((b, i) => {
+ b.setAttribute('data-active', i === idx ? 'true' : 'false');
+ b.style.background = i === idx ? 'rgba(154,124,255,0.12)' : 'transparent';
+ if (i === idx) b.scrollIntoView({ block: 'nearest' });
+ });
+}
+
+function activate(btn) {
+ const path = btn.getAttribute('data-path');
+ if (path) location.href = path;
+}
+
+function open() {
+ const el = ensureOverlay();
+ render('');
+ el.style.display = 'flex';
+ const input = el.querySelector('[data-role="palette-input"]');
+ input.value = '';
+ setTimeout(() => input.focus(), 0);
+}
+
+function close() {
+ if (overlayEl) overlayEl.style.display = 'none';
+}
+
+export function mountPaletteBehavior() {
+ window.addEventListener('dn:palette:open', open);
+ window.addEventListener('dn:palette:close', close);
+}
diff --git a/src/dashboard-next/components/sidebar.js b/src/dashboard-next/components/sidebar.js
new file mode 100644
index 000000000..480b0ab31
--- /dev/null
+++ b/src/dashboard-next/components/sidebar.js
@@ -0,0 +1,74 @@
+// dashboard-next — sidebar rail (groups + items + collapse toggle).
+//
+// Reads the route registry from nav.js and renders one section per
+// group. Marks the current route via aria-current="page". Persists
+// collapse state to localStorage so it survives page transitions.
+
+import { NAV, GROUPS, ICONS, currentRoute } from '../nav.js';
+import { esc } from '../api.js';
+
+const STORAGE_KEY = 'dn:rail:collapsed';
+
+/** Build the sidebar HTML for the current pathname. */
+export function renderSidebar(pathname) {
+ const here = currentRoute(pathname)?.path;
+ const groups = GROUPS.map((group) => {
+ const items = NAV.filter((r) => r.group === group);
+ if (!items.length) return '';
+ const links = items
+ .map((r) => {
+ const active = r.path === here ? ' aria-current="page"' : '';
+ const icon = ICONS[r.icon] || '';
+ return `
+ <a href="${esc(r.path)}" class="dn-rail-item"${active} data-route="${esc(r.path)}">
+ <span class="dn-rail-item-icon" aria-hidden="true">${icon}</span>
+ <span class="dn-rail-item-text">${esc(r.label)}</span>
+ </a>`;
+ })
+ .join('');
+ return `
+ <div class="dn-rail-group">
+ <div class="dn-rail-group-label">${esc(group)}</div>
+ ${links}
+ </div>`;
+ }).join('');
+
+ return `
+ <aside class="dn-rail" data-component="rail">
+ <div class="dn-rail-head">
+ <a href="/dashboard-next" aria-label="Dashboard home">
+ <img class="dn-rail-full" src="/three.svg" alt="three.ws" />
+ <img class="dn-rail-mark" src="/favicon.ico" alt="three.ws" style="width:22px;height:22px;border-radius:5px" />
+ </a>
+ </div>
+ <nav class="dn-rail-scroll" aria-label="Dashboard sections">
+ ${groups}
+ </nav>
+ <div class="dn-rail-foot">
+ <button type="button" class="dn-rail-item" data-action="rail-collapse" title="Collapse sidebar">
+ <span class="dn-rail-item-icon" aria-hidden="true">
+ <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5l-5 5 5 5"/></svg>
+ </span>
+ <span class="dn-rail-item-text">Collapse</span>
+ </button>
+ </div>
+ </aside>`;
+}
+
+/** Wire the collapse toggle + restore persisted state. */
+export function mountSidebarBehavior(shellEl) {
+ const collapsed = (() => {
+ try { return localStorage.getItem(STORAGE_KEY) === '1'; }
+ catch { return false; }
+ })();
+ if (collapsed) shellEl.setAttribute('data-rail-collapsed', 'true');
+
+ shellEl.addEventListener('click', (e) => {
+ const btn = e.target.closest?.('[data-action="rail-collapse"]');
+ if (!btn) return;
+ const next = shellEl.getAttribute('data-rail-collapsed') !== 'true';
+ shellEl.setAttribute('data-rail-collapsed', next ? 'true' : 'false');
+ try { localStorage.setItem(STORAGE_KEY, next ? '1' : '0'); }
+ catch { /* private mode — ignore */ }
+ });
+}
diff --git a/src/dashboard-next/components/topbar.js b/src/dashboard-next/components/topbar.js
new file mode 100644
index 000000000..128cd88d3
--- /dev/null
+++ b/src/dashboard-next/components/topbar.js
@@ -0,0 +1,105 @@
+// dashboard-next — topbar (breadcrumb + search + drawer toggle + user).
+//
+// The search button is the click-handle for the command palette (⌘K).
+// The drawer toggle controls the right-hand activity rail.
+
+import { currentRoute } from '../nav.js';
+import { esc, getMe, initialsOf } from '../api.js';
+
+const DRAWER_KEY = 'dn:drawer:open';
+
+export function renderTopbar(pathname) {
+ const here = currentRoute(pathname);
+ const crumb = here?.label || 'Dashboard';
+ return `
+ <header class="dn-topbar" data-component="topbar">
+ <div class="dn-topbar-crumb">
+ <span>Dashboard</span>
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><path d="M4 2l4 4-4 4"/></svg>
+ <strong>${esc(crumb)}</strong>
+ </div>
+ <div class="dn-topbar-spacer"></div>
+ <button type="button" class="dn-topbar-search" data-action="open-palette" aria-label="Open command palette">
+ <span style="display:inline-flex;align-items:center;gap:8px">
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="7" cy="7" r="4.5"/><path d="M13 13l-2.6-2.6"/></svg>
+ Search or jump to…
+ </span>
+ <kbd>⌘K</kbd>
+ </button>
+ <button type="button" class="dn-topbar-btn" data-action="toggle-drawer" aria-label="Toggle activity drawer" aria-pressed="false">
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v2M8 13v2M1 8h2M13 8h2M3.2 3.2l1.4 1.4M11.4 11.4l1.4 1.4M3.2 12.8l1.4-1.4M11.4 4.6l1.4-1.4"/></svg>
+ </button>
+ <div class="dn-topbar-user" data-action="open-user-menu" data-component="topbar-user" aria-haspopup="true">
+ <div class="dn-topbar-user-avatar" data-slot="initials">··</div>
+ <span data-slot="label">Loading…</span>
+ </div>
+ </header>`;
+}
+
+/** Wire drawer toggle, palette opener, and fill the user chip. */
+export function mountTopbarBehavior(shellEl) {
+ // Restore drawer state. Default closed on first visit to avoid a heavy
+ // first-paint while the activity feed mounts.
+ const drawerOpen = (() => {
+ try { return localStorage.getItem(DRAWER_KEY) === '1'; }
+ catch { return false; }
+ })();
+ setDrawerOpen(shellEl, drawerOpen);
+
+ shellEl.addEventListener('click', (e) => {
+ const palette = e.target.closest?.('[data-action="open-palette"]');
+ if (palette) {
+ window.dispatchEvent(new CustomEvent('dn:palette:open'));
+ return;
+ }
+ const drawer = e.target.closest?.('[data-action="toggle-drawer"]');
+ if (drawer) {
+ const next = shellEl.getAttribute('data-drawer-open') !== 'true';
+ setDrawerOpen(shellEl, next);
+ try { localStorage.setItem(DRAWER_KEY, next ? '1' : '0'); }
+ catch { /* private mode — ignore */ }
+ return;
+ }
+ const user = e.target.closest?.('[data-action="open-user-menu"]');
+ if (user) {
+ // Minimal: jump to account page. Could be a popover later.
+ location.href = '/dashboard-next/account';
+ }
+ });
+
+ // Keyboard: ⌘K / Ctrl+K opens palette globally.
+ window.addEventListener('keydown', (e) => {
+ if ((e.metaKey || e.ctrlKey) && (e.key === 'k' || e.key === 'K')) {
+ e.preventDefault();
+ window.dispatchEvent(new CustomEvent('dn:palette:open'));
+ }
+ });
+
+ // Fill the user chip from /api/auth/me.
+ getMe().then((me) => {
+ const chip = shellEl.querySelector('[data-component="topbar-user"]');
+ if (!chip) return;
+ if (!me) {
+ chip.querySelector('[data-slot="label"]').textContent = 'Sign in';
+ chip.querySelector('[data-slot="initials"]').textContent = '?';
+ chip.dataset.action = 'sign-in';
+ chip.onclick = () => {
+ const ret = encodeURIComponent(location.pathname + location.search);
+ location.href = `/login?return=${ret}`;
+ };
+ return;
+ }
+ chip.querySelector('[data-slot="initials"]').textContent = initialsOf(me);
+ const label = me.display_name || me.handle || me.email || 'Account';
+ chip.querySelector('[data-slot="label"]').textContent = String(label).slice(0, 18);
+ }).catch(() => {
+ /* network blip — chip stays "Loading…" rather than ever showing wrong identity */
+ });
+}
+
+function setDrawerOpen(shellEl, open) {
+ shellEl.setAttribute('data-drawer-open', open ? 'true' : 'false');
+ const btn = shellEl.querySelector('[data-action="toggle-drawer"]');
+ if (btn) btn.setAttribute('aria-pressed', open ? 'true' : 'false');
+ window.dispatchEvent(new CustomEvent('dn:drawer:toggled', { detail: { open } }));
+}
diff --git a/src/dashboard-next/nav.js b/src/dashboard-next/nav.js
new file mode 100644
index 000000000..129d1991f
--- /dev/null
+++ b/src/dashboard-next/nav.js
@@ -0,0 +1,52 @@
+// dashboard-next — route registry.
+//
+// Single source of truth for the sidebar AND the command palette.
+// Each route declares:
+// path — absolute URL the link navigates to
+// label — visible text
+// icon — short SVG keyword (rendered by sidebar.js)
+// group — sidebar section ('Create' | 'Distribute' | 'Monetize' | 'Account')
+// tags — extra keywords the command palette can match on
+// external — if true, opens outside the dashboard (escape hatch to legacy)
+//
+// Adding a new dashboard page = add one entry here. The sidebar and
+// palette pick it up automatically; the per-page HTML and JS still need
+// to be created under pages/dashboard-next/ and src/dashboard-next/pages/.
+
+export const NAV = [
+ // ── Create ──────────────────────────────────────────────────────────
+ { path: '/dashboard-next', label: 'Overview', icon: 'home', group: 'Create', tags: ['home', 'dashboard', 'start'] },
+ { path: '/dashboard-next/avatars', label: 'Avatars', icon: 'avatar', group: 'Create', tags: ['models', 'glb', 'creations'] },
+ { path: '/dashboard-next/library', label: 'Library', icon: 'library', group: 'Create', tags: ['animations', 'memory', 'voice', 'strategy', 'clips'] },
+
+ // ── Distribute ──────────────────────────────────────────────────────
+ { path: '/dashboard-next/widgets', label: 'Widgets', icon: 'widget', group: 'Distribute', tags: ['embed', 'iframe', '<threews-avatar>'] },
+ { path: '/dashboard-next/api', label: 'API & Embed', icon: 'code', group: 'Distribute', tags: ['keys', 'token', 'mcp', 'snippets', 'embed-policy'] },
+
+ // ── Monetize ────────────────────────────────────────────────────────
+ { path: '/dashboard-next/monetize', label: 'Monetize', icon: 'coin', group: 'Monetize', tags: ['revenue', 'payments', 'subscriptions', 'withdrawals', 'earnings', 'tokens', 'plan', 'billing'] },
+
+ // ── Account ─────────────────────────────────────────────────────────
+ { path: '/dashboard-next/account', label: 'Account', icon: 'user', group: 'Account', tags: ['wallets', 'sns', 'delegation', 'profile', 'action log'] },
+];
+
+export const GROUPS = ['Create', 'Distribute', 'Monetize', 'Account'];
+
+/** Inline-SVG icon strings keyed by the `icon` field above. */
+export const ICONS = {
+ home: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l7-6 7 6v8a1 1 0 01-1 1h-4v-6H8v6H4a1 1 0 01-1-1V9z"/></svg>',
+ avatar: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="7" r="3.2"/><path d="M3.5 17c1.1-3.4 3.8-5 6.5-5s5.4 1.6 6.5 5"/></svg>',
+ library: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h4v12H4zM12 4h4v12h-4z"/><path d="M6 7h0M14 7h0"/></svg>',
+ widget: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="6" height="6" rx="1.2"/><rect x="11" y="3" width="6" height="6" rx="1.2"/><rect x="3" y="11" width="6" height="6" rx="1.2"/><rect x="11" y="11" width="6" height="6" rx="1.2"/></svg>',
+ code: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M7 5l-4 5 4 5M13 5l4 5-4 5"/></svg>',
+ coin: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="6.5"/><path d="M10 6v8M7.5 8h4a1.5 1.5 0 010 3H8.5a1.5 1.5 0 000 3h4"/></svg>',
+ user: '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="7" r="3.2"/><path d="M4 17a6 6 0 0112 0"/></svg>',
+};
+
+/** Resolve the route for the current pathname (exact match wins; falls back to startsWith). */
+export function currentRoute(pathname = location.pathname) {
+ const exact = NAV.find((r) => r.path === pathname);
+ if (exact) return exact;
+ return NAV.find((r) => r.path !== '/dashboard-next' && pathname.startsWith(r.path)) ||
+ NAV.find((r) => r.path === '/dashboard-next');
+}
diff --git a/src/dashboard-next/pages/home.js b/src/dashboard-next/pages/home.js
new file mode 100644
index 000000000..78c59a920
--- /dev/null
+++ b/src/dashboard-next/pages/home.js
@@ -0,0 +1,64 @@
+// dashboard-next — Overview / home page (foundation placeholder).
+//
+// Prompt #1 will replace this with the full hero strip (live 3D avatar
+// previews via <threews-avatar>), KPI cards, recent activity rail, and
+// quick-action grid. The placeholder below proves the shell works
+// end-to-end and lets the user click through every sidebar item before
+// any page has been built out.
+
+import { mountShell } from '../shell.js';
+import { requireUser, getMe } from '../api.js';
+import { NAV, GROUPS, ICONS } from '../nav.js';
+
+(async function boot() {
+ const main = await mountShell();
+ const me = await requireUser().catch(() => null);
+ if (!me) return; // requireUser will have redirected
+
+ main.innerHTML = `
+ <h1 class="dn-h1">Welcome back${me?.display_name ? `, ${escape(me.display_name)}` : ''}.</h1>
+ <p class="dn-h1-sub">Your creator dashboard, redesigned. Pick where to go next.</p>
+
+ <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px">
+ ${GROUPS.map((group) => {
+ const items = NAV.filter((r) => r.group === group);
+ return `
+ <div class="dn-panel">
+ <div class="dn-panel-title">${group}</div>
+ <div class="dn-panel-sub">${items.length} ${items.length === 1 ? 'section' : 'sections'}</div>
+ <div style="display:flex;flex-direction:column;gap:6px">
+ ${items.map((r) => `
+ <a href="${r.path}" style="
+ display:flex;align-items:center;gap:10px;
+ padding:8px 10px;border-radius:8px;
+ color:var(--nxt-ink-dim);font-size:13px;
+ transition:background 0.12s ease,color 0.12s ease;
+ " onmouseover="this.style.background='rgba(255,255,255,0.04)';this.style.color='var(--nxt-ink)'"
+ onmouseout="this.style.background='transparent';this.style.color='var(--nxt-ink-dim)'">
+ <span style="width:16px;height:16px;display:inline-grid;place-items:center;color:var(--nxt-ink-fade)">
+ ${ICONS[r.icon] || ''}
+ </span>
+ <span>${r.label}</span>
+ </a>
+ `).join('')}
+ </div>
+ </div>`;
+ }).join('')}
+ </div>
+
+ <div class="dn-panel" style="margin-top:18px">
+ <div class="dn-panel-title">Prototype build</div>
+ <div class="dn-panel-sub">You're on <code>/dashboard-next</code> — the redesigned dashboard prototype. Each page is being built in parallel; tap a section above to see its current state.</div>
+ <div style="display:flex;gap:8px;flex-wrap:wrap">
+ <a class="dn-btn" href="/dashboard">← Production dashboard</a>
+ <button class="dn-btn" onclick="window.dispatchEvent(new CustomEvent('dn:palette:open'))">Open command palette · ⌘K</button>
+ </div>
+ </div>
+ `;
+})();
+
+function escape(s) {
+ return String(s ?? '').replace(/[&<>"']/g, (c) => ({
+ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;',
+ })[c]);
+}
diff --git a/src/dashboard-next/shell.js b/src/dashboard-next/shell.js
new file mode 100644
index 000000000..ebee4945a
--- /dev/null
+++ b/src/dashboard-next/shell.js
@@ -0,0 +1,65 @@
+// dashboard-next — shell bootstrap.
+//
+// Every page in /dashboard-next imports this module. It renders the
+// sidebar / topbar / drawer slot / palette overlay into <body>, then
+// hands control back so the page module can render its own content
+// into the <main> slot.
+//
+// Usage from a page entry module:
+//
+// import { mountShell } from '/src/dashboard-next/shell.js';
+// const main = await mountShell();
+// main.innerHTML = '<h1>Hello</h1>';
+
+import { renderSidebar, mountSidebarBehavior } from './components/sidebar.js';
+import { renderTopbar, mountTopbarBehavior } from './components/topbar.js';
+import { renderDrawer, mountDrawerBehavior } from './components/drawer.js';
+import { mountPaletteBehavior } from './components/palette.js';
+
+/**
+ * Build the shell, mount its behaviour, and resolve to the <main> slot
+ * the caller should write its page content into.
+ *
+ * @returns {Promise<HTMLElement>} the inner content container
+ */
+export async function mountShell() {
+ if (document.querySelector('.dn-shell')) {
+ // Some other page module already mounted us — return the slot.
+ const existing = document.querySelector('.dn-main-inner');
+ if (existing) return existing;
+ }
+
+ document.body.classList.add('dn-body');
+
+ const shell = document.createElement('div');
+ shell.className = 'dn-shell';
+ shell.setAttribute('data-rail-collapsed', 'false');
+ shell.setAttribute('data-drawer-open', 'false');
+ shell.innerHTML = `
+ ${renderSidebar(location.pathname)}
+ ${renderTopbar(location.pathname)}
+ <main class="dn-main" id="dn-main">
+ <div class="dn-main-inner" data-slot="page"></div>
+ </main>
+ ${renderDrawer()}
+ `;
+ document.body.appendChild(shell);
+
+ mountSidebarBehavior(shell);
+ mountTopbarBehavior(shell);
+ mountDrawerBehavior(shell);
+ mountPaletteBehavior();
+
+ // Light-up touch — the sidebar item we land on gets a brief accent
+ // pulse so users see "you are here" without having to track the
+ // indicator bar. Tasteful, not festive.
+ const here = shell.querySelector('.dn-rail-item[aria-current="page"]');
+ if (here) {
+ here.animate(
+ [{ background: 'rgba(154,124,255,0.32)' }, { background: 'rgba(154,124,255,0.18)' }],
+ { duration: 600, easing: 'ease-out' },
+ );
+ }
+
+ return shell.querySelector('[data-slot="page"]');
+}
diff --git a/vercel.json b/vercel.json
index e8a77fa66..6143c7f10 100644
--- a/vercel.json
+++ b/vercel.json
@@ -417,6 +417,14 @@
"src": "/dashboard/",
"dest": "/dashboard/index.html"
},
+ {
+ "src": "/dashboard-next/?",
+ "dest": "/dashboard-next/index.html"
+ },
+ {
+ "src": "/dashboard-next/([^./]+)/?",
+ "dest": "/dashboard-next/$1.html"
+ },
{
"src": "/dashboard/agent-pumpfun",
"dest": "/dashboard/agent-pumpfun.html"
diff --git a/vite.config.js b/vite.config.js
index 49ed5403d..34d7b6a2b 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite';
import { resolve } from 'path';
-import { readFileSync, cpSync, createReadStream, existsSync, statSync, rmSync } from 'fs';
-import { extname } from 'path';
+import { readFileSync, readdirSync, cpSync, createReadStream, existsSync, statSync, rmSync } from 'fs';
+import { extname, basename } from 'path';
import { VitePWA } from 'vite-plugin-pwa';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
@@ -28,6 +28,22 @@ const DEV_API_PROXY = process.env.DEV_API_PROXY || 'https://three.ws';
// crash the dev server with an unhandled ECONNREFUSED proxy error.
const X402_PAY_DEV_URL = process.env.X402_PAY_DEV_URL ?? '';
+// Auto-discover dashboard-next sub-pages so each agent can add an HTML file
+// under pages/dashboard-next/ without touching this config. The Rollup input
+// key is `dn-<filename>` (e.g. dn-index, dn-avatars). Missing directory is
+// tolerated so the build keeps working before any page has landed.
+function discoverDashboardNextInputs() {
+ const dir = resolve(__dirname, 'pages/dashboard-next');
+ if (!existsSync(dir)) return {};
+ const entries = {};
+ for (const f of readdirSync(dir)) {
+ if (!f.endsWith('.html')) continue;
+ const name = basename(f, '.html');
+ entries[`dn-${name}`] = resolve(dir, f);
+ }
+ return entries;
+}
+
const appConfig = {
server: {
proxy: {
@@ -215,6 +231,10 @@ const appConfig = {
'agents-face-mocap': resolve(__dirname, 'public/demos/agents/face-mocap.html'),
'agents-gemini-live': resolve(__dirname, 'public/demos/agents/gemini-live.html'),
'agents-auto-rig': resolve(__dirname, 'public/demos/agents/auto-rig.html'),
+ // dashboard-next prototype — sub-pages auto-discovered so the parallel
+ // agents that land new pages/dashboard-next/*.html files don't have to
+ // touch this config to register them as Rollup inputs.
+ ...discoverDashboardNextInputs(),
},
},
},
@@ -320,6 +340,8 @@ const appConfig = {
'/import/rpm': resolve(root, 'pages/import-rpm.html'),
'/import/rpm/': resolve(root, 'pages/import-rpm.html'),
'/dashboard': resolve(root, 'public/dashboard/index.html'),
+ '/dashboard-next': resolve(root, 'pages/dashboard-next/index.html'),
+ '/dashboard-next/': resolve(root, 'pages/dashboard-next/index.html'),
'/studio': resolve(root, 'public/studio/index.html'),
'/studio/': resolve(root, 'public/studio/index.html'),
'/widgets': resolve(root, 'public/widgets-gallery/index.html'),
@@ -883,8 +905,16 @@ const appConfig = {
for (const entry of readdirSync(pagesOut)) {
const from = resolve(pagesOut, entry);
const to = resolve(__dirname, 'dist', entry);
- if (!statSync(from).isFile()) continue;
- cpSync(from, to, { force: true });
+ const stat = statSync(from);
+ if (stat.isFile()) {
+ cpSync(from, to, { force: true });
+ } else if (stat.isDirectory()) {
+ // Nested page directories (e.g. pages/dashboard-next/) keep
+ // their structure inside dist/ so /dashboard-next/<page> URLs
+ // resolve. Recursive merge preserves any sibling assets
+ // already copied from public/dashboard-next/.
+ cpSync(from, to, { recursive: true, force: true });
+ }
}
rmSync(pagesOut, { recursive: true, force: true });
},