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
perf(mobile): keep the wallet SDK and full-size thumbnails off the mobile path
nirholas8e0e385a2557
diff --git a/pages/marketplace.html b/pages/marketplace.htmlindex b49175d38..71d3946a7 100644--- a/pages/marketplace.html+++ b/pages/marketplace.html@@ -404,6 +404,16 @@color: #fde047;border: 1px solid rgba(253, 224, 71, 0.25);}+ /* The hero rotates every 6.5s through avatars whose names and blurbs+ are different lengths, and updateHeroMeta() writes both into the+ same boxes. Unreserved, that moved the actions row, the dots and+ the whole grid below the hero on every rotation, forever: measured+ on a Pixel 5 against production on 2026-09-08, `section#market-hero`+ was 0.1094 + 0.2045 of the page's 0.4381 CLS, the worst on the+ site. Both boxes are clamped AND floored to the same line count, so+ every slide occupies identical space and a rotation moves nothing.+ Clamp without a floor is only half the fix: it caps the tall case+ and still lets the short case collapse. */.market-hero-title {font-family: var(--font-display);font-size: 32px;@@ -412,6 +422,11 @@margin: 0;line-height: 1.1;word-break: break-word;+ display: -webkit-box;+ -webkit-line-clamp: 2;+ -webkit-box-orient: vertical;+ overflow: hidden;+ min-height: 2.2em;}.market-hero-desc {font-size: 14px;@@ -422,6 +437,7 @@-webkit-line-clamp: 3;-webkit-box-orient: vertical;overflow: hidden;+ min-height: 4.5em;}.market-hero-actions {display: flex;@@ -3271,8 +3287,15 @@<button class="market-hero-secondary" id="market-hero-lobby" data-i18n="marketplace.open_3d_lobby">Open 3D Lobby</button>- <button class="market-hero-secondary" id="market-hero-fork" hidden data-i18n="marketplace.fork_agent">- Fork agent+ <!-- Ships visible and disabled, carrying the exact label+ updateHeroMeta() writes. It used to ship `hidden`+ and be revealed with a different label, which added+ a button to a flex-wrap row after first paint and+ re-wrapped everything under it. The label is written+ by JS, so per docs/site-performance.md rule 6 the+ node cannot carry a data-i18n key. -->+ <button class="market-hero-secondary" id="market-hero-fork" disabled data-no-i18n>+ Start an agent →</button><a class="market-hero-secondary" href="/marketplace-walk" data-i18n="marketplace.walk_browse_the_gallery">Walk-Browse the gallery →</a><a class="market-hero-secondary" href="/forge" data-i18n="marketplace.forge_your_own_from_text">Forge your own from text →</a>diff --git a/scripts/mobile-touch-audit.mjs b/scripts/mobile-touch-audit.mjsindex 172a6b373..b22e796bb 100644--- a/scripts/mobile-touch-audit.mjs+++ b/scripts/mobile-touch-audit.mjs@@ -19,7 +19,9 @@* a viewer embedded in a scrolling page).* 3. Safe-area handling: whether the viewport meta opts into* `viewport-fit=cover` (without it `env(safe-area-inset-*)` always resolves- * to 0), and which bottom-anchored fixed/sticky bars have no CSS rule+ * to 0), and which bottom-anchored fixed/sticky bars (those that actually+ * declare an offset from the bottom edge, so a horizontally-sticky table+ * cell that happens to be low on screen is not one) have no CSS rule* mentioning `safe-area-inset` applying to them. Those bars land under the* iOS home indicator.* 4. Horizontal overflow at the mobile viewport width (scrollWidth > clientWidth).@@ -208,6 +210,14 @@ function auditDom(minTarget) {for (const el of Array.from(document.body.querySelectorAll('*'))) {const cs = getComputedStyle(el);if (cs.position !== 'fixed' && cs.position !== 'sticky') continue;+ // Anchored to the bottom, not merely sitting near it. A sticky table cell+ // is `position: sticky` with a `left` offset so it survives a horizontal+ // scroll, and it lands wherever the row happens to be: on /markets that+ // put 101 `td.left.name-cell` elements into this list as "bottom bars+ // missing a safe-area rule", which is not a defect and is not something+ // any fix could clear. A real bottom bar declares an offset from the+ // bottom edge; without one, `bottom` computes to `auto`.+ if (cs.bottom === 'auto') continue;const box = el.getBoundingClientRect();if (!isVisible(el, cs, box)) continue;const distanceFromBottom = window.innerHeight - box.bottom;diff --git a/src/marketplace.js b/src/marketplace.jsindex e14341527..33769e356 100644--- a/src/marketplace.js+++ b/src/marketplace.js@@ -28,6 +28,7 @@ import { skeletonHTML, emptyStateHTML, errorStateHTML, ensureStateKitStyles } frimport { debounce, syncStateToUrl } from './shared/list-controls.js';import { log } from './shared/log.js';import { track, trackError, ANALYTICS_EVENTS } from './analytics.js';+import { resizedImageUrl } from './shared/image-url.js';ensureStateKitStyles();const API = '/api';@@ -1139,7 +1140,11 @@ function updateHeroMeta() {}const fork = $('market-hero-fork');if (fork) {+ // The markup already ships this button, enabled-looking and holding the+ // same label, so the actions row is its final size in the first frame.+ // Only the wiring arrives here.fork.hidden = false;+ fork.disabled = false;fork.textContent = 'Start an agent →';fork.onclick = () => {activeAvatar = a;@@ -1586,6 +1591,31 @@ function observeCardModelViewers() {});}+// A grid card's thumbnail, fetched at the size the card actually paints.+//+// Avatar and forge thumbnails are stored full-size on R2 (768x768 renders, and+// forge previews up to 344 KB each) and painted into a card 160-370 CSS px+// wide. On 2026-09-08 a Pixel 5 over slow 4G pulled 2,488 KB of images across+// 206 <img> elements opening /marketplace, which was 60% of the page's whole+// 4,141 KB. /api/img re-encodes to WebP at a fixed width ladder and caches the+// result immutably at the edge, so the same picture costs a tenth of that.+//+// srcset rather than one width because the card is 160px in a phone's two-up+// grid and 370px in its one-up, and a DPR-2 screen wants twice either; the+// browser is in a better position to choose than this function is. The `sizes`+// list mirrors public/marketplace.css's own grid breakpoints.+const CARD_THUMB_SIZES = '(max-width: 600px) 100vw, (max-width: 900px) 50vw, 300px';+function cardThumbHtml(url, alt) {+ const srcset = [320, 480, 960]+ .map((w) => `${escapeHtml(resizedImageUrl(url, w))} ${w}w`)+ .join(', ');+ return (+ `<img src="${escapeHtml(resizedImageUrl(url, 480))}" srcset="${srcset}" sizes="${CARD_THUMB_SIZES}"` ++ ` alt="${alt}" loading="lazy" decoding="async" data-fallback="element"` ++ ` data-fallback-class="card-img-fallback" />`+ );+}+// ── Avatar detail modal ──────────────────────────────────────────────────let activeAvatar = null;@@ -4635,7 +4665,7 @@ function renderAvatarCard(a, spotlight = false) {// reveal="auto" (default) means model-viewer un-veils the model on load;// no explicit dismissPoster() call needed.const preview = a.image- ? `<img src="${escapeHtml(a.image)}" alt="${name}" loading="lazy" decoding="async" data-fallback="element" data-fallback-class="card-img-fallback" />`+ ? cardThumbHtml(a.image, name): a.glbUrl? `${placeholderHtml(a.name)}<model-viewerdata-src="${escapeHtml(a.glbUrl)}"@@ -4803,7 +4833,7 @@ function renderOnchainCard(a) {const href = a.viewerUrl || a.tokenExplorerUrl || '#';const priceBadge = priceBadgeHtml(a.price);const preview = a.image- ? `<img src="${escapeHtml(a.image)}" alt="${name}" loading="lazy" decoding="async" data-fallback="element" data-fallback-class="card-img-fallback" />`+ ? cardThumbHtml(a.image, name): a.glbUrl? `${placeholderHtml(a.name)}<model-viewerdata-src="${escapeHtml(a.glbUrl)}"diff --git a/src/shared/irl-drops.js b/src/shared/irl-drops.jsindex 94a11e345..57dc6a654 100644--- a/src/shared/irl-drops.js+++ b/src/shared/irl-drops.js@@ -12,7 +12,19 @@ import {Group, Mesh, CylinderGeometry, TorusGeometry, MeshStandardMaterial,MeshBasicMaterial, Vector3,} from 'three';-import { tipAgent, TipError } from './agent-tip.js';+// agent-tip.js pulls @solana/web3.js and @solana/spl-token, which Rollup pins+// into the 146 KB `solana` chunk. A static import here put that chunk on the+// critical path of /irl, which imports this module at its top level: measured on+// a Pixel 5 over slow 4G on 2026-09-08, /irl transferred 1,173 KB of script and+// blocked the main thread for 14,580 ms, 7,283 ms of it in one task, for a+// wallet signing path that only runs when someone funds a drop. Loaded at that+// moment instead, which is already a "approve in your wallet" interaction with+// its own progress stage, so the download is invisible.+let tipModule = null;+function loadTip() {+ if (!tipModule) tipModule = import('./agent-tip.js');+ return tipModule;+}import { detectSolanaWallet, solanaTxExplorerUrl } from '../erc8004/solana-deploy.js';const VIOLET = 0xc4b5fd;@@ -530,8 +542,11 @@ function openCreate() {// 2. Fund the escrow with the creator's own signed transfer.setStage('Approve in your wallet…');let funding;+ let TipError = null;try {- funding = await tipAgent({+ const tip = await loadTip();+ TipError = tip.TipError;+ funding = await tip.tipAgent({toAddress: escrow, token: state.asset,amount: Number(state.amount) * state.maxClaims,onStage: (s) => setStage(stageLabel(s)),@@ -539,7 +554,7 @@ function openCreate() {} catch (e) {// Roll the unfunded drop back so it isn't orphaned.cancelSilently(dropId);- if (e instanceof TipError && e.code === 'cancelled') { setStage('Fund & drop'); go.disabled = false; state.busy = false; return; }+ if (TipError && e instanceof TipError && e.code === 'cancelled') { setStage('Fund & drop'); go.disabled = false; state.busy = false; return; }throw new Error(e?.message || 'Funding was not completed.');}