commit db0a620f98c66bb552718bb8be8ea21fa775d22e
parent 4cbd4dd17959f7858303f53c529c3183aa5bab92
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 26 Oct 2026 22:59:54 -0400
report-to-video: the posts feed's frames reused by their keys too
The feed plans its cues in the page from its cards' measured heights, so
its frames are keyed by its events instead: the page less its times, and
how many cue-grid steps ago each post came in and the column moved --
the plan is a function of exactly those (feedCues now puts every time on
the grid first). Refused when the plan, run here at both extremes of card
height, has a cue running past FEED_EVENT_CAP after its event.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 118 insertions(+), 9 deletions(-)
diff --git a/umtool/report-to-video/chrome-feed.mjs b/umtool/report-to-video/chrome-feed.mjs
@@ -33,7 +33,7 @@
// fixed name (`embedFn`, docs/quirks.md); the tests call the same function
// with heights of their choosing. Every cue is a fromTo whose FROM is stated:
// a render is a seek per frame, from parallel workers, in any order.
-import { deckChoreography, feedGeometry, pageDuration, resolveDeck } from "./deck.mjs";
+import { CUE_GRID, deckChoreography, feedGeometry, pageDuration, resolveDeck } from "./deck.mjs";
import { mix, rgba } from "./chrome-deck.mjs";
import { embedFn, PLATFORM_LABEL, postDate, postParagraphs, postWho } from "./chrome-posts.mjs";
@@ -115,9 +115,14 @@ export function feedLayout(render) {
export function feedCues({
posts, heights, column, visibility = [], startsHidden = false, slideX = 600, enterX = 600,
gap = 16, push = 0.4, lag = 0.22, enter = 0.6, glowAt = 0.2, glowUp = 0.2, glowDown = 1.2, newest = 0.55,
- calm = 0.8, leave = 0.45,
+ calm = 0.8, leave = 0.45, grid = 0,
}) {
const R = (v) => Math.round(v * 10000) / 10000;
+ // `grid` (steps a second, deck.mjs CUE_GRID × fps): every time on it, the
+ // posts' and the column's own first -- so a cut moved by whole frames moves
+ // every cue by whole steps (frame-keys.mjs). 0: four decimals, as it was.
+ const G = grid > 0 ? (v) => Math.round(v * grid) / grid : R;
+ const after = grid > 0 ? (v) => Math.ceil(v * grid - 1e-6) / grid : R;
const MIN = 0.001;
const n = posts.length;
const init = { col: { x: startsHidden ? slideX : 0 } };
@@ -127,12 +132,12 @@ export function feedCues({
}
const ev = [];
- const add = (k, at, dur, to, ease, why) => ev.push({ k, at: R(at), dur: R(Math.max(MIN, dur)), to, ease, why });
+ const add = (k, at, dur, to, ease, why) => ev.push({ k, at: G(at), dur: R(Math.max(MIN, dur)), to, ease, why });
const y = new Array(n).fill(0);
const visible = [];
const gone = new Array(n).fill(null);
for (let m = 0; m < n; m += 1) {
- const t = posts[m].in;
+ const t = G(posts[m].in);
const id = posts[m].id;
const room = (heights[m] || 0) + gap;
// Room at the top: every card in moves down by the new one's height, and
@@ -158,7 +163,8 @@ export function feedCues({
}
for (const v of visibility) {
if (v.at[1] - v.at[0] <= 0 && v.i === 0) continue; // hidden from the first frame: that is init
- add("col", v.at[0], v.at[1] - v.at[0], { x: v.hide ? slideX : 0 }, v.hide ? "power2.in" : "power3.out",
+ const a0 = G(v.at[0]);
+ add("col", a0, G(v.at[1]) - a0, { x: v.hide ? slideX : 0 }, v.hide ? "power2.in" : "power3.out",
`${v.hide ? "hide" : "show"} @${v.i}`);
}
@@ -175,14 +181,14 @@ export function feedCues({
const free = freeAt[e.k] ?? -Infinity;
if (at < free) {
const end = at + dur;
- at = R(free);
+ at = after(free);
dur = R(Math.max(MIN, end - at));
}
const cur = state[e.k] ?? (state[e.k] = {});
const from = {};
for (const q of Object.keys(e.to)) from[q] = cur[q];
Object.assign(cur, e.to);
- freeAt[e.k] = R(at + dur);
+ freeAt[e.k] = grid > 0 ? at + dur : R(at + dur);
cues.push({ k: e.k, at, dur, from, to: e.to, ease: e.ease, why: e.why, i: cues.length });
}
cues.sort((a, b) => a.at - b.at || a.i - b.i);
@@ -358,6 +364,8 @@ export function feedHtml(schedule, render, opts = {}) {
enterX: left ? -(lay.stack.width + lay.padX) : lay.stack.width + lay.padX,
visibility: vis.map((v) => ({ i: v.i, hide: v.hide, at: v.at.map(r4) })),
motion: FEED_MOTION,
+ // The cue grid (feedCues `grid`): steps a second.
+ grid: Number(schedule.fps ?? render.fps ?? 30) * CUE_GRID,
ids: posts.map((p) => p.id),
posts: posts.map((p) => ({ id: p.id, in: p.in })),
};
@@ -532,7 +540,7 @@ export function feedHtml(schedule, render, opts = {}) {
posts: F.posts, heights, column: F.column, visibility: F.visibility, startsHidden: F.startsHidden,
slideX: F.slideX, enterX: F.enterX, gap: M.gap, push: M.push, lag: M.lag, enter: M.enter,
glowAt: M.glowAt, glowUp: M.glowUp, glowDown: M.glowDown, newest: M.newest, calm: M.calm,
- leave: M.leave,
+ leave: M.leave, grid: F.grid,
});
for (const k of Object.keys(plan.init)) if (byK[k]) gsap.set(byK[k], plan.init[k]);
const inner = gsap.timeline({ paused: true });
diff --git a/umtool/report-to-video/frame-keys.mjs b/umtool/report-to-video/frame-keys.mjs
@@ -41,6 +41,7 @@ import { readFileSync } from "node:fs";
import vm from "node:vm";
import { GSAP_FILE } from "./chrome-deck.mjs";
+import { feedCues } from "./chrome-feed.mjs";
/** Bumped when what a frame key covers changes: every frame is captured once more. */
export const FRAME_KEY_VERSION = 1;
@@ -49,8 +50,18 @@ export const FRAME_KEY_VERSION = 1;
export const FRAME_KEY_REGIONS = Object.freeze({
deck: { data: "deck-data", omit: ["init", "cues", "window", "total", "ids"] },
stamp: { data: "stamp-data", omit: ["init", "cues", "window", "total", "ids"] },
+ // The feed plans its cues IN the page, from the heights its cards measure
+ // (chrome-feed.mjs): keyed by its EVENTS instead (feedFrameKeys).
+ feed: { data: "feed-data", omit: ["window", "total", "ids", "posts", "visibility"], events: true },
});
+/**
+ * How long after a feed event (a post in, the column hidden or shown) its
+ * cues can still run, at most: FEED_MOTION's longest chain is under two
+ * seconds. Checked per page (feedFrameKeys) against the plan itself.
+ */
+export const FEED_EVENT_CAP = 12;
+
let gsapEase = null;
/** GSAP's own ease, by name (the vendored file, in a sandbox, once). */
export function easeOf(name) {
@@ -107,7 +118,7 @@ export function staticKey({ html, region, assets = [], fps, version, frames = nu
// A window is refused -- but not the whole cut written as one (a total off
// the 4-decimal grid makes deckHtml "window" [0, r4(total)]: the identity).
if (data.window && !(data.window.from === 0 && frames != null && Math.abs(data.window.dur - frames / fps) < 1 / fps)) return null;
- if (!data.init || !Array.isArray(data.cues)) return null;
+ if (spec.events ? !(Array.isArray(data.posts) && Array.isArray(data.visibility) && data.grid > 0) : !data.init || !Array.isArray(data.cues)) return null;
// Every data-duration is the page's own (the root and its one clip).
const durs = [...html.matchAll(/data-duration="([^"]*)"/g)].map((m) => m[1]);
if (!durs.length || durs.some((d) => d !== durs[0])) return null;
@@ -132,6 +143,7 @@ const repr = (v) => (typeof v === "number" ? `n${gsapRound(v)}` : `s${JSON.strin
export function frameKeys({ html, region, assets = [], fps, frames, version }) {
const sk = staticKey({ html, region, assets, fps, version, frames });
if (!sk) return null;
+ if (FRAME_KEY_REGIONS[region].events) return feedFrameKeys({ html, sk, fps, frames });
const { data } = splitData(html, FRAME_KEY_REGIONS[region].data);
const init = data.init;
const cues = data.cues;
@@ -235,3 +247,63 @@ export function frameKeys({ html, region, assets = [], fps, frames, version }) {
}
return out;
}
+
+/**
+ * The feed's frame keys. Its cues are planned in the page from the heights
+ * its cards measure, so they are not in it; but every cue time is an event's
+ * time on the cue grid plus a FEED_MOTION constant (feedCues with `grid`),
+ * and the plan is a function of the page's static part (which fixes the
+ * heights) and those times. So a frame's key is the static part and, for
+ * each event, how many grid steps ago it was -- "not yet" when it is to
+ * come, "settled" once FEED_EVENT_CAP has passed. Refused (null) when the
+ * page's plan, run here with the shortest and the tallest cards, has a cue
+ * that runs past the cap after the event before it.
+ */
+function feedFrameKeys({ html, sk, fps, frames }) {
+ const { data } = splitData(html, FRAME_KEY_REGIONS.feed.data);
+ const g = Number(data.grid);
+ const per = g / fps;
+ if (!Number.isInteger(per) || per <= 0) return null;
+ const steps = (v) => Math.round(v * g);
+ const events = [];
+ data.posts.forEach((p, j) => {
+ if (!Number.isFinite(p?.in)) throw new Error(`frame keys: feed post ${j} has no time`);
+ events.push({ tag: `p${j}`, at: steps(p.in) });
+ });
+ data.visibility.forEach((v, j) => {
+ const [a0, a1] = v.at ?? [];
+ if (!Number.isFinite(a0) || !Number.isFinite(a1)) throw new Error(`frame keys: feed visibility ${j} has no times`);
+ const skipped = a1 - a0 <= 0 && v.i === 0;
+ events.push({ tag: `v${j}:${v.i}:${v.hide ? 1 : 0}:${steps(a1) - steps(a0)}:${skipped ? 1 : 0}`, at: steps(a0) });
+ });
+ const cap = FEED_EVENT_CAP * g;
+
+ // The cap, checked against the plan itself at both extremes of card height.
+ const M = data.motion ?? {};
+ const times = events.map((e) => e.at / g).sort((x, y) => x - y);
+ for (const h of [1, 1e6]) {
+ const plan = feedCues({
+ posts: data.posts, heights: data.posts.map(() => h), column: data.column, visibility: data.visibility,
+ startsHidden: data.startsHidden, slideX: data.slideX, enterX: data.enterX, gap: M.gap, push: M.push,
+ lag: M.lag, enter: M.enter, glowAt: M.glowAt, glowUp: M.glowUp, glowDown: M.glowDown, newest: M.newest,
+ calm: M.calm, leave: M.leave, grid: g,
+ });
+ for (const c of plan.cues) {
+ let last = -Infinity;
+ for (const t of times) if (t <= c.at + 1e-9) last = t;
+ if (!(c.at + c.dur - last < FEED_EVENT_CAP - 1)) return null;
+ }
+ }
+
+ const out = new Array(frames);
+ for (let f = 0; f < frames; f += 1) {
+ const t = f * per;
+ let sig = "";
+ for (const e of events) {
+ const d = t - e.at;
+ sig += `${e.tag}=${d < 0 ? "f" : d >= cap ? "s" : d};`;
+ }
+ out[f] = createHash("sha1").update(sk).update(sig).digest("hex");
+ }
+ return out;
+}
diff --git a/umtool/report-to-video/frame-keys.test.mjs b/umtool/report-to-video/frame-keys.test.mjs
@@ -206,3 +206,32 @@ test("stampHtml registers its timeline the one way the frame list replaces", ()
assert.equal(html.split('window.__timelines["stamp"] = tl;').length, 2);
assert.equal(deckHtml(schedule(0), RENDER, { fonts: FONTS }).split('window.__timelines["deck"] = tl;').length, 2);
});
+
+test("feed frame keys: by its events; a moved post keys as it did, a changed one where it shows", async () => {
+ const { feedHtml } = await import("./chrome-feed.mjs");
+ const { deckSchedule } = await import("./deck.mjs");
+ const FEED = { ...RENDER, chrome: { engine: "hyperframes", layout: "deck", deck: { posts: { layout: "feed" } } } };
+ const CLIPS = [
+ { id: "c1", type: "clip", video: "a", start: 0, end: 10, date: "2024-09-05" },
+ { id: "c2", type: "clip", video: "b", start: 0, end: 20, date: "2024-10-01" },
+ { id: "k1", type: "card", seconds: 4 },
+ { id: "c3", type: "clip", video: "c", start: 0, end: 6, date: "2025-12-08" },
+ ];
+ const POST = (id, date) => ({ id, platform: "bluesky", author: "P", handle: "p.live", date, text: `words of ${id}`, url: `https://bsky.app/profile/p.live/post/${id}` });
+ const POSTS = [POST("a", "2024-10-19"), POST("b", "2024-11-27"), POST("c", "2024-12-01"), POST("z", "2026-01-22")];
+ const keys = (durs) => {
+ const s = deckSchedule({ entries: CLIPS, durs, D: 0.5, render: FEED, provenance: { siteOrigin: "https://x.test", channelSlug: "c" }, posts: POSTS });
+ const html = feedHtml(s, FEED, { fonts: FONTS });
+ return { s, k: frameKeys({ html, region: "feed", fps: 30, frames: Math.round(s.total * 30), version: "v" }) };
+ };
+ const A = keys([10, 20, 4, 6]);
+ const B = keys([10 + 1 / 3, 20, 4, 6]);
+ assert.ok(A.k && B.k, "the feed is modelled");
+ const firstIn = A.s.posts?.[0]?.in ?? 9.5;
+ let same = 0, n = 0;
+ for (let f = Math.ceil((firstIn + 1) * 30); f < A.k.length; f += 1) { n += 1; if (B.k[f + 10] === A.k[f]) same += 1; }
+ assert.equal(same, n, "every moved frame keys as it did");
+ // The second clip 1 s longer: frames before its posts' times are the same, later ones moved.
+ const C = keys([10, 21, 4, 6]);
+ assert.equal(C.k[200], A.k[200]);
+});