commit 7bcc59f6eeb87d5805fc81954c51b276ad5002ae
parent 2ccab81462ef02cc1e0e515d819c5587005ba13c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sun, 25 Oct 2026 00:55:56 -0400
umtool e2e flakes: the play engine says when a frame is painted; drafts come with their provenance
Play the cut: the engine sets data-play-drawn="<itemId>:<media second>" on the
footage canvas once a frame is actually drawn, and play-cut's "note at the
playhead" waits on it (c04) before reading the pixels, instead of polling them
for 15 s while the decode is still behind under load.
The Media tab: /api/report/drafts returns every field's provenance beside its
rows, and the tab (and the review bench) prefer it to the page's, so a row
re-read after a draft carries its draft file at once rather than after the
router refresh (media-surfaces' "cut-draft.json" race).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 56 insertions(+), 17 deletions(-)
diff --git a/umtool/app/api/report/drafts/route.ts b/umtool/app/api/report/drafts/route.ts
@@ -2,6 +2,7 @@ import { invalidateProjects } from "@/lib/projects";
import { withEditNotes } from "@/lib/report/guard";
import { StaleToken, StructureRefused, manifestToken, writeDraftedField } from "@/lib/report/manifest.mjs";
import { alternativeById, draftsView } from "@/lib/report/drafts.mjs";
+import { readFieldProvenance } from "@/lib/report/draft-provenance.mjs";
import { currentFieldValue, valueFromEdit } from "@/lib/report/draftEdit.mjs";
import { readManifest } from "@/lib/projects/report.mjs";
import { resolveReport } from "@/lib/report/serve.mjs";
@@ -30,6 +31,11 @@ export const dynamic = "force-dynamic";
//
// Verdicts live in <project>/drafts.review.json (report-to-video's
// drafts-review.mjs); a final build refuses a drafted field not approved.
+//
+// Every answer carries `provenance` (lib/report/draft-provenance.mjs) beside
+// the rows: a field's draft file, its attempts and the rules they broke. A
+// Media tab that re-reads its rows after a draft then has the whole row at
+// once, instead of a row now and its provenance after the page refreshes.
type Body = Record<string, unknown>;
const noStore = { "cache-control": "no-store" };
@@ -38,7 +44,12 @@ export async function GET(request: Request) {
const url = new URL(request.url);
const r = await resolveReport(url.searchParams.get("project") ?? "");
if ("error" in r) return Response.json({ error: r.error }, { status: r.status });
- return Response.json({ ...(await draftsView(r.project.dir, r.manifest)), token: await manifestToken(r.project.dir) }, { headers: noStore });
+ const [view, provenance, token] = await Promise.all([
+ draftsView(r.project.dir, r.manifest),
+ readFieldProvenance(r.project.dir, r.manifest),
+ manifestToken(r.project.dir),
+ ]);
+ return Response.json({ ...view, provenance, token }, { headers: noStore });
}
export async function POST(request: Request) {
@@ -102,5 +113,6 @@ export async function POST(request: Request) {
}
const fresh = await resolveReport(String(body.project));
const manifest = "error" in fresh ? r.manifest : fresh.manifest;
- return Response.json({ ok: true, ...(await draftsView(dir, manifest)), token: await manifestToken(dir), editNotes }, { headers: noStore });
+ const [view, provenance, token] = await Promise.all([draftsView(dir, manifest), readFieldProvenance(dir, manifest), manifestToken(dir)]);
+ return Response.json({ ok: true, ...view, provenance, token, editNotes }, { headers: noStore });
}
diff --git a/umtool/components/projects/MediaDrafts.tsx b/umtool/components/projects/MediaDrafts.tsx
@@ -17,7 +17,7 @@ import { citationText } from "@/lib/research/facets.mjs";
import type { DraftRowView, DraftRunSummary, ProjectIteration } from "@/lib/articles/projectDraft";
import { awaitingReview } from "@/lib/inbox/drafts.mjs";
import { DraftControl, modelsFor, usePolicy } from "./DraftPanel";
-import { DraftAlternatives, announceDraftsChanged, useDrafts, type DraftAct, type DraftRow, type DraftsView } from "./drafts";
+import { DraftAlternatives, announceDraftsChanged, useDrafts, type DraftAct, type DraftRow, type DraftsView, type FieldProvenance } from "./drafts";
import { announceManifestChanged } from "./timelineApi";
import { BenchBody, VerdictBar } from "./bench/BenchShell";
import CopyCitation from "./bench/CopyCitation";
@@ -38,16 +38,8 @@ import CopyCitation from "./bench/CopyCitation";
// first). Signal is the lit field's Approve draft only.
// ---------------------------------------------------------------------------
-export type FieldProvenance = {
- file: string;
- model: string | null;
- at: string | null;
- attempts: number;
- chosen: number | null;
- repaired: boolean;
- failed: { attempt: number; hard: string[] }[];
- soft: string[];
-};
+// Where a drafted field came from: declared beside the drafts view, which carries it from the route.
+export type { FieldProvenance } from "./drafts";
/** The sections, in Draft everything's order: a field's address starts with its section's task. */
export const MEDIA_SECTIONS: { task: string; label: string }[] = [
@@ -416,7 +408,7 @@ export function ApproveAll({ view, act, provenance }: { view: DraftsView; act: D
export default function MediaDrafts({
project,
initial,
- provenance,
+ provenance: pageProvenance,
link,
rows,
runs: initialRuns,
@@ -434,6 +426,8 @@ export default function MediaDrafts({
const router = useRouter();
const drafts = useDrafts(project, initial);
const view = drafts.view ?? initial;
+ // The route's, re-read with the rows; the page's until the first re-read.
+ const provenance = view.provenance ?? pageProvenance;
const linked = link.ok && link.status === "done";
const { policy, error: policyError } = usePolicy(linked);
const [runs, setRuns] = useState(initialRuns);
@@ -610,7 +604,7 @@ export type FieldEvidence = {
export function MediaReview({
project,
initial,
- provenance,
+ provenance: pageProvenance,
evidence,
deckHref,
}: {
@@ -623,6 +617,7 @@ export function MediaReview({
}) {
const drafts = useDrafts(project, initial);
const view = drafts.view ?? initial;
+ const provenance = view.provenance ?? pageProvenance;
const [lit, setLit] = useState<string | null>(null);
const hydrated = useHydrated();
const row = view.rows.find((r) => r.address === lit) ?? null;
diff --git a/umtool/components/projects/drafts.tsx b/umtool/components/projects/drafts.tsx
@@ -42,6 +42,18 @@ export type DraftAlternative = {
reason: string;
inUse: boolean;
};
+/** Where a drafted field came from (lib/report/draft-provenance.mjs): its draft file, the attempts, the rules broken. */
+export type FieldProvenance = {
+ file: string;
+ model: string | null;
+ at: string | null;
+ attempts: number;
+ chosen: number | null;
+ repaired: boolean;
+ failed: { attempt: number; hard: string[] }[];
+ soft: string[];
+};
+
export type DraftsView = {
file: string;
exists: boolean;
@@ -52,6 +64,12 @@ export type DraftsView = {
drafted: number;
gate: { errors: string[]; warnings: string[] };
token?: string | null;
+ /**
+ * Every drafted field's provenance, by address, as /api/report/drafts reads it beside the rows -- so a row
+ * re-read after a draft is complete on first paint, with no wait on the page's own refresh.
+ * Absent on a view the page rendered (the page passes its own).
+ */
+ provenance?: Record<string, FieldProvenance>;
};
export const DRAFTS_CHANGED = "umtool:drafts-changed";
diff --git a/umtool/components/projects/review/playEngine/engine.ts b/umtool/components/projects/review/playEngine/engine.ts
@@ -624,12 +624,15 @@ export class PlayEngine {
if (!el) return;
const items = this.plan.items;
const out: FootageLayer[] = [];
+ // Which clip's frame each drawn layer is, and its media second: what data-play-drawn says.
+ const drawn: { i: number; mediaTime: number }[] = [];
let missing = false;
for (const l of layers) {
if (!l.source || !(l.w > 0)) {
missing = true;
continue;
}
+ drawn.push({ i: l.i, mediaTime: l.source instanceof HTMLVideoElement ? l.source.currentTime : (l.source as VideoFrame).timestamp / 1e6 });
const it = items[l.i];
const e = this.entries.get(it.id);
const src = sourceAt(it, t);
@@ -648,6 +651,11 @@ export class PlayEngine {
el.dataset.playLayers = String(out.length);
drawFootageLayers(el, out, this.bg);
this.shown = out.length > 0;
+ // A frame is ON the canvas now: "<itemId>:<media second>" of the current clip's layer (else the first drawn),
+ // set only after it is painted, so a reader (the e2e) can wait for the picture rather than poll its pixels.
+ const mine = drawn.find((d) => d.i === this.cur) ?? drawn[0];
+ if (mine) el.dataset.playDrawn = `${items[mine.i]?.id}:${mine.mediaTime.toFixed(3)}`;
+ else delete el.dataset.playDrawn;
}
private publish() {
diff --git a/umtool/e2e/play-cut.spec.ts b/umtool/e2e/play-cut.spec.ts
@@ -136,14 +136,20 @@ test("a note at the playhead: its kind, the cut second, the clip and its source
await expect(page.locator("[data-play-note-add]")).toHaveText("Note at 00:08.0");
// Paused, the clip's frame is in the picture (the fixture's window is dark green), not a black box --
// half of it: c04's first shown second is the middle of its crossfade from c03 (no media: the ground).
+ // The engine says when c04's frame is painted (data-play-drawn, set after the draw): under load its
+ // decode can take a while, so the wait is on that, and the pixels are read once it is there.
+ const footage = page.locator("[data-play-footage]");
+ // (A short poll after it only covers a canvas resized between the paint and the read, which clears it
+ // until the next frame redraws.)
+ await expect(footage).toHaveAttribute("data-play-drawn", /^c04:/, { timeout: 30_000 });
await expect
.poll(
() =>
- page.locator("[data-play-footage]").evaluate((c: HTMLCanvasElement) => {
+ footage.evaluate((c: HTMLCanvasElement) => {
const [r, g, b] = c.getContext("2d")!.getImageData(Math.floor(c.width / 2), Math.floor(c.height / 2), 1, 1).data;
return g > 35 && g > r + 20 && g > b + 20;
}),
- { timeout: 15_000 },
+ { timeout: 2_000 },
)
.toBe(true);
await page.keyboard.press("m");