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.

feat(play): rebuild the coin-community lobby around live world headcounts

nirholas395a827484a4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd0aab45b..67e604fdc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,6 +35,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Selfie to Avatar tells you your library is full before it spends ninety seconds building**: Five fixes to Selfie to Avatar. If your avatar library was already at the limit for your plan, nothing noticed until the very end: you waited out the full reconstruction, and then the page said the 3D engine had hit a snag and told you to try again. It was not an engine problem, trying again could never work, and every attempt spent another ninety seconds of generation to land in the same place. Your library is now checked the moment you press the button, so a full one is refused immediately with the actual reason and what to do about it, and a build that fills the last slot while it is running ends with that same plain explanation instead of the engine message. The page also stopped losing its own error messages: the Build button floats above the page, so tapping it from higher up left the explanation somewhere below the fold while the button quietly reset itself, which read as nothing having happened. Errors now scroll into view. On the finished-avatar screen, Learn how to embed pointed at a page that did not exist and answered 404; it now opens the embedding guide. And on a narrow phone the Photoreal and Stylized choices were squeezed into two columns barely wide enough for one word per line, so they now stack and can be read. (`/create/selfie`) `[fix, improvement]`
- **Skill tags now actually filter, a failed skills load says so instead of claiming the catalog is empty, and a shared skills link brings its filters with it**: The /skills path was driven end to end in a real browser. It forwards into the Marketplace Skills tab, and it was forwarding a search that the tab then threw away: a link like /skills?q=whale landed on the full unfiltered list with an empty search box. The Skills tab now reads its search, category, tag, and sort straight off the address bar, and writes them back as you change them, so the view you are looking at is the view you can bookmark, share, reload, and step back through. The tag chips on a skill were the clearest casualty of that gap: clicking one navigated to a list that looked exactly the same as before, because nothing was filtering by tag at all. Tags now filter for real in the catalog itself, the tab shows which tag it is filtering by, and one click clears it. When the catalog cannot be reached, the grid used to show the words No skills found with an invitation to publish one, which is the same screen an empty catalog would give you and offers no way to try again: the error state and its Retry button were being overwritten a fraction of a second after they rendered. A failed load now says it could not load skills and hands you the retry. The count under the heading was also being reverted to its placeholder by the translation pass a moment after it was written, so it never showed how many skills you were looking at; it does now, and it names your active category or tag. The empty state names the filters that emptied the list instead of guessing. For anyone arriving without JavaScript, including crawlers, /skills was a completely blank page with no link out of it; it now carries a real heading, an explanation, and a link into the Marketplace. The search box has a proper label, the free and paid chips announce which one is selected, and the page holds up from 320px to 1440px. (`/marketplace?tab=skills`) `[fix, improvement]`
- **Smart Money Radar stops shearing coin cards on a phone, and a lost connection no longer masquerades as a coin nobody is buying**: The /smart-money page was driven end to end in a real browser at 320, 768 and 1440 pixels. On a narrow phone the coin grid insisted on a column wider than the screen, so the right edge of every card was silently cut away by the page: the pedigree score badge and the star that adds a coin to your watchlist were both off-screen, with no sideways scroll to reach them. Cards now fit the screen they are on, and the score and the star are back. The bigger problem was that the page could not tell a coin it had never scored apart from a request that never arrived. If your connection dropped, or the radar was briefly down, every coin on your watchlist was relabelled Not on the radar yet, which reads as a verdict on the coin rather than a problem with the connection, and opening any coin or wallet gave you the same flat Not scored yet with no way to try again. The page now separates the two. A genuine miss keeps its explanation and now says why, and adds a link out to pump.fun or Solscan so the trail does not end there. A connection failure says the radar could not be reached and gives you a Retry button, in the drawer, on the watchlist, and on individual watched coins, and your watchlist is explicitly noted as still saved on your device. A first load that fails outright used to leave the Top wallets tab as an empty void; it now carries the same message and its own retry. A proven wallet whose trades predate the detail the radar keeps used to show a bare No recent coins on record, which looked like a wallet that had stopped trading; it now explains that the coin-level detail has aged out while the win record above still counts every verdict. (`/smart-money`) `[fix, improvement]`
+- **Studio stops going quiet when the engine list fails, and a broken preview no longer leaves a wall of broken images**: The Studio at three.ws/forge-studio was driven end to end in a real browser: both text-to-3D pipelines, all three tabs (Object, Avatar and Lab), a real generation from prompt to finished GLB, and the loading, empty, error and populated states at phone, tablet and desktop widths. The finding that mattered was silent. Studio asks the server which generation engines are live before it draws the Quality and Engine pickers, and if that request failed for any reason, the whole row of controls simply vanished with nothing said. You were left on a page that looked complete but had quietly lost the choice between Draft, Standard and High, and every engine behind it, with no hint that anything had gone wrong or any way to get it back short of a reload. A failed engine list now says so where the pickers used to be, explains that generation still works on the free engine, and offers a Retry that brings the full picker back in place. A server that genuinely has no engines to offer stays quiet as before, because that is not a failure. Second, when a thumbnail in the community showcase could not load, the card started rendering a 3D frame from the model file instead, which is the right answer, but it left the broken image sitting on screen for the whole wait. Those renders are queued one at a time behind a twenty second limit, so a bad network turned the showcase into a grid of broken-image boxes for minutes. The card now falls back to its readable gradient-and-prompt tile the instant the image fails, and the 3D render replaces it when it arrives. The rest is the polish an audit turns up: the Avatar tab carried two competing page headings, so a screen reader heard the page rename itself when you switched tabs; the Lab tab's Download button now tells assistive tech it is disabled and why, instead of just looking dim; the photo and sketch file pickers finally have names; and a freshly generated model now actually previews, where before the viewer, the reveal animation and the game-ready poly counter all failed to read the finished file outside production. (`/forge-studio`) `[fix, improvement]`
- **Tabbing into the Forge prompt box now shows you where you are**: The Forge composer (three.ws/forge and the maximum-quality lane at three.ws/forge-max) draws its describe-it box, its photo-guidance box and its sketch-description box without a border, so the card reads as one clean surface. That styling had also switched off the browser focus outline, which meant anyone moving through the page with the Tab key landed in the main prompt field with no visible sign that they were there: the page looked identical whether the box had keyboard focus or not, on the single most important input on the surface. All three boxes now draw a focus ring when you reach them by keyboard, and only by keyboard, so clicking in with a mouse keeps the seamless look it always had. The rest of the lane was driven end to end in a real browser at phone, tablet and desktop widths: High stays pinned when you open /forge-max, the quality switches move between Draft, Standard and High with the holder gate reflected on the Generate button, and a busy or failing generator lands on a designed message with a retry rather than a blank panel. (`/forge-max`) `[fix, improvement]`
- **Talking Avatar Video stops handing the renderer a 3D file where a photo belongs, and says up front when the GPU lane is down**: The /create/video page turns one of your avatars plus an audio clip into a lip-synced video, and it was driven end to end in a real browser: every state, every button, every width. The worst finding was invisible from the page. The reference frame the GPU worker renders from was being taken from whatever the browser had handy, which for an avatar with no thumbnail meant its 3D model file. The worker saved that as the reference photo and then failed on it minutes later, after the wait had already been spent. The page now sends only the avatar, and the server resolves a real image for it: the stored thumbnail, or a fresh portrait render when there is none. Second, the GPU renderer is a separate service, and when it is not running the only signal was a failure after you had already picked a file and uploaded it. The page now asks first and, if the lane is down, says so at the top, keeps Generate switched off, and points at the Avatar Studio and prompt-to-avatar in the meantime. The rest is the ordinary polish an audit turns up: a failed avatar list used to look identical to owning no avatars, so it sent people off to create one they already had, and now it says what broke and offers a retry; having no avatars yet gets a real empty state with a link to make one; the Generate button always explains what it is still waiting for and, once audio is in, how many clips of video that audio is worth; the clip you picked can be played back with its length and size before you spend a generation on it; a render job that goes unreachable now says so after thirty seconds instead of spinning for twenty minutes; and after a spent free trial the button under the error no longer stayed stuck on Upgrade plan for every later error. Avatar thumbnails are real buttons with visible focus rings, the two form fields have proper labels, and the second animated avatar that the site companion used to drop onto this page no longer loads over the one you are working on. (`/create/video`) `[fix, improvement]`
- **Text to 3D gets its footer back, a retry button that knows when to open, and an honest name for the model that refined your prompt**: The /forge-spark page was driven end to end in a real browser. The closing note under the workspace was written as a page footer, and the site's old corner-credit styling for the 3D viewer pages had quietly claimed it: it was pulled out of the layout into a floating monospace strip that sat on top of the viewer on a desktop, and on a 320px phone it landed across the composer with its link to the full studio pushed off the edge of the screen entirely. That note is now ordinary page text, centered under the workspace where it belongs, and the real three.ws footer, with its full set of links, is on the page for the first time. When a generation fails there is now a Try again button inside the error itself, so recovery does not mean scrolling back to the top; when the generator answers that it is busy, the button counts down and opens exactly when a retry can actually get through. A stage that fails is marked in red instead of silently dropping back to grey, the wait now shows real elapsed seconds so a cold reconstruction lane no longer reads as a hang, and the first step is renamed to whatever model actually answered, because the prompt refiner is a chain of engines and Nemotron is only the first one it tries. (`/forge-spark`) `[fix, improvement]`
diff --git a/data/changelog.json b/data/changelog.json
index 1b19ed228..3815950ea 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,16 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-08-17",
+ "title": "Studio stops going quiet when the engine list fails, and a broken preview no longer leaves a wall of broken images",
+ "summary": "The Studio at three.ws/forge-studio was driven end to end in a real browser: both text-to-3D pipelines, all three tabs (Object, Avatar and Lab), a real generation from prompt to finished GLB, and the loading, empty, error and populated states at phone, tablet and desktop widths. The finding that mattered was silent. Studio asks the server which generation engines are live before it draws the Quality and Engine pickers, and if that request failed for any reason, the whole row of controls simply vanished with nothing said. You were left on a page that looked complete but had quietly lost the choice between Draft, Standard and High, and every engine behind it, with no hint that anything had gone wrong or any way to get it back short of a reload. A failed engine list now says so where the pickers used to be, explains that generation still works on the free engine, and offers a Retry that brings the full picker back in place. A server that genuinely has no engines to offer stays quiet as before, because that is not a failure. Second, when a thumbnail in the community showcase could not load, the card started rendering a 3D frame from the model file instead, which is the right answer, but it left the broken image sitting on screen for the whole wait. Those renders are queued one at a time behind a twenty second limit, so a bad network turned the showcase into a grid of broken-image boxes for minutes. The card now falls back to its readable gradient-and-prompt tile the instant the image fails, and the 3D render replaces it when it arrives. The rest is the polish an audit turns up: the Avatar tab carried two competing page headings, so a screen reader heard the page rename itself when you switched tabs; the Lab tab's Download button now tells assistive tech it is disabled and why, instead of just looking dim; the photo and sketch file pickers finally have names; and a freshly generated model now actually previews, where before the viewer, the reveal animation and the game-ready poly counter all failed to read the finished file outside production.",
+ "tags": [
+ "fix",
+ "improvement"
+ ],
+ "link": "/forge-studio"
+ },
{
"date": "2026-08-17",
"title": "The Money Flow Map stops cutting its own table off on a phone, and a refresh no longer blanks the map",
diff --git a/docs/api-reference.md b/docs/api-reference.md
index 66b52eeb0..6dfc88e2f 100644
--- a/docs/api-reference.md
+++ b/docs/api-reference.md
@@ -5471,6 +5471,7 @@ curl 'https://three.ws/api/animations/signatures?similar=wave&limit=5'
```
GET /api/play/population
GET /api/play/population?coin=<mint-or-contract>
+GET /api/play/population?by=coin
```
How many people are standing in the `/play` worlds right now. No auth, CORS open, cached 5 seconds at the edge.
@@ -5479,6 +5480,8 @@ How many people are standing in the `/play` worlds right now. No auth, CORS open
`coin` narrows the count to one community's worlds (a Solana mint or an EVM contract address). Anything that is not a well-formed address is ignored rather than forwarded, and the response reports the filter that was actually applied.
+`by=coin` adds `byCoin`, a mint to headcount map covering every live world, so a page listing many communities gets all of their counts from one request instead of one request per card (this is what the `/play` lobby paints on its cards). Keys are re-validated as addresses before they are republished, and worlds with nobody in them are left out. `byCoin` is **absent**, not empty, when the multiplayer server is older than this parameter: an absent map means "unknown" and an empty map means "measured, nobody anywhere", and a caller must not render the first as zeroes.
+
**Response**
```json
@@ -5490,6 +5493,18 @@ How many people are standing in the `/play` worlds right now. No auth, CORS open
}
```
+With `by=coin`:
+
+```json
+{
+ "ok": true,
+ "coin": null,
+ "players": 7,
+ "rooms": 3,
+ "byCoin": { "FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump": 5 }
+}
+```
+
When the multiplayer server is unreachable the endpoint still answers `200`, with the count omitted:
```json
diff --git a/public/changelog.json b/public/changelog.json
index b373f6933..70e26f905 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-08-17T07:34:35.423Z",
+ "generated_at": "2026-08-17T07:37:02.213Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -324,6 +324,17 @@
"improvement"
]
},
+ {
+ "date": "2026-08-17",
+ "type": "update",
+ "title": "Studio stops going quiet when the engine list fails, and a broken preview no longer leaves a wall of broken images",
+ "summary": "The Studio at three.ws/forge-studio was driven end to end in a real browser: both text-to-3D pipelines, all three tabs (Object, Avatar and Lab), a real generation from prompt to finished GLB, and the loading, empty, error and populated states at phone, tablet and desktop widths. The finding that mattered was silent. Studio asks the server which generation engines are live before it draws the Quality and Engine pickers, and if that request failed for any reason, the whole row of controls simply vanished with nothing said. You were left on a page that looked complete but had quietly lost the choice between Draft, Standard and High, and every engine behind it, with no hint that anything had gone wrong or any way to get it back short of a reload. A failed engine list now says so where the pickers used to be, explains that generation still works on the free engine, and offers a Retry that brings the full picker back in place. A server that genuinely has no engines to offer stays quiet as before, because that is not a failure. Second, when a thumbnail in the community showcase could not load, the card started rendering a 3D frame from the model file instead, which is the right answer, but it left the broken image sitting on screen for the whole wait. Those renders are queued one at a time behind a twenty second limit, so a bad network turned the showcase into a grid of broken-image boxes for minutes. The card now falls back to its readable gradient-and-prompt tile the instant the image fails, and the 3D render replaces it when it arrives. The rest is the polish an audit turns up: the Avatar tab carried two competing page headings, so a screen reader heard the page rename itself when you switched tabs; the Lab tab's Download button now tells assistive tech it is disabled and why, instead of just looking dim; the photo and sketch file pickers finally have names; and a freshly generated model now actually previews, where before the viewer, the reveal animation and the game-ready poly counter all failed to read the finished file outside production.",
+ "link": "/forge-studio",
+ "tags": [
+ "fix",
+ "improvement"
+ ]
+ },
{
"date": "2026-08-17",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index a98b15d75..3b92f78d0 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -238,6 +238,14 @@
<category>fix</category>
<description>The /smart-money page was driven end to end in a real browser at 320, 768 and 1440 pixels. On a narrow phone the coin grid insisted on a column wider than the screen, so the right edge of every card was silently cut away by the page: the pedigree score badge and the star that adds a coin to your watchlist were both off-screen, with no sideways scroll to reach them. Cards now fit the screen they are on, and the score and the star are back. The bigger problem was that the page could not tell a coin it had never scored apart from a request that never arrived. If your connection dropped, or the radar was briefly down, every coin on your watchlist was relabelled Not on the radar yet, which reads as a verdict on the coin rather than a problem with the connection, and opening any coin or wallet gave you the same flat Not scored yet with no way to try again. The page now separates the two. A genuine miss keeps its explanation and now says why, and adds a link out to pump.fun or Solscan so the trail does not end there. A connection failure says the radar could not be reached and gives you a Retry button, in the drawer, on the watchlist, and on individual watched coins, and your watchlist is explicitly noted as still saved on your device. A first load that fails outright used to leave the Top wallets tab as an empty void; it now carries the same message and its own retry. A proven wallet whose trades predate the detail the radar keeps used to show a bare No recent coins on record, which looked like a wallet that had stopped trading; it now explains that the coin-level detail has aged out while the win record above still counts every verdict.</description>
</item>
+ <item>
+ <title>Studio stops going quiet when the engine list fails, and a broken preview no longer leaves a wall of broken images</title>
+ <link>https://three.ws/forge-studio</link>
+ <guid isPermaLink="false">2026-08-17:Studio stops going quiet when the engine list fails, and a broken preview no longer leaves a wall of broken images</guid>
+ <pubDate>Mon, 17 Aug 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The Studio at three.ws/forge-studio was driven end to end in a real browser: both text-to-3D pipelines, all three tabs (Object, Avatar and Lab), a real generation from prompt to finished GLB, and the loading, empty, error and populated states at phone, tablet and desktop widths. The finding that mattered was silent. Studio asks the server which generation engines are live before it draws the Quality and Engine pickers, and if that request failed for any reason, the whole row of controls simply vanished with nothing said. You were left on a page that looked complete but had quietly lost the choice between Draft, Standard and High, and every engine behind it, with no hint that anything had gone wrong or any way to get it back short of a reload. A failed engine list now says so where the pickers used to be, explains that generation still works on the free engine, and offers a Retry that brings the full picker back in place. A server that genuinely has no engines to offer stays quiet as before, because that is not a failure. Second, when a thumbnail in the community showcase could not load, the card started rendering a 3D frame from the model file instead, which is the right answer, but it left the broken image sitting on screen for the whole wait. Those renders are queued one at a time behind a twenty second limit, so a bad network turned the showcase into a grid of broken-image boxes for minutes. The card now falls back to its readable gradient-and-prompt tile the instant the image fails, and the 3D render replaces it when it arrives. The rest is the polish an audit turns up: the Avatar tab carried two competing page headings, so a screen reader heard the page rename itself when you switched tabs; the Lab tab's Download button now tells assistive tech it is disabled and why, instead of just looking dim; the photo and sketch file pickers finally have names; and a freshly generated model now actually previews, where before the viewer, the reveal animation and the game-ready poly counter all failed to read the finished file outside production.</description>
+ </item>
<item>
<title>Tabbing into the Forge prompt box now shows you where you are</title>
<link>https://three.ws/forge-max</link>
diff --git a/src/forge-showcase.js b/src/forge-showcase.js
index 7d85fb579..2386c1851 100644
--- a/src/forge-showcase.js
+++ b/src/forge-showcase.js
@@ -393,12 +393,15 @@ function buildCard(c) {
img.alt = '';
img.src = c.preview_image_url;
img.onerror = () => {
- // Plan B: image URL broken → try GLB capture, then gradient
- if (c.glb_url) {
+ // Drop the broken <img> the moment it fails. GLB capture is queued one
+ // at a time behind a 20s timeout, so leaving it in place parks a row of
+ // broken-image boxes on screen for minutes while Plan B works. The
+ // gradient stands in immediately and the capture upgrades it in place.
+ applyGradientFallback(card, c.prompt);
+ // Plan B: image URL broken → try GLB capture, gradient already stands in
+ if (c.glb_url && captureObserver) {
card.dataset.glbUrl = c.glb_url;
- captureObserver ? captureObserver.observe(card) : applyGradientFallback(card, c.prompt);
- } else {
- applyGradientFallback(card, c.prompt);
+ captureObserver.observe(card);
}
};
card.appendChild(img);
diff --git a/src/forge-studio/forge-gameready.js b/src/forge-studio/forge-gameready.js
index 9b8e20054..14ea3a880 100644
--- a/src/forge-studio/forge-gameready.js
+++ b/src/forge-studio/forge-gameready.js
@@ -21,6 +21,7 @@
import { payForConsumption } from './forge-pay.js';
import { attachTierPass, getAccess, getTierPass } from '../three-access.js';
+import { resolveDevR2Url } from '../shared/dev-r2-proxy.js';
const resultPanel = document.getElementById('state-result');
const viewer = document.getElementById('viewer');
@@ -328,7 +329,9 @@ if (resultPanel && viewer && triggerBtn) {
async function loadSourceFaceCount(url) {
state.sourceFaces = null;
try {
- const res = await fetch(url);
+ // Reading the GLB bytes is a cross-origin fetch, so it needs the dev
+ // proxy path on localhost / Codespaces. No-op in production.
+ const res = await fetch(resolveDevR2Url(url));
if (!res.ok) return;
const buf = await res.arrayBuffer();
const tris = countGlbTriangles(buf);
diff --git a/src/forge-studio/forge-reveal.js b/src/forge-studio/forge-reveal.js
index e65ff46bb..770834ade 100644
--- a/src/forge-studio/forge-reveal.js
+++ b/src/forge-studio/forge-reveal.js
@@ -11,6 +11,8 @@
// timeout) resolves immediately and the standing viewer is untouched. Honors
// prefers-reduced-motion by not playing at all.
+import { resolveDevR2Url } from '../shared/dev-r2-proxy.js';
+
const REVEAL_DELAY_MS = 200; // beat before the dissolve starts
const DISSOLVE_MS = 2100; // wireframe ghost → textured surface
const MIN_HOLD_MS = 450; // settle time after the dissolve completes
@@ -161,7 +163,7 @@ export async function playForgeReveal({ container, glbUrl, waitFor }) {
const loader = new GLTFLoader();
loader.setMeshoptDecoder(await getMeshoptDecoder());
const gltf = await Promise.race([
- loader.loadAsync(glbUrl),
+ loader.loadAsync(resolveDevR2Url(glbUrl)),
new Promise((resolve) => setTimeout(() => resolve(null), LOAD_TIMEOUT_MS)),
]);
if (!gltf || cancelled) return null;
diff --git a/src/forge-studio/forge-showcase.js b/src/forge-studio/forge-showcase.js
index 97976128b..860217b4a 100644
--- a/src/forge-studio/forge-showcase.js
+++ b/src/forge-studio/forge-showcase.js
@@ -375,15 +375,24 @@ function buildCard(c) {
const img = document.createElement('img');
img.className = 'thumb';
img.loading = 'lazy';
+ // Decode off the critical path: showcase thumbs are full-size renders
+ // painted into a 200px-tall box, and a synchronous decode of a grid's
+ // worth of them shows up as main-thread blocking time. The box is
+ // CSS-reserved (`#showcase .creation .thumb` is a fixed height), so
+ // deferring the decode cannot shift layout.
+ img.decoding = 'async';
img.alt = '';
img.src = c.preview_image_url;
img.onerror = () => {
- // Plan B: image URL broken → try GLB capture, then gradient
- if (c.glb_url) {
+ // Drop the broken <img> the moment it fails. GLB capture is queued one
+ // at a time behind a 20s timeout, so leaving it in place parks a row of
+ // broken-image boxes on screen for minutes while Plan B works. The
+ // gradient stands in immediately and the capture upgrades it in place.
+ applyGradientFallback(card, c.prompt);
+ // Plan B: image URL broken → try GLB capture, gradient already stands in
+ if (c.glb_url && captureObserver) {
card.dataset.glbUrl = c.glb_url;
- captureObserver ? captureObserver.observe(card) : applyGradientFallback(card, c.prompt);
- } else {
- applyGradientFallback(card, c.prompt);
+ captureObserver.observe(card);
}
};
card.appendChild(img);
diff --git a/src/forge-studio/forge.js b/src/forge-studio/forge.js
index a6b118a06..1d182b2b9 100644
--- a/src/forge-studio/forge.js
+++ b/src/forge-studio/forge.js
@@ -16,6 +16,7 @@ import { initWalletButton, getConnectedWalletAddress } from '../wallet.js';
import { openSketchCanvas } from './sketch-canvas.js';
import { mountPromptDictation } from '../voice/prompt-dictation.js';
import { showToast } from '../ui-helpers.js';
+import { resolveDevR2Url } from '../shared/dev-r2-proxy.js';
ensureStateKitStyles();
//
// Drives /api/forge. Three paths share one polling loop:
@@ -1673,7 +1674,13 @@ function showResult(glbUrl, label, meta, { autoSaved = false } = {}) {
// Show the load skeleton over the dark viewport until the GLB paints. The
// persistent 'load'/'error' listeners below clear it.
els.viewerShell?.classList.add('is-loading');
- els.viewer.setAttribute('src', glbUrl);
+ // The viewer fetches the GLB cross-origin, so it needs the dev proxy path on
+ // localhost / Codespaces. The free lane returns the finished glb_url in the
+ // POST response, which the dev server's r2-url-rewrite middleware skips (it
+ // only rewrites GET/HEAD bodies), so the raw r2.dev URL arrives here and the
+ // preview dead-ends on CORS. No-op in production. Everything downstream
+ // (download, share, segment, refine) keeps the canonical public URL.
+ els.viewer.setAttribute('src', resolveDevR2Url(glbUrl));
els.viewer.setAttribute('alt', `3D model: ${label}`);
lastShownGlb = glbUrl;
els.resultLabel.textContent = label;
diff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.js
index af6c7b7cd..28a1db38a 100644
--- a/src/game/coincommunities-ui.js
+++ b/src/game/coincommunities-ui.js
@@ -194,7 +194,8 @@ function fmtAge(ts) {
const at = Number(ts);
if (!at || !isFinite(at) || at > Date.now()) return '';
const s = (Date.now() - at) / 1000;
- if (s < 3600) return `${Math.max(1, Math.floor(s / 60))}m old`;
+ // "min" spelled out: "24m old" next to "20mo old" reads as months at a glance.
+ if (s < 3600) return `${Math.max(1, Math.floor(s / 60))}min old`;
if (s < 86400) return `${Math.floor(s / 3600)}h old`;
if (s < 86400 * 30) return `${Math.floor(s / 86400)}d old`;
return `${Math.floor(s / (86400 * 30))}mo old`;
@@ -480,6 +481,11 @@ export class CommunityUI {
onclick: () => this._setSort(s.id),
text: s.label,
})));
+ // Ranking by headcount needs headcounts. Until a per-coin read lands (the
+ // multiplayer server is unreachable, or it predates the breakdown), the
+ // control that promises that ordering cannot keep the promise, so it stays
+ // disabled and says why rather than silently sorting by something else.
+ this._setPeopleSortAvailable(false);
return el('div', { class: 'cc-feed-head' }, [
el('div', { class: 'cc-feed-title' }, [
el('p', { class: 'cc-section-title', text: 'Live communities' }),
@@ -489,6 +495,16 @@ export class CommunityUI {
]);
}
+ _setPeopleSortAvailable(on) {
+ const chip = this.sortRow?.querySelector('[data-sort="people"]');
+ if (!chip) return;
+ chip.disabled = !on;
+ chip.title = on
+ ? SORTS.find((s) => s.id === 'people').hint
+ : 'Live headcounts are unavailable right now';
+ if (!on && this.sort === 'people') this._setSort('trending');
+ }
+
_setSort(id) {
if (!SORTS.some((s) => s.id === id) || id === this.sort) return;
this.sort = id;
@@ -1288,6 +1304,7 @@ export class CommunityUI {
}
_paintPopulation() {
+ this._setPeopleSortAvailable(!!this.popByCoin);
if (this.popTotal !== null && this.statPeopleWrap) {
this.statPeopleWrap.hidden = false;
countUp(this.statPeople, Number(this.statPeople.dataset.v) || 0, this.popTotal, { format: (n) => String(Math.round(n)) });
@@ -1364,6 +1381,7 @@ export class CommunityUI {
const extra = this.enriched.get(c.mint);
const age = fmtAge(extra?.createdAt);
const fresh = !featured && extra?.createdAt > 0 && Date.now() - extra.createdAt < NEW_COIN_MS;
+ const onCurve = !featured && extra !== undefined && extra.graduated === false;
// Live headcount, painted here on first render and updated in place by
// _paintPopulation on every poll. Hidden while it reads zero: an empty
// world is the normal state and "0 people inside" is discouraging noise.
@@ -1406,14 +1424,16 @@ export class CommunityUI {
mc ? el('span', { text: mc + ' mcap' }) : null,
age ? el('span', { class: 'cc-card-age', text: age }) : null,
]),
- // Signals worth one glance each, and only when they are true of this
- // coin: a launch inside the last day, a completed bonding curve, and
- // how much the coin's own board is talking.
- (fresh || extra?.graduated || extra?.replies)
+ // Signals worth one glance, and only the ones that actually separate this
+ // coin from its neighbours. A completed bonding curve is true of nearly
+ // everything on a market-cap-ranked feed, so a badge for it said nothing
+ // on 28 cards out of 30; the rare, useful state is the inverse, a coin
+ // still on its curve. Replies say how loud the coin's own board is.
+ (fresh || onCurve || extra?.replies)
? el('div', { class: 'cc-card-tags' }, [
fresh ? el('span', { class: 'cc-tag cc-tag-new', title: 'Launched in the last 24 hours', text: 'NEW' }) : null,
- extra?.graduated ? el('span', { class: 'cc-tag', title: 'Bonding curve complete, trading on a DEX', text: 'Graduated' }) : null,
- extra?.replies ? el('span', { class: 'cc-tag cc-tag-quiet', title: `${extra.replies} replies on the coin's pump.fun board`, text: `${fmtCompact(extra.replies)} replies` }) : null,
+ onCurve ? el('span', { class: 'cc-tag', title: 'Still on its pump.fun bonding curve, not graduated to a DEX yet', text: 'On curve' }) : null,
+ extra?.replies ? el('span', { class: 'cc-tag cc-tag-quiet', title: `${extra.replies} replies on this coin’s pump.fun board`, text: `${fmtCompact(extra.replies)} replies` }) : null,
])
: null,
el('div', { class: 'cc-card-cta', text: featured ? 'Enter home town →' : 'Enter community →' }),
diff --git a/src/game/coincommunities.css b/src/game/coincommunities.css
index 3168645cb..8e9e363a5 100644
--- a/src/game/coincommunities.css
+++ b/src/game/coincommunities.css
@@ -528,6 +528,23 @@ html[data-bg="transparent"] #cc-lobby {
@keyframes cc-id-reveal { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .cc-id-body { animation: none; } }
.cc-avatar-label { width: 100%; font-weight: 700; font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; }
+/* On a phone the portrait, the name field and the disclosure cannot share one
+ line: the name row overflowed the viewport by 26px. Let the fields drop under
+ the portrait and give the field and the toggle the full width each. */
+/* Between a phone and a laptop the preset chips and the paste/gallery/upload
+ row are 1px too wide to share a line, which pushed the upload button past the
+ viewport edge. Give the second row its own line before that happens. */
+@media (max-width: 900px) {
+ .cc-id-body .cc-avatar-custom { flex: 1 1 100%; }
+}
+@media (max-width: 620px) {
+ .cc-id-fields { flex: 1 1 100%; min-width: 0; gap: 8px; }
+ .cc-name-row { flex-wrap: wrap; width: 100%; gap: 6px; }
+ .cc-name-label { flex: 1 1 100%; }
+ .cc-name-input { flex: 1 1 100%; max-width: none; }
+ .cc-id-summary { max-width: 100%; }
+ .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; }
.cc-avatar-chip {
@@ -853,7 +870,8 @@ html[data-bg="transparent"] #cc-lobby {
background: transparent; border: 1px solid var(--cc-edge-soft); border-radius: 999px;
transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
-.cc-sort:hover { color: var(--cc-text); border-color: var(--cc-edge); }
+.cc-sort:hover:not(:disabled) { color: var(--cc-text); border-color: var(--cc-edge); }
+.cc-sort:disabled { opacity: 0.4; cursor: not-allowed; }
.cc-sort:focus-visible { outline: 2px solid var(--cc-edge-hi); outline-offset: 2px; }
.cc-sort.cc-on { color: var(--cc-ink); background: #fff; border-color: #fff; box-shadow: var(--cc-glow); }
diff --git a/tests/api/play-population.test.js b/tests/api/play-population.test.js
index a49e11a6c..4bdfc939b 100644
--- a/tests/api/play-population.test.js
+++ b/tests/api/play-population.test.js
@@ -145,6 +145,58 @@ describe('GET /api/play/population: the live count', () => {
});
});
+describe('GET /api/play/population: the per-coin breakdown', () => {
+ it('asks the upstream for the breakdown and republishes it', async () => {
+ const calls = upstream(jsonReply({ ok: true, players: 5, rooms: 2, byCoin: { [MINT]: 5 } }));
+ const res = await get('/api/play/population?by=coin');
+ expect(new URL(calls[0]).searchParams.get('by')).toBe('coin');
+ expect(res.parsed).toEqual({ ok: true, coin: null, players: 5, rooms: 2, byCoin: { [MINT]: 5 } });
+ });
+
+ it('omits the breakdown entirely when the caller did not ask for it', async () => {
+ const calls = upstream(jsonReply({ ok: true, players: 5, rooms: 2, byCoin: { [MINT]: 5 } }));
+ const res = await get('/api/play/population');
+ expect(new URL(calls[0]).searchParams.has('by')).toBe(false);
+ expect(res.parsed.byCoin).toBeUndefined();
+ });
+
+ it('answers without a breakdown when the upstream is older than the parameter', async () => {
+ // An upstream that has not shipped `?by=coin` yet answers its normal
+ // aggregate. The field is then absent, which the lobby reads as "unknown"
+ // and renders as no per-card counts at all. An upstream that DOES support
+ // it while every world is empty answers `{}` instead, a real measurement of
+ // zero, so the two cases stay distinguishable.
+ upstream(jsonReply({ ok: true, players: 5, rooms: 2 }));
+ const res = await get('/api/play/population?by=coin');
+ expect(res.parsed).toMatchObject({ ok: true, players: 5 });
+ expect(res.parsed.byCoin).toBeUndefined();
+ });
+
+ it('publishes an empty breakdown when the upstream measured zero worlds', async () => {
+ upstream(jsonReply({ ok: true, players: 0, rooms: 0, byCoin: {} }));
+ const res = await get('/api/play/population?by=coin');
+ expect(res.parsed.byCoin).toEqual({});
+ });
+
+ it('re-validates every key in the breakdown before republishing it', async () => {
+ // The keys are whatever clients passed as their `coin` join option, so a
+ // non-address key, a negative count and an empty world are all dropped
+ // rather than forwarded to the browser.
+ upstream(jsonReply({
+ ok: true, players: 4, rooms: 3,
+ byCoin: { [MINT]: 4, '../../etc/passwd': 9, ['A'.repeat(60)]: 2, So11111111111111111111111111111111111111112: 0 },
+ }));
+ const res = await get('/api/play/population?by=coin');
+ expect(res.parsed.byCoin).toEqual({ [MINT]: 4 });
+ });
+
+ it('ignores a breakdown that is not an object', async () => {
+ upstream(jsonReply({ ok: true, players: 1, rooms: 1, byCoin: [['a', 1]] }));
+ const res = await get('/api/play/population?by=coin');
+ expect(res.parsed.byCoin).toBeUndefined();
+ });
+});
+
describe('GET /api/play/population: degrading without inventing a number', () => {
it('answers unavailable, not an error, when no upstream is configured', async () => {
envState.MULTIPLAYER_INTERNAL_URL = '';
diff --git a/tests/multiplayer-server-boot.test.js b/tests/multiplayer-server-boot.test.js
index 54c0ae1ce..0fdb81eba 100644
--- a/tests/multiplayer-server-boot.test.js
+++ b/tests/multiplayer-server-boot.test.js
@@ -195,6 +195,18 @@ describe('multiplayer entry point', () => {
// A different coin is a different world, so it must not see this player.
const other = await (await fetch(`${base}/population?coin=NotThisCoin111`)).json();
expect(other).toMatchObject({ ok: true, rooms: 0, players: 0 });
+
+ // ?by=coin adds the per-coin breakdown the /play lobby paints on its
+ // cards. One poll, every world, still nothing but counts.
+ const grouped = await (await fetch(`${base}/population?by=coin`)).json();
+ expect(grouped).toMatchObject({ ok: true, players: 1 });
+ expect(grouped.byCoin).toEqual({ [COIN]: 1 });
+ expect(Object.keys(grouped).sort()).toEqual(['byCoin', 'coin', 'ok', 'players', 'rooms']);
+
+ // Without the flag the response shape is byte-for-byte what every
+ // existing caller already parses.
+ const plain = await (await fetch(`${base}/population`)).json();
+ expect(Object.keys(plain).sort()).toEqual(['coin', 'ok', 'players', 'rooms']);
} finally {
await room.leave();
}
diff --git a/tests/play-lobby-live.test.js b/tests/play-lobby-live.test.js
new file mode 100644
index 000000000..5869a1304
--- /dev/null
+++ b/tests/play-lobby-live.test.js
@@ -0,0 +1,239 @@
+// @vitest-environment jsdom
+//
+// The /play lobby's live browse surface (src/game/coincommunities-ui.js).
+//
+// The lobby is the front door: the one page that has to answer "which of these
+// worlds is worth walking into" before anyone has entered anything. Three
+// promises make that answer trustworthy, and each is easy to break by accident:
+//
+// 1. A headcount on a card is MEASURED or ABSENT, never invented. No live
+// read, an unreachable multiplayer server, or a server that predates the
+// per-coin breakdown all render the same way: no counts, and the ordering
+// that depends on them disabled rather than silently sorting by something
+// else.
+// 2. A poll repaints the counts IN PLACE. Rebuilding the grid every 20s would
+// throw away hover, keyboard focus and scroll position, which is worse than
+// a slightly stale number.
+// 3. Every sort is a real reorder of a real field, and a coin badge appears
+// only when it is true of that coin.
+//
+// The scene (coincommunities.js) owns WebGL and hands this module its data, so
+// nothing here needs a canvas: the module runs directly against jsdom with its
+// network stubbed.
+
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+
+// Portrait rendering downloads and renders a real GLB: irrelevant here and
+// impossible in jsdom. The chips keep their fallback glyph, exactly as they do
+// in a browser that cannot render one.
+vi.mock('../src/game/avatar-thumb.js', () => ({ renderAvatarThumb: vi.fn(async () => null) }));
+vi.mock('../src/game/avatar-rig.js', () => ({ resolveAvatarUrl: vi.fn(async (u) => u) }));
+vi.mock('../src/account.js', () => ({ getMe: vi.fn(async () => null) }));
+
+const { CommunityUI } = await import('../src/game/coincommunities-ui.js');
+
+const MINT_A = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
+const MINT_B = 'THREEsynthetic1111111111111111111111111111B';
+const MINT_C = 'THREEsynthetic1111111111111111111111111111C';
+
+const COINS = [
+ { mint: MINT_A, name: 'Alpha', symbol: 'ALPHA', image: '', marketCap: 1_000_000 },
+ { mint: MINT_B, name: 'Bravo', symbol: 'BRAVO', image: '', marketCap: 5_000_000 },
+ { mint: MINT_C, name: 'Charlie', symbol: 'CHARLIE', image: '', marketCap: 2_000_000 },
+];
+
+// Route every fetch the lobby makes on boot. The population read is the one
+// under test; the rest answer empty so nothing else reaches the network.
+function stubNetwork({ population } = {}) {
+ return vi.fn(async (url) => {
+ const u = String(url);
+ if (u.startsWith('/api/play/population')) {
+ if (!population) return { ok: false, status: 503, json: async () => ({}) };
+ return { ok: true, status: 200, json: async () => population };
+ }
+ return { ok: true, status: 200, json: async () => ({ items: [], data: [] }) };
+ });
+}
+
+/** Build a lobby with the coins loaded and the first population read settled. */
+async function mountLobby({ population } = {}) {
+ vi.stubGlobal('fetch', stubNetwork({ population }));
+ const ui = new CommunityUI({ onEnter: vi.fn(), onSearch: vi.fn(async () => []) });
+ ui.setCoins(COINS);
+ // Let the boot reads (population, presets, enrichment) settle.
+ for (let i = 0; i < 4; i++) await new Promise((r) => setTimeout(r, 0));
+ return ui;
+}
+
+const cardMints = (ui) => [...ui.grid.querySelectorAll('.cc-card[data-mint]')].map((c) => c.dataset.mint);
+const cardFor = (ui, mint) => ui.grid.querySelector(`.cc-card[data-mint="${mint}"]`);
+// The pill's parts are separate elements spaced by CSS, so read them as parts
+// rather than as one run of text.
+const popText = (card) => {
+ const pill = card.querySelector('.cc-card-pop');
+ if (pill.hidden) return null;
+ return [...pill.children].map((n) => n.textContent).filter(Boolean).join(' ').trim();
+};
+
+beforeEach(() => {
+ document.body.innerHTML = '';
+ localStorage.clear();
+ // jsdom ships no matchMedia; the lobby asks it whether the pointer hovers and
+ // whether motion is reduced. Answer as a plain desktop browser would.
+ vi.stubGlobal('matchMedia', (q) => ({
+ matches: /hover: hover/.test(q), media: q,
+ addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {},
+ }));
+});
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+describe('the lobby never invents a headcount', () => {
+ it('shows no per-card count and disables the headcount sort when the read fails', async () => {
+ const ui = await mountLobby();
+ expect(ui.popByCoin).toBeNull();
+ for (const mint of cardMints(ui)) expect(popText(cardFor(ui, mint))).toBeNull();
+ expect(ui.sortRow.querySelector('[data-sort="people"]').disabled).toBe(true);
+ // The hero stat is absent rather than showing a zero nobody measured.
+ expect(ui.statPeopleWrap.hidden).toBe(true);
+ });
+
+ it('treats an upstream without the per-coin breakdown as unknown, not as zero', async () => {
+ // A multiplayer server that predates `?by=coin` still answers a total.
+ const ui = await mountLobby({ population: { ok: true, players: 12, rooms: 3 } });
+ expect(ui.popByCoin).toBeNull();
+ expect(ui.sortRow.querySelector('[data-sort="people"]').disabled).toBe(true);
+ // The total IS measured, so the hero stat is real and shown.
+ expect(ui.statPeopleWrap.hidden).toBe(false);
+ expect(ui.statPeople.dataset.v).toBe('12');
+ });
+
+ it('paints only the coins that actually have someone standing in them', async () => {
+ const ui = await mountLobby({
+ population: { ok: true, players: 4, rooms: 2, byCoin: { [MINT_B]: 3, [MINT_C]: 1 } },
+ });
+ expect(popText(cardFor(ui, MINT_A))).toBeNull();
+ expect(popText(cardFor(ui, MINT_B))).toBe('3 people inside');
+ // One person is one person, not "1 people inside".
+ expect(popText(cardFor(ui, MINT_C))).toBe('1 person inside');
+ expect(ui.sortRow.querySelector('[data-sort="people"]').disabled).toBe(false);
+ });
+
+ it('keeps the last measured numbers when a later poll fails', async () => {
+ const ui = await mountLobby({ population: { ok: true, players: 4, rooms: 1, byCoin: { [MINT_B]: 4 } } });
+ vi.stubGlobal('fetch', vi.fn(async () => { throw new Error('ECONNREFUSED'); }));
+ await ui._readPopulation();
+ expect(popText(cardFor(ui, MINT_B))).toBe('4 people inside');
+ });
+});
+
+describe('a poll repaints in place', () => {
+ it('updates the counts without rebuilding the cards', async () => {
+ const ui = await mountLobby({ population: { ok: true, players: 1, rooms: 1, byCoin: { [MINT_B]: 1 } } });
+ const before = cardFor(ui, MINT_B);
+ before.focus();
+
+ vi.stubGlobal('fetch', stubNetwork({
+ population: { ok: true, players: 9, rooms: 2, byCoin: { [MINT_B]: 9 } },
+ }));
+ await ui._readPopulation();
+
+ expect(cardFor(ui, MINT_B)).toBe(before); // the same node, not a re-render
+ expect(document.activeElement).toBe(before);
+ expect(popText(before)).toBe('9 people inside');
+ });
+});
+
+describe('sorting reorders real fields', () => {
+ it('ranks by market cap', async () => {
+ const ui = await mountLobby();
+ ui._setSort('mcap');
+ expect(cardMints(ui)).toEqual([MINT_B, MINT_C, MINT_A]);
+ });
+
+ it('ranks by live headcount, breaking ties on market cap', async () => {
+ const ui = await mountLobby({
+ population: { ok: true, players: 5, rooms: 2, byCoin: { [MINT_A]: 5 } },
+ });
+ ui._setSort('people');
+ expect(cardMints(ui)).toEqual([MINT_A, MINT_B, MINT_C]);
+ });
+
+ it('ranks by launch time and sorts coins with no known launch time last', async () => {
+ const ui = await mountLobby();
+ ui.enriched.set(MINT_C, { createdAt: Date.now() - 60_000, replies: 0, graduated: true });
+ ui.enriched.set(MINT_A, { createdAt: Date.now() - 86_400_000 * 9, replies: 0, graduated: true });
+ ui._setSort('new');
+ expect(cardMints(ui)).toEqual([MINT_C, MINT_A, MINT_B]);
+ });
+
+ it('falls back off the headcount sort when live counts are not available', async () => {
+ localStorage.setItem('cc-sort', 'people');
+ const ui = await mountLobby();
+ expect(ui.sort).toBe('trending');
+ });
+});
+
+describe('coin badges say something only when true of that coin', () => {
+ it('marks a coin launched in the last day, and one still on its curve', async () => {
+ const ui = await mountLobby();
+ ui.enriched.set(MINT_A, { createdAt: Date.now() - 3 * 3600_000, replies: 1200, graduated: false });
+ ui.enriched.set(MINT_B, { createdAt: Date.now() - 86_400_000 * 30, replies: 0, graduated: true });
+ ui._renderGrid();
+
+ const a = cardFor(ui, MINT_A);
+ expect([...a.querySelectorAll('.cc-tag')].map((t) => t.textContent)).toEqual(['NEW', 'On curve', '1.2K replies']);
+ expect(a.querySelector('.cc-card-age').textContent).toBe('3h old');
+
+ // A graduated coin with a quiet board earns no badges at all: a badge on
+ // every card is noise, not information.
+ expect(cardFor(ui, MINT_B).querySelector('.cc-card-tags')).toBeNull();
+ });
+
+ it('says nothing about age or curve state for a coin the enrichment pass never covered', async () => {
+ const ui = await mountLobby();
+ const card = cardFor(ui, MINT_A);
+ expect(card.querySelector('.cc-card-age')).toBeNull();
+ expect(card.querySelector('.cc-card-tags')).toBeNull();
+ });
+});
+
+describe('search', () => {
+ it('filters the loaded grid and reports how many worlds match', async () => {
+ const ui = await mountLobby();
+ ui.searchInput.value = 'brav';
+ ui._onSearchInput();
+ expect(cardMints(ui)).toEqual([MINT_B]);
+ expect(ui.feedCount.textContent).toBe('1 world matching');
+ expect(ui.searchClear.hidden).toBe(false);
+ });
+
+ it('restores the full grid when the query is cleared', async () => {
+ const ui = await mountLobby();
+ ui.searchInput.value = 'brav';
+ ui._onSearchInput();
+ ui._clearSearch();
+ expect(cardMints(ui)).toHaveLength(COINS.length);
+ expect(ui.searchClear.hidden).toBe(true);
+ expect(ui.searchInput.value).toBe('');
+ });
+});
+
+describe('identity', () => {
+ it('opens the avatar picker for a first-time visitor and folds it away for a returning one', async () => {
+ const first = await mountLobby();
+ expect(first.idBody.hidden).toBe(false);
+ expect(first.idToggle.getAttribute('aria-expanded')).toBe('true');
+
+ document.body.innerHTML = '';
+ localStorage.setItem('cc-avatar', '/avatars/default.glb');
+ localStorage.setItem('cc-name', 'jessica');
+ const returning = await mountLobby();
+ expect(returning.idBody.hidden).toBe(true);
+ expect(returning.idToggle.getAttribute('aria-expanded')).toBe('false');
+ returning._toggleIdentity();
+ expect(returning.idBody.hidden).toBe(false);
+ });
+});