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(x-content): let a reel show the walk companion when the companion is the story

nirholasb5cbd912601c
diff --git a/api/_lib/x-content/reel.js b/api/_lib/x-content/reel.js
index 71dbb4da0..bc6179f7f 100644
--- a/api/_lib/x-content/reel.js
+++ b/api/_lib/x-content/reel.js
@@ -42,7 +42,7 @@ import { tmpdir } from 'node:os';
import { dirname, join, resolve } from 'node:path';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
-import { chromeStylesheet } from './site-chrome.js';
+import { SITE_CHROME, chromeStylesheet } from './site-chrome.js';
import { parseFfmpegProbe } from './media.js';
export const PROOF_DIR = 'data/x-content/proofs';
@@ -96,6 +96,12 @@ export function scenarioProblems(scenario) {
const problems = [];
if (scenario.format !== undefined && !FORMATS[scenario.format]) problems.push(`format must be one of ${Object.keys(FORMATS).join(', ')}`);
if (scenario.fps !== undefined && !between(scenario.fps, [12, 60])) problems.push('fps must be between 12 and 60');
+ for (const key of ['hide', 'show']) {
+ if (scenario[key] !== undefined && !(Array.isArray(scenario[key]) && scenario[key].every((selector) => typeof selector === 'string' && selector))) problems.push(`${key} must be a list of selectors`);
+ }
+ for (const selector of Array.isArray(scenario.show) ? scenario.show : []) {
+ if (!SITE_CHROME.includes(selector)) problems.push(`show "${selector}" is not site chrome; show only names chrome the camera would otherwise hide (${SITE_CHROME.join(', ')})`);
+ }
const steps = scenario.steps;
if (!Array.isArray(steps) || !steps.length) return [...problems, 'scenario has no steps'];
if (stepKind(steps[0]) !== 'goto') problems.push('the first step must be a goto, so the reel starts on a real page');
@@ -664,7 +670,7 @@ export async function runScenario(scenario, { film = true, stamp = '', framesDir
const bar = await Bar.open(context, format, stamp);
const page = await context.newPage();
await page.clock.install();
- await page.addInitScript(installPointer, { stylesheet: chromeStylesheet(scenario.hide) });
+ await page.addInitScript(installPointer, { stylesheet: chromeStylesheet(scenario.hide, scenario.show) });
const take = new Take(page, { fps, film, framesDir, bar, size, compose: film ? await composer() : null });
for (const [offset, step] of scenario.steps.entries()) {
@@ -799,13 +805,13 @@ export async function proveItem(item, { root, film = true, now = Date.now(), fai
// What a person would look for before writing a scenario: the controls, the
// fields, the headings, and the lines of the page that carry a number.
-export async function scoutPage(url, { format = 'landscape', settle = 7000, shot = null, hide = [] } = {}) {
+export async function scoutPage(url, { format = 'landscape', settle = 7000, shot = null, hide = [], show = [] } = {}) {
const { chromium } = await import('playwright');
const size = FORMATS[format];
const browser = await chromium.launch({ args: BROWSER_ARGS });
try {
const page = await browser.newPage({ viewport: { width: size.width, height: size.height }, deviceScaleFactor: size.scale });
- await page.addInitScript(installPointer, { stylesheet: chromeStylesheet(hide) });
+ await page.addInitScript(installPointer, { stylesheet: chromeStylesheet(hide, show) });
const response = await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60_000 });
await page.waitForLoadState('networkidle', { timeout: 15_000 }).catch(() => {});
await page.waitForTimeout(settle);
diff --git a/api/_lib/x-content/site-chrome.js b/api/_lib/x-content/site-chrome.js
index 4d425f6c7..ef422ccda 100644
--- a/api/_lib/x-content/site-chrome.js
+++ b/api/_lib/x-content/site-chrome.js
@@ -26,4 +26,7 @@ export const SITE_CHROME = [
// A stylesheet installed before any page script runs holds regardless of when a
// node appears. Removing nodes once after load is not enough: the discovery
// card is injected on a timer and reappeared during the settle.
-export const chromeStylesheet = (extra = []) => `${[...SITE_CHROME, ...extra].join(',')}{display:none !important}`;
+//
+// `show` names chrome that is the subject of this capture and must stay: the
+// walk companion is chrome on every page except the ones about what it does.
+export const chromeStylesheet = (extra = [], show = []) => `${[...SITE_CHROME.filter((selector) => !show.includes(selector)), ...extra].join(',')}{display:none !important}`;
diff --git a/docs/x-story-authoring.md b/docs/x-story-authoring.md
index 52a49dd94..7cbc1bad3 100644
--- a/docs/x-story-authoring.md
+++ b/docs/x-story-authoring.md
@@ -148,6 +148,10 @@ the action has to cause. The run fails if no such request answers, or if it answ
the page. The stamp says which production commit was filmed and when.
- **Hide only what is not the subject.** Floating site chrome is hidden for you. `"hide":
["selector"]` on the scenario hides more. Never hide part of the feature to make it look better.
+- **Keep chrome that is the subject.** The walk companion is hidden on every page, because it is
+ chrome everywhere except on the pages about what it does. A story about Herald is a story about
+ the companion, so its scenario says `"show": [".walk-companion"]`. `show` only accepts selectors
+ the camera would otherwise hide.
## Filming it
diff --git a/tests/x-content-reel.test.js b/tests/x-content-reel.test.js
index 4986edce3..5833cf04a 100644
--- a/tests/x-content-reel.test.js
+++ b/tests/x-content-reel.test.js
@@ -312,6 +312,22 @@ describe('measured posts for calibration', () => {
});
});
+describe('chrome that is the subject', () => {
+ it('stays in frame when the scenario names it', () => {
+ const sheet = chromeStylesheet([], ['.walk-companion']);
+ expect(sheet).not.toMatch(/(^|,)\.walk-companion(,|\{)/);
+ expect(sheet).toContain('.walk-trail-layer');
+ expect(sheet).toContain('#cookie-banner');
+ });
+
+ it('is only ever site chrome', () => {
+ const steps = SCENARIO.steps;
+ expect(scenarioProblems({ steps, show: ['.walk-companion'], hide: ['.promo'] })).toEqual([]);
+ expect(scenarioProblems({ steps, show: ['main'] }).join('\n')).toMatch(/show "main" is not site chrome/);
+ expect(scenarioProblems({ steps, show: '.walk-companion' }).join('\n')).toMatch(/show must be a list of selectors/);
+ });
+});
+
describe('site chrome', () => {
it('hides every floating layer, and whatever a scenario adds', () => {
const sheet = chromeStylesheet(['.promo-banner']);