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
test(trial-status): cover the buyer-view count and update the cosmos doc
nirholasab0bbe445278
diff --git a/docs/cosmos.md b/docs/cosmos.mdindex c2094f064..fc13b4bb2 100644--- a/docs/cosmos.md+++ b/docs/cosmos.md@@ -28,6 +28,7 @@ On the page (`src/cosmos.js`), the avatar is a Google `<model-viewer>` with a tr4. Optionally set a seed for a reproducible render.5. Click Generate. A real progress state runs while the NVCF job renders; expect roughly 60 to 120 seconds on the free tier.6. When the world lands it plays behind your avatar. Preview it, regenerate with a new prompt or seed, or download the clip.+7. Share copies a link that carries the finished clip, the avatar, the prompt, and the seed (`?world=…&avatar=…&prompt=…&seed=…`), so whoever opens it lands on the world already playing rather than an empty stage.## Examplesdiff --git a/pages/coin3d.html b/pages/coin3d.htmlindex 5cacb0717..11dee7120 100644--- a/pages/coin3d.html+++ b/pages/coin3d.html@@ -399,6 +399,16 @@display: block;overflow: visible;}+ .c3d-spark-none {+ height: 44px;+ margin: 0;+ display: grid;+ place-items: center;+ border: 1px dashed var(--border);+ border-radius: 8px;+ color: var(--muted);+ font-size: 12px;+ }.c3d-spark-empty {height: 44px;border-radius: 8px;diff --git a/pages/create.html b/pages/create.htmlindex 00240e265..c894904d9 100644--- a/pages/create.html+++ b/pages/create.html@@ -596,6 +596,11 @@border-color: rgba(160, 150, 255, 0.25);background: rgba(160, 150, 255, 0.07);}+ .chip-soon {+ color: #ffd9a8;+ border-color: rgba(255, 190, 110, 0.28);+ background: rgba(255, 190, 110, 0.08);+ }.chip-live-dot {display: inline-block;width: 5px;@@ -745,6 +750,96 @@color: #fff;}+ /* ── Inline alert ─────────────────────────────────────────────────────+ A toast disappears; a failure that leaves the visitor with nothing to+ look at must not. Hard errors (a remix that could not be loaded) land+ here instead: named, explained, and recoverable without a reload. */+ .create-alert {+ display: flex;+ flex-direction: column;+ gap: 8px;+ margin: 0 0 24px;+ padding: 16px 18px;+ border-radius: 14px;+ border: 1px solid rgba(255, 92, 92, 0.38);+ background: #140a0a;+ animation: ya-in 0.35s ease both;+ }+ .create-alert-title {+ display: flex;+ align-items: center;+ gap: 8px;+ font-size: 14px;+ font-weight: 600;+ line-height: 1.3;+ margin: 0;+ color: #ffb3b3;+ }+ .create-alert-title svg {+ width: 16px;+ height: 16px;+ flex: 0 0 auto;+ }+ .create-alert-body {+ margin: 0;+ font-size: 13px;+ line-height: 1.55;+ color: rgba(255, 214, 214, 0.8);+ }+ .create-alert-actions {+ display: flex;+ flex-wrap: wrap;+ gap: 8px;+ margin-top: 4px;+ }+ .create-alert-btn {+ display: inline-flex;+ align-items: center;+ min-height: 36px;+ padding: 8px 14px;+ border-radius: 9px;+ border: 1px solid rgba(255, 255, 255, 0.16);+ background: rgba(255, 255, 255, 0.06);+ color: var(--text);+ font: inherit;+ font-size: 12.5px;+ font-weight: 600;+ cursor: pointer;+ transition:+ background 0.15s,+ border-color 0.15s,+ transform 0.15s;+ }+ .create-alert-btn:hover {+ background: rgba(255, 255, 255, 0.12);+ border-color: rgba(255, 255, 255, 0.3);+ transform: translateY(-1px);+ }+ .create-alert-btn:active {+ transform: none;+ }+ .create-alert-btn:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+ }+ .create-alert-btn--primary {+ background: var(--accent);+ border-color: transparent;+ color: var(--accent-ink);+ }+ .create-alert-btn--primary:hover {+ background: #fff;+ border-color: transparent;+ }+ @media (prefers-reduced-motion: reduce) {+ .create-alert {+ animation: none;+ }+ .create-alert-btn:hover {+ transform: none;+ }+ }+/* ── Status toast ─────────────────────────────────────────────────── */.status-toast {position: fixed;@@ -1148,20 +1243,40 @@crossorigin="anonymous"></script><script>- fetch('/api/auth/me', { credentials: 'include' })- .then(function (r) {- return r.ok ? r.json() : null;- })- .then(function (data) {- window.__authed = !!(data && data.user);- var el = document.getElementById('page-loading');- if (el) el.remove();- })- .catch(function () {- window.__authed = false;+ (function () {+ var cleared = false;+ function clearBootOverlay() {+ if (cleared) return;+ cleared = true;var el = document.getElementById('page-loading');if (el) el.remove();- });+ }+ // #page-loading is a full-screen blackout. A rejected fetch clears it,+ // but a request that simply never answers (stalled edge, captive+ // portal, hung upstream) would leave it up forever and the whole page+ // would read as broken. Bound the wait: an unanswered probe means+ // "treat as signed out" and hand the page back. The auth-gated cards+ // re-check at /login, so a wrong guess here costs one redirect.+ var timer = setTimeout(function () {+ if (window.__authed === undefined) window.__authed = false;+ clearBootOverlay();+ }, 6000);+ function settle(authed) {+ window.__authed = authed;+ clearTimeout(timer);+ clearBootOverlay();+ }+ fetch('/api/auth/me', { credentials: 'include' })+ .then(function (r) {+ return r.ok ? r.json() : null;+ })+ .then(function (data) {+ settle(!!(data && data.user));+ })+ .catch(function () {+ settle(false);+ });+ })();</script><link rel="canonical" href="https://three.ws/create" />@@ -1263,6 +1378,9 @@ · Make a 3D avatar</p></div>+ <!-- Hard-failure surface (see .create-alert): filled by src/create.js -->+ <div id="create-alert-slot" role="alert" aria-live="assertive"></div>+<!-- Returning users: remix one you already made --><section class="your-avatars" id="your-avatars" hidden aria-label="Your avatars"><div class="your-avatars-head">@@ -1540,12 +1658,12 @@Upload audio and your avatar lip-syncs to it. Generates a video you canshare anywhere.</p>- <div class="card-meta" aria-hidden="true">+ <div class="card-meta" id="card-video-avatar-meta" aria-hidden="true"><span class="chip chip-auth" data-i18n="create.sign_in_3">Sign-in</span><span class="chip" data-i18n="create.lip_sync">Lip-sync</span></div><span class="card-cta card-cta--ghost">- Generate video+ <span id="card-video-avatar-cta">Generate video</span><svgwidth="13"height="13"diff --git a/tests/e2e/community-page.spec.js b/tests/e2e/community-page.spec.jsnew file mode 100644index 000000000..f3e12d29d--- /dev/null+++ b/tests/e2e/community-page.spec.js@@ -0,0 +1,146 @@+/**+ * /community, driven in a real browser.+ *+ * The defect this file exists for is invisible to a unit test and to a reader+ * of the source: the live-activity rows were built as an <a> wrapped around+ * another <a> (the row linked to the creation, the creator's name linked to+ * their profile). That is unparseable HTML, so every browser split each row+ * into three sibling fragments and the list rendered as stacked, gap-ridden+ * debris. The template string looked correct; only the DOM the browser built+ * from it was wrong, which is exactly what a browser test can see.+ *+ * The rest pins the states a visitor can actually land in: a feed that fails,+ * a feed that returns nothing, and a body that is not JSON at all (which used+ * to throw past the handler and leave the skeletons shimmering forever).+ */++import { test, expect } from '@playwright/test';++const COMMUNITY = '/community';+const FEED = '**/api/users/me/feed*';++// This suite shares a box with the rest of the e2e run and the first hit pays+// the dev server's on-demand transform, so the waits are explicit.+const SLOW = 45_000;++function feedPayload(count) {+ return {+ items: Array.from({ length: count }, (_, i) => ({+ kind: 'avatar',+ id: `id-${i}`,+ created_at: new Date(Date.now() - i * 60_000).toISOString(),+ actor: { username: `creator${i}`, display_name: `Creator ${i}`, avatar_url: null },+ title: `Avatar ${i}`,+ href: `/avatars/id-${i}`,+ image: null,+ })),+ };+}++async function serveFeed(page, body, status = 200) {+ await page.route(FEED, (route) =>+ route.fulfill({ status, contentType: 'application/json', body: JSON.stringify(body) }),+ );+}++test.describe('/community', () => {+ test('renders one intact row per feed item, with both of its links reachable', async ({ page }) => {+ const errors = [];+ page.on('pageerror', (e) => errors.push(e.message));+ await serveFeed(page, feedPayload(6));++ await page.goto(COMMUNITY);+ await page.waitForSelector('.activity-row', { timeout: SLOW });++ // Six items must produce six rows. Nested anchors produced eighteen.+ expect(await page.locator('.activity-row').count()).toBe(6);+ expect(await page.locator('.activity-row > .activity-main').count()).toBe(6);+ // No anchor may contain another anchor anywhere on the page.+ expect(await page.locator('a a').count()).toBe(0);++ const first = page.locator('.activity-row').first();+ await expect(first.locator('.activity-main')).toHaveAttribute('href', '/avatars/id-0');+ await expect(first.locator('.activity-user')).toHaveAttribute('href', '/u/creator0');+ await expect(first.locator('.activity-line')).toContainText('created a new avatar');+ await expect(first.locator('.activity-meta')).toContainText('Avatar 0');++ // One h1, and every row link is keyboard-reachable.+ expect(await page.locator('h1').count()).toBe(1);+ expect(await first.locator('a').count()).toBe(2);++ // Clicking the row body (not the name) opens the creation.+ await first.click({ position: { x: 220, y: 30 } });+ await page.waitForURL('**/avatars/id-0', { waitUntil: 'commit', timeout: SLOW });++ expect(errors).toEqual([]);+ });++ test('a feed that fails, or answers with something unreadable, offers a working retry', async ({ page }) => {+ let attempt = 0;+ await page.route(FEED, (route) => {+ attempt += 1;+ if (attempt === 1) return route.abort('failed');+ if (attempt === 2) return route.fulfill({ status: 500, body: 'server error' });+ if (attempt === 3) return route.fulfill({ status: 200, contentType: 'application/json', body: 'not json' });+ return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(feedPayload(3)) });+ });++ await page.goto(COMMUNITY);+ // Each failure mode lands in the same designed, actionable state instead+ // of a blank box or a permanent skeleton.+ for (let i = 0; i < 3; i += 1) {+ await page.waitForSelector('.activity-retry', { timeout: SLOW });+ await expect(page.locator('.activity-error')).toContainText('Could not load live activity');+ expect(await page.locator('.activity-skeleton').count()).toBe(0);+ await page.click('.activity-retry');+ }++ await page.waitForSelector('.activity-row', { timeout: SLOW });+ expect(await page.locator('.activity-row').count()).toBe(3);+ });++ test('an empty feed says what to do next instead of showing a blank box', async ({ page }) => {+ await serveFeed(page, { items: [] });++ await page.goto(COMMUNITY);+ await page.waitForSelector('.activity-empty', { timeout: SLOW });+ await expect(page.locator('.activity-empty a')).toHaveAttribute('href', '/create');+ });++ test('the newsletter signup validates locally and posts to the real endpoint', async ({ page }) => {+ await serveFeed(page, feedPayload(2));+ await page.goto(COMMUNITY);+ await page.waitForSelector('.newsletter-form', { timeout: SLOW });++ // The field is labelled, so a screen reader announces it.+ await expect(page.locator('label[for="community-newsletter-email"]')).toHaveCount(1);++ await page.fill('#community-newsletter-email', 'not-an-email');+ await page.click('.newsletter-form button');+ await expect(page.locator('p.newsletter-msg')).toHaveText('Please enter a valid email.');++ let posted = null;+ await page.route('**/api/newsletter/subscribe', (route) => {+ posted = route.request().postDataJSON();+ return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true }) });+ });+ await page.fill('#community-newsletter-email', '[email protected]');+ await page.click('.newsletter-form button');+ await expect(page.locator('p.newsletter-msg')).toHaveClass(/is-success/, { timeout: SLOW });+ expect(posted).toEqual({ email: '[email protected]' });+ });++ test('lays out without a sideways scrollbar from 320px up', async ({ page }) => {+ await serveFeed(page, feedPayload(8));+ await page.goto(COMMUNITY);+ await page.waitForSelector('.activity-row', { timeout: SLOW });++ for (const width of [320, 768, 1440]) {+ await page.setViewportSize({ width, height: 900 });+ const overflow = await page.evaluate(+ () => document.documentElement.scrollWidth > document.documentElement.clientWidth + 1,+ );+ expect(overflow, `horizontal overflow at ${width}px`).toBe(false);+ }+ });+});diff --git a/tests/marketplace-trial-status.test.js b/tests/marketplace-trial-status.test.jsindex 130ba360b..750f8aca1 100644--- a/tests/marketplace-trial-status.test.js+++ b/tests/marketplace-trial-status.test.js@@ -170,6 +170,11 @@ describe('sellerView', () => {const out = await sellerView(USER);expect(out.role).toBe('seller');+ // "Edit pricing" pointed at /dashboard-next/agent, which 404s. The agent+ // editor's monetization panel is the surface that actually sets a skill's+ // price and trial grant.+ expect(out.queue[0].pricingUrl).toBe(`/agent/${AGENT}/edit?tab=monetization`);+ expect(out.queue[0].agentUrl).toBe(`/agents/${AGENT}`);expect(out.summary.warmLeads).toBe(3);expect(out.summary.sold).toBe(2);// 6dp mint: 2 exhausted buyers x 2 each. $THREE: 1 exhausted buyer x 0.5.@@ -198,13 +203,13 @@ describe('buyerView', () => {{id: 'p1', agent_id: AGENT, skill: 'icon-set', trial_remaining: 0,created_at: '2026-08-01T00:00:00.000Z', updated_at: '2026-08-03T00:00:00.000Z',- agent_name: 'Ink', agent_image: null,+ agent_name: 'Ink', agent_image: null, total_trials: 2,trial_uses: 3, amount: '2000000', currency_mint: MINT_6DP, chain: 'solana', mint_decimals: 6,},{id: 'p2', agent_id: AGENT, skill: 'lore', trial_remaining: 3,created_at: '2026-08-01T00:00:00.000Z', updated_at: '2026-08-02T00:00:00.000Z',- agent_name: 'Ink', agent_image: null,+ agent_name: 'Ink', agent_image: null, total_trials: 2,trial_uses: 3, amount: null, currency_mint: null, chain: null, mint_decimals: null,},]];@@ -213,8 +218,12 @@ describe('buyerView', () => {expect(out.role).toBe('buyer');expect(out.summary).toEqual({ active: 2, fresh: 1, runningLow: 0, exhausted: 1 });+ expect(out.truncated).toBe(false);+ expect(out.total).toBe(2);+ // `/agent/:id` answers 301 and drops the query string, which ate the+ // `?skill=` deep link the page's Buy CTA appends.expect(out.trials[0]).toMatchObject({- purchaseId: 'p1', skill: 'icon-set', state: 'exhausted', agentUrl: `/agent/${AGENT}`,+ purchaseId: 'p1', skill: 'icon-set', state: 'exhausted', agentUrl: `/agents/${AGENT}`,});expect(out.trials[0].price).toEqual({atomic: '2000000', decimals: 6, display: '2', mint: MINT_6DP, chain: 'solana',@@ -222,6 +231,32 @@ describe('buyerView', () => {// A delisted skill still shows its trial, just without a price to convert at.expect(out.trials[1].price).toBeNull();});++ it('reports the true total when the list is capped, instead of counting the page', async () => {+ // The window count is taken before the LIMIT, so a buyer past the cap is+ // told the list is partial rather than reading a total that stops at 200.+ sqlQueue = [[+ {+ id: 'p1', agent_id: AGENT, skill: 'icon-set', trial_remaining: 0,+ created_at: '2026-08-01T00:00:00.000Z', updated_at: '2026-08-03T00:00:00.000Z',+ agent_name: 'Ink', agent_image: null, total_trials: 412,+ trial_uses: 3, amount: '2000000', currency_mint: MINT_6DP, chain: 'solana', mint_decimals: 6,+ },+ ]];++ const out = await buyerView(USER);++ expect(out.total).toBe(412);+ expect(out.truncated).toBe(true);+ });++ it('answers an empty result without inventing a total', async () => {+ sqlQueue = [[]];+ const out = await buyerView(USER);+ expect(out.trials).toEqual([]);+ expect(out.total).toBe(0);+ expect(out.truncated).toBe(false);+ });});describe('GET /api/marketplace/trial-status', () => {