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(asl-alphabet): answer every Check press instead of silently ignoring it
nirholas1dcb8bfb2ef4
diff --git a/pages/asl-alphabet.html b/pages/asl-alphabet.htmlindex a74c242bc..a8e4a8909 100644--- a/pages/asl-alphabet.html+++ b/pages/asl-alphabet.html@@ -304,7 +304,7 @@<button id="aa-practice-replay" class="aa-btn aa-btn-quiet" type="button" hidden>Show it again</button><button id="aa-practice-reveal" class="aa-btn aa-btn-quiet" type="button" hidden>Reveal</button></div>- <div class="aa-feedback" id="aa-practice-feedback">Press start and the avatar will spell something.</div>+ <div class="aa-feedback" id="aa-practice-feedback" role="status" aria-live="polite">Press start and the avatar will spell something.</div><div class="aa-score"><span>Streak <strong id="aa-streak">0</strong></span><span>Best <strong id="aa-best">0</strong></span>@@ -317,8 +317,9 @@anything with no sign of its own. Words that have signs are <em>signed</em>, and youcan watch those, get signed AI chat replies, and sign back with your webcam at<a href="/sign-language">/sign-language</a>. The full reference is in- <a href="/docs/sign-language">the documentation</a>, and the engine behind both pages is- published as <a href="https://www.npmjs.com/package/@three-ws/sign-language">@three-ws/sign-language</a>.+ <a href="/docs/sign-language">the documentation</a>, and the engine behind both pages ships as the+ <a href="https://github.com/nirholas/three.ws/tree/main/packages/sign-language">@three-ws/sign-language</a>+ package, installable from a clone until its registry publish lands.</p></main>diff --git a/pages/avatar-studio.html b/pages/avatar-studio.htmlindex e9d313380..fd4785aac 100644--- a/pages/avatar-studio.html+++ b/pages/avatar-studio.html@@ -12,7 +12,7 @@<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" /><link rel="manifest" href="/manifest.webmanifest" />- <meta name="description" content="Build a custom 3D avatar from scratch. Choose body type, sculpt face and body, add outfits and accessories — no selfie required." data-i18n-attr="content:avatar_studio.meta_description"/>+ <meta name="description" content="Build a custom 3D avatar from scratch. Choose body type, sculpt face and body, add outfits and accessories. No selfie required." data-i18n-attr="content:avatar_studio.meta_description"/><meta property="og:type" content="website" /><meta property="og:site_name" content="three.ws" /><meta property="og:url" content="https://three.ws/avatar-studio" />@@ -84,6 +84,7 @@}.as-back:hover { color: var(--text); }.as-bar-title {+ margin: 0;font-family: var(--font-display);font-size: 14px;font-weight: 600;@@ -91,6 +92,10 @@color: var(--text);text-align: center;flex: 1;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.as-actions { display: flex; gap: 8px; }.as-btn {@@ -280,9 +285,11 @@color: var(--text); border-color: var(--accent);background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));}+ /* Ink, not #fff: --accent is white in the dark theme, so a hardcoded+ white label rendered the badge as a blank pill. */.as-base-new {font-size: 10px; padding: 1px 6px; border-radius: 999px;- background: var(--accent); color: #fff; line-height: 1.5;+ background: var(--accent); color: var(--accent-ink); line-height: 1.5;}/* ── Tabs ─────────────────────────────────────────────── */@@ -308,6 +315,9 @@}.as-tab:hover { color: var(--text-2); }.as-tab.active { color: var(--text); border-color: var(--accent); }+ .as-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }+ /* Shown only in the narrow layout, where the word labels are hidden. */+ .as-tab-icon { display: none; }/* ── Chips ────────────────────────────────────────────── */.as-chips {@@ -957,14 +967,34 @@}.as-toast-link:hover { text-decoration: underline; }- /* ── Mobile: icon tabs ─────────────────────────────────── */+ /* ── Mobile: icon tabs + a top bar that fits 320px ─────── */@media (max-width: 480px) {.as-tab-label { display: none; }- .as-tab::before {+ .as-tab-icon {+ display: inline-block;font-size: 16px;line-height: 1;}.as-btn-label { display: none; }+ /* At 320px the full bar (Back label + centred title + five+ actions) overflowed the viewport and pushed "Save avatar"+ off-screen entirely. Drop the two redundant labels, tighten+ the padding, and everything fits with room to spare. The+ title stays in the a11y tree as the page's only h1. */+ .as-bar { padding: 10px 12px; gap: 8px; }+ .as-back-label { display: none; }+ .as-bar-title {+ position: absolute;+ width: 1px;+ height: 1px;+ padding: 0;+ margin: -1px;+ overflow: hidden;+ clip-path: inset(50%);+ white-space: nowrap;+ }+ .as-actions { gap: 6px; }+ .as-btn { padding: 7px 10px; }}/* ── Save overlay ─────────────────────────────────────── */@@ -1025,11 +1055,11 @@</head><body><header class="as-bar">- <a class="as-back" id="as-back" href="/create">+ <a class="as-back" id="as-back" href="/create" aria-label="Back to Create"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>- Back+ <span class="as-back-label">Back</span></a>- <div class="as-bar-title">Avatar Studio</div>+ <h1 class="as-bar-title">Avatar Studio</h1><div class="as-actions"><button class="as-btn as-icon-btn" id="as-undo" type="button" title="Undo (Ctrl+Z)" aria-label="Undo" disabled data-i18n-attr="aria-label:avatar_studio.undo_arialabel;title:avatar_studio.undo_ctrl_z_title"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7v6h6"/><path d="M3 13C5.5 7.5 12 5 17 8s6 9 3 13"/></svg>diff --git a/pages/bundles.html b/pages/bundles.htmlindex 9caf99166..983befb20 100644--- a/pages/bundles.html+++ b/pages/bundles.html@@ -98,8 +98,10 @@.bd-priceline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }.bd-priceline span { color: var(--ink-dim); font-size: 0.85rem; }.bd-priceline b { font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--ink-bright, var(--ink)); }- .bd-priceinput { display: flex; align-items: center; gap: 10px; }- .bd-priceinput input[type="number"] { flex: 1 1 auto; min-width: 0; padding: 11px 12px; border-radius: 9px; border: 1px solid var(--stroke); background: var(--bg-0); color: var(--ink); font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }+ /* Wraps rather than squeezing: on a 320px screen an unwrapped row left the+ price field 31px wide, too narrow to read the number being typed in it. */+ .bd-priceinput { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }+ .bd-priceinput input[type="number"] { flex: 1 1 140px; min-width: 120px; padding: 11px 12px; border-radius: 9px; border: 1px solid var(--stroke); background: var(--bg-0); color: var(--ink); font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }.bd-priceinput input[type="number"]:focus-visible { outline: 2px solid var(--accent, #6d8cff); outline-offset: 1px; border-color: transparent; }.bd-priceinput .bd-unit { flex: none; color: var(--ink-dim); font-size: 0.86rem; }.bd-slider { width: 100%; margin: 12px 0 2px; accent-color: var(--accent, #6d8cff); }@@ -312,7 +314,7 @@</main><script type="module">- import { apiFetch } from '/src/api.js';+ import { apiFetch, noteSession } from '/src/api.js';const $ = (id) => document.getElementById(id);const show = (el, on) => el.classList.toggle('bd-hide', !on);@@ -366,7 +368,27 @@let pricingSeq = 0; // guards against an out-of-order response overwriting a newer one// ── boot ────────────────────────────────────────────────────────+ const SIGN_IN_GATE = '<b>Sign in to build a bundle.</b> Bundles belong to an agent you own, so this page needs your account. <a href="/login?next=%2Fbundles">Sign in</a> or <a href="/register">create an account</a>.';+async function boot() {+ // Clear any gate a previous attempt left on screen, so a successful retry+ // does not leave its own error note sitting above the builder it recovered.+ show($('bd-gate'), false);+ // Ask who the visitor is before asking what they own. /api/auth/me answers+ // 200 with `{ user: null }` when signed out, so an anonymous visitor reaches+ // the sign-in gate without a red 401 in the console, and noteSession() then+ // spares every later call a CSRF pre-flight that could only 401.+ try {+ const who = await apiFetch('/api/auth/me', { allowAnonymous: true });+ const me = who.ok ? await who.json().catch(() => null) : null;+ if (me) {+ noteSession(!!me.user);+ if (!me.user) return gate(SIGN_IN_GATE);+ }+ } catch {+ return gate('<b>Could not reach three.ws.</b> Your connection dropped before the page could tell who you are.', boot);+ }+// GET /api/agents lists the caller's agents and answers 401 with no session.// Its sibling /api/agents/me answers 200 with a SINGLE agent (auto-creating// one) even for an anonymous visitor, so reading a list off it told every@@ -377,9 +399,7 @@} catch {return gate('<b>Could not reach three.ws.</b> Your connection dropped before your agents loaded.', boot);}- if (res.status === 401) {- return gate('<b>Sign in to build a bundle.</b> Bundles belong to an agent you own, so this page needs your account. <a href="/login?next=%2Fbundles">Sign in</a> or <a href="/register">create an account</a>.');- }+ if (res.status === 401) return gate(SIGN_IN_GATE);if (!res.ok) return gate('<b>Could not load your agents</b> (HTTP ' + res.status + ').', boot);const body = await res.json().catch(() => null);@@ -392,7 +412,9 @@sel.innerHTML = agents.map((a) => '<option value="' + esc(a.id) + '">' + esc(a.name || a.id) + '</option>').join('');// A single agent needs no picker: one less control, one less decision.show($('bd-agent-field'), agents.length > 1);- sel.addEventListener('change', () => selectAgent(sel.value));+ // Assigned rather than added: boot() runs again after a retry, and a second+ // listener would fetch this agent's skills and bundles twice per change.+ sel.onchange = () => selectAgent(sel.value);show($('bd-builder'), true);await selectAgent(agents[0].id);@@ -660,6 +682,9 @@let betterSeq = 0;function refreshBetterOff(price) {const el = $('bd-better');+ // A price of zero is rejected by the endpoint (below one atomic unit), so+ // answer it here rather than leaving the tile dimmed on a doomed request.+ if (!(price > 0)) { el.textContent = '0'; delete el.dataset.pending; return; }el.dataset.pending = '1';clearTimeout(betterDebounce);const seq = ++betterSeq;diff --git a/pages/sign-mirror.html b/pages/sign-mirror.htmlindex 51701203e..31877e06e 100644--- a/pages/sign-mirror.html+++ b/pages/sign-mirror.html@@ -338,8 +338,9 @@This is the practice half of the signing loop. The reference for every letter and numberlives at <a href="/asl-alphabet">/asl-alphabet</a>, whole words and signed chat replies at<a href="/sign-language">/sign-language</a>, and the engine behind all three pages is- documented in <a href="/docs/sign-language">the sign language docs</a> and published as- <a href="https://www.npmjs.com/package/@three-ws/sign-language">@three-ws/sign-language</a>.+ documented in <a href="/docs/sign-language">the sign language docs</a> and shipped as the+ <a href="https://github.com/nirholas/three.ws/tree/main/packages/sign-language">@three-ws/sign-language</a>+ package, installable from a clone until its registry publish lands.The avatar, the target diagram, and the grader all read the same handshape spec, so whatis taught and what is graded can never drift apart.</p>diff --git a/src/agora/README.md b/src/agora/README.mdindex 130c4c11b..5ce098b48 100644--- a/src/agora/README.md+++ b/src/agora/README.md@@ -70,13 +70,15 @@ Deep links: `?task=<pda>`, `?arena=<pda>`, `?guild=<pda>` (plus `&cluster=`) opeStyle modules ([agora.css](agora.css), [economy-layer.css.js](economy-layer.css.js), [trust-surface.css.js](trust-surface.css.js), [arena-guild.css.js](arena-guild.css.js), [humans.css.js](humans.css.js), [player-mode.css.js](player-mode.css.js)) carry each layer's CSS; the `.css.js` files self-inject so a layer ships its own styles.+**How the crowd gets dressed.** A community avatar runs 2.7 MB to 21 MB, and the square renders the 200 most recently active citizens, so loading everyone's own model is close to a gigabyte and leaves the plaza empty for minutes. [citizen-avatar.js](citizen-avatar.js) splits presence from fidelity: every citizen is placed on the shared default rig (one GLB for the whole crowd), and the first `MAX_PERSONAL_AVATARS` citizens that carry their own avatar upgrade to it in the background, swapping in place without losing position, facing, or an in-flight walk. Nobody is missing and nobody is invented; only the look arrives progressively. [agora-world.js](agora-world.js) places them in batches with a frame in between, so the world keeps painting while the square fills and the population chip reads `n / total` until it is done.+**The bottom-edge stack.** The Commons is a full-bleed canvas, so several independent layers compete for the bottom of the viewport: the job board panel and the activity ticker ([economy-layer.css.js](economy-layer.css.js)), the humans dock ([humans.css.js](humans.css.js)), the "Enter the Commons" button and the population chip ([agora.css](agora.css)), and the platform language switcher ([src/i18n.js](../i18n.js)). Anything new that pins itself to the bottom must join that stack instead of hard-coding an offset, or it will land on top of a control. The shared tokens are declared and documented at the top of [agora.css](agora.css): `--agora-corner-band`, `--agora-pop-band`, `--agora-dock-floor`, and `--agora-dock-h` (the dock's live measured height, published by [me-hud.js](me-hud.js) through a `ResizeObserver` so the stack follows the dock through every signed-out/signed-in state).## Backend endpoints consumedAll under [api/agora/[action].js](../../api/agora/%5Baction%5D.js) (reads) and [api/agora/act.js](../../api/agora/act.js) (writes):-- `GET /api/agora/citizens` : the world-renderable population+- `GET /api/agora/citizens` : the world-renderable population. `avatarUrl` is a ready-to-load GLB URL: the projection stores an `avatars.id`, and the endpoint resolves the whole page in one batch read (public and unlisted avatars only, so a private one arrives with its id still in the field and its citizen wears the shared rig). `avatarId` carries the id- `GET /api/agora/board` : open AgenC tasks + x402 bazaar services as claimable jobs. `maxItems` (default 60) bounds the whole board, not just each facilitator's page loop; the response carries `serviceTotal` and `truncated` so a client can report the real size of the open economy while rendering a bounded slice of it- `GET /api/agora/pulse` : population breakdown, 24h flows, top earners, narration- `GET /api/agora/passport?id=|agentPda=|agentId=` : one citizen's living passportdiff --git a/src/agora/agora-world.js b/src/agora/agora-world.jsindex 537e9ea23..8098ae7cd 100644--- a/src/agora/agora-world.js+++ b/src/agora/agora-world.js@@ -65,6 +65,10 @@ function citizenPosition(citizen, i) {}const CITIZENS_URL = '/api/agora/citizens?limit=200';+// How many citizens are placed per frame while the crowd fills in.+const PLACE_BATCH = 10;+// Yield to the browser so the world paints between placement batches.+const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => resolve()));// The citizens and the buildings are independent fetches, but the population one// used to start only after the OSM ladder settled. When Overpass is slow that@@ -264,15 +268,24 @@ async function main() {// Progressive populate: every citizen stands up on the shared rig, then the// most recently active ones upgrade to their own avatar in the background.// Loads are pooled inside CitizenPopulation so the fleet streams in smoothly.+ //+ // Placed in batches with a frame between them. The whole crowd shares one+ // template, so an unchunked pass resolves all 200 in a single microtask+ // flush: 200 skeleton clones and 200 label canvases back to back, which+ // locks the main thread and freezes the world mid-boot. Batching keeps the+ // render loop breathing and lets the population chip climb honestly.let personalBudget = MAX_PERSONAL_AVATARS;- await Promise.all(citizens.map((citizen, i) => {- // Claimed synchronously, in list order, before the first await, so the- // personal-avatar budget goes to the most recently active citizens that- // actually carry one.- const personal = Boolean(citizen.avatarUrl) && personalBudget-- > 0;- return population.add(citizen, citizenPosition(citizen, i), { personal })- .then(renderCount);- }));+ for (let i = 0; i < citizens.length; i += PLACE_BATCH) {+ const batch = citizens.slice(i, i + PLACE_BATCH);+ await Promise.all(batch.map((citizen, j) => {+ // Claimed in list order, so the personal-avatar budget goes to the most+ // recently active citizens that actually carry one.+ const personal = Boolean(citizen.avatarUrl) && personalBudget-- > 0;+ return population.add(citizen, citizenPosition(citizen, i + j), { personal });+ }));+ renderCount();+ await nextFrame();+ }renderCount();} catch (err) {log.warn('[agora] citizens fetch failed', err?.message);diff --git a/src/asl-alphabet-page.js b/src/asl-alphabet-page.jsindex 4d87c6c8f..6ebd7da6e 100644--- a/src/asl-alphabet-page.js+++ b/src/asl-alphabet-page.js@@ -304,6 +304,19 @@ async function boot() {};renderScore();+ // The drill speaks in one place, and the start button's label names the phase+ // the drill is actually in, so the feedback line can point at it by name.+ const say = (text, state) => {+ if (!practiceFeedback) return;+ practiceFeedback.textContent = text;+ practiceFeedback.dataset.state = state;+ };++ const setStartLabel = () => {+ if (!startBtn) return;+ startBtn.textContent = !practice.answer ? 'Start practising' : practice.active ? 'Skip to the next one' : 'Next one';+ };+const currentMode = () => [...modeInputs].find((i) => i.checked)?.value || 'letters';const nextRound = async () => {@@ -313,10 +326,7 @@ async function boot() {? 'The avatar is still loading: the drill starts as soon as it is on stage.': 'This drill needs the live avatar, which could not load. Reload the page to try again.';setStatus(msg);- if (practiceFeedback) {- practiceFeedback.textContent = msg;- practiceFeedback.dataset.state = 'shown';- }+ say(msg, 'shown');return;}practice.active = true;@@ -324,10 +334,7 @@ async function boot() {currentMode() === 'words'? PRACTICE_WORDS[Math.floor(Math.random() * PRACTICE_WORDS.length)]: CHARS[Math.floor(Math.random() * CHARS.length)];- if (practiceFeedback) {- practiceFeedback.textContent = 'Watch, then type what it spelled.';- practiceFeedback.dataset.state = 'asking';- }+ say('Watch, then type what it spelled.', 'asking');if (practiceInput) {practiceInput.value = '';practiceInput.disabled = false;@@ -335,15 +342,30 @@ async function boot() {}if (replayBtn) replayBtn.hidden = false;if (revealBtn) revealBtn.hidden = false;- if (startBtn) startBtn.textContent = 'Skip to the next one';+ setStartLabel();// The whole point is to read it, so the keys must not give it away.await play(practice.answer, { describe: false });};+ // Check is live from first paint, so it answers every press: with no round to+ // grade it says how to start one, with an empty box it says what to put there.+ // A press that changes nothing on screen reads as a broken button.const checkAnswer = () => {- if (!practice.active) return;+ if (!practice.active) {+ say(+ practice.answer+ ? 'That round is finished. Press "Next one" to keep reading.'+ : 'Press start and the avatar will spell something to read.',+ 'shown',+ );+ return;+ }const guess = normalizeWord(practiceInput?.value || '').replace(/\s+/g, '');- if (!guess) return;+ if (!guess) {+ say('Type what you read, then press Check. "Show it again" replays it.', 'asking');+ practiceInput?.focus();+ return;+ }const right = guess === practice.answer;practice.streak = right ? practice.streak + 1 : 0;if (practice.streak > practice.best) {@@ -351,24 +373,23 @@ async function boot() {saveSignPrefs({ aslBest: practice.best });}renderScore();- if (practiceFeedback) {- practiceFeedback.textContent = right+ say(+ right? `Correct: ${practice.answer}. Next one is coming.`- : `That was ${practice.answer}, not ${guess}. Watch it again.`;- practiceFeedback.dataset.state = right ? 'right' : 'wrong';- }+ : `That was ${practice.answer}, not ${guess}. Show it again to see the shape, then take the next one.`,+ right ? 'right' : 'wrong',+ );practice.active = false;+ setStartLabel();if (right) setTimeout(nextRound, 1200);};startBtn?.addEventListener('click', nextRound);replayBtn?.addEventListener('click', () => play(practice.answer, { describe: false }));revealBtn?.addEventListener('click', () => {- if (practiceFeedback) {- practiceFeedback.textContent = `It spelled ${practice.answer}.`;- practiceFeedback.dataset.state = 'shown';- }+ say(`It spelled ${practice.answer}.`, 'shown');practice.active = false;+ setStartLabel();});practiceInput?.addEventListener('keydown', (e) => {if (e.key === 'Enter') {@@ -389,10 +410,7 @@ async function boot() {for (const el of [startBtn, replayBtn, revealBtn, checkBtn, practiceInput, ...modeInputs]) {if (el) el.disabled = !canSign;}- if (!canSign && practiceFeedback) {- practiceFeedback.textContent = 'This drill needs the live avatar, which could not load. Reload the page to try again.';- practiceFeedback.dataset.state = 'shown';- }+ if (!canSign) say('This drill needs the live avatar, which could not load. Reload the page to try again.', 'shown');};// ── Settings ─────────────────────────────────────────────────────────────diff --git a/src/avatar-studio.js b/src/avatar-studio.jsindex e03bcfc0d..ca71366fa 100644--- a/src/avatar-studio.js+++ b/src/avatar-studio.js@@ -137,7 +137,7 @@ function queueOp(fn) {}const TABS = [- { id: 'color', label: 'Color', kinds: [], color: true },+ { id: 'color', label: 'Color', kinds: [], emoji: '🎨', color: true },{ id: 'hat', label: 'Hats', kinds: ['hat'], emoji: '🎩', single: true },{ id: 'glasses', label: 'Glasses', kinds: ['glasses'], emoji: '🕶️', single: true },{ id: 'earrings', label: 'Earrings', kinds: ['earrings'], emoji: '💎', single: false },@@ -203,7 +203,7 @@ const EYE_OFF =init().catch((err) => {log.error('[avatar-studio] init', err);- renderStageError($('as-shell'), 'Character Studio couldn’t load. Check your connection and try again.');+ renderStageError($('as-shell'), 'Avatar Studio couldn’t load. Check your connection and try again.');});// Render an actionable error (Retry + Back) into a container, replacing whatever@@ -636,10 +636,15 @@ function renderTabs() {const el = $('as-tabs');el.innerHTML = TABS.map((t) => {const active = t.id === activeTab;+ // The icon carries the tab on narrow viewports, where the word label is+ // hidden. `aria-label` is unconditional so the button keeps its name in+ // that layout instead of announcing an emoji (or nothing at all).return `<button class="as-tab${active ? ' active' : ''}" data-tab="${t.id}" role="tab"id="as-tab-${t.id}" aria-selected="${active ? 'true' : 'false'}"- aria-controls="as-panel" tabindex="${active ? '0' : '-1'}">+ aria-controls="as-panel" tabindex="${active ? '0' : '-1'}"+ aria-label="${esc(t.label)}" title="${esc(t.label)}">+ <span class="as-tab-icon" aria-hidden="true">${t.emoji}</span><span class="as-tab-label">${t.label}</span></button>`;}).join('');@@ -726,6 +731,7 @@ function renderActivePanel() {<div class="as-search-wrap"><input class="as-search" id="as-search" type="search"placeholder="Search ${esc(tab.label.toLowerCase())}..."+ aria-label="Search ${esc(tab.label.toLowerCase())}"value="${esc(searchQuery)}" autocomplete="off" /></div>`;@@ -1713,7 +1719,19 @@ async function saveAvatar() {return;}- setStatus('err', `Save failed: ${err.message || 'Unknown error'}`);+ // A dropped connection surfaces as the browser's bare "Failed to fetch",+ // which tells the user nothing they can act on. Name the cause and the+ // next move instead; every other error already carries a server message+ // worth showing, so that one only needs the retry nudge appended.+ const offline = typeof navigator !== 'undefined' && navigator.onLine === false;+ const networkFailure =+ offline || /failed to fetch|networkerror|load failed|network request failed/i.test(err.message || '');+ setStatus(+ 'err',+ networkFailure+ ? 'Save failed: could not reach three.ws. Your look is still here, so check your connection and press Save again.'+ : `Save failed: ${err.message || 'Unknown error'}. Press Save to try again.`,+ );saveBtn.disabled = false;resetBtn.disabled = false;}diff --git a/src/chains.js b/src/chains.jsindex b195b69b2..c594f16f0 100644--- a/src/chains.js+++ b/src/chains.js@@ -200,6 +200,9 @@ function renderTable() {state.sortDir = key === 'name' ? 'asc' : 'desc';}renderTable();+ // The header this came from is a fresh node after the re-render, so+ // keyboard users would otherwise be dropped back to the document.+ $('chains-table')?.querySelector(`th[data-key="${key}"]`)?.focus();};th.addEventListener('click', activate);th.addEventListener('keydown', (e) => {diff --git a/src/voice/camera-presets.js b/src/voice/camera-presets.jsindex 3ef332467..98b333a0f 100644--- a/src/voice/camera-presets.js+++ b/src/voice/camera-presets.js@@ -64,11 +64,28 @@ export function computeFraming({ box, preset = 'full', aspectRatio = 1 } = {}) {// 0.5 = mid-torso, 0.65 = chest, 0.85 = head, 1.0 = top of head.const targetY = box.min.y + height * cfg.targetFrac;- // Distance back from the subject — scales with avatar height, then backs- // off further on narrow viewports so a T-pose silhouette still fits- // horizontally. Wider-than-tall viewports never need that extra nudge.+ // Distance back from the subject. The heuristic term scales with avatar+ // height and backs off further on narrow viewports so a T-pose silhouette+ // still fits horizontally; wider-than-tall viewports never need that nudge.const aspectBackoff = Math.max(1, 1 / aspectRatio);- const distance = Math.max(cfg.minDistance, height * cfg.distanceMul * aspectBackoff);+ const heuristic = height * cfg.distanceMul * aspectBackoff;++ // ...but a multiplier alone cannot promise that the preset's subject is+ // actually inside the frustum: `full` at 35 deg FOV and 1.05x height showed+ // barely two thirds of a humanoid, so the head and the feet were cropped in+ // the avatar studio. Solve the projection instead. `coverFrac` is the share+ // of the avatar's height the preset must keep in frame and `coverWidthFrac`+ // the share of its width (a full-body shot has to clear the arms; a headshot+ // only the skull), both padded so the silhouette never kisses the edge.+ const halfFovY = (cfg.fov * Math.PI) / 360;+ const pad = 1 + cfg.padding;+ const fitForHeight = (height * cfg.coverFrac * pad) / 2 / Math.tan(halfFovY);+ const halfFovX = Math.atan(Math.tan(halfFovY) * aspectRatio);+ const fitForWidth = (size.x * cfg.coverWidthFrac * pad) / 2 / Math.tan(halfFovX);++ // Measured from the box centre, so half the depth is inside the body: add it+ // back or a deep subject (a cape, a backpack) eats into the clearance.+ const distance = Math.max(cfg.minDistance, heuristic, fitForHeight, fitForWidth) + size.z / 2;// Camera height: slightly above target so the look-vector slopes very// gently downward. Avoids the up-the-nose angle when the avatar is short.@@ -83,11 +100,18 @@ export function computeFraming({ box, preset = 'full', aspectRatio = 1 } = {}) {const PRESET_CONFIG = {full: {- targetFrac: 0.55,+ // Aim at the vertical middle so the whole silhouette is centred: the+ // framing below keeps head-to-toe in frame, and an off-centre target+ // would spend that headroom on one end.+ targetFrac: 0.5,distanceMul: 1.05,minDistance: 0.7,cameraHeightOffsetMul: 0.05,fov: 35,+ // Head to toe, arms included.+ coverFrac: 1,+ coverWidthFrac: 1,+ padding: 0.1,},half: {// Aim at sternum-height; pull in to ~70% of avatar height.@@ -97,6 +121,10 @@ const PRESET_CONFIG = {cameraHeightOffsetMul: 0.02,// Slightly tighter FOV reads more "portrait" / "video call".fov: 32,+ // Upper torso + head: a little under half the body, shoulders wide.+ coverFrac: 0.44,+ coverWidthFrac: 0.9,+ padding: 0.06,},headshot: {// Aim near the face.@@ -105,6 +133,10 @@ const PRESET_CONFIG = {minDistance: 0.35,cameraHeightOffsetMul: 0.0,fov: 28,+ // Head + neck only, so the arms are deliberately out of frame.+ coverFrac: 0.23,+ coverWidthFrac: 0.45,+ padding: 0.06,},};diff --git a/tests/agora-read-model.test.js b/tests/agora-read-model.test.jsindex 228892676..719a6026c 100644--- a/tests/agora-read-model.test.js+++ b/tests/agora-read-model.test.js@@ -25,6 +25,7 @@ const H = vi.hoisted(() => ({completed: [{ n: 0 }],recent: [],topEarners: [],+ avatars: [],passportRow: undefined, // undefined ⇒ not foundactivity: [],bazaarItems: [],@@ -56,6 +57,9 @@ vi.mock('../api/_lib/db.js', () => {else if (q.includes('from agora_citizens where agenc_agent_pda')) rows = H.passportRow === undefined ? [] : [H.passportRow];else if (q.includes('from agora_citizens where agenc_agent_id')) rows = H.passportRow === undefined ? [] : [H.passportRow];else if (q.includes('from agora_citizens')) rows = H.citizens;+ // The batch avatar resolve behind `avatarUrl` (public/unlisted only); the+ // visibility filter lives in the SQL, so the fake returns what it selected.+ else if (q.includes('from avatars')) rows = H.avatars;return Promise.resolve(rows);};return { sql, isDbUnavailableError: () => false, isDbCapacityError: () => false };@@ -76,6 +80,11 @@ vi.mock('../api/_lib/x402/bazaar-client.js', () => ({filterByNetwork: (items) => items,filterByMaxPrice: (items) => items,}));+// Object storage is an I/O boundary like the DB: give publicUrl a domain so the+// citizens batch resolve can build a real URL without S3 config in the test env.+vi.mock('../api/_lib/r2.js', () => ({+ publicUrlOrNull: (key) => (key ? `https://cdn.example/${key}` : null),+}));vi.mock('@tetsuo-ai/sdk', () => ({ getAgent: async () => null }));import handler from '../api/agora/[action].js';@@ -104,6 +113,7 @@ async function call(action, { method = 'GET', query = {} } = {}) {beforeEach(() => {H.citizens = [];+ H.avatars = [];H.openTasks = [];H.pop = [{ total: 0, agents: 0, humans: 0, active_24h: 0 }];H.prof = []; H.status = [];@@ -170,6 +180,40 @@ describe('citizens', () => {expect(c.agenc.registered).toBe(true);expect(c.professions.map((p) => p.key)).toContain('sculptor'); // bit 1 set});++ // agora_citizens.avatar_url holds an avatars.id, not a URL. The Commons used to+ // take the column at its name and resolve every citizen with its own+ // /api/avatars/<id> round trip, which cost 184 requests on a full square and+ // starved the economy poller of connections. The endpoint resolves the page in+ // one batch read now, so the field means what it says.+ it('resolves a citizen avatar id into a loadable URL in one batch read', async () => {+ H.citizens = [+ { id: 'c1', display_name: 'Aria', avatar_url: '11111111-1111-4111-8111-111111111111', capability_bits: 0 },+ { id: 'c2', display_name: 'Sol', avatar_url: 'https://already/a.glb', capability_bits: 0 },+ { id: 'c3', display_name: 'Nyx', avatar_url: null, capability_bits: 0 },+ ];+ H.avatars = [{ id: '11111111-1111-4111-8111-111111111111', storage_key: 'u/aria/model.glb' }];++ const { body } = await call('citizens');+ const [aria, sol, nyx] = body.citizens;+ expect(aria.avatarUrl).toBe('https://cdn.example/u/aria/model.glb');+ expect(aria.avatarId).toBe('11111111-1111-4111-8111-111111111111');+ // A URL already in the column is passed through untouched.+ expect(sol.avatarUrl).toBe('https://already/a.glb');+ expect(nyx.avatarUrl).toBe(null);+ });++ // A private avatar would need a presigned credential minted per citizen for a+ // world anyone can watch, so it stays unresolved and its citizen renders on the+ // shared default rig rather than blocking or leaking a signed URL.+ it('leaves an unresolvable avatar id alone rather than inventing a URL', async () => {+ H.citizens = [{ id: 'c1', display_name: 'Aria', avatar_url: '22222222-2222-4222-8222-222222222222', capability_bits: 0 }];+ H.avatars = []; // private / deleted: the visibility-filtered read returns nothing++ const { body } = await call('citizens');+ expect(body.citizens[0].avatarUrl).toBe('22222222-2222-4222-8222-222222222222');+ expect(body.citizens[0].avatarId).toBe('22222222-2222-4222-8222-222222222222');+ });});describe('board', () => {