AI media harness for planning, generating, and editing locally
TypeScript
Wait for decoded thumbnail frames before capture
Bitti05de90b2ca4a
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex acedf8a..844b10f 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -22,6 +22,7 @@ Changes since 0.3.2.## Fixes and improvements+- Video cards match Shot sizing, show the opening playback frame and open scenes on click; card/popout playback shares Timeline's prepared players and continuous display.- Editing generated music creates a separate draft; cards distinguish drafts from playable songs.- Single Shot initializes both passes from the previous clip's final latents, with a Continuation control defaulting to 30% for appearance guidance.- Updated First/Last Frame Fast to the eight-step FastH3 Omni model and corrected Omni and First/Last Frame weight fallbacks.diff --git a/src/components/workspace/ShotThumbnail.test.tsx b/src/components/workspace/ShotThumbnail.test.tsxindex e14575d..4cd6c72 100644--- a/src/components/workspace/ShotThumbnail.test.tsx+++ b/src/components/workspace/ShotThumbnail.test.tsx@@ -3,7 +3,7 @@import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";import { createProjectConfig, parseProjectConfig, sceneShots, type GenerationJob } from "../../lib/project";-import { ShotThumbnail } from "./ShotThumbnail";+import { ShotThumbnail, shotPoster } from "./ShotThumbnail";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));@@ -100,6 +100,25 @@ const rendered = (folder: string): GenerationJob => {};describe("a shot's picture", () => {+ it("waits for the first presented frame before drawing the thumbnail", async () => {+ const prototype = HTMLVideoElement.prototype;+ const originalRequest = prototype.requestVideoFrameCallback, originalCancel = prototype.cancelVideoFrameCallback;+ let present: VideoFrameRequestCallback | undefined;+ prototype.requestVideoFrameCallback = (callback) => { present = callback; return 1; };+ prototype.cancelVideoFrameCallback = vi.fn();+ try {+ await withFakeFile({ seconds: 10 }, async seen => {+ const pending = shotPoster("C:/Presented first frame", "media/first.mp4", 0);+ await waitFor(() => expect(present).toBeTypeOf("function"));+ expect(seen.posters()).toHaveLength(0);+ present!(0, {} as VideoFrameCallbackMetadata);+ expect((await pending).poster).toContain("frame-0");+ expect(seen.posters()).toHaveLength(1);+ });+ } finally {+ prototype.requestVideoFrameCallback = originalRequest; prototype.cancelVideoFrameCallback = originalCancel;+ }+ });it("pops a shot into the board, respects its source offset and cut, and replays without reopening the file", async () => {const folder = "C:\\Popout shot replay", job = rendered(folder);await withFakeFile({ seconds: 20 }, async seen => {diff --git a/src/components/workspace/ShotThumbnail.tsx b/src/components/workspace/ShotThumbnail.tsxindex f1f1ab1..7f8fff2 100644--- a/src/components/workspace/ShotThumbnail.tsx+++ b/src/components/workspace/ShotThumbnail.tsx@@ -131,9 +131,24 @@ function abandon(file: string, result: PosterResult) {queue?.forEach((waiting) => waiting.settle(result));}+/** loadeddata can precede a drawable frame in Chromium. Subscribe before loading+ * or seeking so a paused video presents its exact opening/cut frame first. */+function presentedFrame(video: HTMLVideoElement) {+ let finish = () => {};+ const ready = new Promise<void>((resolve) => {+ if (typeof video.requestVideoFrameCallback !== "function") { resolve(); return; }+ let callback = 0;+ const timer = window.setTimeout(() => finish(), SEEK_LIMIT_MS);+ finish = () => { window.clearTimeout(timer); video.cancelVideoFrameCallback(callback); resolve(); };+ callback = video.requestVideoFrameCallback(() => finish());+ });+ return { ready, cancel: () => finish() };+}+async function drain(folderPath: string, relativePath: string, file: string): Promise<void> {const video = document.createElement("video");let url: string | null = null;+ let presentation: ReturnType<typeof presentedFrame> | undefined;try {url = await readMediaFileUrl(folderPath, { relativePath }, "video/mp4");// Browser preview: there is no project folder, so there is nothing to show@@ -146,8 +161,10 @@ async function drain(folderPath: string, relativePath: string, file: string): Prvideo.muted = true;video.preload = "auto";video.playsInline = true;+ presentation = presentedFrame(video);video.src = url;await settled(video, "loadeddata");+ await presentation.ready;/* Drained rather than iterated: a card that mounts while the file is openjoins this same pass instead of opening it a second time. */for (;;) {@@ -165,10 +182,12 @@ async function drain(folderPath: string, relativePath: string, file: string): Prconst target = Math.min(Math.max(next.seconds, 0), end);if (Math.abs(video.currentTime - target) > 0.01) {const seek = settled(video, "seeked");+ presentation = presentedFrame(video);video.currentTime = target;// A seek that fails costs this frame its offset and nothing else —// whatever the decoder is holding is still a frame of this scene.await orGiveUp(seek, SEEK_LIMIT_MS);+ await presentation.ready;}const poster = tryDraw(video);if (poster) {@@ -182,6 +201,7 @@ async function drain(folderPath: string, relativePath: string, file: string): PrUNREADABLE.add(file);abandon(file, BROKEN);} finally {+ presentation?.cancel();release(video);if (url) URL.revokeObjectURL(url);OPEN.delete(file);