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
feat(play): polish the friends panel and onboarding, and cover the photo path in the journey audit
nirholas2921793a24b8
diff --git a/scripts/play-journey-audit.mjs b/scripts/play-journey-audit.mjsindex e76d573eb..87cabcb84 100644--- a/scripts/play-journey-audit.mjs+++ b/scripts/play-journey-audit.mjs@@ -105,11 +105,20 @@ async function overflowScan(label) {const out = [];const doc = document.scrollingElement;if (doc.scrollWidth > doc.clientWidth + 1) out.push({ sel: 'document', right: doc.scrollWidth, w: doc.clientWidth });+ // The defect this scan exists to catch is content the player can SEE being+ // cut off by the screen edge, so an element only counts when it actually+ // straddles that edge. /play pins <body> to `overflow: hidden`, and three+ // harmless classes of element live entirely outside the viewport behind+ // that clip: name labels the 3D projection puts at x=10000 when their+ // subject is off camera, buttons parked past the end of the horizontally+ // scrollable emote tray, and a closed right-docked drawer. All three used+ // to be reported every run, which buried the hits that mattered.+ const straddles = (r) => (r.right > vw + 1 && r.left < vw) || (r.left < -1 && r.right > 0);for (const n of document.querySelectorAll('body *')) {if (!n.offsetParent && getComputedStyle(n).position !== 'fixed') continue;const r = n.getBoundingClientRect();if (r.width === 0 || r.height === 0) continue;- if (r.right > vw + 1 || r.left < -1) {+ if (straddles(r)) {const sel = n.id ? `#${n.id}` : `${n.tagName.toLowerCase()}.${String(n.className).split(' ').slice(0, 2).join('.')}`;out.push({ sel, left: Math.round(r.left), right: Math.round(r.right) });}@@ -257,8 +266,8 @@ function summarize() {console.log('CLS:', findings.cls?.cls);}-async function noteState(label, fn) {- const v = await page.evaluate(fn).catch((e) => ({ error: String(e) }));+async function noteState(label, fn, arg) {+ const v = await page.evaluate(fn, arg).catch((e) => ({ error: String(e) }));findings.states.push({ label, v });console.log(at(), `[state:${label}]`, JSON.stringify(v));return v;@@ -443,7 +452,11 @@ await focusSweep('world');const PANELS = [['store', /store|shop|boutique/i],['bank', /bank|wallet|balance/i],- ['wheel', /wheel|spin/i],+ // "emote wheel" also matches /wheel/, and its button sits in the HUD while+ // the Wheel of Fortune is proximity-gated behind its station. Without the+ // exclusion this step opened the emote wheel and reported it as the spin+ // wheel, so a real gap would have read as a pass.+ ['wheel', /(?<!emote )wheel|spin/i],['quests', /quest|job|board/i],['friends', /friend|crew/i],['emotes', /emote/i],@@ -490,8 +503,14 @@ const left = await page.evaluate(() => {return true;});await page.waitForTimeout(2500);-await noteState('after-leave', () => ({ leaveButton: left, lobbyVisible: !!document.querySelector('#cc-lobby:not([hidden])') }))- .catch(() => {});+// `left` lives in this Node scope, so it has to be passed in; referencing it+// inside the page threw "left is not defined" and the whole leave step was+// silently swallowed by the .catch(), never verifying the lobby came back.+await noteState('after-leave', (clicked) => ({+ leaveButton: clicked,+ lobbyVisible: !!document.querySelector('#cc-lobby:not([hidden])'),+ worldGone: !document.querySelector('#cc-hud:not([hidden])'),+}), left);findings.cls = await page.evaluate(() => ({ cls: Number((window.__cls || 0).toFixed(4)), shifts: (window.__shifts || []).slice(0, 8) }));console.log(at(), '[cls]', JSON.stringify(findings.cls));diff --git a/src/friends-panel.css b/src/friends-panel.cssindex f4400a590..b7304762e 100644--- a/src/friends-panel.css+++ b/src/friends-panel.css@@ -597,3 +597,10 @@box-shadow: 0 0 0 2px var(--bg-0);pointer-events: none;}+++/* Thumb-sized actions on a phone. The panel is a drawer on /play, where every+ tap happens one-handed mid-session; 35px was under the bar. */+@media (pointer: coarse) {+ .kg-fr-btn { min-height: 40px; }+}diff --git a/src/game/coincommunities.css b/src/game/coincommunities.cssindex fb208cd61..699791142 100644--- a/src/game/coincommunities.css+++ b/src/game/coincommunities.css@@ -383,6 +383,9 @@ html[data-bg="transparent"] #cc-lobby {does not apply to them. */.cc-foot-links a {display: inline-flex; align-items: center; min-height: 44px;+ /* The row already cleared 44px of height; a four-letter label ("Docs", "API")+ was still only 31px wide, so the padding buys the other axis too. */+ padding: 0 6px; margin: 0 -6px; min-width: 40px; justify-content: center;color: var(--cc-dim); font-size: 13px; transition: color 0.15s ease;}.cc-foot-links a:hover { color: var(--cc-text); }@@ -546,7 +549,10 @@ html[data-bg="transparent"] #cc-lobby {.cc-id-toggle { flex: 1 1 100%; justify-content: center; }}.cc-avatar-label small { display: block; color: var(--cc-dim); font-weight: 400; font-size: 12px; margin-top: 3px; text-transform: none; letter-spacing: 0; }-.cc-avatar-presets { display: flex; gap: 8px; flex-wrap: wrap; }+/* The presets arrive from the avatar API a beat after first paint. Reserving one+ chip-row of height keeps the fields and the community grid below from being+ shoved down when they land (it was the lobby's largest layout shift). */+.cc-avatar-presets { display: flex; gap: 8px; flex-wrap: wrap; min-height: 50px; }.cc-avatar-chip {width: 50px; height: 50px; border-radius: var(--cc-radius); overflow: hidden;border: 1px solid var(--cc-edge); background: var(--cc-bg2);@@ -1268,6 +1274,10 @@ body.is-zen #cc-photo-btn:hover, body.is-zen #cc-photo-btn:focus-visible { opacidisplay: flex; gap: 6px; background: var(--cc-panel); border: 1px solid var(--cc-edge);border-radius: var(--cc-radius); padding: 7px; box-shadow: var(--cc-shadow); backdrop-filter: blur(10px);}+/* The tray is built empty and filled once the emote manifest lands. An empty+ bordered pill sitting there and then jumping to full width was the biggest+ layout shift in the world HUD; hide it until it has something to show. */+#cc-emotes:empty { display: none; }.cc-emote {width: 44px; height: 44px; border-radius: var(--cc-radius-sm); border: 1px solid transparent;background: rgba(255, 255, 255, 0.04); cursor: pointer; font-size: 21px; filter: grayscale(1);@@ -2564,6 +2574,49 @@ body.is-zen #cc-photo-btn:hover, body.is-zen #cc-photo-btn:focus-visible { opaci.cc-friends-panel-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }/* The FriendsPanel renders its own scrolling list into this body. */.cc-friends-panel-body { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }++/* Drawer states owned by the frame, not by FriendsPanel: the window between the+ tap and the view chunk landing, and the chunk never landing at all. Shaped and+ shimmered like the economy panels so the whole surface loads the same way. */+.cc-friends-skel { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }+.cc-friends-skel-row {+ display: flex; align-items: center; gap: 10px; padding: 9px 10px;+ background: rgba(255, 255, 255, 0.03); border: 1px solid var(--cc-edge-soft); border-radius: var(--cc-radius-sm);+}+.cc-friends-skel-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }+.cc-friends-skel-dot, .cc-friends-skel-line {+ background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.12) 37%, rgba(255, 255, 255, 0.05) 63%);+ background-size: 400% 100%;+ animation: cc-friends-skel-shimmer 1.4s ease infinite;+ border-radius: 3px;+}+.cc-friends-skel-dot { width: 26px; height: 26px; flex: none; border-radius: 50%; }+.cc-friends-skel-line { height: 9px; width: 58%; }+.cc-friends-skel-line-sm { height: 8px; width: 32%; }+@keyframes cc-friends-skel-shimmer {+ 0% { background-position: 100% 50%; }+ 100% { background-position: 0 50%; }+}+@media (prefers-reduced-motion: reduce) {+ .cc-friends-skel-dot, .cc-friends-skel-line { animation: none; }+}++.cc-friends-loaderr {+ display: flex; flex-direction: column; align-items: center; gap: 8px;+ padding: 30px 22px; text-align: center;+}+.cc-friends-loaderr-glyph { font-size: 26px; line-height: 1; opacity: 0.75; }+.cc-friends-loaderr-title { margin: 0; font-size: 13px; font-weight: 700; color: var(--cc-text); }+.cc-friends-loaderr-sub { margin: 0; font-size: 12px; line-height: 1.5; color: var(--cc-dim); max-width: 34ch; }+.cc-friends-loaderr-retry {+ margin-top: 4px; min-height: 40px; padding: 0 16px;+ background: transparent; color: var(--cc-text); font: inherit; font-size: 12px; font-weight: 700;+ border: 1px solid var(--cc-edge); border-radius: var(--cc-radius-sm); cursor: pointer;+ transition: border-color 0.14s ease, background 0.14s ease;+}+.cc-friends-loaderr-retry:hover { border-color: var(--cc-edge-hi); background: rgba(255, 255, 255, 0.08); }+.cc-friends-loaderr-retry:active { background: rgba(255, 255, 255, 0.14); }+.cc-friends-loaderr-retry:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }.cc-friends-panel-hint {flex: none; padding: 8px 14px 12px;color: var(--cc-dim, #8b93a3); font-size: 11px; letter-spacing: 0.02em;@@ -3707,3 +3760,32 @@ summary:focus-visible,animation: none !important;}}+++/* ── Touch targets on a coarse pointer ─────────────────────────────────────────+ Measured with scripts/play-journey-audit.mjs at 375px: the whole world HUD and+ the lobby's sort chips painted at 26-36px tall, under the 40px a thumb needs,+ so every one of them was a near-miss waiting to happen on the device most of+ this surface's players arrive on. The desktop density is deliberate and stays+ exactly as it is; these bumps apply only where the pointer is coarse.+ `min-*` clamps a fixed `width`/`height`, so the square closers grow too. */+@media (pointer: coarse) {+ /* Lobby */+ .cc-sort { min-height: 40px; }++ /* World HUD bar and the fixed right-edge stack */+ .cc-shop-btn, .cc-wardrobe-btn, .cc-avatarbtn, .cc-jobs-btn, .cc-friends-btn,+ .cc-buy-btn, .cc-leave, .cc-voice, .cc-power-btn, .cc-zen-btn,+ .cc-build-toggle, .cc-chat-head, #cc-status, .cc-photo-hud-btn {+ min-height: 40px;+ }++ /* Emote and reaction trays: the reaction pills were the smallest of all. */+ .cc-reaction { min-width: 40px; min-height: 40px; }++ /* Panel chrome: closers, tabs, filter chips, primary actions. */+ .cc-shop-close, .cc-ew-close, .cc-shop-flex, .cc-friends-panel-close {+ min-width: 40px; min-height: 40px;+ }+ .cc-shop-chip, .cc-shop-buy, .cc-friends-panel-crew { min-height: 40px; }+}diff --git a/src/game/play-onboard.js b/src/game/play-onboard.jsindex 1708fb301..72a413555 100644--- a/src/game/play-onboard.js+++ b/src/game/play-onboard.js@@ -150,7 +150,7 @@ export class PlayOnboard {tag: 'Welcome',title: name + (sym ? ' · ' + sym : ''),body:- 'A shared 3D world — everyone in ' ++ 'A shared 3D world. Everyone in ' +(sym || `the ${name} community`) +' meets here. Walk around, chat, build, and trade together. ' +'Others are in this world with you right now.',@@ -165,8 +165,8 @@ export class PlayOnboard {title: 'The economy',body:'Real ' + (sym || name) + ' trades drive this world: buys light the boundary ring green, sells ripple red, volume spins the totem, and price momentum shifts the weather. ' +- 'Two AI agents — ORACLE and NOVA — trade on-chain here too: NOVA pays ORACLE in USDC via x402, and every settlement is a real Solana transaction with a Solscan link. Walk up to them by the plaza and press E (or tap them) to watch a live payment round. ' +- 'Across the plaza, the ' + (sym || name) + ' Intel Kiosk sells live market intel — pay $0.01 USDC from your own wallet to light up its screen.',+ 'Two AI agents, ORACLE and NOVA, trade on-chain here too: NOVA pays ORACLE in USDC via x402, and every settlement is a real Solana transaction with a Solscan link. Walk up to them by the plaza and press E (or tap them) to watch a live payment round. ' ++ 'Across the plaza, the ' + (sym || name) + ' Intel Kiosk sells live market intel: pay $0.01 USDC from your own wallet to light up its screen.',},];}@@ -603,6 +603,15 @@ body.po-onboarding #cc-joystick { z-index: 60; }#po-help .po-ctrl-grid { margin-bottom: 0; max-height: 280px; }+/* Thumb-sized targets on a coarse pointer. The card is the first thing a phone+ player touches, and its skip cross was a 28px square. Desktop keeps the tight+ density it was drawn for. */+@media (pointer: coarse) {+ .po-close { min-width: 40px; min-height: 40px; }+ .po-help-close { min-width: 40px; min-height: 40px; }+ .po-btn, .po-ctrl-btn { min-height: 40px; }+}+/* Reduced-motion overrides */@media (prefers-reduced-motion: reduce) {#po-overlay, .po-card, #po-help { transition: none; }diff --git a/tests/e2e/play-photo-mode.spec.js b/tests/e2e/play-photo-mode.spec.jsindex d3425223c..f99b8a8b2 100644--- a/tests/e2e/play-photo-mode.spec.js+++ b/tests/e2e/play-photo-mode.spec.js@@ -20,14 +20,29 @@ import { serveHarness, collectPageErrors } from './_support.js';const HARNESS = '**/e2e/photo-mode';const URL = 'http://localhost:3000/e2e/photo-mode';-// The synthetic world's clear colour. Distinctive enough that finding it in the-// PNG proves the shot is the scene and not an empty buffer.+// The synthetic world's clear colour, distinctive enough that finding it in the+// PNG proves the shot is the scene and not an empty buffer. Set from a hex+// literal on purpose: three.js reads a hex as sRGB, so the value below is+// exactly what a correct capture must write back, which also pins the render+// target's colour-space handling (a target left in linear space comes back+// visibly washed out).const CLEAR = { r: 18, g: 92, b: 176 };+const CLEAR_HEX = 0x125cb0;+// Vite re-bundles the moment it first sees a new dependency and drops the+// module requests that were in flight while it does, which surfaces as "Failed+// to fetch dynamically imported module" on a cold dev server. Retry rather than+// report a build-server restart as a product failure. Three.js is a large cold+// transform and WebKit is the slowest to get through it, hence the patience.const RETRYING_IMPORT = `window.__imp = async (path) => {let last;- for (let i = 0; i < 4; i++) {- try { return await import(path); } catch (e) { last = e; await new Promise((r) => setTimeout(r, 700)); }+ for (let i = 0; i < 8; i++) {+ // A retry must ask for a NEW specifier, not the same one: JSC caches the+ // failed module record, so re-importing the identical path in WebKit+ // replays the original failure forever no matter how long you wait. Vite+ // serves the query-suffixed path as the same module, freshly transformed.+ const spec = i === 0 ? path : path + (path.includes('?') ? '&' : '?') + 'e2eRetry=' + i;+ try { return await import(spec); } catch (e) { last = e; await new Promise((r) => setTimeout(r, 1200)); }}throw last;};`;@@ -36,7 +51,7 @@ const RETRYING_IMPORT = `window.__imp = async (path) => {// report what landed: the preview chrome, and the decoded pixels of the PNG the// player would download.async function shoot(page, { width, height }) {- return page.evaluate(async ({ w, h, clear }) => {+ return page.evaluate(async ({ w, h, clearHex }) => {const THREE = await window.__imp('/node_modules/three/build/three.module.js');const { takePhoto, photoPreviewOpen, closePhotoPreview } = await window.__imp('/src/game/photo-mode.js');@@ -48,7 +63,7 @@ async function shoot(page, { width, height }) {const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });renderer.setPixelRatio(1);renderer.setSize(w, h, false);- renderer.setClearColor(new THREE.Color(clear.r / 255, clear.g / 255, clear.b / 255), 1);+ renderer.setClearColor(clearHex, 1);const scene = new THREE.Scene();scene.add(new THREE.AmbientLight(0xffffff, 2));@@ -124,7 +139,7 @@ async function shoot(page, { width, height }) {renderer.dispose();canvas.remove();return result;- }, { w: width, h: height, clear: CLEAR });+ }, { w: width, h: height, clearHex: CLEAR_HEX });}function near(actual, expected, tolerance = 26) {@@ -146,6 +161,17 @@ for (const engine of ENGINES) {test.beforeAll(async () => {browser = await engine.type.launch();+ // Pay the cold Vite transform of the three.js graph once, outside the+ // tests, so the first assertion is not racing the build server.+ const warm = await browser.newPage({ baseURL: 'http://localhost:3000' });+ await serveHarness(warm, HARNESS, { title: 'warm-up' });+ await warm.addInitScript(RETRYING_IMPORT);+ await warm.goto(URL);+ await warm.evaluate(async () => {+ await window.__imp('/node_modules/three/build/three.module.js');+ await window.__imp('/src/game/photo-mode.js');+ });+ await warm.close();});test.afterAll(async () => { await browser?.close(); });