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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(brain): land the chat handler, SDK page and scene-capture coverage from this worktree
nirholasa104bc42fe41
diff --git a/api/brain/chat.js b/api/brain/chat.jsindex ea63ecea4..fc42fa372 100644--- a/api/brain/chat.js+++ b/api/brain/chat.js@@ -845,6 +845,12 @@ export function getAvailableProviders() {maxOutput: spec.maxOutput,description: spec.description,available,+ // `available` means the deployment holds a route for the model;+ // `requiresAuth` means the caller still needs a session to use it+ // (the anon gate below). A client that cannot tell them apart offers+ // a signed-out visitor a model that can only answer 401, which is+ // exactly what the brain page used to do with its default line-up.+ requiresAuth: !ANON_BRAIN_PROVIDERS.has(key),};});}diff --git a/data/changelog.json b/data/changelog.jsonindex 7cad4cbbf..712b8076b 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,26 @@{"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-08-16",+ "title": "The model viewer tells you when a file will not open, and how to recover",+ "summary": "The viewer at /app had two dead ends. Drop a file that is not a glTF or GLB and nothing happened at all: the rejection went to the browser console, where no one would see it, so the page just sat there looking broken. It now says plainly that no model was found in the drop and offers a button to pick a different file. And when a model failed to download, the error card offered a Retry button only to signed-in members loading their own agent; everyone else got a dead card with no way forward. Retry now works for any load, including a file you dropped yourself. The page title and description in search results also went back to describing the viewer instead of the platform, the keyboard focus outline on the chat box and the animation and share fields is now actually visible rather than a barely-there glow, the scene search and chat boxes gained screen-reader labels, and the footer's GitHub links pointed at a repository that no longer exists and now reach the real one.",+ "tags": [+ "fix",+ "improvement"+ ],+ "link": "/app"+ },+ {+ "date": "2026-08-16",+ "title": "The background agent mint says out loud whether it ran",+ "summary": "Every avatar that finishes a scan or a prompt is given a draft on-chain identity in the background. That step is deliberately best-effort, so it can never cost you your avatar, but it was also completely silent: whether it minted, was skipped because the deployment holds no minting key, or was switched off entirely, the logs looked identical, which is how a run of avatars can go by without anyone noticing the identity was never created. Each finished avatar now records the outcome of both chains, including the reason a leg was skipped. The documentation for the feature also gained a way to prove the whole path on a machine that cannot reach the public test-network faucet, which is routinely exhausted on shared build machines: run your own node with the real Metaplex programs, and the proof reports which node served it rather than handing back an explorer link that leads nowhere.",+ "tags": [+ "improvement",+ "docs"+ ],+ "link": "/docs/draft-agent-mint"+ },{"date": "2026-08-16","title": "The arbitrage board says which price feeds it actually reached",diff --git a/src/avatar-sdk-page.js b/src/avatar-sdk-page.jsindex be9700752..fc060b03b 100644--- a/src/avatar-sdk-page.js+++ b/src/avatar-sdk-page.js@@ -1,13 +1,56 @@-(async () => {- try {- const { ThreeWsViewerElement } = await import('../avatar-sdk/src/viewer.js');- if (typeof customElements !== 'undefined' && !customElements.get('three-ws-viewer')) {- customElements.define('three-ws-viewer', ThreeWsViewerElement);- }- } catch {}-})();+const VIEWER_TAG = 'three-ws-viewer';+const AGENT_TAG = 'agent-3d';+const SDK_SOURCE_URL = 'https://github.com/nirholas/three.ws/tree/main/avatar-sdk';++// Register <three-ws-viewer> from the package source this page documents, so+// every demo on the page is the shipped SDK rather than a lookalike. Resolves+// to `false` (never rejects) when the module cannot load, and the DOM-ready+// handler below swaps a designed card in for each viewer instead of leaving+// the browser to render an inert unknown tag as an empty box.+const viewerReady = import('../avatar-sdk/src/viewer.js')+ .then(({ ThreeWsViewerElement }) => {+ if (typeof customElements === 'undefined') return false;+ if (!customElements.get(VIEWER_TAG)) customElements.define(VIEWER_TAG, ThreeWsViewerElement);+ return true;+ })+ .catch((err) => {+ console.error(`[avatar-sdk] <${VIEWER_TAG}> failed to register`, err);+ return false;+ });++function renderViewerFallback(host) {+ if (host.dataset.fallbackRendered) return;+ host.dataset.fallbackRendered = '1';+ host.style.display = 'none';++ const card = document.createElement('div');+ card.className = 'sdk-viewer-fallback';++ const title = document.createElement('p');+ title.className = 'sdk-viewer-fallback-title';+ title.textContent = '3D preview unavailable';++ const body = document.createElement('p');+ body.className = 'sdk-viewer-fallback-body';+ body.textContent =+ 'This browser could not load the viewer module, so the live demo is off. The package itself installs and runs the same way in your app.';++ const link = document.createElement('a');+ link.className = 'sdk-btn-ghost';+ link.href = SDK_SOURCE_URL;+ link.target = '_blank';+ link.rel = 'noopener';+ link.textContent = 'Read the source';++ card.append(title, body, link);+ host.insertAdjacentElement('afterend', card);+}document.addEventListener('DOMContentLoaded', () => {+ viewerReady.then((ok) => {+ if (!ok) document.querySelectorAll(VIEWER_TAG).forEach(renderViewerFallback);+ });+// ── Scroll reveal ────────────────────────────────────────────────────────const revealObserver = new IntersectionObserver((entries) => {@@ -23,27 +66,47 @@ document.addEventListener('DOMContentLoaded', () => {document.querySelectorAll('.sdk-reveal').forEach((el) => revealObserver.observe(el));// ── Copy-to-clipboard ────────────────────────────────────────────────────+ // Clipboard writes are blocked outright in some embedded browsers and on+ // insecure origins, so the failure path selects the snippet and says so:+ // the reader can still finish the copy with a keystroke.+ function flashCopyLabel(btn, label, restore) {+ btn.textContent = label;+ btn.classList.add('copied');+ setTimeout(() => {+ btn.textContent = restore;+ btn.classList.remove('copied');+ }, 2000);+ }++ function selectNode(node) {+ const sel = window.getSelection();+ if (!sel) return;+ const range = document.createRange();+ range.selectNodeContents(node);+ sel.removeAllRanges();+ sel.addRange(range);+ }++ async function copyText(text, node) {+ try {+ await navigator.clipboard.writeText(text);+ return true;+ } catch {+ if (node) selectNode(node);+ return false;+ }+ }+document.querySelectorAll('.sdk-copy-btn').forEach((btn) => {btn.addEventListener('click', async (e) => {e.stopPropagation();const target = document.getElementById(btn.dataset.target);if (!target) return;- const text = target.textContent;- try {- await navigator.clipboard.writeText(text);- btn.textContent = 'Copied!';- btn.classList.add('copied');- setTimeout(() => {- btn.textContent = 'Copy';- btn.classList.remove('copied');- }, 2000);- } catch {- const sel = window.getSelection();- const range = document.createRange();- range.selectNodeContents(target);- sel.removeAllRanges();- sel.addRange(range);- }+ // Read the label per click: runtime i18n swaps this text after load.+ const label = btn.classList.contains('copied') ? btn.dataset.copyLabel : btn.textContent;+ btn.dataset.copyLabel = label;+ const ok = await copyText(target.textContent, target);+ flashCopyLabel(btn, ok ? 'Copied!' : 'Selected, press Ctrl+C', label);});});@@ -53,38 +116,75 @@ document.addEventListener('DOMContentLoaded', () => {const handler = () => installCmd.querySelector('.sdk-install-copy')?.click();installCmd.addEventListener('click', handler);installCmd.addEventListener('keydown', (e) => {- if (e.key === 'Enter' || e.key === ' ') handler();+ if (e.key === 'Enter' || e.key === ' ') {+ e.preventDefault();+ handler();+ }});}// ── Tab switching ────────────────────────────────────────────────────────- document.querySelectorAll('.sdk-tabs').forEach((tabs) => {- const buttons = tabs.querySelectorAll('.sdk-tab-btn');- const panels = tabs.querySelectorAll('.sdk-tab-panel');+ // Full tablist semantics: aria-controls wiring, roving tabindex and arrow+ // keys, so the framework examples are reachable without a mouse.+ document.querySelectorAll('.sdk-tabs').forEach((tabs, tabsIndex) => {+ const buttons = [...tabs.querySelectorAll('.sdk-tab-btn')];+ const panels = [...tabs.querySelectorAll('.sdk-tab-panel')];const copyRow = tabs.querySelector('.sdk-tab-copy-row .sdk-copy-btn');+ if (!buttons.length) return;+buttons.forEach((btn, i) => {- btn.addEventListener('click', () => {- buttons.forEach((b, j) => {- b.classList.toggle('active', j === i);- b.setAttribute('aria-selected', j === i ? 'true' : 'false');- });- panels.forEach((p, j) => {- p.hidden = j !== i;- });- if (copyRow && panels[i]) {- const pre = panels[i].querySelector('pre');- if (pre) copyRow.dataset.target = pre.id;+ const panel = panels[i];+ btn.type = 'button';+ btn.id ||= `sdk-tab-${tabsIndex}-${i}`;+ if (panel) {+ panel.id ||= `sdk-tabpanel-${tabsIndex}-${i}`;+ btn.setAttribute('aria-controls', panel.id);+ panel.setAttribute('aria-labelledby', btn.id);+ }+ });++ function select(i, focus) {+ buttons.forEach((b, j) => {+ b.classList.toggle('active', j === i);+ b.setAttribute('aria-selected', j === i ? 'true' : 'false');+ b.tabIndex = j === i ? 0 : -1;+ });+ panels.forEach((p, j) => {+ p.hidden = j !== i;+ });+ if (copyRow && panels[i]) {+ const pre = panels[i].querySelector('pre');+ if (pre) copyRow.dataset.target = pre.id;+ }+ if (focus) buttons[i].focus();+ }++ buttons.forEach((btn, i) => {+ btn.addEventListener('click', () => select(i, false));+ btn.addEventListener('keydown', (e) => {+ const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;+ if (step) {+ e.preventDefault();+ select((i + step + buttons.length) % buttons.length, true);+ } else if (e.key === 'Home') {+ e.preventDefault();+ select(0, true);+ } else if (e.key === 'End') {+ e.preventDefault();+ select(buttons.length - 1, true);}});});++ select(Math.max(0, buttons.findIndex((b) => b.classList.contains('active'))), false);});// ── Interactive Playground ───────────────────────────────────────────────- const pgViewer = document.getElementById('pg-viewer');const pgAvatar = document.getElementById('pg-avatar');const pgBg = document.getElementById('pg-bg');const pgComponent = document.getElementById('pg-component');const pgRotate = document.getElementById('pg-rotate');+ const pgNote = document.getElementById('pg-note');const pgCodeOutput = document.getElementById('pg-code-output');const pgCopyBtn = document.getElementById('pg-copy-btn');@@ -92,112 +192,160 @@ document.addEventListener('DOMContentLoaded', () => {return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');}- function updatePlayground() {- if (!pgViewer || !pgCodeOutput) return;-- const avatarSrc = pgAvatar.value;- const bg = pgBg.value;- const component = pgComponent.value;- const rotate = pgRotate.classList.contains('active');+ function setNote(html, isError) {+ if (!pgNote) return;+ pgNote.innerHTML = html;+ pgNote.classList.toggle('is-error', Boolean(isError));+ }- pgViewer.setAttribute('src', avatarSrc);- pgViewer.setAttribute('background', bg);+ // `auto-rotate` is a <three-ws-viewer> attribute. The full <agent-3d>+ // runtime drives its camera from the agent's own state and ignores it, so+ // the control is disabled (with a reason) rather than emitting a snippet+ // that silently does nothing.+ const supportsAutoRotate = (tag) => tag === VIEWER_TAG;+ const AUTOROTATE_NOTE =+ '<code>auto-rotate</code> is a <code><three-ws-viewer></code> attribute. The full runtime drives its own camera.';+ const restingNote = () => setNote(pgRotate.disabled ? AUTOROTATE_NOTE : '');- const isViewer = component === 'three-ws-viewer';- const importPath = isViewer ? '@three-ws/avatar/viewer' : '@three-ws/avatar';- const tagName = component;+ function renderCode(tag, avatarSrc, bg, rotate) {+ if (!pgCodeOutput) return;+ const importPath = tag === VIEWER_TAG ? '@three-ws/avatar/viewer' : '@three-ws/avatar';- const attrs = [];- attrs.push(` <span class="t-attr">src</span>=<span class="t-str">"${escapeHtml(avatarSrc)}"</span>`);+ const attrs = [` <span class="t-attr">src</span>=<span class="t-str">"${escapeHtml(avatarSrc)}"</span>`];if (bg !== 'transparent') {attrs.push(` <span class="t-attr">background</span>=<span class="t-str">"${escapeHtml(bg)}"</span>`);}attrs.push(` <span class="t-attr">alt</span>=<span class="t-str">"My avatar"</span>`);- if (rotate) {+ if (rotate && supportsAutoRotate(tag)) {attrs.push(` <span class="t-attr">auto-rotate</span>`);}attrs.push(` <span class="t-attr">style</span>=<span class="t-str">"width:400px;height:560px"</span>`);- const code = [+ pgCodeOutput.innerHTML = [`<span class="t-tag"><script</span> <span class="t-attr">type</span>=<span class="t-str">"module"</span><span class="t-tag">></span>`,` <span class="t-kw">import</span> <span class="t-str">'${importPath}'</span><span class="t-op">;</span>`,`<span class="t-tag"></script></span>`,``,- `<span class="t-tag"><${tagName}</span>`,+ `<span class="t-tag"><${tag}</span>`,...attrs,- `<span class="t-tag">></${tagName}></span>`,+ `<span class="t-tag">></${tag}></span>`,].join('\n');+ }++ // Every apply() runs against the latest control values; a stale one that+ // finishes after a newer selection bails instead of overwriting it.+ let applyToken = 0;++ async function applyPlayground() {+ const token = ++applyToken;+ const avatarSrc = pgAvatar.value;+ const bg = pgBg.value;+ const tag = pgComponent.value;+ const rotate = pgRotate.classList.contains('active');- pgCodeOutput.innerHTML = code;+ renderCode(tag, avatarSrc, bg, rotate);++ pgRotate.disabled = !supportsAutoRotate(tag);+ pgRotate.setAttribute('aria-disabled', String(pgRotate.disabled));+ restingNote();++ let host = document.getElementById('pg-viewer');+ if (!host) return;++ if (host.tagName.toLowerCase() !== tag) {+ if (tag === AGENT_TAG) {+ setNote('Loading the full <code><agent-3d></code> runtime. This is the heavy bundle the lightweight viewer avoids.');+ try {+ const { ensureAgent3D } = await import('../avatar-sdk/src/agent.js');+ await ensureAgent3D();+ } catch (err) {+ console.error('[avatar-sdk] <agent-3d> runtime failed to load', err);+ if (token !== applyToken) return;+ setNote('The full runtime could not load. Showing the lightweight viewer instead.', true);+ pgComponent.value = VIEWER_TAG;+ applyPlayground();+ return;+ }+ } else {+ await viewerReady;+ }+ if (token !== applyToken) return;++ host = document.getElementById('pg-viewer');+ if (!host) return;+ const next = document.createElement(tag);+ next.id = 'pg-viewer';+ next.setAttribute('alt', 'Playground avatar preview');+ next.style.cssText = 'width:100%;height:100%';+ host.replaceWith(next);+ host = next;+ restingNote();+ }++ host.setAttribute('src', avatarSrc);+ host.setAttribute('background', bg);+ if (rotate && supportsAutoRotate(tag)) host.setAttribute('auto-rotate', '');+ else host.removeAttribute('auto-rotate');}- if (pgAvatar) {- pgAvatar.addEventListener('change', updatePlayground);- pgBg.addEventListener('change', updatePlayground);- pgComponent.addEventListener('change', updatePlayground);+ if (pgAvatar && pgBg && pgComponent && pgRotate) {+ pgAvatar.addEventListener('change', applyPlayground);+ pgBg.addEventListener('change', applyPlayground);+ pgComponent.addEventListener('change', applyPlayground);pgRotate.addEventListener('click', () => {+ if (pgRotate.disabled) return;pgRotate.classList.toggle('active');- pgRotate.setAttribute('aria-checked', pgRotate.classList.contains('active'));- updatePlayground();+ pgRotate.setAttribute('aria-checked', String(pgRotate.classList.contains('active')));+ applyPlayground();});- updatePlayground();+ applyPlayground();}- if (pgCopyBtn) {+ if (pgCopyBtn && pgCodeOutput) {pgCopyBtn.addEventListener('click', async () => {- const text = pgCodeOutput.textContent;- try {- await navigator.clipboard.writeText(text);- pgCopyBtn.textContent = 'Copied!';- pgCopyBtn.classList.add('copied');- setTimeout(() => {- pgCopyBtn.textContent = 'Copy code';- pgCopyBtn.classList.remove('copied');- }, 2000);- } catch {}+ const label = pgCopyBtn.classList.contains('copied') ? pgCopyBtn.dataset.copyLabel : pgCopyBtn.textContent;+ pgCopyBtn.dataset.copyLabel = label;+ const ok = await copyText(pgCodeOutput.textContent, pgCodeOutput);+ flashCopyLabel(pgCopyBtn, ok ? 'Copied!' : 'Selected, press Ctrl+C', label);});}// ── Creator demo ─────────────────────────────────────────────────────────const creatorBtn = document.getElementById('sdk-creator-open');const creatorStatus = document.getElementById('sdk-creator-status');- if (creatorBtn) {+ if (creatorBtn && creatorStatus) {+ const setStatus = (text, kind) => {+ creatorStatus.textContent = text;+ creatorStatus.className = `sdk-creator-status ${kind}`;+ };+ let creator = null;+creatorBtn.addEventListener('click', async () => {+ if (creator) return;+ creatorBtn.disabled = true;+ setStatus('Opening Avatar Studio…', 'info');try {const mod = await import('../avatar-sdk/src/creator.js');- creatorStatus.textContent = 'Opening Avatar Studio…';- creatorStatus.className = 'sdk-creator-status info';- const creator = new mod.AvatarCreator({+ creator = new mod.AvatarCreator({studioUrl: new URL('/avatar-studio/', location.origin).toString(),onExport: (blob) => {- creatorStatus.textContent = `Avatar exported — ${(blob.size / 1024).toFixed(0)} KB GLB`;- creatorStatus.className = 'sdk-creator-status ok';+ setStatus(`Avatar exported: ${(blob.size / 1024).toFixed(0)} KB GLB`, 'ok');},onClose: () => {if (!creatorStatus.classList.contains('ok')) {- creatorStatus.textContent = 'Closed without export.';- creatorStatus.className = 'sdk-creator-status muted';+ setStatus('Closed without export.', 'muted');}+ creator = null;+ creatorBtn.disabled = false;},});await creator.open();+ setStatus('Avatar Studio open. Build an avatar, then export to send it back here.', 'info');} catch (err) {- creatorStatus.textContent = 'Error: ' + err.message;- creatorStatus.className = 'sdk-creator-status err';- }- });- }-- // ── Hero viewer fallback ─────────────────────────────────────────────────- const heroViewer = document.querySelector('.sdk-hero-viewer three-ws-viewer');- if (heroViewer) {- heroViewer.addEventListener('error', () => {- const wrap = document.querySelector('.sdk-hero-viewer');- if (wrap) {- const msg = document.createElement('p');- msg.style.cssText = 'text-align:center;color:var(--ink-dim);font-size:13px;padding:24px';- msg.textContent = 'Avatar preview unavailable in this environment.';- wrap.appendChild(msg);+ console.error('[avatar-sdk] Avatar Creator failed to open', err);+ setStatus(`Could not open Avatar Studio: ${err.message}. Reload the page to try again.`, 'err');+ creator = null;+ creatorBtn.disabled = false;}});}diff --git a/src/bnb-latency-helpers.js b/src/bnb-latency-helpers.jsindex 026a72148..9b7e0edc5 100644--- a/src/bnb-latency-helpers.js+++ b/src/bnb-latency-helpers.js@@ -136,6 +136,24 @@ export function ageLabel(ms) {return `${Math.floor(s / 86400)}d ago`;}+/**+ * Epoch ms a measurement was actually taken, from the payload's own+ * `measuredAt`. Ages must be computed against the SERVER's measurement time,+ * not the moment the browser received the bytes: an HTTP cache can replay a+ * body seconds after it was measured, and dating it "now" would report stale+ * data as fresh. Falls back to `now` for a missing/unparseable stamp, and+ * clamps a server clock that runs ahead of the client so nothing is ever+ * measured in the future.+ * @param {string} iso+ * @param {number} [now]+ * @returns {number}+ */+export function measuredAtMs(iso, now = Date.now()) {+ const t = Date.parse(iso);+ if (!Number.isFinite(t)) return now;+ return Math.min(t, now);+}+/*** Honest speedup ratio between two REAL measured averages ("BNB confirms* N.Nx faster than Base right now") — always computed from live numbers ondiff --git a/src/brain.js b/src/brain.jsindex bf4de4838..20dd0f923 100644--- a/src/brain.js+++ b/src/brain.js@@ -26,9 +26,10 @@ const NETWORK_COLORS = {const UNKNOWN_NETWORK_COLOR = '#8a8a8a';// Preferred opening line-up, filtered against what the server reports as-// available. Anything unavailable falls through to the first live model, so the-// page never boots with a column that cannot answer.+// usable for THIS visitor. Anything unusable falls through to the first live+// model, so the page never boots with a column that can only answer 401.const DEFAULT_MODEL_KEYS = ['gpt-oss-120b', 'claude-sonnet-5', 'gpt-5.6-luna', 'groq-llama'];+const ANON_DEFAULT_MODEL_KEYS = ['gpt-oss-120b', 'nvidia-kimi-k2', 'nvidia-nemotron-120b', 'nvidia-llama4-maverick'];const PMAP = new Map();@@ -48,9 +49,20 @@ function decorateProvider(spec) {function providerTitle(p) {const head = [p.label, p.network, p.tier].filter(Boolean).join(' · ');if (!p.available) return `${head} (not configured on this deployment)`;+ if (isLocked(p)) return `${head} (sign in to use this model)`;return p.description ? `${head}\n${p.description}` : head;}+// A model the deployment can reach but this visitor cannot use yet. The server+// answers 401 for these while signed out, so the page marks them rather than+// letting a click turn into an error message inside a column.+function isLocked(p) {+ return Boolean(p.available && p.requiresAuth && !state.authed);+}+function isSelectable(p) {+ return Boolean(p.available) && !isLocked(p);+}+// ── Archetype quick-picks ────────────────────────────────────────────────────const ARCHETYPES = [{@@ -640,22 +652,27 @@ function renderPlayControls() {label.textContent = 'Models';ctrl.innerHTML = `<div class="br-provider-pills">${[...PMAP.values()].map(p => {- const cls = ['br-pill', state.active.has(p.key) ? 'on' : ''].filter(Boolean).join(' ');+ const locked = isLocked(p);+ const cls = ['br-pill', state.active.has(p.key) ? 'on' : '', locked ? 'locked' : ''].filter(Boolean).join(' ');+ const badge = !p.available+ ? '<span class="br-pill-na" aria-hidden="true">✕</span>'+ : locked ? '<span class="br-pill-lock" aria-hidden="true">🔒</span>' : '';return `<button type="button" class="${cls}" style="--pc:${p.color}" data-key="${escHtml(p.key)}"aria-pressed="${state.active.has(p.key)}"${p.available ? '' : ' disabled'}title="${escHtml(providerTitle(p))}"><span class="br-pill-dot"></span><span>${escHtml(p.short)}</span>- ${p.available ? '' : '<span class="br-pill-na" aria-hidden="true">✕</span>'}+ ${badge}</button>`;}).join('')}</div>`;} else {label.textContent = 'Model';ctrl.innerHTML = `<select class="br-focus-sel" id="brFocusSel" aria-label="Model">${- [...PMAP.values()].map(p =>- `<option value="${escHtml(p.key)}"${p.key === state.focusKey ? ' selected' : ''}${p.available ? '' : ' disabled'}>${escHtml(p.label)}${p.available ? '' : ' (unavailable)'}</option>`- ).join('')+ [...PMAP.values()].map(p => {+ const suffix = !p.available ? ' (unavailable)' : isLocked(p) ? ' (sign in)' : '';+ return `<option value="${escHtml(p.key)}"${p.key === state.focusKey ? ' selected' : ''}${p.available ? '' : ' disabled'}>${escHtml(p.label)}${suffix}</option>`;+ }).join('')}</select>`;}bindPlayControlEvents();@@ -665,8 +682,8 @@ function renderPlayControls() {// serve. Runs on every successful roster load, so a model that goes offline// between visits is dropped instead of failing on the next send.function reconcileSelection() {- const availableKeys = [...PMAP.values()].filter(p => p.available).map(p => p.key);- const live = new Set(availableKeys);+ const usableKeys = [...PMAP.values()].filter(isSelectable).map(p => p.key);+ const usable = new Set(usableKeys);if (!state.selectionRestored) {const saved = load('brain_models_v1');@@ -675,12 +692,13 @@ function reconcileSelection() {state.selectionRestored = true;}- for (const key of [...state.active]) if (!live.has(key)) state.active.delete(key);+ for (const key of [...state.active]) if (!usable.has(key)) state.active.delete(key);if (!state.active.size) {- for (const key of DEFAULT_MODEL_KEYS) if (live.has(key)) state.active.add(key);+ const preferred = state.authed ? DEFAULT_MODEL_KEYS : ANON_DEFAULT_MODEL_KEYS;+ for (const key of preferred) if (usable.has(key)) state.active.add(key);}- if (!state.active.size && availableKeys.length) state.active.add(availableKeys[0]);- if (!live.has(state.focusKey)) state.focusKey = [...state.active][0] || availableKeys[0] || '';+ if (!state.active.size && usableKeys.length) state.active.add(usableKeys[0]);+ if (!usable.has(state.focusKey)) state.focusKey = [...state.active][0] || usableKeys[0] || '';persistSelection();}@@ -1142,6 +1160,11 @@ function bindPlayControlEvents() {document.querySelectorAll('.br-pill').forEach(pill => {pill.addEventListener('click', () => {const key = pill.dataset.key;+ const spec = PMAP.get(key);+ if (isLocked(spec)) {+ showNotice(`${spec.label} needs an account. Sign in to add it.`);+ return;+ }if (state.active.has(key)) {if (state.active.size === 1) { showNotice('Keep at least one model selected.'); return; }state.active.delete(key);diff --git a/src/chains.css b/src/chains.cssindex 1949496bd..04c8f5c63 100644--- a/src/chains.css+++ b/src/chains.css@@ -61,3 +61,20 @@max-width: 8.5rem;}}++/* Phone widths: the "Dominance" header is the widest thing in the table, and at+ 320px it is what pushed the percentages off the edge. Drop a step of type and+ padding so chain, TVL and dominance all land inside the viewport. */+@media (max-width: 479px) {+ #chains-table .cv-table {+ font-size: 0.8125rem;+ }+ #chains-table .cv-table th,+ #chains-table .cv-table td {+ padding-left: 0.375rem;+ padding-right: 0.375rem;+ }+ #chains-table .cv-table .name-cell .nm {+ max-width: 6rem;+ }+}diff --git a/tests/api/scene-capture.test.js b/tests/api/scene-capture.test.jsindex 0254fc463..75c3da31b 100644--- a/tests/api/scene-capture.test.js+++ b/tests/api/scene-capture.test.js@@ -212,6 +212,17 @@ describe('/api/scene-capture endpoint', () => {expect(json.error).toBe('unconfigured');});+ it('keeps env-var operator instructions out of the visitor-facing 503 message', async () => {+ delete process.env.GCP_VIDEO2SCENE_URL;+ delete process.env.GCP_RECONSTRUCTION_KEY;+ const { json } = await callEndpoint(mockReq({ body: { video_url: 'https://93.184.216.34/walk.mp4' } }));+ // /capture renders `message` verbatim in its error overlay, so it has to read+ // as a status a visitor can act on, not a deployment checklist.+ expect(json.message).not.toMatch(/GCP_VIDEO2SCENE_URL|GCP_RECONSTRUCTION_KEY|Cloud Run/);+ expect(json.message).toMatch(/offline/i);+ expect(json.hint).toMatch(/GCP_VIDEO2SCENE_URL/);+ });+it('starts a job and returns a job_id when configured', async () => {globalThis.fetch = vi.fn(async () =>new Response(JSON.stringify({ task_id: 'task-xyz', status: 'queued' }), { status: 202 }),