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.

test(bnb): pin the hero tally and probe cleanup the route audit found

nirholas1192e65e6d91
diff --git a/pages/autopilot.html b/pages/autopilot.html
index 7aaf52f64..4b2ca28e3 100644
--- a/pages/autopilot.html
+++ b/pages/autopilot.html
@@ -145,6 +145,7 @@
.amt-wrap { position: relative; flex: 1; max-width: 140px; }
.amt-wrap input { width: 100%; background: var(--surface-2); border: 1px solid var(--hairline-strong); color: var(--text); border-radius: 7px; padding: 7px 36px 7px 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.amt-wrap input:focus { outline: none; border-color: rgba(120,200,140,0.5); }
+ .amt-wrap input:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.amt-wrap .amt-unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--text-4); pointer-events: none; }
.rule-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.rule.off { opacity: 0.5; }
diff --git a/pages/bundles.html b/pages/bundles.html
index db3f4e9c7..59f2d3f6e 100644
--- a/pages/bundles.html
+++ b/pages/bundles.html
@@ -117,6 +117,9 @@
.bd-tile dd { margin: 0; font-size: 1.18rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink-bright, var(--ink)); }
.bd-tile dd[data-tone="up"] { color: var(--bd-evidence); }
.bd-tile dd[data-tone="down"] { color: var(--bd-loss); }
+ /* Dimmed while the server is re-backtesting a dragged price, so a stale
+ number never reads as the answer to the price now on screen. */
+ .bd-tile dd[data-pending] { opacity: 0.45; }
/* ── buttons ────────────────────────────────────────────────────── */
.bd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 9px; border: 1px solid var(--stroke); background: var(--surface-2, rgba(255,255,255,0.05)); color: var(--ink); font-size: 0.92rem; font-weight: 600; cursor: pointer; transition: background 130ms ease, border-color 130ms ease, transform 90ms ease; }
@@ -277,6 +280,7 @@
</div>
</dl>
+ <div id="bd-nohistory" class="bd-note bd-hide" style="margin-top:12px"></div>
<div id="bd-unpriced" class="bd-note bd-hide" style="margin-top:12px"></div>
<label class="bd-field" style="margin-top:16px">
@@ -576,6 +580,18 @@
$('bd-buyers').textContent = h.multi_skill_buyers;
$('bd-paid').textContent = fmt(h.revenue_atomic);
+
+ // Four tiles reading zero is a true answer that looks like a broken panel.
+ // Say what the zeros mean, so a seller with no multi-skill history reads
+ // them as "nothing to backtest yet" rather than "this feature is dead".
+ const nohist = $('bd-nohistory');
+ show(nohist, !h.multi_skill_buyers);
+ if (!h.multi_skill_buyers) {
+ nohist.innerHTML = '<b>No one has bought two or more of these skills yet.</b> ' +
+ 'The backtest below has nobody to run against, so every figure is zero. ' +
+ 'You can still publish at the suggested price; the numbers fill in as buyers arrive.';
+ }
+
updateDerived();
renderUnpriced();
}
@@ -599,12 +615,17 @@
d.textContent = h.multi_skill_buyers ? signed(String(delta)) : '0';
d.dataset.tone = delta > 0n ? 'up' : delta < 0n ? 'down' : '';
- // "Better off" needs per-buyer baskets, which the server does not expose
- // (that would leak individual spend). Report the server's count for the
- // suggested price and say so, rather than inventing a number per drag.
- $('bd-better').textContent = Math.abs(price - fromAtomic(pricing.suggested.price)) < 1e-9
- ? pricing.suggested.buyers_better_off
- : '&#183;';
+ // "Better off" needs per-buyer baskets, which the server never exposes
+ // (that would leak individual spend). At the suggested price the server
+ // already answered; at any other price ask it, debounced, instead of
+ // inventing a number locally or leaving a dot on screen.
+ if (!h.multi_skill_buyers) {
+ $('bd-better').textContent = '0';
+ } else if (Math.abs(price - fromAtomic(pricing.suggested.price)) < 1e-9) {
+ $('bd-better').textContent = pricing.suggested.buyers_better_off;
+ } else {
+ refreshBetterOff(price);
+ }
const off = sumOfParts > 0 ? ((sumOfParts - price) / sumOfParts) * 100 : 0;
const disc = $('bd-discount');
@@ -620,6 +641,36 @@
: off < 0 ? 'Price it below the sum of the parts first.' : '';
}
+ // GET ?action=pricing&price=<atomic> backtests one candidate price server
+ // side and returns how many of the real multi-skill buyers came out ahead at
+ // it. Debounced so a slider drag is one request at rest, not one per frame.
+ let betterDebounce;
+ let betterSeq = 0;
+ function refreshBetterOff(price) {
+ const el = $('bd-better');
+ el.dataset.pending = '1';
+ clearTimeout(betterDebounce);
+ const seq = ++betterSeq;
+ const forAgent = agentId;
+ const skills = [...selected].join(',');
+ betterDebounce = setTimeout(async () => {
+ const qs = new URLSearchParams({ action: 'pricing', skills, price: toAtomic(price) });
+ try {
+ const res = await apiFetch('/api/agents/' + encodeURIComponent(forAgent) + '/bundles?' + qs);
+ if (seq !== betterSeq) return;
+ if (!res.ok) return;
+ const body = await res.json().catch(() => null);
+ const asked = body?.data?.asked;
+ if (seq !== betterSeq || !asked) return;
+ el.textContent = asked.buyers_better_off;
+ delete el.dataset.pending;
+ } catch {
+ // The tile keeps its last answer and stays marked pending; the panel
+ // already surfaces connection failures, so this stays quiet.
+ }
+ }, 400);
+ }
+
function renderUnpriced() {
const missing = pricing?.unpriced_skills || [];
const box = $('bd-unpriced');
diff --git a/pages/categories.html b/pages/categories.html
index a1589d879..d14b0f712 100644
--- a/pages/categories.html
+++ b/pages/categories.html
@@ -21,7 +21,7 @@
<title data-i18n="categories.meta_title">Crypto Categories · three.ws</title>
<meta
name="description"
- content="Every crypto sector ranked by market cap — Layer 1s, DeFi, memes, AI, RWAs and more. See which categories are leading and lagging with live 24h moves and volume."
+ content="Every crypto sector ranked by market cap: Layer 1s, DeFi, memes, AI, RWAs and more. Search 700+ categories, sort by market cap, 24h change or volume, and see which narratives lead the market right now."
data-i18n-attr="content:categories.meta_description"/>
<meta property="og:type" content="website" />
<meta property="og:site_name" content="three.ws" />
@@ -29,7 +29,7 @@
<meta property="og:title" content="Crypto Categories · three.ws" data-i18n-attr="content:categories.meta_og_title"/>
<meta
property="og:description"
- content="Every crypto sector ranked by market cap — Layer 1s, DeFi, memes, AI, RWAs and more, with live 24h moves and volume."
+ content="Every crypto sector ranked by market cap: Layer 1s, DeFi, memes, AI, RWAs and more, with live 24h moves and volume."
data-i18n-attr="content:categories.meta_og_description"/>
<meta
property="og:image"
@@ -110,6 +110,35 @@
</div>
</div>
+ <!-- Filters the ~750 categories the upstream reports. Revealed by
+ src/categories.js once a populated list has actually loaded. -->
+ <div class="cat-filters">
+ <div class="cv-search" id="cat-search" hidden>
+ <span class="mag" aria-hidden="true">
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <circle cx="11" cy="11" r="8" />
+ <path d="m21 21-4.3-4.3" />
+ </svg>
+ </span>
+ <input
+ id="cat-search-input"
+ type="search"
+ placeholder="Search categories…"
+ autocomplete="off"
+ spellcheck="false"
+ aria-label="Search crypto categories by name"
+ />
+ </div>
+ <p class="cat-count" id="cat-count" role="status" aria-live="polite"></p>
+ </div>
+
<!-- Category table. Hydrated by src/categories.js. -->
<section id="cat-table" aria-label="Crypto categories by market cap"></section>
<p class="cv-updated" id="cat-updated"></p>
diff --git a/src/brain.js b/src/brain.js
index 38acf60ba..c193b952a 100644
--- a/src/brain.js
+++ b/src/brain.js
@@ -1,7 +1,7 @@
// ── brain.js — Persona builder + multi-model playground ─────────────────────
import { renderMarkdown } from './shared/markdown.js';
-import { apiFetch } from './api.js';
+import { apiFetch, noteSession } from './api.js';
// ── Provider roster ──────────────────────────────────────────────────────────
// The roster is NOT declared here. GET /api/brain/chat is the only place that
@@ -284,7 +284,7 @@ function renderArchetypes() {
const grid = $('brArchetypeGrid');
if (!grid) return;
grid.innerHTML = ARCHETYPES.map((a, i) => `
- <button class="br-archetype-chip" data-archetype="${i}" type="button">
+ <button class="br-archetype-chip" data-archetype="${i}" type="button" aria-pressed="false">
<span class="br-archetype-chip-label">${escHtml(a.label)}</span>
<span class="br-archetype-chip-desc">${escHtml(a.desc)}</span>
</button>
@@ -303,6 +303,7 @@ function applyArchetype(index) {
updateStatusBar(archetype.label);
document.querySelectorAll('.br-archetype-chip').forEach((chip, i) => {
chip.classList.toggle('selected', i === index);
+ chip.setAttribute('aria-pressed', String(i === index));
});
autoSavePersonaToAgent(archetype.label);
}
@@ -514,72 +515,70 @@ function closeEditMode() {
}
// ── Persona: Agent list + auto-select ────────────────────────────────────────
+// Resolve the session once per tab. /api/auth/me answers 200 with
+// `{ user: null }` when signed out, so this costs one clean request and buys
+// the owner-only roster read (/api/agents) an answer up front instead of a 401
+// that lands as a red console error on every signed-out visit.
+let _sessionPromise = null;
+function hasSession() {
+ if (!_sessionPromise) {
+ _sessionPromise = fetch('/api/auth/me', { credentials: 'include', headers: { accept: 'application/json' } })
+ .then(r => (r.ok ? r.json() : null))
+ .then(d => !!(d && d.user))
+ .catch(() => false)
+ .then(ok => { noteSession(ok); return ok; });
+ }
+ return _sessionPromise;
+}
+
+function setAgentSelectMessage(text) {
+ const sel = $('brAgentSelect');
+ sel.innerHTML = `<option value="">${escHtml(text)}</option>`;
+ sel.disabled = true;
+}
+
async function loadAgents() {
+ const sel = $('brAgentSelect');
+ state.authed = await hasSession();
+ if (!state.authed) {
+ setAgentSelectMessage('Sign in to save to an agent');
+ return;
+ }
+
try {
- const res = await fetch('/api/agents', { credentials: 'include' });
- if (!res.ok) return;
+ const res = await apiFetch('/api/agents', {
+ credentials: 'include',
+ allowAnonymous: true,
+ headers: { accept: 'application/json' },
+ });
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
state.agents = data.agents || data || [];
renderAgentSelect();
// Auto-select most recently used agent, or fall back to first
const saved = load('brain_active_agent');
- const sel = $('brAgentSelect');
if (saved && state.agents.find(a => a.id === saved)) {
sel.value = saved;
} else if (state.agents.length > 0) {
sel.value = state.agents[0].id;
}
- } catch {}
+ } catch {
+ setAgentSelectMessage('Could not load your agents');
+ }
}
function renderAgentSelect() {
const sel = $('brAgentSelect');
if (!state.agents.length) {
- sel.innerHTML = '<option value="">No agents yet</option>';
+ setAgentSelectMessage('No agents yet');
return;
}
+ sel.disabled = false;
sel.innerHTML = state.agents.map(a =>
`<option value="${escHtml(a.id)}">${escHtml(a.name || `Agent ${a.id.slice(0,8)}`)}</option>`
).join('');
}
-async function savePersonaToAgent() {
- const agentId = $('brAgentSelect').value;
- if (!agentId || !state.persona) return;
-
- const btn = $('brSaveToAgent');
- btn.disabled = true;
- btn.textContent = 'Saving...';
-
- try {
- const persona = {
- system_prompt: buildPersonaSystemPrompt(state.persona),
- tone: state.persona.tone,
- traits: [
- ...(state.persona.vocabulary || []),
- ...(state.persona.interests || []),
- ],
- };
- const res = await apiFetch(`/api/agents/${agentId}`, {
- method: 'PUT',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ persona }),
- });
- if (!res.ok) {
- const data = await res.json().catch(() => ({}));
- throw new Error(data.error || `HTTP ${res.status}`);
- }
- const agentName = state.agents.find(a => a.id === agentId)?.name || 'agent';
- toast(`Persona saved to ${agentName}`);
- } catch (err) {
- toast(`Save failed: ${err.message}`);
- } finally {
- btn.disabled = false;
- btn.textContent = 'Save to Agent';
- }
-}
-
// ── Render: Sidebar sessions ─────────────────────────────────────────────────
function renderSidebar() {
const el = $('brSessions');
@@ -1113,15 +1112,22 @@ function bindPlayControlEvents() {
document.querySelectorAll('.br-pill').forEach(pill => {
pill.addEventListener('click', () => {
const key = pill.dataset.key;
- if (state.active.has(key)) { if (state.active.size > 1) state.active.delete(key); }
- else state.active.add(key);
- pill.classList.toggle('on', state.active.has(key));
+ if (state.active.has(key)) {
+ if (state.active.size === 1) { showNotice('Keep at least one model selected.'); return; }
+ state.active.delete(key);
+ } else {
+ state.active.add(key);
+ }
+ const on = state.active.has(key);
+ pill.classList.toggle('on', on);
+ pill.setAttribute('aria-pressed', String(on));
+ persistSelection();
renderCanvas();
});
});
} else {
const sel = document.getElementById('brFocusSel');
- if (sel) sel.addEventListener('change', () => { state.focusKey = sel.value; renderCanvas(); });
+ if (sel) sel.addEventListener('change', () => { state.focusKey = sel.value; persistSelection(); renderCanvas(); });
}
}
@@ -1229,6 +1235,13 @@ function bindEvents() {
if (copy) copyProvider(copy.dataset.copy);
});
+ // Roster retry: the button is rendered into both the play bar and the
+ // canvas error state, so one delegated handler covers whichever the user
+ // reaches first.
+ document.addEventListener('click', e => {
+ if (e.target.closest('[data-retry-providers]')) fetchProviderRoster();
+ });
+
// Persona banner
$('brBannerDismiss').addEventListener('click', () => {
state.personaEnabled = false;
@@ -1241,15 +1254,22 @@ loadSessions();
loadPersona();
renderArchetypes();
-renderPlayControls();
renderSidebar();
-renderCanvas();
bindEvents();
-fetchProviderAvailability();
+fetchProviderRoster();
if (state.persona) {
renderPersonaCard(state.persona);
updateStatusBar(state.persona._label || 'Custom persona');
+ // Reflect a persisted archetype pick in the grid, so a returning visitor
+ // sees which vibe is live instead of an unselected row.
+ const picked = ARCHETYPES.findIndex(a => a.label === state.persona._label);
+ if (picked >= 0) {
+ document.querySelectorAll('.br-archetype-chip').forEach((chip, i) => {
+ chip.classList.toggle('selected', i === picked);
+ chip.setAttribute('aria-pressed', String(i === picked));
+ });
+ }
}
updatePersonaMini();
updatePersonaBanner();
diff --git a/src/categories.css b/src/categories.css
index e42b73bec..21ab02b62 100644
--- a/src/categories.css
+++ b/src/categories.css
@@ -25,3 +25,27 @@
.cv-table .name-cell .inner {
gap: 0.625rem;
}
+
+/* Search box and the live "showing N of M" readout share one row on desktop and
+ stack on narrow screens, where the search field takes the full width. */
+.cat-filters {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 0.5rem 1rem;
+ margin-bottom: 0.875rem;
+ min-height: 1.25rem;
+}
+.cat-count {
+ margin: 0;
+ font-size: 0.8125rem;
+ color: var(--cv-text-3);
+}
+
+@media (max-width: 640px) {
+ .cat-filters .cv-search {
+ max-width: none;
+ flex: 1 1 100%;
+ }
+}
diff --git a/src/categories.js b/src/categories.js
index 6882f9275..cd94f7ca4 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -229,7 +229,7 @@ function renderTable() {
el.innerHTML = `
<div class="cv-table-wrap">
<table class="cv-table">
- <caption class="cv-sr-only">Crypto categories ranked by market cap, showing ${page.length} of ${matches.length}</caption>
+ <caption class="sr-only">Crypto categories ranked by market cap, showing ${page.length} of ${matches.length}</caption>
<thead><tr>${head}</tr></thead>
<tbody>${rows}</tbody>
</table>
diff --git a/src/coin-pages.css b/src/coin-pages.css
index d884ca9c7..1027c4e0f 100644
--- a/src/coin-pages.css
+++ b/src/coin-pages.css
@@ -711,7 +711,10 @@ html.cv-page,
opacity: 0.4;
font-size: 0.6875rem;
}
-.cv-table th[aria-sort] .arrow {
+/* A sortable-but-inactive header carries aria-sort="none" so screen readers
+ announce it as sortable; only the column actually sorted gets the bright
+ arrow, so exclude "none" rather than matching the attribute's presence. */
+.cv-table th[aria-sort]:not([aria-sort='none']) .arrow {
opacity: 1;
}
diff --git a/tests/e2e/bnb-hub.spec.js b/tests/e2e/bnb-hub.spec.js
new file mode 100644
index 000000000..487939d98
--- /dev/null
+++ b/tests/e2e/bnb-hub.spec.js
@@ -0,0 +1,77 @@
+// /bnb hub: the two regressions the route audit found, both of which reproduced
+// live on production before the fix.
+//
+// 1. The hero tally ("3 of 3 demo tracks live now") is written by src/bnb.js,
+// but #bnb-progress also carries data-i18n for its "Checking…" placeholder.
+// The i18n catalog pass lands after an async /api/locale fetch and reverted
+// the finished tally back to the placeholder, so the page permanently read
+// "Checking which tracks are live…" while every card already said Live.
+// src/bnb.js now claims the element with data-i18n-owned.
+//
+// 2. Each card probes its route with HEAD/OPTIONS and reads only the status.
+// Leaving the body unread kept the stream open while the 4s timeout signal
+// stayed armed, so the browser cancelled all four probes seconds later and
+// logged a net::ERR_ABORTED failed request per card. src/bnb.js now drains
+// the response.
+//
+// Both assertions are about the page settling correctly, so each test waits
+// past the point where the old bugs surfaced rather than sampling at load.
+
+import { test, expect } from '@playwright/test';
+
+// Longer than the 4s probe timeout, so a re-introduced abort has time to fire.
+const SETTLE_MS = 6_000;
+
+test('/bnb reports the real track tally instead of the i18n placeholder', async ({ page }) => {
+ await page.goto('/bnb', { waitUntil: 'domcontentloaded', timeout: 60_000 });
+ await page.waitForTimeout(SETTLE_MS);
+
+ const progress = page.locator('#bnb-progress');
+ // The script sets data-any-live once it has resolved every card, so this
+ // pins the assertion to a finished run rather than a slow one.
+ await expect(progress).toHaveAttribute('data-i18n-owned', '1');
+ await expect(progress).toHaveText(/\d+ of \d+ demo tracks? live/);
+
+ const cards = page.locator('.bnb-card');
+ await expect(cards).toHaveCount(3);
+ for (const state of await cards.locator('.bnb-status').evaluateAll((els) => els.map((e) => e.dataset.state)))
+ expect(state, 'every card resolves to a decided state').not.toBe('checking');
+});
+
+test('/bnb settles with no aborted probe requests and no console errors', async ({ page }) => {
+ const failed = [];
+ const errors = [];
+ page.on('requestfailed', (r) => failed.push(`${r.method()} ${r.url()} :: ${r.failure()?.errorText}`));
+ page.on('console', (m) => {
+ // The Vite dev client's HMR websocket cannot reach a forwarded port in a
+ // container; that is the harness, not this page. Production serves the
+ // same page with an empty console.
+ if (m.type() === 'error' && !m.text().includes('WebSocket') && !m.text().includes('[vite]'))
+ errors.push(m.text());
+ });
+ page.on('pageerror', (e) => {
+ if (!e.message.includes('WebSocket')) errors.push(`pageerror: ${e.message}`);
+ });
+
+ await page.goto('/bnb', { waitUntil: 'domcontentloaded', timeout: 60_000 });
+ await page.waitForTimeout(SETTLE_MS);
+
+ expect(failed, 'card probes must drain their response, not get cancelled').toEqual([]);
+ expect(errors).toEqual([]);
+});
+
+test('/bnb shows an actionable error state when the block-time API is unreachable', async ({ page }) => {
+ let offline = true;
+ await page.route('**/api/bnb/block-time**', (route) => (offline ? route.abort() : route.continue()));
+
+ await page.goto('/bnb', { waitUntil: 'domcontentloaded', timeout: 60_000 });
+
+ const retry = page.locator('#bnb-proof-retry');
+ await expect(retry).toBeVisible({ timeout: 20_000 });
+ await expect(page.locator('#bnb-proof-card [role="alert"]')).toContainText(/unreachable/i);
+
+ // Recovering has to be possible from the page itself, not by reloading.
+ offline = false;
+ await retry.click();
+ await expect(page.locator('.bnb-proof-num')).toBeVisible({ timeout: 30_000 });
+});