feat: zoom agent clips
No files matched your search
@@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 292 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 233 KiB After Width: | Height: | Size: 329 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 147 KiB |
@@ -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();
|
||||
|
||||
@@ -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]}`);
|
||||
|
||||
@@ -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] } = {}) {
|
||||
|
||||