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.

fix(launch): carry a recipe's fee routing through as a reward coin

nirholas0c1144af1958
diff --git a/pages/launches.html b/pages/launches.html
index 13f4ae76b..3c3a28295 100644
--- a/pages/launches.html
+++ b/pages/launches.html
@@ -122,6 +122,8 @@
data-network="mainnet"
role="tab"
aria-selected="true"
+ aria-controls="lx-feed"
+ id="lx-net-mainnet"
data-i18n="launches.mainnet_2">
Mainnet
</button>
@@ -131,6 +133,9 @@
data-network="devnet"
role="tab"
aria-selected="false"
+ aria-controls="lx-feed"
+ tabindex="-1"
+ id="lx-net-devnet"
data-i18n="launches.devnet">
Devnet
</button>
@@ -153,7 +158,14 @@
<a class="lx-explore-link" href="/launchpad" data-i18n="launches.launchpad_studio">Launchpad Studio →</a>
</nav>
- <section id="lx-feed" class="lx-grid" aria-label="Launched coins" aria-busy="true"></section>
+ <section
+ id="lx-feed"
+ class="lx-grid"
+ role="tabpanel"
+ aria-labelledby="lx-net-mainnet"
+ tabindex="-1"
+ aria-busy="true"
+ ></section>
<div id="lx-footer-state" class="lx-footer-state"></div>
</main>
diff --git a/src/launches.js b/src/launches.js
index 4384cc6f3..6a0ba5db5 100644
--- a/src/launches.js
+++ b/src/launches.js
@@ -743,18 +743,37 @@ function renderEmpty() {
text: 'Clear filters',
onclick: () => { setAgentFilter(null); setOracleTier(''); },
})
- : el('div', { class: 'lx-state-ctas' }, [
- el('a', {
- class: 'lx-btn lx-btn-primary',
- href: '/create-agent',
- text: 'Create an agent',
- }),
- el('a', {
- class: 'lx-btn',
- href: '/forge',
- text: 'Forge its 3D body',
- }),
- ]),
+ : state.network === 'devnet'
+ ? el('div', { class: 'lx-state-ctas' }, [
+ // The copy above tells the reader to switch networks, so the
+ // state hands them the switch instead of pointing at the toolbar.
+ el('button', {
+ class: 'lx-btn lx-btn-primary',
+ type: 'button',
+ text: 'Switch to mainnet',
+ onclick: () => {
+ setNetwork('mainnet');
+ document.querySelector('.lx-net-btn[data-network="mainnet"]')?.focus();
+ },
+ }),
+ el('a', {
+ class: 'lx-btn',
+ href: '/create-agent',
+ text: 'Create an agent',
+ }),
+ ])
+ : el('div', { class: 'lx-state-ctas' }, [
+ el('a', {
+ class: 'lx-btn lx-btn-primary',
+ href: '/create-agent',
+ text: 'Create an agent',
+ }),
+ el('a', {
+ class: 'lx-btn',
+ href: '/forge',
+ text: 'Forge its 3D body',
+ }),
+ ]),
]),
);
}
@@ -922,14 +941,24 @@ function syncUrl() {
history.replaceState(null, '', url);
}
-function setNetwork(network) {
- if (state.network === network) return;
- state.network = network;
+// The network toggle is a real tablist over one panel (the feed), so the
+// selected tab is the only tab stop and the arrow keys move between them. A
+// tablist that announces itself but ignores the arrow keys strands anyone who
+// takes the announcement at its word.
+function syncNetworkTabs(network) {
document.querySelectorAll('.lx-net-btn').forEach((b) => {
const active = b.dataset.network === network;
b.classList.toggle('active', active);
b.setAttribute('aria-selected', String(active));
+ b.tabIndex = active ? 0 : -1;
+ if (active && b.id) feedEl.setAttribute('aria-labelledby', b.id);
});
+}
+
+function setNetwork(network) {
+ if (state.network === network) return;
+ state.network = network;
+ syncNetworkTabs(network);
syncUrl();
loadPage({ reset: true });
}
@@ -994,11 +1023,19 @@ function boot() {
const oracleTierParam = qs.get('oracle_tier') || '';
state.oracleTier = VALID_TIERS.has(oracleTierParam) ? oracleTierParam : '';
- document.querySelectorAll('.lx-net-btn').forEach((b) => {
- const active = b.dataset.network === state.network;
- b.classList.toggle('active', active);
- b.setAttribute('aria-selected', String(active));
+ const netBtns = [...document.querySelectorAll('.lx-net-btn')];
+ syncNetworkTabs(state.network);
+ netBtns.forEach((b, i) => {
b.addEventListener('click', () => setNetwork(b.dataset.network));
+ b.addEventListener('keydown', (e) => {
+ const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;
+ const jump = e.key === 'Home' ? 0 : e.key === 'End' ? netBtns.length - 1 : null;
+ const next = jump != null ? netBtns[jump] : step ? netBtns[(i + step + netBtns.length) % netBtns.length] : null;
+ if (!next) return;
+ e.preventDefault();
+ setNetwork(next.dataset.network);
+ next.focus();
+ });
});
document.querySelectorAll('.lx-of-btn').forEach((b) => {
diff --git a/tests/e2e/launch-coin-page.spec.js b/tests/e2e/launch-coin-page.spec.js
new file mode 100644
index 000000000..48ca8ab25
--- /dev/null
+++ b/tests/e2e/launch-coin-page.spec.js
@@ -0,0 +1,139 @@
+import { test, expect } from '@playwright/test';
+
+// Regression guards for /launch, the "Launch a Coin" page.
+//
+// Two bugs this pins down, both found by driving the page as a first-time user
+// with a real session and a real agent list:
+//
+// 1. The primary CTA went dead the moment the form became valid. The panel
+// patches the name/symbol/description inputs into the DOM instead of
+// re-rendering (a full render on each keystroke destroys the caret), and the
+// launch button's label and data-action were only ever computed inside that
+// render. So a visitor who arrived with the description empty (the real
+// default: the panel prefills name and symbol from the avatar, never the
+// description) filled the form and was left with a button still reading
+// "Add name, symbol & description to launch" whose focus-form action found no
+// empty field and did nothing at all. The one action the page exists for was
+// unreachable.
+// 2. Pressing that CTA with a field missing moved the caret into the gap and
+// explained nothing: the inline "… is required." hints only appeared after a
+// field had been visited and blurred, which pressing the CTA never did.
+//
+// A third guard covers the picker: a failing /api/avatars used to be reported to
+// a signed-in owner as "No agents yet … create one first", pushing them toward a
+// duplicate agent, because the loader swallowed every fault into an empty list.
+//
+// Auth and the agent list are stubbed at the network seam (the nav-auth.spec.js
+// technique); everything from the keystroke to the assertion is shipped code.
+
+const USER = { id: 'launch-test-user', handle: 'tester', email: '[email protected]' };
+const AVATARS = [
+ {
+ id: 'launch-test-avatar-1',
+ name: 'Overlay Knight',
+ slug: 'overlay-knight',
+ description: 'A knight that answers lore questions for a fee.',
+ thumbnail_url: null,
+ visibility: 'public',
+ },
+];
+
+const json = (body) => ({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });
+
+// Only the agent-list read, never the per-avatar /api/avatars/:id/* routes.
+const isAvatarList = (url) => url.pathname === '/api/avatars';
+
+function stubSession(page, { avatars = AVATARS } = {}) {
+ return Promise.all([
+ page.route('**/api/auth/me', (route) => route.fulfill(json({ user: USER }))),
+ page.route(isAvatarList, (route) => route.fulfill(json({ avatars }))),
+ ]);
+}
+
+// The panel mounts asynchronously behind a runtime import; wait for the CTA.
+async function openLaunch(page) {
+ await page.goto('/launch', { waitUntil: 'domcontentloaded' });
+ await expect(page.locator('#lp-go')).toBeVisible({ timeout: 60_000 });
+}
+
+test.describe('/launch · Launch a Coin', () => {
+ test.beforeEach(({ page }) => {
+ page.on('pageerror', (err) => {
+ // Vite HMR socket noise on the forwarded Codespace port is not a product bug.
+ if (/websocket|hmr|wss:|failed to connect/i.test(err.message)) return;
+ throw new Error(`Page error: ${err.message}`);
+ });
+ });
+
+ test('the launch CTA becomes a real action as soon as the form is complete', async ({ page }) => {
+ test.setTimeout(120_000);
+ await stubSession(page);
+ await openLaunch(page);
+
+ const cta = page.locator('#lp-go');
+ // The avatar prefills name and symbol but never the description, so the
+ // page opens on the "something is missing" CTA.
+ await expect(cta).toHaveAttribute('data-action', 'focus-form');
+ await expect(page.locator('#lp-desc')).toHaveValue('');
+
+ await page.fill('#lp-desc', 'A knight that answers lore questions for a fee.');
+
+ // The CTA must leave focus-form the moment the last gap is filled, with no
+ // blur, no re-render and no other interaction.
+ await expect(cta).not.toHaveAttribute('data-action', 'focus-form');
+ await expect(cta).not.toContainText('Add name, symbol');
+ // It also has to carry a real explanation of what pressing it does.
+ await expect(cta).toHaveAttribute('title', /.+/);
+
+ // And it must go back when the form stops being valid.
+ await page.fill('#lp-name', '');
+ await expect(cta).toHaveAttribute('data-action', 'focus-form');
+ });
+
+ test('pressing the CTA with a gap says which field is missing', async ({ page }) => {
+ test.setTimeout(120_000);
+ await stubSession(page);
+ await openLaunch(page);
+
+ const hint = page.locator('#lp-desc-msg');
+ await expect(hint).toBeHidden();
+
+ await page.click('#lp-go');
+
+ await expect(hint).toBeVisible();
+ await expect(hint).toContainText('required');
+ await expect(page.locator('#lp-desc')).toHaveAttribute('aria-invalid', 'true');
+ await expect(page.locator('#lp-desc')).toBeFocused();
+
+ // Typing clears the hint again.
+ await page.fill('#lp-desc', 'A knight that answers lore questions for a fee.');
+ await expect(hint).toBeHidden();
+ await expect(page.locator('#lp-desc')).toHaveAttribute('aria-invalid', 'false');
+ });
+
+ test('a failing agent list reports the fault and recovers on retry', async ({ page }) => {
+ test.setTimeout(120_000);
+ let failing = true;
+ await page.route('**/api/auth/me', (route) => route.fulfill(json({ user: USER })));
+ await page.route(isAvatarList, (route) =>
+ failing
+ ? route.fulfill({ status: 503, contentType: 'application/json', body: '{"error":"unavailable"}' })
+ : route.fulfill(json({ avatars: AVATARS })),
+ );
+
+ await page.goto('/launch', { waitUntil: 'domcontentloaded' });
+
+ const err = page.locator('.lc-err');
+ await expect(err).toBeVisible({ timeout: 60_000 });
+ await expect(err).toContainText('Could not load your agents');
+ // The fault is named, not disguised as an empty account.
+ await expect(err).toContainText('503');
+ await expect(page.locator('.lc-pick')).not.toContainText('No agents yet');
+
+ failing = false;
+ await page.click('#lc-retry');
+
+ await expect(page.locator('.lc-card')).toHaveCount(AVATARS.length, { timeout: 30_000 });
+ await expect(page.locator('.lc-err')).toHaveCount(0);
+ });
+});