AI media harness for planning, generating, and editing locally
TypeScript
Keep Video playback continuous across scene joins and updates
Bitti2d9dba3e2c9a
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex ef3c75d..849683f 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -23,6 +23,7 @@ Changes since 0.3.2.## Fixes and improvements- Video cards match Shot sizing, show the opening playback frame and open scenes on click; playback shares Timeline's prepared players. Returning to the Video tab restores the open video.+- Video card and popout playback preserve full rendered scene ranges and keep decoders running through background updates.- Application Back returns from scenes to Video and from image versions to their parent bar.- Editing generated music creates a separate draft; cards distinguish drafts from playable songs.- Single Shot uses previous latents only as its starting anchor, fresh noise for the middle and a generated ending anchor, avoiding repeated source imagery.diff --git a/src/components/workspace/VideoLibraryView.test.tsx b/src/components/workspace/VideoLibraryView.test.tsxindex 3f66d9f..eeaffe1 100644--- a/src/components/workspace/VideoLibraryView.test.tsx+++ b/src/components/workspace/VideoLibraryView.test.tsx@@ -104,7 +104,7 @@ it("removes folders without deleting their videos and removes video scenes withoawait waitFor(() => expect(view.config().videos).toHaveLength(0)); expect(view.config().generationJobs).toHaveLength(0); expect(view.config().timeline).toEqual(config.timeline);});-it("prepares later clips before playback, retains decoders across cuts, replays and closes the popout", async () => {+it.each([false, true])("keeps decoders through project updates and cuts, and replays (popout: %s)", async (popout) => {(window as unknown as Record<string, unknown>).__TAURI_INTERNALS__ = {};vi.spyOn(PreviewSources.prototype, "url").mockImplementation(async (asset) => 'blob:' + asset.relativePath);const ready = vi.spyOn(HTMLMediaElement.prototype, "readyState", "get").mockReturnValue(0);@@ -118,18 +118,30 @@ it("prepares later clips before playback, retains decoders across cuts, replaysconfig.assets = config.generationJobs.map((job, index) => ({ id: generationAssetId(job.id), kind: "generated", name: job.id, relativePath: 'media/' + job.id + '.mp4', mimeType: "video/mp4", createdAt: config.createdAt, durationMs: 10000,sceneSegments: [{ sceneId: job.id, startFrame: index * 96, frameCount: 96, latentRelativePath: 'latents/' + job.id + '.safetensors' }] }));const video = { ...newVideo(null), title: "Film", sceneIds: ["a", "b"] }, close = vi.fn();- const view = render(<VideoPlayback video={video} config={config} folderPath="D:/Project" popout onClose={close} />);+ const view = render(<VideoPlayback video={video} config={config} folderPath="D:/Project" popout={popout} onClose={close} />);await waitFor(() => expect(view.container.querySelectorAll("video")).toHaveLength(2));const incoming = view.container.querySelector<HTMLVideoElement>('[data-clip-id="video-preview-b"] video')!;await tick(5000); expect(view.container.querySelector('.video-card__position')).toHaveTextContent('1 / 2');ready.mockReturnValue(4); fireEvent.loadedData(incoming); expect(incoming.currentTime).toBe(4);- await tick(16); await tick(3001);+ const outgoing = view.container.querySelector<HTMLVideoElement>('[data-clip-id="video-preview-a"] video')!;+ vi.mocked(HTMLMediaElement.prototype.load).mockClear();+ const updated = { ...config, generationJobs: config.generationJobs.map((job) => ({ ...job, progress: 0.5 })),+ assets: config.assets.map((asset) => ({ ...asset, relativePath: 'media/regenerated.mp4' })) };+ view.rerender(<VideoPlayback video={{ ...video }} config={updated} folderPath="D:/Project" popout={popout} onClose={close} />);+ await act(async () => undefined);+ expect(view.container.querySelector('[data-clip-id="video-preview-a"] video')).toBe(outgoing);+ expect(view.container.querySelector('[data-clip-id="video-preview-b"] video')).toBe(incoming);+ expect(outgoing).toHaveAttribute('src', 'blob:media/a.mp4');+ expect(HTMLMediaElement.prototype.load).not.toHaveBeenCalled();+ await tick(16); await tick(4001);expect(view.container.querySelector('[data-clip-id="video-preview-b"] video')).toBe(incoming);expect(view.container.querySelector('.video-card__position')).toHaveTextContent('2 / 2');- await tick(3100); fireEvent.click(screen.getByRole("button", { name: "Replay Film" }));+ await tick(4100); fireEvent.click(screen.getByRole("button", { name: "Replay Film" }));expect(view.container.querySelector('.video-card__position')).toHaveTextContent('1 / 2');- fireEvent.pointerDown(screen.getByRole("dialog")); expect(close).not.toHaveBeenCalled();- fireEvent.pointerDown(view.container.querySelector(".shot-popout")!); expect(close).toHaveBeenCalledTimes(1);+ if (popout) {+ fireEvent.pointerDown(screen.getByRole("dialog")); expect(close).not.toHaveBeenCalled();+ fireEvent.pointerDown(view.container.querySelector(".shot-popout")!); expect(close).toHaveBeenCalledTimes(1);+ }view.unmount(); expect(incoming.pause).toHaveBeenCalled(); expect(incoming).not.toHaveAttribute('src');});diff --git a/src/components/workspace/VideoPlayback.tsx b/src/components/workspace/VideoPlayback.tsxindex 12c3529..f6bfa0e 100644--- a/src/components/workspace/VideoPlayback.tsx+++ b/src/components/workspace/VideoPlayback.tsx@@ -1,4 +1,4 @@-import { useEffect, useMemo, useRef, useState, type CSSProperties } from "react";+import { useEffect, useRef, useState, type CSSProperties } from "react";import type { ProjectConfig, ProjectVideo } from "../../lib/project";import { outputDimensions } from "../../lib/export";import { videoPlaybackConfig, videoPlaylist } from "../../lib/videoPlayback";@@ -10,14 +10,15 @@ export { videoPlaylist } from "../../lib/videoPlayback";export function VideoPlayback({ video: item, config, folderPath, popout, onClose }: {video: ProjectVideo; config: ProjectConfig; folderPath: string; popout: boolean; onClose: () => void;}) {- const preview = useMemo(() => videoPlaybackConfig(item, config), [item, config]);- const playlist = useMemo(() => videoPlaylist(item, config), [item, config]);+ // Play the takes opened by the user. Progress updates and completed renders+ // must not recreate media objects, unload decoders or replace a playing file.+ const [{ preview, playlist }] = useState(() => ({ preview: videoPlaybackConfig(item, config), playlist: videoPlaylist(item, config) }));const [playhead, setPlayhead] = useState(0), [playing, setPlaying] = useState(true);const frame = useRef<HTMLDivElement>(null), close = useRef(onClose); close.current = onClose;const duration = preview.timeline.tracks[0].clips.reduce((end, clip) => Math.max(end, clip.startMs + clip.durationMs), 0);const index = Math.max(0, playlist.findIndex((clip) => playhead < clip.startMs + clip.durationMs));const current = playlist[playhead >= duration ? playlist.length - 1 : index];- const dimensions = outputDimensions(config.settings.resolution, config.settings.aspectRatio);+ const dimensions = outputDimensions(preview.settings.resolution, preview.settings.aspectRatio);useEffect(() => {const focused = document.activeElement as HTMLElement | null;const library = popout ? frame.current?.closest(".video-library-stage")?.querySelector<HTMLElement>(".music-library") : null;diff --git a/src/lib/videoLibrary.test.ts b/src/lib/videoLibrary.test.tsindex a64510f..311f717 100644--- a/src/lib/videoLibrary.test.ts+++ b/src/lib/videoLibrary.test.ts@@ -92,18 +92,21 @@ it("plays scenes in video order, skips drafts and excludes joined continuation pconst config = project(); config.generationJobs = [scene("first"), scene("draft"), scene("last", 8)];const video = { ...newVideo(null), sceneIds: ["last", "draft", "first"] };config.assets = [asset(generationAssetId("first"), "generated", 10250), { ...asset(generationAssetId("last"), "generated", 19000), sceneSegments: [{ sceneId: "last", startFrame: 240, frameCount: 216, latentRelativePath: "latents/last.safetensors" }] }];- expect(videoPlaylist(video, config).map(({ sceneId, start, end }) => ({ sceneId, start, end }))).toEqual([{ sceneId: "last", start: 10, end: 18 }, { sceneId: "first", start: 0, end: 10 }]);+ expect(videoPlaylist(video, config).map(({ sceneId, start, end }) => ({ sceneId, start, end }))).toEqual([{ sceneId: "last", start: 10, end: 19 }, { sceneId: "first", start: 0, end: 10.25 }]);});it("uses the latest joined decode for both the opening poster and uninterrupted playback across scene boundaries", () => {const config = project();- const segments = ["a", "b"].map((sceneId, index) => ({ sceneId, startFrame: index * 120, frameCount: 120, latentRelativePath: `latents/${sceneId}.safetensors` }));+ const segments = ["a", "b"].map((sceneId, index) => ({ sceneId, startFrame: index * 124, frameCount: 124, latentRelativePath: `latents/${sceneId}.safetensors` }));config.generationJobs = segments.map((part) => ({ ...scene(part.sceneId, 5), latentRelativePath: part.latentRelativePath }));config.assets = segments.map((part, index) => ({ ...asset(generationAssetId(part.sceneId), "generated", (index + 1) * 5000), sceneSegments: segments.slice(0, index + 1) }));const video = { ...newVideo(null), sceneIds: ["a", "b"] }, original = structuredClone(config);const playlist = videoPlaylist(video, config);expect(playlist.map((entry) => entry.asset.id)).toEqual([generationAssetId("b"), generationAssetId("b")]);- expect(playlist.map((entry) => [entry.start, entry.end])).toEqual([[0, 5], [5, 10]]);+ expect(playlist.map((entry) => entry.durationMs)).toEqual([5167, 5167]);+ expect(playlist[0].start).toBe(0);+ expect(playlist[1].start).toBeCloseTo(124 / 24);+ expect(playlist[0].end).toBeCloseTo(playlist[1].start, 3);const preview = videoPlaybackConfig(video, config), tracks = continuationPlaybackTracks(preview);const keys = previewPlayerKeys(tracks, new Map(preview.assets.map((asset) => [asset.id, asset])));expect(keys.get("video-preview-a")).toBe(keys.get("video-preview-b"));diff --git a/src/lib/videoPlayback.ts b/src/lib/videoPlayback.tsindex 8fd0d2a..2fbd5db 100644--- a/src/lib/videoPlayback.ts+++ b/src/lib/videoPlayback.ts@@ -14,7 +14,9 @@ export function videoPlaybackConfig(video: ProjectVideo, config: ProjectConfig):if (!selected?.relativePath) continue;const asset = { ...selected, id: generationAssetId(scene.id) };assets.set(asset.id, asset);- const durationMs = Math.round(Math.min(sceneDurationSeconds(scene) * 1000, sceneMediaDurationMs(asset) ?? Infinity));+ // Generated lengths are frame-aligned and can exceed the requested length.+ // Keep every rendered frame so joined scenes share one uninterrupted decoder.+ const durationMs = Math.round(sceneMediaDurationMs(asset) ?? sceneDurationSeconds(scene) * 1000);if (durationMs <= 0) continue;clips.push({ id: `video-preview-${scene.id}`, assetId: asset.id, trackId: "video-preview", startMs, durationMs,sourceStartMs: 0, label: scene.title, status: "generated" });