commit 534d2ab62c86693be1a09342b4208082f5e373b9
parent f14437b4974ccae5ae9d83f9853b6da2c9737b80
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 27 Oct 2026 10:46:49 -0400
Merge lane/x-shot-crop: X post and Article shots are viewport clips, never a full-page capture that re-lays the page out
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 410 insertions(+), 22 deletions(-)
diff --git a/common/social/playwrightRuntime.ts b/common/social/playwrightRuntime.ts
@@ -43,12 +43,17 @@ export type PageLike = {
evaluate: (fn: string) => Promise<unknown>;
on: (event: string, cb: (arg: never) => void) => void;
// The post capture's shot (xPostCapture.ts): a PNG of the page, clipped to
- // the post. `clip` is in document coordinates when `fullPage` is set.
+ // the post. `clip` is in document coordinates when `fullPage` is set, in
+ // the window's otherwise.
screenshot: (opts?: {
type?: "png" | "jpeg";
fullPage?: boolean;
clip?: { x: number; y: number; width: number; height: number };
}) => Promise<Uint8Array>;
+ // The window's size, grown so a post taller than it is shot from the window
+ // rather than by a full-page capture (viewportShot.ts says why). Optional:
+ // a page without it is shot the full-page way.
+ setViewportSize?: (size: { width: number; height: number }) => Promise<void>;
// A report's PDF export (publish/reportExports.ts): the export's HTML set as
// the page, printed. Optional: the fetchers' fakes do not print.
setContent?: (html: string, opts?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }) => Promise<void>;
diff --git a/common/social/viewportShot.test.ts b/common/social/viewportShot.test.ts
@@ -0,0 +1,155 @@
+// Shooting an element from the window, against a fake page: a window of a
+// set size, an element at a set box, scrolls and resizes that move it. No
+// browser.
+//
+// Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test social/viewportShot.test.ts
+
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import type { PageLike } from "./playwrightRuntime";
+import { shootFromViewport, TOP_ROOM, VIEW_SCRIPT_MARKER, type ElementView } from "./viewportShot";
+
+const PNG = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
+
+type Box = { x: number; y: number; width: number; height: number };
+
+type FakeWindow = PageLike & {
+ shots: unknown[];
+ sizes: { width: number; height: number }[];
+ scrolls: number[];
+};
+
+// A window `vw`×`vh` holding the element at `box` (viewport coordinates). A
+// scroll moves it; a resize changes the window. `views` overrides what the
+// measure returns, in turn (to fake a page still laying out).
+function fakeWindow(opts: {
+ box: Box;
+ vw?: number;
+ vh?: number;
+ resizable?: boolean;
+ views?: (ElementView | null)[];
+ onResize?: (box: Box) => Box;
+}): FakeWindow {
+ let box = { ...opts.box };
+ let vw = opts.vw ?? 1280;
+ let vh = opts.vh ?? 720;
+ const views = opts.views ? [...opts.views] : undefined;
+ const shots: unknown[] = [];
+ const sizes: { width: number; height: number }[] = [];
+ const scrolls: number[] = [];
+ const page: FakeWindow = {
+ shots,
+ sizes,
+ scrolls,
+ goto: async () => undefined,
+ waitForSelector: async () => undefined,
+ waitForTimeout: async () => undefined,
+ on: () => {},
+ evaluate: async (script: string) => {
+ if (script.includes(VIEW_SCRIPT_MARKER)) {
+ if (views?.length) return views.length > 1 ? views.shift() : views[0];
+ return { ...box, vw, vh };
+ }
+ const m = /window\.scrollBy\(0, (-?\d+)\)/.exec(script);
+ if (m) {
+ scrolls.push(Number(m[1]));
+ box = { ...box, y: box.y - Number(m[1]) };
+ }
+ return undefined;
+ },
+ screenshot: async (o?: unknown) => {
+ shots.push(o);
+ return PNG;
+ },
+ };
+ if (opts.resizable !== false) {
+ page.setViewportSize = async (s) => {
+ sizes.push(s);
+ vw = s.width;
+ vh = s.height;
+ if (opts.onResize) box = opts.onResize(box);
+ };
+ }
+ return page;
+}
+
+const SEL = "[data-archilyzer-capture]";
+
+test("an element inside the window is shot from it: a viewport clip, no full page, no resize", async () => {
+ const p = fakeWindow({ box: { x: 283.5, y: 43, width: 598, height: 668.75 } });
+ const res = await shootFromViewport(p, { selector: SEL, settleMs: 0 });
+ assert.deepEqual(res, { png: PNG, trimmed: false });
+ assert.deepEqual(p.shots, [{ type: "png", clip: { x: 283, y: 43, width: 598, height: 669 } }]);
+ assert.deepEqual(p.sizes, []);
+ assert.deepEqual(p.scrolls, []);
+});
+
+test("an element taller than the window grows the window's height (never its width), then puts it back", async () => {
+ const p = fakeWindow({ box: { x: 283.5, y: 53, width: 598, height: 1500 } });
+ const res = await shootFromViewport(p, { selector: SEL, settleMs: 0 });
+ assert.ok(res && "png" in res);
+ assert.deepEqual(p.sizes, [
+ { width: 1280, height: 53 + 1500 + 16 },
+ { width: 1280, height: 720 },
+ ]);
+ assert.deepEqual(p.shots, [{ type: "png", clip: { x: 283, y: 53, width: 598, height: 1500 } }]);
+});
+
+test("an element above the window is scrolled into it, below the sticky header", async () => {
+ const p = fakeWindow({ box: { x: 283, y: -400, width: 598, height: 300 } });
+ const res = await shootFromViewport(p, { selector: SEL, settleMs: 0 });
+ assert.ok(res && "png" in res);
+ assert.deepEqual(p.scrolls, [-400 - TOP_ROOM]);
+ assert.deepEqual(p.shots, [{ type: "png", clip: { x: 283, y: TOP_ROOM, width: 598, height: 300 } }]);
+ assert.deepEqual(p.sizes, []);
+});
+
+test("maxHeight shoots the element's top and says it trimmed", async () => {
+ const p = fakeWindow({ box: { x: 0, y: 64, width: 600, height: 5000 } });
+ const res = await shootFromViewport(p, { selector: SEL, settleMs: 0, maxHeight: 2000 });
+ assert.deepEqual(res, { png: PNG, trimmed: true });
+ assert.deepEqual(p.shots, [{ type: "png", clip: { x: 0, y: 64, width: 600, height: 2000 } }]);
+});
+
+test("a page that cannot grow its window, or an element past the grow limit, falls back (null)", async () => {
+ const fixed = fakeWindow({ box: { x: 283, y: 53, width: 598, height: 1500 }, resizable: false });
+ assert.equal(await shootFromViewport(fixed, { selector: SEL, settleMs: 0 }), null);
+ assert.deepEqual(fixed.shots, []);
+ const huge = fakeWindow({ box: { x: 283, y: 53, width: 598, height: 40_000 } });
+ assert.equal(await shootFromViewport(huge, { selector: SEL, settleMs: 0 }), null);
+ assert.deepEqual(huge.sizes, []);
+});
+
+test("a page that answers no box (a fake, a missing element) falls back; one wider than the window too", async () => {
+ const none = fakeWindow({ box: { x: 0, y: 0, width: 1, height: 1 }, views: [null] });
+ assert.equal(await shootFromViewport(none, { selector: SEL, settleMs: 0 }), null);
+ const wide = fakeWindow({ box: { x: 0, y: 53, width: 1400, height: 300 } });
+ assert.equal(await shootFromViewport(wide, { selector: SEL, settleMs: 0 }), null);
+ assert.deepEqual(wide.shots, []);
+});
+
+test("a box that moved during the shot is shot again; one that never settles is an error", async () => {
+ const at = (x: number): ElementView => ({ x, y: 53, width: 598, height: 300, vw: 1280, vh: 720 });
+ // first, loop measure, shot, after (moved) → loop measure, shot, after (steady).
+ const settling = fakeWindow({ box: at(0), views: [at(283), at(283), at(180), at(283), at(283)] });
+ const ok = await shootFromViewport(settling, { selector: SEL, settleMs: 0 });
+ assert.ok(ok && "png" in ok);
+ assert.equal(settling.shots.length, 2);
+
+ let n = 0;
+ const restless = fakeWindow({ box: at(0), views: [at(283)] });
+ const measure = restless.evaluate;
+ restless.evaluate = async (s: string) => (s.includes(VIEW_SCRIPT_MARKER) ? at(283 + 50 * n++) : measure(s));
+ const bad = await shootFromViewport(restless, { selector: SEL, settleMs: 0 });
+ assert.ok(bad && "error" in bad, JSON.stringify(bad));
+ assert.equal(restless.shots.length, 2);
+});
+
+test("the window is put back even when the shot throws", async () => {
+ const p = fakeWindow({ box: { x: 283, y: 53, width: 598, height: 1500 } });
+ p.screenshot = async () => {
+ throw new Error("Target closed");
+ };
+ await assert.rejects(shootFromViewport(p, { selector: SEL, settleMs: 0 }), /Target closed/);
+ assert.deepEqual(p.sizes.at(-1), { width: 1280, height: 720 });
+});
diff --git a/common/social/viewportShot.ts b/common/social/viewportShot.ts
@@ -0,0 +1,155 @@
+// Shooting one element of a live page FROM THE WINDOW, never with Chromium's
+// beyond-viewport capture.
+//
+// WHY. `page.screenshot({ fullPage: true, clip })` on a page taller than the
+// window makes Playwright ask Chromium for `captureBeyondViewport`, which
+// resizes the page's frame for the capture and back. The page sees that
+// resize. Measured on x.com (2026-10-27) in the X session profile: the page's
+// resize handler read the window as 1×1, X's responsive layout reflowed for
+// it mid-capture (its nav laid over the post, the column shifted ~100 px left,
+// the focal post moved down below its parent), and the pixels captured came
+// from that layout, not from the one the clip was measured in. Whether a shot
+// lands in the bad layout is a race, which is why the same post came out
+// offset on one capture and fine on the next. Re-measuring afterwards cannot
+// catch it: by then the page has laid itself out again.
+//
+// So the element is made to fit the window first — scrolled into it, and the
+// window grown (its height only, so no width breakpoint moves) when the element
+// is taller — the layout is let settle and measured again, and the shot is a
+// plain viewport clip: no resize during the capture, nothing for the page to
+// react to. The box is measured once more after the shot; a box that moved
+// means the page was still laying out, and the shot is taken again.
+//
+// A page that cannot grow its window (the tests' fakes), or an element taller
+// than the window may grow, gets `null`: the caller falls back to its
+// full-page clip.
+
+import type { PageLike } from "./playwrightRuntime";
+
+// The element's box in VIEWPORT coordinates, and the window it is in.
+export type ElementView = {
+ x: number;
+ y: number;
+ width: number;
+ height: number;
+ vw: number;
+ vh: number;
+};
+
+export type ViewportShotOptions = {
+ // The element, as a selector the page can query (a marker attribute the
+ // caller set).
+ selector: string;
+ // Shoot at most this much of the element's height, from its top.
+ maxHeight?: number;
+ // The tallest window it will grow to (default 16 384 px).
+ growLimit?: number;
+ // How long a scroll or a resize is let settle before the box is read again.
+ settleMs?: number;
+ onLog?: (line: string) => void;
+};
+
+export type ViewportShotResult =
+ | { png: Uint8Array; trimmed: boolean }
+ | { error: string };
+
+// Room left above an element scrolled into the window: X's sticky column
+// header (53 px) would otherwise lie over the element's top.
+export const TOP_ROOM = 64;
+const BOTTOM_ROOM = 16;
+const DEFAULT_GROW_LIMIT = 16_384;
+const DEFAULT_SETTLE_MS = 750;
+// A box that moved by more than this between the measure and the check after
+// the shot was shot mid-layout.
+const MOVED_PX = 1;
+
+export const VIEW_SCRIPT_MARKER = "__archilyzerElementView";
+
+export const viewScript = (selector: string) => `(() => {
+ const ${VIEW_SCRIPT_MARKER} = true;
+ const el = document.querySelector(${JSON.stringify(selector)});
+ if (!el) return null;
+ const r = el.getBoundingClientRect();
+ return { x: r.left, y: r.top, width: r.width, height: r.height, vw: window.innerWidth, vh: window.innerHeight };
+})()`;
+
+const scrollScript = (dy: number) => `window.scrollBy(0, ${Math.round(dy)})`;
+
+function asView(v: unknown): ElementView | null {
+ const o = v as Partial<ElementView> | null;
+ if (!o || typeof o !== "object") return null;
+ for (const k of ["x", "y", "width", "height", "vw", "vh"] as const) {
+ if (typeof o[k] !== "number" || !Number.isFinite(o[k])) return null;
+ }
+ return o as ElementView;
+}
+
+const fits = (v: ElementView, h: number) =>
+ v.x >= 0 && v.y >= 0 && v.x + v.width <= v.vw + 0.5 && v.y + h <= v.vh + 0.5;
+
+const moved = (a: ElementView, b: ElementView) =>
+ Math.abs(a.x - b.x) > MOVED_PX ||
+ Math.abs(a.y - b.y) > MOVED_PX ||
+ Math.abs(a.width - b.width) > MOVED_PX ||
+ Math.abs(a.height - b.height) > MOVED_PX ||
+ a.vw !== b.vw ||
+ a.vh !== b.vh;
+
+// null: this page cannot be shot from the window (the caller falls back).
+export async function shootFromViewport(
+ page: PageLike,
+ opts: ViewportShotOptions,
+): Promise<ViewportShotResult | null> {
+ const settleMs = opts.settleMs ?? DEFAULT_SETTLE_MS;
+ const growLimit = opts.growLimit ?? DEFAULT_GROW_LIMIT;
+ const measure = async () => asView(await page.evaluate(viewScript(opts.selector)).catch(() => null));
+
+ const first = await measure();
+ if (!first) return null;
+ if (first.width < 1 || first.height < 1) return { error: "The element has no size to shoot." };
+ // Wider than the window: growing the width would move the page's
+ // breakpoints, which is the very thing this avoids.
+ if (first.width > first.vw) return null;
+ const original = { width: first.vw, height: first.vh };
+ let grown = false;
+ try {
+ for (let attempt = 0; attempt < 2; attempt++) {
+ let v = await measure();
+ if (!v) return { error: "The element vanished before its shot." };
+ const want = Math.ceil(Math.min(v.height, opts.maxHeight ?? Infinity));
+ // Into the window: its top below the sticky header.
+ if (v.y < 0 || (v.y + want > v.vh && v.y > TOP_ROOM)) {
+ await page.evaluate(scrollScript(v.y - TOP_ROOM)).catch(() => {});
+ await page.waitForTimeout(settleMs);
+ v = (await measure()) ?? v;
+ }
+ // Taller than the window: grow the window to hold it.
+ if (!fits(v, want)) {
+ const height = Math.ceil(Math.max(v.y, 0) + want + BOTTOM_ROOM);
+ if (!page.setViewportSize || height > growLimit) return null;
+ await page.setViewportSize({ width: original.width, height });
+ grown = true;
+ await page.waitForTimeout(settleMs);
+ v = (await measure()) ?? v;
+ }
+ if (!fits(v, want)) {
+ opts.onLog?.("The element did not stay inside the window; measuring it again.");
+ continue;
+ }
+ const clip = {
+ x: Math.max(0, Math.floor(v.x)),
+ y: Math.max(0, Math.floor(v.y)),
+ width: Math.ceil(v.width),
+ height: want,
+ };
+ const png = await page.screenshot({ type: "png", clip });
+ const after = await measure();
+ if (after && !moved(v, after)) return { png, trimmed: v.height > want };
+ opts.onLog?.("The element moved while it was being shot; shooting it again.");
+ await page.waitForTimeout(settleMs);
+ }
+ return { error: "The element kept moving; no steady shot of it." };
+ } finally {
+ if (grown) await page.setViewportSize?.(original).catch(() => {});
+ }
+}
diff --git a/common/social/xArticleCapture.ts b/common/social/xArticleCapture.ts
@@ -26,6 +26,7 @@ import { mkdir, readdir, rm, writeFile } from "node:fs/promises";
import path from "node:path";
import { writeFileAtomic, writeJsonAtomic } from "../lib/jsonFile-server";
import type { PageLike } from "./playwrightRuntime";
+import { shootFromViewport } from "./viewportShot";
import {
ARTICLE_HTML_FILENAME,
ARTICLE_JSON_FILENAME,
@@ -252,16 +253,30 @@ export async function captureXArticle(
let png: Uint8Array | undefined;
let error: string | undefined;
try {
- png = await page.screenshot({
- type: "png",
- fullPage: true,
- clip: {
- x: Math.max(0, Math.floor(rect.x)),
- y: Math.max(0, Math.floor(rect.y)),
- width: Math.ceil(rect.width),
- height: Math.min(Math.ceil(rect.height), ARTICLE_SHOT_MAX_HEIGHT),
- },
+ // From the window, as a post is (viewportShot.ts: a full-page capture
+ // lets X lay itself out again under the shot); the full-page clip when
+ // the page cannot grow its window.
+ const fromWindow = await shootFromViewport(page, {
+ selector: "[data-archilyzer-article]",
+ maxHeight: ARTICLE_SHOT_MAX_HEIGHT,
+ onLog,
});
+ if (fromWindow && "error" in fromWindow) {
+ error = `The article could not be shot: ${fromWindow.error}`;
+ } else if (fromWindow) {
+ png = fromWindow.png;
+ } else {
+ png = await page.screenshot({
+ type: "png",
+ fullPage: true,
+ clip: {
+ x: Math.max(0, Math.floor(rect.x)),
+ y: Math.max(0, Math.floor(rect.y)),
+ width: Math.ceil(rect.width),
+ height: Math.min(Math.ceil(rect.height), ARTICLE_SHOT_MAX_HEIGHT),
+ },
+ });
+ }
} catch (err) {
error = `The article's screenshot failed: ${firstLine(err)}`;
}
diff --git a/common/social/xPostCapture.test.ts b/common/social/xPostCapture.test.ts
@@ -20,6 +20,7 @@ import {
type XPostSnapshot,
} from "./xPostCapture";
import { readPostCapture, SHOT_FILENAME, writePostCapture } from "./postCapture";
+import { VIEW_SCRIPT_MARKER, type ElementView } from "./viewportShot";
import type { PostCaptureInput } from "./fetchers";
const sha = (b: string | Uint8Array) => createHash("sha256").update(b).digest("hex");
@@ -82,11 +83,17 @@ test("classify: X refusing pages stops the run; an age wall and an empty page ar
type FakePage = PageLike & { calls: string[]; shots: unknown[] };
// A page whose snapshot evaluate returns `snaps` in turn (the last repeats);
-// the sensitive-cover click flips a sensitive article to an open one.
-function fakePage(snaps: XPostSnapshot[], opts: { gotoFails?: boolean } = {}): FakePage {
+// the sensitive-cover click flips a sensitive article to an open one. With
+// `view`, it also answers the window measure (viewportShot.ts) and can grow
+// its window; without, it answers none and is shot the full-page way.
+function fakePage(
+ snaps: XPostSnapshot[],
+ opts: { gotoFails?: boolean; view?: ElementView } = {},
+): FakePage {
let i = 0;
const calls: string[] = [];
const shots: unknown[] = [];
+ let view = opts.view;
return {
calls,
shots,
@@ -97,7 +104,16 @@ function fakePage(snaps: XPostSnapshot[], opts: { gotoFails?: boolean } = {}): F
waitForSelector: async () => undefined,
waitForTimeout: async () => undefined,
on: () => {},
+ ...(view
+ ? {
+ setViewportSize: async (s: { width: number; height: number }) => {
+ calls.push(`viewport ${s.width}x${s.height}`);
+ view = { ...view!, vw: s.width, vh: s.height };
+ },
+ }
+ : {}),
evaluate: async (script: string) => {
+ if (script.includes(VIEW_SCRIPT_MARKER)) return view ?? null;
if (script.includes("b.click()")) {
calls.push("open-sensitive");
return 1;
@@ -115,7 +131,31 @@ function fakePage(snaps: XPostSnapshot[], opts: { gotoFails?: boolean } = {}): F
};
}
-test("shot: the post's own box, clipped from a full-page PNG, hashed beside it", async () => {
+test("shot: a post inside the window is shot from it — a viewport clip, never a full-page capture", async () => {
+ // The case that came out offset (post 2114859155022389342): 598×669 at
+ // (283.5, 43) in a 1280×720 window.
+ const dir = path.join(await mkdtemp(path.join(os.tmpdir(), "xshot-")), "1");
+ const p = fakePage([post()], { view: { x: 283.5, y: 43, width: 598, height: 668.75, vw: 1280, vh: 720 } });
+ const res = await shootXPost(p, "1", dir);
+ assert.equal(res.state, "captured");
+ assert.deepEqual(p.shots, [{ type: "png", clip: { x: 283, y: 43, width: 598, height: 669 } }]);
+ assert.equal(p.calls.filter((c) => c.startsWith("viewport")).length, 0);
+ assert.deepEqual(new Uint8Array(await readFile(path.join(dir, SHOT_FILENAME))), PNG);
+});
+
+test("shot: a post taller than the window grows the window to hold it, shoots it whole, and puts it back", async () => {
+ const dir = path.join(await mkdtemp(path.join(os.tmpdir(), "xshot-")), "1");
+ const p = fakePage([post()], { view: { x: 283.5, y: 53, width: 598, height: 2400, vw: 1280, vh: 720 } });
+ const res = await shootXPost(p, "1", dir);
+ assert.equal(res.state, "captured");
+ assert.deepEqual(p.shots, [{ type: "png", clip: { x: 283, y: 53, width: 598, height: 2400 } }]);
+ assert.deepEqual(
+ p.calls.filter((c) => c.startsWith("viewport")),
+ [`viewport 1280x${53 + 2400 + 16}`, "viewport 1280x720"],
+ );
+});
+
+test("shot: a page that cannot be measured in its window falls back to the full-page clip", async () => {
const dir = path.join(await mkdtemp(path.join(os.tmpdir(), "xshot-")), "1");
const p = fakePage([post()]);
const res = await shootXPost(p, "1", dir);
diff --git a/common/social/xPostCapture.ts b/common/social/xPostCapture.ts
@@ -53,6 +53,10 @@ import {
} from "./postCapture";
import { xArticleLinkFromArchive, type XArticleLink } from "./xArticle";
import { captureXArticle, xArticleLinkFromCard } from "./xArticleCapture";
+import { shootFromViewport } from "./viewportShot";
+
+// The post's own article, marked by the snapshot.
+const CAPTURE_SELECTOR = "[data-archilyzer-capture]";
export function xStatusUrl(id: string): string {
return `https://x.com/i/status/${id}`;
@@ -240,17 +244,30 @@ export async function shootXPost(
if (!rect || rect.width < 1 || rect.height < 1) {
return { state: "error", error: "The post rendered with no size to shoot." };
}
- const clip = {
- x: Math.max(0, Math.floor(rect.x)),
- y: Math.max(0, Math.floor(rect.y)),
- width: Math.ceil(rect.width),
- height: Math.ceil(rect.height),
- };
let png: Uint8Array;
try {
- // fullPage, so a post taller than the window is shot whole; the clip is in
- // document coordinates, which is what the snapshot measured.
- png = await page.screenshot({ type: "png", fullPage: true, clip });
+ // From the window, the post made to fit it: a full-page capture resizes
+ // the page under the shot and X lays itself out again mid-capture, which
+ // is how a shot came out offset from the post (viewportShot.ts).
+ const fromWindow = await shootFromViewport(page, { selector: CAPTURE_SELECTOR, onLog });
+ if (fromWindow && "error" in fromWindow) {
+ return { state: "error", error: `The post could not be shot: ${fromWindow.error}` };
+ }
+ if (fromWindow) {
+ png = fromWindow.png;
+ } else {
+ // A page that cannot grow its window, or a post taller than it may
+ // grow: the full-page clip, in document coordinates — what the
+ // snapshot measured.
+ onLog?.(`${id}: shooting the post from a full-page capture.`);
+ const clip = {
+ x: Math.max(0, Math.floor(rect.x)),
+ y: Math.max(0, Math.floor(rect.y)),
+ width: Math.ceil(rect.width),
+ height: Math.ceil(rect.height),
+ };
+ png = await page.screenshot({ type: "png", fullPage: true, clip });
+ }
} catch (err) {
return { state: "error", error: `The screenshot failed: ${firstLine(err)}` };
}
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
+- **An X post's screenshot is of the post, not of a page in the middle of laying itself out.** On 2026-10-27 a forced capture of TheQuartering's post 2114859155022389342 came out shifted about 100 px: its left edge cut off, X's menu laid over its words and the gap beside the column showing; another post once came out as a strip of the post above it. The shot was a full-page capture, which resizes the page for the moment of the capture — in the X session profile the page saw its window go to 1×1 — and X laid itself out again for that size while it was being captured, so the shot was cut from a different layout than the one measured. A post is now shot from the window as it stands: scrolled into it, the window made taller first when the post is taller than it, so nothing is resized under the shot; and the post is measured again after the shot and shot again if it moved. An X Article's shot is taken the same way. Posts taller than the tallest window (16,384 px) are still shot from a full-page capture. Needs a restart of the editor.
- **Use with AI is the homepage's.** A published site's header and slide-out menu no longer carry it (nor the hub's header); a site still reaches the homepage's AI and MCP doc from its footer and from Ask AI, and its corpus.json and llms.txt still name it. Rebuild a site to see it.
- **The site-swap intro no longer shifts vertically on the chime.** With the URLs under MEDIA the drawing used to rise to stay centred; the lockup is now centred as the plain intro centres it and the URLs hang below it, so on the chime it only moves sideways. Intros without a site swap are unchanged.
- **Record live works on YouTube.** On 2026-10-26 `pnpm ops record-live` on a live YouTube stream failed at once with "Requested format is not available" and recorded nothing, though the stream's first 33 minutes were there to record. The recorder asked for one stream holding both video and audio, which Rumble and Kick have and YouTube's from-the-start recording does not: it offers the video and the audio separately. On YouTube a recording now takes the video at the chosen height (720p by default, the tallest with `"maxHeight": null`) plus the best audio, and joins them when the stream ends. `"separate": true` or `false` chooses for any stream, and the Record live form has a **Streams** choice. Stopping a recording (`job cancel`), or a crash, before the two were joined no longer loses it: the video and audio left behind are joined without re-encoding and land as one mp4 with sound, and a pair an earlier run left is landed by the next one. Rumble and Kick record exactly as before. A stream recorded as one stream that turns out to have none says to try `"separate": true`. Needs a restart of the editor.