diff --git a/AGENTS.md b/AGENTS.md index bf03e607..f96d8e48 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -421,6 +421,11 @@ flow (what to show when) is `src/hooks/use-tips.ts`. State (`tips_auto_show`, frame) and loops cleanly: it ends where it started, or crossfades back. Animated WebP plays in WKWebView, WebKitGTK without GStreamer codecs, and WebView2. Keep a clip near 250 KB. +- A clip never shows the app smaller than life: the recorder refuses a take + whose zoom (the 800 px frame over the app pixels it holds) is under 1. + `pnpm clips --measure` prints the zoom of each clip and records nothing. A + page made for a wide window is recorded in a narrow one and framed on its + content (`agentPage` in `clips.mjs`), never shrunk to fit. - Clips are decorative and never hide the copy. Under reduced motion only the still shows. The coach mark plays its clip for a few loops and then rests on the still, so the main page does not animate all day; a return to the diff --git a/public/clips/agent-chat-dark-still.webp b/public/clips/agent-chat-dark-still.webp index 484e5b7c..e487c168 100644 Binary files a/public/clips/agent-chat-dark-still.webp and b/public/clips/agent-chat-dark-still.webp differ diff --git a/public/clips/agent-chat-dark.webp b/public/clips/agent-chat-dark.webp index 59d6b4e6..4e79beca 100644 Binary files a/public/clips/agent-chat-dark.webp and b/public/clips/agent-chat-dark.webp differ diff --git a/public/clips/agent-chat-light-still.webp b/public/clips/agent-chat-light-still.webp index 44f3444f..d8455d98 100644 Binary files a/public/clips/agent-chat-light-still.webp and b/public/clips/agent-chat-light-still.webp differ diff --git a/public/clips/agent-chat-light.webp b/public/clips/agent-chat-light.webp index ba6e1f71..d97f71c2 100644 Binary files a/public/clips/agent-chat-light.webp and b/public/clips/agent-chat-light.webp differ diff --git a/public/clips/agent-routine-dark-still.webp b/public/clips/agent-routine-dark-still.webp index 1e56c97f..208f5fb9 100644 Binary files a/public/clips/agent-routine-dark-still.webp and b/public/clips/agent-routine-dark-still.webp differ diff --git a/public/clips/agent-routine-dark.webp b/public/clips/agent-routine-dark.webp index ca43deec..0ec27589 100644 Binary files a/public/clips/agent-routine-dark.webp and b/public/clips/agent-routine-dark.webp differ diff --git a/public/clips/agent-routine-light-still.webp b/public/clips/agent-routine-light-still.webp index d38ae08d..7d1c8045 100644 Binary files a/public/clips/agent-routine-light-still.webp and b/public/clips/agent-routine-light-still.webp differ diff --git a/public/clips/agent-routine-light.webp b/public/clips/agent-routine-light.webp index 05235c94..331bdcea 100644 Binary files a/public/clips/agent-routine-light.webp and b/public/clips/agent-routine-light.webp differ diff --git a/public/clips/agent-run-dark-still.webp b/public/clips/agent-run-dark-still.webp index fff20616..b7a8f0a5 100644 Binary files a/public/clips/agent-run-dark-still.webp and b/public/clips/agent-run-dark-still.webp differ diff --git a/public/clips/agent-run-dark.webp b/public/clips/agent-run-dark.webp index 35e4b704..2195b0f6 100644 Binary files a/public/clips/agent-run-dark.webp and b/public/clips/agent-run-dark.webp differ diff --git a/public/clips/agent-run-light-still.webp b/public/clips/agent-run-light-still.webp index 1d768462..d550003b 100644 Binary files a/public/clips/agent-run-light-still.webp and b/public/clips/agent-run-light-still.webp differ diff --git a/public/clips/agent-run-light.webp b/public/clips/agent-run-light.webp index fff70ba6..1357966c 100644 Binary files a/public/clips/agent-run-light.webp and b/public/clips/agent-run-light.webp differ diff --git a/public/clips/agent-templates-dark-still.webp b/public/clips/agent-templates-dark-still.webp index 8f12efbe..e6d791b2 100644 Binary files a/public/clips/agent-templates-dark-still.webp and b/public/clips/agent-templates-dark-still.webp differ diff --git a/public/clips/agent-templates-dark.webp b/public/clips/agent-templates-dark.webp index ad0e2e80..85849dae 100644 Binary files a/public/clips/agent-templates-dark.webp and b/public/clips/agent-templates-dark.webp differ diff --git a/public/clips/agent-templates-light-still.webp b/public/clips/agent-templates-light-still.webp index 34c0ee36..67ba0d04 100644 Binary files a/public/clips/agent-templates-light-still.webp and b/public/clips/agent-templates-light-still.webp differ diff --git a/public/clips/agent-templates-light.webp b/public/clips/agent-templates-light.webp index 384a32de..90d1a018 100644 Binary files a/public/clips/agent-templates-light.webp and b/public/clips/agent-templates-light.webp differ diff --git a/scripts/clips/clips.mjs b/scripts/clips/clips.mjs index 58675bc9..ebbb5233 100644 --- a/scripts/clips/clips.mjs +++ b/scripts/clips/clips.mjs @@ -7,6 +7,9 @@ // animated WebP pays for in full. const SMALL = { width: 680, height: 420 }; +// The agent's pages fill a wide window. In a narrow one the page beside the +// sidebar is about 560 px, so the frame shows it larger than life. +const AGENT_PAGE = { width: 840, height: 520 }; const row = (page, name) => page.locator("tbody tr", { hasText: name }).first(); const nameCell = (page, name) => @@ -73,6 +76,25 @@ const topOfWindow = (take) => ({ height: take.viewport.width / take.aspect, }); +/** + * The agent's page beside its sidebar, at the clip's aspect: from its top, + * or from `from`, moved down by `shift`, when the page is taller than the + * frame. + */ +async function agentPage(take, from, shift = 0) { + const pane = await take.page + .locator('[data-slot="agent-chat"]') + .boundingBox(); + const gutter = 14; + const width = pane.width + gutter * 2; + return { + x: pane.x - gutter, + y: from ? (await from.boundingBox()).y - gutter + shift : pane.y, + width, + height: width / take.aspect, + }; +} + /** The smallest box that holds every box given. */ function union(...boxes) { const x = Math.min(...boxes.map((b) => b.x)); @@ -1175,10 +1197,10 @@ export const CLIPS = { }, "agent-chat": { length: 7000, - fps: 18, + fps: 14, fade: 600, - poster: 0.55, - viewport: { width: 1280, height: 640 }, + poster: 0.5, + viewport: AGENT_PAGE, demo: { agentPlan: true }, async setup(take) { const { page } = take; @@ -1186,13 +1208,16 @@ export const CLIPS = { await page .locator('[data-slot="chat-list-item"][data-chat-id="chat-comments"]') .click(); - await page.locator('[data-slot="agent-live-view"]').waitFor(); + await page.locator('[data-slot="agent-live-strip"]').waitFor(); await page.waitForTimeout(900); - await take.camera(topOfWindow(take), { dur: 0, pad: 0 }); + await take.camera(await agentPage(take), { dur: 0, pad: 0 }); const live = await page - .locator('[data-slot="agent-live-view"]') + .locator('[data-slot="agent-live-strip"]') .boundingBox(); - take.state.rest = { x: live.x - 90, y: live.y + live.height * 0.75 }; + take.state.rest = { + x: live.x + live.width * 0.8, + y: live.y + live.height + 150, + }; await take.place(take.state.rest); }, async run(take) { @@ -1201,9 +1226,9 @@ export const CLIPS = { window.__agentDemo.play({ every: 950, run: false }), ); await take.wait(2400); - await take.move(page.locator('[data-slot="agent-live-view"]'), { + await take.move(page.locator('[data-slot="agent-live-strip"]'), { dur: 800, - at: [0.5, 0.45], + at: [0.12, 0.6], }); await take.wait(2600); await take.move(take.state.rest, { dur: 700, hover: false }); @@ -1214,7 +1239,7 @@ export const CLIPS = { fps: 18, fade: 500, poster: 0.5, - viewport: { width: 1180, height: 640 }, + viewport: AGENT_PAGE, demo: { agentPlan: true }, async setup(take) { const { page } = take; @@ -1224,16 +1249,19 @@ export const CLIPS = { .click(); await page.locator('[data-slot="agent-run-pane"]').waitFor(); await page.waitForTimeout(900); - await take.camera(page.locator('[data-slot="agent-run-pane"]'), { - dur: 0, - pad: 8, - }); - const pane = await page - .locator('[data-slot="agent-run-pane"]') - .boundingBox(); + const frame = await agentPage( + take, + page + .locator('[data-slot="agent-run-pane"]') + .getByText(/finished/) + .first(), + // Below the summary line, so the captions of the tiles fit. + 28, + ); + await take.camera(frame, { dur: 0, pad: 0 }); take.state.rest = { - x: pane.x + pane.width * 0.8, - y: pane.y + pane.height * 0.85, + x: frame.x + frame.width * 0.5, + y: frame.y + frame.height * 0.9, }; await take.place(take.state.rest); }, @@ -1243,7 +1271,7 @@ export const CLIPS = { window.__agentDemo.play({ every: 800, chat: false }), ); await take.wait(1800); - await take.move(page.locator('[data-slot="agent-batch-tile"]').nth(3), { + await take.move(page.locator('[data-slot="agent-batch-tile"]').nth(1), { dur: 800, }); await take.wait(2400); @@ -1255,7 +1283,7 @@ export const CLIPS = { fps: 18, fade: 500, poster: 0.6, - viewport: { width: 1180, height: 640 }, + viewport: AGENT_PAGE, demo: { agentPlan: true }, async setup(take) { const { page } = take; @@ -1267,20 +1295,26 @@ export const CLIPS = { .click(); await page.locator('[data-slot="agent-routine-batch"]').nth(2).waitFor(); await page.waitForTimeout(900); - await take.camera(page.locator('[data-slot="agent-routine"]'), { + // Only the run with a failure opens in the take. + const batches = page.locator( + '[data-slot="agent-routine-batch"] > button', + ); + await batches.first().click(); + await page.waitForTimeout(600); + const runs = page + .locator('[data-slot="agent-routine"]') + .getByText("Runs", { exact: true }); + await take.camera(await agentPage(take, runs), { dur: 0, - pad: 8, + pad: 0, }); - const box = await page - .locator('[data-slot="agent-routine-batch"] > button') - .nth(2) - .boundingBox(); + const box = await batches.nth(2).boundingBox(); take.state.rest = { x: box.x + box.width * 0.6, y: box.y + 90 }; await take.place(take.state.rest); }, async run(take) { const { page } = take; - // The newest run is open; the one with a failure opens and closes. + // The run with a failure opens and closes. const toggle = page .locator('[data-slot="agent-routine-batch"] > button') .nth(2); @@ -1297,7 +1331,7 @@ export const CLIPS = { fps: 18, fade: 500, poster: 0.25, - viewport: { width: 1180, height: 640 }, + viewport: AGENT_PAGE, demo: { agentPlan: true }, async setup(take) { const { page } = take; @@ -1305,10 +1339,7 @@ export const CLIPS = { await page.locator('[data-slot="agent-templates-open"]').click(); await page.locator('[data-slot="agent-templates"]').waitFor(); await page.waitForTimeout(900); - await take.camera(page.locator('[data-slot="agent-templates"]'), { - dur: 0, - pad: 8, - }); + await take.camera(await agentPage(take), { dur: 0, pad: 0 }); const search = await page .locator('[data-slot="agent-templates-search"]') .boundingBox(); diff --git a/scripts/clips/record.mjs b/scripts/clips/record.mjs index 066124b0..211d0b3e 100644 --- a/scripts/clips/record.mjs +++ b/scripts/clips/record.mjs @@ -5,6 +5,7 @@ // pnpm clips groups vpn only these clips // --theme=dark one theme // --no-build reuse the last static build +// --measure run each setup and print the zoom, record nothing // --ref=HEAD build a commit instead of the working tree // --work=DIR scratch folder (default: system temp) // @@ -24,6 +25,9 @@ const HERE = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(HERE, "../.."); const OUT = path.join(ROOT, "public/clips"); const FPS = 24; +// A clip never shows the app smaller than life: text that is 12 px in the +// app is at least 12 px in the 800 px frame, which a tip shows at 512 px. +const MIN_ZOOM = 1; const THEMES = ["dark", "light"]; const args = process.argv.slice(2); @@ -251,6 +255,7 @@ function encode({ frames: captured, clip, name }) { } const encodeOnly = args.includes("--encode-only"); +const measureOnly = args.includes("--measure"); const dist = encodeOnly || args.includes("--no-build") ? path.join(work, "app/dist") @@ -301,6 +306,12 @@ async function record(clip, name, theme) { let recorded = 0; try { if (clip.setup) await clip.setup(take); + if (measureOnly) return take.zoom; + if (take.zoom < MIN_ZOOM) { + throw new Error( + `zoom ${take.zoom.toFixed(2)} is under ${MIN_ZOOM}: the app shows smaller than life. Narrow the viewport or the frame`, + ); + } await take.start(); try { await clip.run(take); @@ -343,6 +354,13 @@ try { ), ) : await record(clip, name, theme); + if (measureOnly) { + console.log( + `${name}: zoom ${frames.toFixed(2)}${frames < MIN_ZOOM ? " UNDER" : ""}`, + ); + if (frames < MIN_ZOOM) failed.push(name); + continue; + } } catch (error) { failed.push(name); console.log(`${name}: FAILED ${String(error.message).split("\n")[0]}`); diff --git a/scripts/clips/take.mjs b/scripts/clips/take.mjs index d2fbf964..0637f47a 100644 --- a/scripts/clips/take.mjs +++ b/scripts/clips/take.mjs @@ -68,6 +68,8 @@ export class Take { height: viewport.height, }); this.cam = new Track(full); + /** The smallest zoom the camera has asked for: output over app pixels. */ + this.zoom = output.width / full.w; this.cursor = new Track({ x: viewport.width * 0.62, y: viewport.height * 0.7, @@ -141,7 +143,11 @@ export class Take { height: Math.max(rect.y + rect.height, other.y + other.height) - y, }; } - this.cam.go(this.now(), dur, this.fit(rect, { pad, width }), mixRect); + const to = this.fit(rect, { pad, width }); + this.zoom = dur + ? Math.min(this.zoom, this.output.width / to.w) + : this.output.width / to.w; + this.cam.go(this.now(), dur, to, mixRect); } async point(target, { at = [0.5, 0.5] } = {}) {