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
fix(x-content): measure every reel caption in the real bar and refuse one the format would cut off
nirholasfebf01f151af
diff --git a/api/_lib/x-content/reel.js b/api/_lib/x-content/reel.jsindex cdbb4fa51..f40982314 100644--- a/api/_lib/x-content/reel.js+++ b/api/_lib/x-content/reel.js@@ -385,11 +385,54 @@ class Bar {const next = { ...this.state, ...change };if (JSON.stringify(next) === JSON.stringify(this.state) && this.shot) return;this.state = next;- await this.page.evaluate((state) => {+ const clipped = await this.page.evaluate((state) => {for (const [id, text] of Object.entries(state)) document.getElementById(id).textContent = text;+ const caption = document.getElementById('caption');+ return caption.scrollHeight > caption.clientHeight + 1;}, next);+ // The bar shows two lines and cuts the rest with an ellipsis. How much+ // fits depends on the format and the font, so it is measured, not counted:+ // a caption cut off mid-word would ship in the reel.+ if (clipped) throw new Error(`the caption "${next.caption}" does not fit the bar in this format; shorten it`);this.shot = await this.page.screenshot({ type: 'png', scale: 'device' });}++ // Whether a caption fits the bar, without changing what it shows.+ async fits(caption) {+ return this.page.evaluate((text) => {+ const node = document.getElementById('caption');+ const before = node.textContent;+ node.textContent = text;+ const fits = node.scrollHeight <= node.clientHeight + 1;+ node.textContent = before;+ return fits;+ }, caption);+ }+}++// Every caption of a scenario that would be cut off in its format, measured in+// the same bar the camera films. The stamp and the cut badge share the bar's+// width with the caption, so it is measured beside the longest of each, which+// is the narrowest the caption can ever get. Runs before anything is filmed.+export const WIDEST_STAMP = 'live on three.ws @ 000000000, 2026-12-31';+export const WIDEST_BADGE = `cut ${formatCut(59 * 60 + 59)}`;++export async function captionsThatClip(scenario) {+ const captions = [...new Set((scenario.steps || []).map((step) => step.caption).filter(Boolean))];+ if (!captions.length) return [];+ const { chromium } = await import('playwright');+ const format = FORMATS[scenario.format || 'landscape'];+ const browser = await chromium.launch({ args: BROWSER_ARGS });+ try {+ const context = await browser.newContext({ deviceScaleFactor: format.scale });+ const bar = await Bar.open(context, format, scenario.stamp === false ? '' : WIDEST_STAMP);+ await bar.set({ badge: WIDEST_BADGE });+ const clipped = [];+ for (const caption of captions) if (!(await bar.fits(caption))) clipped.push(caption);+ return clipped;+ } finally {+ await browser.close();+ }}const visibleText = () => (document.querySelector('main')?.innerText || document.body?.innerText || '').replace(/[ \t ]+/g, ' ');@@ -818,6 +861,12 @@ async function productionVersion(scenario) {export async function proveItem(item, { root, film = true, now = Date.now(), failureShot = null }) {const problems = scenarioProblems(item.scenario);if (problems.length) throw new Error(`scenario is not runnable: ${problems.join('; ')}`);+ // Measured up front, so a caption too long for the format fails in a+ // second rather than after the whole scenario has been filmed.+ if (film) {+ const clipped = await captionsThatClip(item.scenario);+ if (clipped.length) throw new Error(`caption(s) too long for the ${item.scenario.format || 'landscape'} bar, shorten: ${clipped.map((caption) => `"${caption}"`).join(', ')}`);+ }const version = await productionVersion(item.scenario);const day = new Date(now).toISOString().slice(0, 10);const host = new URL(item.scenario.steps[0].goto).host;diff --git a/docs/ops/x-story-findings-2026-09-30.md b/docs/ops/x-story-findings-2026-09-30.mdindex 9393d86ed..1f0a1d898 100644--- a/docs/ops/x-story-findings-2026-09-30.md+++ b/docs/ops/x-story-findings-2026-09-30.md@@ -46,6 +46,7 @@ Third-party project names are left out on purpose; the pages named below carry t- A tap-only `press` could not walk a character; a key can now be held for a filmed stretch.- A loose control-name match clicked "Clear search" for "Search"; exact names are matched first.- The caption bar clamps at two lines; captions over about 90 characters were cut off, and the validator now refuses them.+- A 90-character limit was still too loose for a square reel: four filmed stories (agent monitor, model inspector, spotlight, glb diff) shipped captions cut off mid-sentence. The camera now measures every caption in the real bar before filming and refuses one that would clip.## Surfaces judged not to be storiesdiff --git a/docs/x-story-author-brief.md b/docs/x-story-author-brief.mdindex 0109a01a8..347f06a1b 100644--- a/docs/x-story-author-brief.md+++ b/docs/x-story-author-brief.md@@ -75,7 +75,8 @@ production and has been filmed, so that `public/x-media/<id>/reel.mp4` and## What good looks like- Reel of 8 to 20 seconds, the action visible, the result held, at least 25% of frames changing.- Captions under about 70 characters: the bar shows two short lines and clips the rest.+ Short captions: the bar shows two lines, and `prove` refuses to film a caption that would be cut+ off in the story's format (about 40 characters is safe in square).- Head post that opens with the strongest true statement as news, in plain words, and stands onits first 280 characters; then the mechanism. 250 to 600 characters is the usual range.- One or two replies with the detail, the limits and what to do next.diff --git a/docs/x-story-authoring.md b/docs/x-story-authoring.mdindex 44758ef72..f09eb6827 100644--- a/docs/x-story-authoring.md+++ b/docs/x-story-authoring.md@@ -117,7 +117,12 @@ covers the thing you meant to film.| `{ "caption": "..." }` | Changes the caption and does nothing else. | no |Any step can carry `"caption"`, up to 90 characters. The caption stays until another replaces it;-`""` clears it. An action (`click`, `type`, `press`) can carry `"awaits": "/api/path"`: the request+`""` clears it. The bar shows two lines, and how much fits depends on the format: a square reel+holds far less than a landscape one, and the stamp and cut badge share the width. `prove` measures+every caption in the real bar before it films, beside the longest stamp and badge, and refuses a+caption that would be cut off, naming it. About 40 characters is safe in square.++An action (`click`, `type`, `press`) can carry `"awaits": "/api/path"`: the requestthe action has to cause. The run fails if no such request answers, or if it answers with an error.### What makes a scenario prove somethingdiff --git a/tests/x-content-reel.test.js b/tests/x-content-reel.test.jsindex c6906e223..97f890d4b 100644--- a/tests/x-content-reel.test.js+++ b/tests/x-content-reel.test.js@@ -4,7 +4,7 @@ import { mkdtempSync, mkdirSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { FORMATS, MIN_MOTION, PROOF_MAX_AGE_DAYS, factCheck, formatCut, proofPath, proofProblems, reelPath, scenarioHash, scenarioProblems, stepKind } from '../api/_lib/x-content/reel.js';+import { FORMATS, MIN_MOTION, PROOF_MAX_AGE_DAYS, captionsThatClip, factCheck, formatCut, proofPath, proofProblems, reelPath, scenarioHash, scenarioProblems, stepKind } from '../api/_lib/x-content/reel.js';import { SITE_CHROME, chromeStylesheet } from '../api/_lib/x-content/site-chrome.js';import { PREMIUM_MAX_LENGTH, STANDARD_MAX_LENGTH, maxLengthOf } from '../api/_lib/x-content/quality.js';import { validateItem } from '../api/_lib/x-content/queue.js';@@ -387,3 +387,23 @@ describe('a held key', () => {expect(scenarioProblems({ steps: [steps[0], { press: 'w', hold: 60_000 }, steps[2]] }).join('\n')).toMatch(/step 2: hold is .* of the key held down/);});});++// The bar is measured in a real browser, because how much of a caption fits+// depends on the font and the format, not on a character count.+const browserStarts = await import('playwright')+ .then(({ chromium }) => chromium.launch())+ .then((browser) => browser.close().then(() => true))+ .catch(() => false);++describe.skipIf(!browserStarts)('caption fit', () => {+ it('finds a caption the square bar would cut off, and passes one that fits', async () => {+ const long = 'The entry opens on the agent itself, standing in 3D, with its name and its last move';+ const short = 'The agent, standing in 3D';+ const clipped = await captionsThatClip({ format: 'square', steps: [{ goto: 'https://three.ws/' }, { caption: long }, { caption: short }] });+ expect(clipped).toEqual([long]);+ }, 60_000);++ it('has nothing to measure in a scenario without captions', async () => {+ expect(await captionsThatClip({ steps: [{ goto: 'https://three.ws/' }] })).toEqual([]);+ });+});