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): keep what the visitor typed when the SOL price lands, and cover the rebuilt /launch

nirholas3ae6db5ff5d4
diff --git a/src/pump/launch-token-modal.js b/src/pump/launch-token-modal.js
index 30ae42908..94e475426 100644
--- a/src/pump/launch-token-modal.js
+++ b/src/pump/launch-token-modal.js
@@ -143,10 +143,19 @@ export class LaunchTokenModal {
return;
}
this._solPriceUsd = price;
- // If modal is open on step 1, re-render to show price hints
- if (this._overlay && this._step === 1) {
- this._renderStep1();
- }
+ // The price usually lands after step 1 is on screen. Fill in its one
+ // price-dependent hint in place: re-rendering the step here wiped
+ // whatever the visitor had already typed into the form.
+ if (this._overlay && this._step === 1) this._refreshBuyUsd();
+ }
+
+ /** Write the dev buy's USD equivalent next to its input, when a price is known. */
+ _refreshBuyUsd() {
+ const buyInput = this._overlay?.querySelector('#ltm-buy');
+ const buyUsd = this._overlay?.querySelector('#ltm-buy-usd');
+ if (!this._solPriceUsd || !buyInput || !buyUsd) return;
+ const sol = parseFloat(buyInput.value) || 0;
+ buyUsd.textContent = `~ $${(sol * this._solPriceUsd).toFixed(2)}`;
}
_injectCss() {
@@ -537,19 +546,11 @@ export class LaunchTokenModal {
const symInput = this._overlay.querySelector('#ltm-sym');
const symErr = this._overlay.querySelector('#ltm-sym-err');
const buyInput = this._overlay.querySelector('#ltm-buy');
- const buyUsd = this._overlay.querySelector('#ltm-buy-usd');
let symTouched = d.symbol !== _nameToSymbol(d.name);
- const updateBuyUsd = () => {
- if (!this._solPriceUsd || !buyUsd) return;
- const sol = parseFloat(buyInput.value) || 0;
- const usd = (sol * this._solPriceUsd).toFixed(2);
- buyUsd.textContent = `~ $${usd}`;
- };
-
if (buyInput) {
- buyInput.addEventListener('input', updateBuyUsd);
- updateBuyUsd();
+ buyInput.addEventListener('input', () => this._refreshBuyUsd());
+ this._refreshBuyUsd();
}
const imgInput = this._overlay.querySelector('#ltm-img');
diff --git a/tests/e2e/launch-coin-page.spec.js b/tests/e2e/launch-coin-page.spec.js
index a0104a0fe..856e4f401 100644
--- a/tests/e2e/launch-coin-page.spec.js
+++ b/tests/e2e/launch-coin-page.spec.js
@@ -1,30 +1,33 @@
import { test, expect } from '@playwright/test';
-// Regression guards for /launch, the "Launch a Coin" page.
+// Regression guards for /launch, the "Launch a Coin" page, in both of the
+// launchers it serves.
//
-// 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:
+// /launch is the launchpad (src/launch/launch-page.js). A Launch Studio recipe
+// link (/launch?reward=...) needs the fee-split handoff that only the full
+// studio panel owns, so those visits mount that panel instead
+// (public/launch/launch.js). Each launcher is guarded against the same three
+// first-time-user failures:
//
-// 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.
+// 1. A dead primary CTA. The recipe panel patches the name/symbol/description
+// inputs into the DOM instead of re-rendering (a full render on each
+// keystroke destroys the caret), and its launch button's label and
+// data-action were once only computed inside that render, so a visitor who
+// filled the form was left with a button still reading "Add name, symbol &
+// description to launch" that did nothing. The launchpad's button has to arm
+// itself the same way: on the keystroke that completes the form, with no
+// blur and no re-render.
+// 2. A gap with no explanation. Pressing the CTA (recipe panel) or reading the
+// checklist (launchpad) has to name the missing field and take the caret to
+// it.
+// 3. A fault disguised as an empty account. 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.
//
-// 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.
+// Auth, the agent list and the launch reads are stubbed at the network seam
+// (the nav-auth.spec.js technique; the dev server would otherwise proxy them to
+// production); everything from the keystroke to the assertion is shipped code.
const USER = { id: 'launch-test-user', handle: 'tester', email: '[email protected]' };
const AVATARS = [
@@ -32,50 +35,158 @@ const AVATARS = [
id: 'launch-test-avatar-1',
name: 'Overlay Knight',
slug: 'overlay-knight',
- // Deliberately blank: the panel prefills the token description from the
- // avatar's, so an avatar WITH one opens on an already-valid form and
- // hides the exact bug these tests exist for. A freshly forged avatar has
- // no description, which is the case that shipped broken.
+ // Deliberately blank: the recipe panel prefills the token description
+ // from the avatar's, so an avatar WITH one opens on an already-valid form
+ // and hides the exact bug these tests exist for. A freshly forged avatar
+ // has no description, which is the case that shipped broken.
description: '',
thumbnail_url: null,
visibility: 'public',
},
];
-const json = (body) => ({ status: 200, contentType: 'application/json', body: JSON.stringify(body) });
+// A clearly synthetic custodial wallet for the agent-launch lane.
+const AGENT_WALLET = { agent_id: 'launch-test-agent-1', address: 'THREEsynthetic111111111111111111111111111111', network: 'mainnet', lamports: 2e9, sol: 2 };
+
+// The shape /api/pump/launch-config answers, minus the fields this page never reads.
+const LAUNCH_CONFIG = {
+ network: 'mainnet',
+ launch_fee_bps: 100,
+ launch_fee_basis: 'dev_buy',
+ create_cost_sol_estimate: 0.022,
+ max_sol_buy_in: 50,
+ tx_v1: { active: false },
+};
+
+// What the API's error() helper sends for an upstream outage.
+const AGENTS_DOWN = { error: 'service_unavailable', error_description: 'the agent directory is temporarily unavailable' };
+
+const json = (body, status = 200) => ({ status, 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 } = {}) {
+// A recipe link: creator fees route to an X account, so /launch mounts the
+// full studio panel. The handle is the platform's own.
+const RECIPE_URL = '/launch?reward=x:trythreews';
+
+function stubSession(page, { avatars = AVATARS, avatarsStatus = () => 200 } = {}) {
return Promise.all([
page.route('**/api/auth/me', (route) => route.fulfill(json({ user: USER }))),
- page.route(isAvatarList, (route) => route.fulfill(json({ avatars }))),
- // The panel blocks on this check before it will paint the form: a synthetic
- // agent id has no launch record, so answer the real "no token yet" shape.
+ page.route(isAvatarList, (route) => {
+ const status = avatarsStatus();
+ return route.fulfill(status === 200 ? json({ avatars }) : json(AGENTS_DOWN, status));
+ }),
+ // The recipe panel blocks on this check before it will paint the form: a
+ // synthetic agent id has no launch record, so answer the real "no token
+ // yet" shape.
page.route('**/api/pump/by-agent**', (route) => route.fulfill(json({ data: null }))),
+ page.route('**/api/pump/launch-config**', (route) => route.fulfill(json({ data: LAUNCH_CONFIG }))),
+ page.route('**/api/pump/agent-wallet', (route) => route.fulfill(json(AGENT_WALLET))),
]);
}
-// 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.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.describe('/launch · the launchpad', () => {
+ // The page boots its agent list behind the session check; wait for the pick.
+ async function openLaunchpad(page) {
+ await page.goto('/launch', { waitUntil: 'domcontentloaded' });
+ await expect(page.locator('.lx-agent[aria-checked="true"]')).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}`);
- });
+ // Launch from the agent's own wallet: the lane a headless browser can sign
+ // for, since it carries no wallet extension.
+ async function launchFromAgent(page) {
+ await page.click('[data-seg="launcher"][data-value="agent"]');
+ await expect(page.locator('#lx-wallet')).toContainText('Agent wallet');
+ }
+
+ test('the launch button arms itself on the keystroke that completes the form', async ({ page }) => {
+ test.setTimeout(120_000);
+ await stubSession(page);
+ await openLaunchpad(page);
+ await launchFromAgent(page);
+
+ const cta = page.locator('#lx-launch');
+ const checklist = page.locator('#lx-checklist');
+ await expect(cta).toBeDisabled();
+ await expect(checklist).toContainText('Name your coin');
+
+ await page.fill('#f-name', 'Overlay Knight');
+
+ // The ticker is suggested from the name, and the button arms with no blur
+ // and no other interaction, naming exactly what it will launch.
+ const ticker = await page.locator('#f-symbol').inputValue();
+ expect(ticker.length).toBeGreaterThanOrEqual(2);
+ await expect(cta).toBeEnabled();
+ await expect(cta).toHaveText(`Launch $${ticker}`);
+ await expect(checklist).toBeHidden();
+
+ // And it disarms the moment the form stops being valid.
+ await page.fill('#f-name', '');
+ await expect(cta).toBeDisabled();
+ await expect(checklist).toContainText('Name your coin');
});
+ test('every gap is named and one click from its field', async ({ page }) => {
+ test.setTimeout(120_000);
+ await stubSession(page);
+ await openLaunchpad(page);
+ await launchFromAgent(page);
+
+ const checklist = page.locator('#lx-checklist');
+ await expect(checklist.locator('[data-focus="name"]')).toHaveText('Name your coin');
+ await expect(checklist.locator('[data-focus="symbol"]')).toContainText('Ticker');
+
+ await checklist.locator('[data-focus="symbol"]').click();
+ await expect(page.locator('#f-symbol')).toBeFocused();
+ await checklist.locator('[data-focus="name"]').click();
+ await expect(page.locator('#f-name')).toBeFocused();
+
+ // Filling the field clears its line from the checklist as it is typed.
+ await page.keyboard.type('Overlay Knight');
+ await expect(checklist.locator('[data-focus="name"]')).toHaveCount(0);
+ });
+
+ test('a failing agent list reports the fault and recovers on retry', async ({ page }) => {
+ test.setTimeout(120_000);
+ let failing = true;
+ await stubSession(page, { avatarsStatus: () => (failing ? 503 : 200) });
+ await page.goto('/launch', { waitUntil: 'domcontentloaded' });
+
+ const err = page.locator('#lx-agents .lx-empty.is-error');
+ 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(AGENTS_DOWN.error_description);
+ await expect(page.locator('#lx-agents')).not.toContainText("You don't have an agent yet");
+
+ failing = false;
+ await page.click('#agents-retry');
+
+ await expect(page.locator('.lx-agent')).toHaveCount(AVATARS.length, { timeout: 30_000 });
+ await expect(page.locator('#lx-agents .is-error')).toHaveCount(0);
+ });
+});
+
+test.describe('/launch?reward= · the recipe launcher', () => {
+ // The panel mounts asynchronously behind a runtime import; wait for the CTA.
+ async function openRecipe(page) {
+ await page.goto(RECIPE_URL, { waitUntil: 'domcontentloaded' });
+ await expect(page.locator('#lp-go')).toBeVisible({ timeout: 60_000 });
+ }
+
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);
+ await openRecipe(page);
const cta = page.locator('#lp-go');
// The avatar prefills name and symbol but never the description, so the
@@ -100,7 +211,7 @@ test.describe('/launch · Launch a Coin', () => {
test('pressing the CTA with a gap says which field is missing', async ({ page }) => {
test.setTimeout(120_000);
await stubSession(page);
- await openLaunch(page);
+ await openRecipe(page);
const hint = page.locator('#lp-desc-msg');
await expect(hint).toBeHidden();
@@ -121,15 +232,8 @@ test.describe('/launch · Launch a Coin', () => {
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('**/api/pump/by-agent**', (route) => route.fulfill(json({ data: null })));
- 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' });
+ await stubSession(page, { avatarsStatus: () => (failing ? 503 : 200) });
+ await page.goto(RECIPE_URL, { waitUntil: 'domcontentloaded' });
const err = page.locator('.lc-err');
await expect(err).toBeVisible({ timeout: 60_000 });
diff --git a/tests/e2e/launch-token-flow.spec.js b/tests/e2e/launch-token-flow.spec.js
index 29b38cfed..b3ada9da1 100644
--- a/tests/e2e/launch-token-flow.spec.js
+++ b/tests/e2e/launch-token-flow.spec.js
@@ -27,6 +27,7 @@ import { test, expect } from '@playwright/test';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import { Transaction, SystemProgram, Keypair } from '@solana/web3.js';
+import { RISK_ACK_STORAGE_KEY, RISK_ACK_VERSION } from '../../public/risk-ack.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const repoRoot = resolve(__dirname, '..', '..');
@@ -66,16 +67,31 @@ async function installHarness(page, { quote = QUOTE_PAYLOAD } = {}) {
const calls = { prep: null, confirm: null, broadcast: 0 };
const txBase64 = buildPrepTxBase64();
- // Pre-accept the Risk Disclosure (public/risk-ack.js gates the sign step of
- // every money flow since 2026-07-03). This spec's subject is the launch flow,
- // not the disclosure dialog — seed the returning-user acceptance record the
- // module reads from localStorage.
- await page.addInitScript(() => {
- window.localStorage.setItem(
- 'threews:risk-ack',
- JSON.stringify({ version: 1, acceptedAt: new Date().toISOString(), context: 'e2e' }),
- );
- });
+ // Pre-sign the real-funds agreements (public/risk-ack.js gates the sign step
+ // of every money flow). This spec's subject is the launch flow, not the
+ // agreement dialog, so seed a returning signer: the local record at the
+ // CURRENT bundle version (read from the module, so a version bump re-signs
+ // here exactly as it re-signs every real user) and the account's server
+ // record that the gate double-checks for a signed-in visitor.
+ await page.addInitScript(
+ ({ key, version }) => {
+ window.localStorage.setItem(
+ key,
+ JSON.stringify({ version, acceptedAt: new Date().toISOString(), context: 'e2e' }),
+ );
+ },
+ { key: RISK_ACK_STORAGE_KEY, version: RISK_ACK_VERSION },
+ );
+ await page.route('**/api/legal/risk-ack', (route) =>
+ route.fulfill({
+ json: {
+ authenticated: true,
+ signed: true,
+ version: RISK_ACK_VERSION,
+ signedAt: new Date().toISOString(),
+ },
+ }),
+ );
// Wallet extension stub — the one acceptable mock (external browser code).
await page.addInitScript((addr) => {
@@ -156,7 +172,7 @@ async function installHarness(page, { quote = QUOTE_PAYLOAD } = {}) {
// Open the real modal on the harness page and return once step 1 is painted.
async function openModal(page) {
- await page.goto('http://localhost:3000/__e2e/launch-harness');
+ await page.goto('/__e2e/launch-harness');
await page.addStyleTag({ path: LTM_CSS });
await page.evaluate(async () => {
const mod = await import('/src/pump/launch-token-modal.js');