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(club): treat an all-zero tip board as the empty state, not a board
nirholas3e1cc50d9beb
diff --git a/pages/compare.html b/pages/compare.htmlindex 9239f9ba9..ef5b46af8 100644--- a/pages/compare.html+++ b/pages/compare.html@@ -75,7 +75,7 @@</nav><h1 class="cv-h1" data-i18n="compare.compare_coins">Compare Coins</h1><p class="cv-sub" data-i18n="compare.put_up_to_four_coins_head_to">- Put up to four coins head to head — overlay how they've performed and line up the+ Put up to four coins head to head: overlay how they've performed and line up thenumbers that matter. Add coins with the search box; the URL updates so you can sharethe matchup.</p>@@ -98,7 +98,7 @@<inputid="cmp-search-input"type="search"- placeholder="Add a coin to compare…"+ placeholder="Add a coin to compare (up to 4)…"autocomplete="off"spellcheck="false"role="combobox"@@ -108,8 +108,29 @@/><div id="cmp-search-pop" class="cv-search-pop" role="listbox" hidden></div></div>- <div class="cmp-chips" id="cmp-chips" aria-label="Selected coins"></div>+ <div class="cmp-chips" id="cmp-chips" role="list" aria-label="Selected coins"></div>+ <button type="button" class="cmp-share" id="cmp-share" disabled>+ <svg+ viewBox="0 0 24 24"+ width="14"+ height="14"+ fill="none"+ stroke="currentColor"+ stroke-width="2"+ stroke-linecap="round"+ stroke-linejoin="round"+ aria-hidden="true"+ >+ <path d="M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7" />+ <path d="M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7" />+ </svg>+ Copy link+ </button></div>+ <p class="cmp-hint" id="cmp-limit-hint" hidden>+ Four coins is the maximum. Remove one to add another.+ </p>+ <p class="cmp-hint" id="cmp-status" role="status" aria-live="polite"></p><!-- Overlay performance chart. Hydrated by src/compare.js. --><sectiondiff --git a/pages/concierge.html b/pages/concierge.htmlindex de8cea1cd..5d4bf7d44 100644--- a/pages/concierge.html+++ b/pages/concierge.html@@ -75,6 +75,14 @@max-width: 1080px;margin: 0 auto;padding: 0 var(--space-md);+ /* body is display:flex site-wide, so this main is a flex item and+ inherits min-width:auto. Its min-content size is set by the+ longest unbreakable line in the install <pre>, which pushed the+ whole column to ~609px inside a 320px viewport; mobile.css clips+ horizontal overflow, so that content was cut off with no way to+ scroll to it. min-width:0 lets the column shrink and hands the+ scrolling back to the <pre>, which is built for it. */+ min-width: 0;}.cl-hero {padding: calc(var(--space-xl) * 2) 0 var(--space-xl);@@ -307,25 +315,25 @@<h2 id="cl-install" data-i18n="concierge.install_in_under_a_minute">Install in under a minute</h2><p class="cl-lede" data-i18n="concierge.pick_your_flavor_every_option_ships_the">Pick your flavor. Every option ships the same widget.</p><div class="cl-tabs" role="tablist" aria-label="Install methods">- <button class="cl-tab" role="tab" aria-selected="true" data-panel="cdn" data-i18n="concierge.one_tag">one tag</button>- <button class="cl-tab" role="tab" aria-selected="false" data-panel="element" data-i18n="concierge.web_component">web component</button>- <button class="cl-tab" role="tab" aria-selected="false" data-panel="npm" data-i18n="concierge.npm">npm</button>- <button class="cl-tab" role="tab" aria-selected="false" data-panel="js" data-i18n="concierge.imperative">imperative</button>+ <button class="cl-tab" type="button" role="tab" id="cl-tab-cdn" aria-controls="cl-panel-cdn" aria-selected="true" tabindex="0" data-panel="cdn" data-i18n="concierge.one_tag">one tag</button>+ <button class="cl-tab" type="button" role="tab" id="cl-tab-element" aria-controls="cl-panel-element" aria-selected="false" tabindex="-1" data-panel="element" data-i18n="concierge.web_component">web component</button>+ <button class="cl-tab" type="button" role="tab" id="cl-tab-npm" aria-controls="cl-panel-npm" aria-selected="false" tabindex="-1" data-panel="npm" data-i18n="concierge.npm">npm</button>+ <button class="cl-tab" type="button" role="tab" id="cl-tab-js" aria-controls="cl-panel-js" aria-selected="false" tabindex="-1" data-panel="js" data-i18n="concierge.imperative">imperative</button></div>- <div class="cl-panel" data-panel="cdn">+ <div class="cl-panel" id="cl-panel-cdn" role="tabpanel" aria-labelledby="cl-tab-cdn" data-panel="cdn"><div class="cl-code">- <button class="cl-copy" type="button" data-copy data-i18n="concierge.copy">copy</button>- <pre><code><script src="https://three.ws/concierge/concierge.global.js"+ <button class="cl-copy" type="button" data-copy aria-label="Copy the one-tag install snippet" data-i18n="concierge.copy">copy</button>+ <pre tabindex="0"><code><script src="https://three.ws/concierge/concierge.global.js"data-conciergedata-site-name="Acme"data-accent="#f97316"data-suggestions="What is Acme?|What does it cost?"></script></code></pre></div></div>- <div class="cl-panel" data-panel="element" hidden>+ <div class="cl-panel" id="cl-panel-element" role="tabpanel" aria-labelledby="cl-tab-element" data-panel="element" hidden><div class="cl-code">- <button class="cl-copy" type="button" data-copy data-i18n="concierge.copy_2">copy</button>- <pre><code>import '@three-ws/concierge';+ <button class="cl-copy" type="button" data-copy aria-label="Copy the web-component install snippet" data-i18n="concierge.copy_2">copy</button>+ <pre tabindex="0"><code>import '@three-ws/concierge';<three-conciergesite-name="Acme"@@ -335,16 +343,16 @@</three-concierge></code></pre></div></div>- <div class="cl-panel" data-panel="npm" hidden>+ <div class="cl-panel" id="cl-panel-npm" role="tabpanel" aria-labelledby="cl-tab-npm" data-panel="npm" hidden><div class="cl-code">- <button class="cl-copy" type="button" data-copy data-i18n="concierge.copy_3">copy</button>- <pre><code>npm install @three-ws/concierge three</code></pre>+ <button class="cl-copy" type="button" data-copy aria-label="Copy the npm install command" data-i18n="concierge.copy_3">copy</button>+ <pre tabindex="0"><code>npm install @three-ws/concierge three</code></pre></div></div>- <div class="cl-panel" data-panel="js" hidden>+ <div class="cl-panel" id="cl-panel-js" role="tabpanel" aria-labelledby="cl-tab-js" data-panel="js" hidden><div class="cl-code">- <button class="cl-copy" type="button" data-copy data-i18n="concierge.copy_4">copy</button>- <pre><code>import { Concierge } from '@three-ws/concierge';+ <button class="cl-copy" type="button" data-copy aria-label="Copy the imperative API snippet" data-i18n="concierge.copy_4">copy</button>+ <pre tabindex="0"><code>import { Concierge } from '@three-ws/concierge';const concierge = new Concierge({siteName: 'Acme',diff --git a/pages/converter.html b/pages/converter.htmlindex b0858fdec..bae182221 100644--- a/pages/converter.html+++ b/pages/converter.html@@ -21,7 +21,7 @@<title data-i18n="converter.meta_title">Crypto Converter · three.ws</title><metaname="description"- content="Convert between any cryptocurrency and major world currencies at live market rates. Crypto to crypto, crypto to fiat, fiat to crypto — instant, accurate, always up to date."+ content="Convert between any cryptocurrency and major world fiat currencies at live market rates: crypto to crypto, crypto to fiat, and back. Type an amount, pick both sides, and share the result via URL."data-i18n-attr="content:converter.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 Converter · three.ws" data-i18n-attr="content:converter.meta_og_title"/><metaproperty="og:description"- content="Convert between any cryptocurrency and major world currencies at live market rates — crypto to crypto, crypto to fiat, and back."+ content="Convert between any cryptocurrency and major world fiat currencies at live market rates: crypto to crypto, crypto to fiat, and back. Share any result via its URL."data-i18n-attr="content:converter.meta_og_description"/><metaproperty="og:image"@@ -61,7 +61,7 @@<link rel="canonical" href="https://three.ws/converter" /><meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" /><meta property="og:locale" content="en_US" />- <meta property="og:image:alt" content="Crypto Converter — three.ws" />+ <meta property="og:image:alt" content="Crypto Converter, three.ws" /><script type="application/ld+json">{@@ -94,9 +94,9 @@</nav><h1 class="cv-h1" data-i18n="converter.crypto_converter">Crypto Converter</h1><p class="cv-sub" data-i18n="converter.convert_between_any_cryptocurrency_and_major">- Convert between any cryptocurrency and major world currencies at live market rates.- Crypto to crypto, crypto to fiat, or fiat to crypto — every price comes straight- from the live market.+ Convert between any cryptocurrency and major world fiat currencies at live market+ rates. Crypto to crypto, crypto to fiat, or fiat to crypto: every price comes+ straight from the live market. Copy the link to share any result.</p><!-- Quick presets. Hydrated by src/converter.js. -->diff --git a/src/club.js b/src/club.jsindex 81fa1d9cd..37302c167 100644--- a/src/club.js+++ b/src/club.js@@ -2511,12 +2511,24 @@ function renderLeaderboardError(kind) {function renderLeaderboard(rows) {if (!lbRowsEl) return;- if (!rows.length) {- lbRowsEl.innerHTML = '<div class="club-lb-empty">No tips yet. Be the first to tip a dancer!</div>';++ // club_dancer_wallets is a payout registry, not tonight's lineup: it holds a+ // row per dancer wallet that has ever been registered, including ones with no+ // pole on this stage. Ranking a stranger the visitor has no way to tip is+ // noise, so a row earns its place by dancing here or by having actually been+ // tipped. An all-zero board is not a board either, that is the empty state,+ // which the registry's zero rows otherwise made permanently unreachable.+ const ranked = rows.filter((row) => (+ POLES.some((p) => p.id === String(row.dancer ?? ''))+ || Number(row.total_atomics || 0) > 0+ ));+ if (!ranked.some((row) => Number(row.total_atomics || 0) > 0)) {+ lbRowsEl.innerHTML = `<div class="club-lb-empty">${LB_EMPTY_COPY[lbWindow] || LB_EMPTY_COPY.all}</div>`;return;}+const frag = document.createDocumentFragment();- rows.forEach((row, i) => {+ ranked.forEach((row, i) => {const total = Number(row.total_atomics || 0);const unpaid = Number(row.unpaid_atomics || 0);const div = document.createElement('div');@@ -2524,8 +2536,12 @@ function renderLeaderboard(rows) {div.style.animationDelay = `${i * 0.06}s`;const dancerId = String(row.dancer || '').replace(/[<>&]/g, '');const dancerIdx = parseInt(dancerId, 10) - 1;+ // The stage name wins over the registry's display_name for a dancer who is+ // on a pole right now: the board sits directly under her card, and the two+ // naming the same pole differently reads as a different dancer entirely.+ // display_name still carries dancers who have left the lineup.const metaName = DANCER_META[dancerIdx]?.name || null;- const name = String(row.display_name || metaName || `Dancer ${dancerId}`).replace(/[<>&]/g, '');+ const name = String(metaName || row.display_name || `Dancer ${dancerId}`).replace(/[<>&]/g, '');// Rank badge: gold/silver/bronze for top 3.let rankClass = '';diff --git a/src/compare.js b/src/compare.jsindex e1da2d669..49559dce4 100644--- a/src/compare.js+++ b/src/compare.js@@ -584,11 +584,12 @@ function wireSearch() {input.setAttribute('aria-expanded', 'true');}- function pick(id) {- addCoin(id);+ async function pick(id) {input.value = '';close();- input.focus();+ const outcome = await addCoin(id);+ if (outcome === 'full') announce(`Remove a coin first. ${MAX_COINS} is the maximum.`);+ else if (!$('cmp-search-input').disabled) $('cmp-search-input').focus();}input.addEventListener('input', () => {@@ -596,14 +597,21 @@ function wireSearch() {const q = input.value.trim();if (!q) return close();timer = setTimeout(async () => {+ lastQuery = q;try {const { coins } = await getJson(`/api/coin/markets?q=${encodeURIComponent(q)}`);- lastQuery = q;items = coins.filter((c) => !state.coins.find((s) => s.id === c.id));active = -1;renderPop();} catch {- close();+ // A silent close reads as a dead search box. Say what happened.+ items = [];+ active = -1;+ pop.innerHTML =+ '<div class="none">Coin search is unavailable right now. Check your connection and type again.</div>';+ pop.hidden = false;+ input.setAttribute('aria-expanded', 'true');+ input.removeAttribute('aria-activedescendant');}}, 250);});@@ -628,16 +636,53 @@ function wireSearch() {});}+// ── Status line + share ───────────────────────────────────────────────────────++let announceTimer = null;++/** One polite live region for outcomes that have no other place to land. */+function announce(message) {+ const el = $('cmp-status');+ if (!el) return;+ el.textContent = message;+ clearTimeout(announceTimer);+ announceTimer = setTimeout(() => {+ if (el.textContent === message) el.textContent = '';+ }, 6000);+}++function wireShare() {+ const btn = $('cmp-share');+ if (!btn) return;+ btn.addEventListener('click', async () => {+ try {+ await navigator.clipboard.writeText(location.href);+ announce('Matchup link copied to the clipboard.');+ } catch {+ // Clipboard access can be refused (insecure origin, denied permission).+ // The URL is already the shareable artifact, so point at it.+ announce('Copying was blocked by the browser. The matchup link is in the address bar.');+ }+ });+}+// ── Boot ──────────────────────────────────────────────────────────────────────async function init() {wireSearch();+ wireShare();renderChips();renderChart();// Default matchup so the page is never an empty void; overridable via ?ids=.const initial = idsFromUrl();const ids = initial.length ? initial : ['bitcoin', 'ethereum', 'solana'];- for (const id of ids) await addCoin(id);+ // Parallel: three sequential round trips left the panel loading far longer+ // than the slowest single request needed.+ await Promise.all(ids.map(addCoin));+ state.booting = false;+ renderChips();+ renderTable();+ renderChart();}init();diff --git a/src/create-prompt.js b/src/create-prompt.jsindex 3b11be475..5856d8309 100644--- a/src/create-prompt.js+++ b/src/create-prompt.js@@ -165,7 +165,7 @@ async function start() {signal: _aborter.signal,});if (res.status === 401) {- window.location.assign(`/login?next=${encodeURIComponent('/create/prompt')}`);+ window.location.assign(loginUrl(prompt));return;}const data = await res.json().catch(() => ({}));@@ -174,27 +174,41 @@ async function start() {}jobId = data.jobId;} catch (err) {- if (_cancelled || err?.name === 'AbortError') return;+ if (isStale(run) || err?.name === 'AbortError') return;failBuild(err);return;}try {- const final = await pollUntilDone(jobId);- await renderDone(final.resultAvatarId);+ const final = await pollUntilDone(jobId, run);+ if (isStale(run)) return;+ await renderDone(final.resultAvatarId, run);} catch (err) {- if (_cancelled || err?.name === 'AbortError') return;+ if (isStale(run) || err?.name === 'AbortError') return;failBuild(err);}}+// Sign-in bounce that keeps the user's words. The composer is the whole point+// of this page, so sending an anonymous user to /login with a bare return path+// threw away everything they had typed. Round-trip the prompt through the+// existing ?prompt= deep link instead, so they land back here with the box+// still filled. safeNext on the login page accepts a relative path with a+// query string, so the redirect survives intact.+function loginUrl(prompt) {+ const next = prompt ? `/create/prompt?prompt=${encodeURIComponent(prompt)}` : '/create/prompt';+ return `/login?next=${encodeURIComponent(next)}`;+}+// Cancel an in-flight build: abort the network, stop the clock, and return to// the compose step. The job may still finish server-side (and will appear on the-// dashboard) — we just stop watching it, so the user is never trapped on a-// spinner.+// dashboard); we just stop watching it, so the user is never trapped on a+// spinner. Gated on the building step rather than on _submitting, because+// failBuild clears _submitting while leaving the user on that step: with the old+// guard, Cancel became a dead button in exactly the state where someone is most+// likely to press it.function cancelBuild() {- if (!_submitting) return;- _cancelled = true;+ if (document.querySelector('.step.active')?.getAttribute('data-step') !== 'building') return;try { _aborter?.abort(); } catch (_) {}resetToCompose();}@@ -245,15 +259,20 @@ function mapSubmitError(status, data) {return description || `The avatar engine returned ${status}. Try again.`;}-async function pollUntilDone(jobId) {+async function pollUntilDone(jobId, run) {const deadline = Date.now() + POLL_TIMEOUT_MS;+ const abandon = () => {+ const e = new Error('abandoned');+ e.name = 'AbortError';+ return e;+ };while (Date.now() < deadline) {- if (_cancelled) {- const e = new Error('cancelled');- e.name = 'AbortError';- throw e;- }+ if (isStale(run)) throw abandon();await sleep(POLL_INTERVAL_MS);+ // Re-check after the sleep: the user may have cancelled (or started a+ // different build) while this loop was parked, and the signal we captured+ // before the sleep is no longer the live one.+ if (isStale(run)) throw abandon();let data;try {const res = await fetch(`${STATUS_ENDPOINT}?jobId=${encodeURIComponent(jobId)}`, {@@ -261,7 +280,7 @@ async function pollUntilDone(jobId) {signal: _aborter?.signal,});if (res.status === 401) {- window.location.assign(`/login?next=${encodeURIComponent('/create/prompt')}`);+ window.location.assign(loginUrl(promptEl.value.trim()));throw new ApiError('redirecting');}data = await res.json().catch(() => ({}));@@ -274,6 +293,7 @@ async function pollUntilDone(jobId) {continue;}+ if (isStale(run)) throw abandon();advanceProgress(data.status);if (data.status === 'done' && data.resultAvatarId) {diff --git a/src/creations.js b/src/creations.jsindex 8813b1999..0d476fd85 100644--- a/src/creations.js+++ b/src/creations.js@@ -198,6 +198,8 @@ async function loadFeed({ reset = false } = {}) {if (reset && host) {host.setAttribute('aria-busy', 'true');host.innerHTML = skeleton();+ // The open lineage belongs to a card that this reload may drop.+ $('cr-lineage-panel')?.classList.add('is-hidden');}setFeedLive('connecting');try {@@ -210,9 +212,14 @@ async function loadFeed({ reset = false } = {}) {if (!res.ok) throw new Error(data?.message || `feed returned ${res.status}`);if (!data.enabled) {setFeedLive('error');+ updateCount();if (host) {host.setAttribute('aria-busy', 'false');- host.innerHTML = `<div class="cr-error"><div class="cr-empty-title">The remix bazaar is temporarily unavailable</div><p>Check back shortly.</p></div>`;+ host.innerHTML =+ `<div class="cr-error"><div class="cr-empty-title">The remix bazaar is temporarily unavailable</div>` ++ `<p>Nothing is lost — published creations reappear as soon as it is back. ` ++ `<button type="button" class="cr-retry" id="cr-retry">Retry</button></p></div>`;+ $('cr-retry')?.addEventListener('click', () => loadFeed({ reset: true }));}return;}@@ -226,6 +233,7 @@ async function loadFeed({ reset = false } = {}) {} catch (err) {log.warn('feed failed', err?.message);setFeedLive('error');+ updateCount();if (reset && host) {host.setAttribute('aria-busy', 'false');host.innerHTML =@@ -265,19 +273,30 @@ function clearFilters() {state.category = '';$('cr-q').value = '';$('cr-category').value = '';- setSort('recent');+ // Reload unconditionally: the empty state that offers this button is+ // reachable while the sort is already "recent", and an early-returning+ // setSort would leave the button doing nothing at all.+ syncSortButtons('recent');+ state.sort = 'recent';+ loadFeed({ reset: true });+ $('cr-q').focus();}// ── controls ────────────────────────────────────────────────────────────────-function setSort(sort) {- if (sort === state.sort) return;- state.sort = sort;+function syncSortButtons(sort) {for (const btn of document.querySelectorAll('[data-sort]')) {const on = btn.dataset.sort === sort;btn.classList.toggle('active', on);btn.setAttribute('aria-selected', String(on));+ btn.tabIndex = on ? 0 : -1;}+}++function setSort(sort) {+ if (sort === state.sort) return;+ state.sort = sort;+ syncSortButtons(sort);loadFeed({ reset: true });}@@ -290,8 +309,19 @@ function debounce(fn, ms) {}function wireControls() {- for (const btn of document.querySelectorAll('[data-sort]')) {+ const sortBtns = [...document.querySelectorAll('[data-sort]')];+ for (const [i, btn] of sortBtns.entries()) {btn.addEventListener('click', () => setSort(btn.dataset.sort));+ // A role="tablist" is expected to move between its tabs with the arrow+ // keys, with only the selected tab in the page's tab order.+ btn.addEventListener('keydown', (e) => {+ const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : e.key === 'Home' ? -i : e.key === 'End' ? sortBtns.length - 1 - i : 0;+ if (!step) return;+ e.preventDefault();+ const next = sortBtns[(i + step + sortBtns.length) % sortBtns.length];+ next.focus();+ setSort(next.dataset.sort);+ });}const qInput = $('cr-q');const onSearch = debounce(() => {@@ -527,8 +557,14 @@ function wirePublishForm() {form.addEventListener('submit', async (e) => {e.preventDefault();- const creationId = $('cr-pub-id').value.trim();- if (!creationId) return;+ const idInput = $('cr-pub-id');+ const creationId = idInput.value.trim();+ if (!creationId) {+ statusEl.dataset.kind = 'error';+ statusEl.textContent = 'Paste the creation id from your Forge result first.';+ idInput.focus();+ return;+ }const wallet = $('cr-pub-wallet').value.trim();const license = licenseSel.value;const royaltyBps = Math.round(Number(royaltyInput.value || 0) * 100);@@ -562,7 +598,8 @@ function wirePublishForm() {: `Published — remixable at ${p.royaltyPercent}% royalty, but add a wallet above to actually collect it.`: 'Published to the gallery — display only, not remixable.';form.reset();- royaltyOut.textContent = '10%';+ royaltyOut.textContent = `${royaltyInput.value}%`;+ royaltyRow.hidden = licenseSel.value === 'all-rights';loadFeed({ reset: true });loadLeaderboards();} catch (err) {diff --git a/src/scene-compose.js b/src/scene-compose.jsindex 17fb5fffe..b227f2b61 100644--- a/src/scene-compose.js+++ b/src/scene-compose.js@@ -876,6 +876,7 @@ function bonesToRegionMap(bones) {function buildBoneSelect(bones, currentBoneName) {const sel = document.createElement('select');sel.className = 'bs';+ sel.setAttribute('aria-label', 'Bone to attach to');const { regionMap, other } = bonesToRegionMap(bones);for (const [region, bs] of Object.entries(regionMap)) {if (!bs.length) continue;@@ -1045,8 +1046,40 @@ function detachFromBone(itemId, updateUI = true) {* @param {object} [record] the avatar record this model came from, when any:* { id, appearance }: what "Save outfit" writes to*/+function showAvatarError(msg) {+ avatarPromptErr.textContent = msg;+ avatarPromptErr.classList.add('on');+}+function clearAvatarError() {+ avatarPromptErr.textContent = '';+ avatarPromptErr.classList.remove('on');+}++/**+ * Resolve whatever the user typed into a loadable model.+ *+ * The field has always promised "GLB URL or avatar ID", but only URLs were ever+ * honoured: an id went straight to GLTFLoader as a relative path and died on a+ * parse error. An id now goes through the same /api/avatars/:id lookup the+ * ?avatar= deep link uses, so both entry points behave identically.+ *+ * @param {string} value a model URL, an avatar id, or an avatar slug+ * @returns {Promise<{ url: string, name: string, record: object|null }>}+ */+async function resolveAvatarInput(value) {+ if (/^(https?:|blob:|data:|\/)/i.test(value)) return { url: value, name: 'Avatar', record: null };+ const res = await fetch(`/api/avatars/${encodeURIComponent(value)}`);+ if (!res.ok) throw new Error(res.status === 404 ? `No avatar found for "${value}"` : `Lookup failed (HTTP ${res.status})`);+ const data = await res.json().catch(() => ({}));+ const record = data.avatar || data;+ const url = record.model_url || record.glbUrl || record.glb_url;+ if (!url) throw new Error(`Avatar "${value}" has no 3D model attached`);+ return { url, name: record.name || 'Avatar', record };+}+async function loadAvatar(url, name = 'Avatar', record = null) {showLoading('Loading avatar…');+ clearAvatarError();avatarPrompt.classList.add('h');canvasHint.classList.remove('h');try {@@ -1069,7 +1102,10 @@ async function loadAvatar(url, name = 'Avatar', record = null) {} catch (err) {log.error('avatar load failed:', err);avatarPrompt.classList.remove('h');- toast(`Failed to load avatar: ${err.message}`);+ // Inline and persistent: a toast is gone in 2.5s, long before someone can+ // read why their model was rejected or fix the URL they pasted.+ showAvatarError(`Could not load that avatar: ${err.message}. Check the URL is a public .glb, or browse your avatars below.`);+ avatarUrlInput.focus();} finally {hideLoading();}@@ -1097,24 +1133,16 @@ async function loadAvatar(url, name = 'Avatar', record = null) {} else if (avatarParam) {showLoading('Fetching avatar…');try {- if (avatarParam.startsWith('http')) {- await loadAvatar(avatarParam, 'Avatar');- } else {- const res = await fetch(`/api/avatars/${encodeURIComponent(avatarParam)}`);- const data = await res.json().catch(() => ({}));- // GET /api/avatars/:id answers { avatar: { …, model_url } }. Reading- // a bare `glbUrl` off the envelope found nothing, so every- // ?avatar=<id> deep link opened an empty stage instead of the avatar.- const record = data.avatar || data;- const u = record.model_url || record.glbUrl || record.glb_url;- if (u) await loadAvatar(u, record.name || 'Avatar', record);- else {- toast(`Avatar ${avatarParam} not found`);- avatarPrompt.classList.remove('h');- hideLoading();- }- }- } catch { hideLoading(); }+ // GET /api/avatars/:id answers { avatar: { …, model_url } }. Reading a+ // bare `glbUrl` off the envelope found nothing, so every ?avatar=<id>+ // deep link opened an empty stage instead of the avatar.+ const { url, name, record } = await resolveAvatarInput(avatarParam);+ await loadAvatar(url, name, record);+ } catch (err) {+ hideLoading();+ avatarPrompt.classList.remove('h');+ showAvatarError(`Could not open avatar "${avatarParam}": ${err.message}`);+ }} else {hideLoading();}