Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): video conditioning media — keyframes, initial video, and trim
Lincoln Stein71f78518aa15
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex 37f9afb22e..286218ccb6 100644--- a/invokeai/frontend/webv2/performance/browser-baseline.json+++ b/invokeai/frontend/webv2/performance/browser-baseline.json@@ -25,13 +25,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 147,+ "domContentLoadedMedianMs": 165.69999980926514,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 147,- "longestTaskMaxMs": 74,+ "loadMedianMs": 165.7999997138977,+ "longestTaskMaxMs": 70,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -41,24 +41,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 37,"scriptRawBytes": 1620456,"scriptRequestCount": 33,- "totalRawBytes": 1789287+ "totalRawBytes": 1791284},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 37,"scriptRawBytes": 1636661,"scriptRequestCount": 33,- "totalRawBytes": 1807180+ "totalRawBytes": 1809197},- "routeReadyMedianMs": 310.3999996185303,+ "routeReadyMedianMs": 336.19999980926514,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -85,13 +85,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 152.40000009536743,+ "domContentLoadedMedianMs": 127.5,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 152.5,- "longestTaskMaxMs": 72,+ "loadMedianMs": 127.69999980926514,+ "longestTaskMaxMs": 76,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -101,24 +101,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 37,"scriptRawBytes": 1620456,"scriptRequestCount": 33,- "totalRawBytes": 1789287+ "totalRawBytes": 1791284},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 37,"scriptRawBytes": 1636661,"scriptRequestCount": 33,- "totalRawBytes": 1807180+ "totalRawBytes": 1809197},- "routeReadyMedianMs": 337.30000019073486,+ "routeReadyMedianMs": 309.19999980926514,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -145,15 +145,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 136,+ "domContentLoadedMedianMs": 135.90000009536743,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,"loadMedianMs": 136.09999990463257,- "longestTaskMaxMs": 101,+ "longestTaskMaxMs": 108,"owner": "workbench",- "projectSwitchMedianMs": 42.80000019073486,+ "projectSwitchMedianMs": 37.200000286102295,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -161,24 +161,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 114,- "scriptRawBytes": 3117993,+ "scriptRawBytes": 3119486,"scriptRequestCount": 109,- "totalRawBytes": 3443200+ "totalRawBytes": 3446690},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 114,- "scriptRawBytes": 3149173,+ "scriptRawBytes": 3150681,"scriptRequestCount": 109,- "totalRawBytes": 3477632+ "totalRawBytes": 3481157},- "routeReadyMedianMs": 697.5999999046326,+ "routeReadyMedianMs": 723.5999999046326,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -205,15 +205,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 146.5,+ "domContentLoadedMedianMs": 138.09999990463257,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 146.59999990463257,- "longestTaskMaxMs": 182,+ "loadMedianMs": 138.19999980926514,+ "longestTaskMaxMs": 193,"owner": "workbench",- "projectSwitchMedianMs": 57.80000019073486,+ "projectSwitchMedianMs": 60.09999990463257,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -221,24 +221,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 114,- "scriptRawBytes": 3117993,+ "scriptRawBytes": 3119486,"scriptRequestCount": 109,- "totalRawBytes": 3443200+ "totalRawBytes": 3446690},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 114,- "scriptRawBytes": 3149173,+ "scriptRawBytes": 3150681,"scriptRequestCount": 109,- "totalRawBytes": 3477632+ "totalRawBytes": 3481157},- "routeReadyMedianMs": 529.5,+ "routeReadyMedianMs": 551.0999999046326,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -265,13 +265,13 @@"scriptRequestCount": 6,"totalRawBytes": 291769},- "domContentLoadedMedianMs": 144.09999990463257,+ "domContentLoadedMedianMs": 132.7000002861023,"id": "editor-canvas",- "layoutAckMedianMs": 8.799999713897705,- "layoutReturnSwitchMedianMs": 34.09999990463257,- "layoutSwitchMedianMs": 75.09999990463257,- "loadMedianMs": 144.19999980926514,- "longestTaskMaxMs": 103,+ "layoutAckMedianMs": 10.599999904632568,+ "layoutReturnSwitchMedianMs": 36.700000286102295,+ "layoutSwitchMedianMs": 83.7000002861023,+ "loadMedianMs": 132.90000009536743,+ "longestTaskMaxMs": 102,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -281,24 +281,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 120,- "scriptRawBytes": 3406873,+ "scriptRawBytes": 3408366,"scriptRequestCount": 115,- "totalRawBytes": 3732080+ "totalRawBytes": 3735570},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 120,- "scriptRawBytes": 3440942,+ "scriptRawBytes": 3442450,"scriptRequestCount": 115,- "totalRawBytes": 3769401+ "totalRawBytes": 3772926},- "routeReadyMedianMs": 1155.3000001907349,+ "routeReadyMedianMs": 1160.7000002861023,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -325,13 +325,13 @@"scriptRequestCount": 6,"totalRawBytes": 291769},- "domContentLoadedMedianMs": 131.40000009536743,+ "domContentLoadedMedianMs": 129.40000009536743,"id": "editor-canvas",- "layoutAckMedianMs": 4.099999904632568,- "layoutReturnSwitchMedianMs": 32.90000009536743,- "layoutSwitchMedianMs": 192.5,- "loadMedianMs": 131.59999990463257,- "longestTaskMaxMs": 379,+ "layoutAckMedianMs": 3.3000001907348633,+ "layoutReturnSwitchMedianMs": 33.90000009536743,+ "layoutSwitchMedianMs": 189.5,+ "loadMedianMs": 129.60000038146973,+ "longestTaskMaxMs": 370,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -341,24 +341,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 120,- "scriptRawBytes": 3406873,+ "scriptRawBytes": 3408366,"scriptRequestCount": 115,- "totalRawBytes": 3732080+ "totalRawBytes": 3735570},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 120,- "scriptRawBytes": 3440942,+ "scriptRawBytes": 3442450,"scriptRequestCount": 115,- "totalRawBytes": 3769401+ "totalRawBytes": 3772926},- "routeReadyMedianMs": 1307,+ "routeReadyMedianMs": 1353,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -385,13 +385,13 @@"scriptRequestCount": 6,"totalRawBytes": 379966},- "domContentLoadedMedianMs": 140.80000019073486,+ "domContentLoadedMedianMs": 139.69999980926514,"id": "editor-workflow",- "layoutAckMedianMs": 9.599999904632568,- "layoutReturnSwitchMedianMs": 30.40000009536743,- "layoutSwitchMedianMs": 92.59999990463257,- "loadMedianMs": 141,- "longestTaskMaxMs": 99,+ "layoutAckMedianMs": 9.800000190734863,+ "layoutReturnSwitchMedianMs": 29.700000286102295,+ "layoutSwitchMedianMs": 99.2999997138977,+ "loadMedianMs": 139.89999961853027,+ "longestTaskMaxMs": 102,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -401,24 +401,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 121,- "scriptRawBytes": 3478783,+ "scriptRawBytes": 3480276,"scriptRequestCount": 115,- "totalRawBytes": 3819403+ "totalRawBytes": 3822893},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 121,- "scriptRawBytes": 3513571,+ "scriptRawBytes": 3515079,"scriptRequestCount": 115,- "totalRawBytes": 3857598+ "totalRawBytes": 3861122},- "routeReadyMedianMs": 1151.5,+ "routeReadyMedianMs": 1158.8000001907349,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "empty"},@@ -445,13 +445,13 @@"scriptRequestCount": 6,"totalRawBytes": 379966},- "domContentLoadedMedianMs": 149.09999990463257,+ "domContentLoadedMedianMs": 155.90000009536743,"id": "editor-workflow",- "layoutAckMedianMs": 3,- "layoutReturnSwitchMedianMs": 38.40000009536743,- "layoutSwitchMedianMs": 132.7000002861023,- "loadMedianMs": 149.19999980926514,- "longestTaskMaxMs": 372,+ "layoutAckMedianMs": 3.5,+ "layoutReturnSwitchMedianMs": 35.90000009536743,+ "layoutSwitchMedianMs": 137.2000002861023,+ "loadMedianMs": 156,+ "longestTaskMaxMs": 364,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -461,24 +461,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 121,- "scriptRawBytes": 3478783,+ "scriptRawBytes": 3480276,"scriptRequestCount": 115,- "totalRawBytes": 3819403+ "totalRawBytes": 3822893},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 121,- "scriptRawBytes": 3513571,+ "scriptRawBytes": 3515079,"scriptRequestCount": 115,- "totalRawBytes": 3857598+ "totalRawBytes": 3861122},- "routeReadyMedianMs": 1289.0999999046326,+ "routeReadyMedianMs": 1305.7000002861023,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "representative"},@@ -505,13 +505,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 141.80000019073486,+ "domContentLoadedMedianMs": 128.7000002861023,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 31.40000009536743,- "loadMedianMs": 141.90000009536743,- "longestTaskMaxMs": 109,+ "layoutSwitchMedianMs": 26.199999809265137,+ "loadMedianMs": 128.90000009536743,+ "longestTaskMaxMs": 106,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -521,24 +521,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 114,- "scriptRawBytes": 3117993,+ "scriptRawBytes": 3119486,"scriptRequestCount": 109,- "totalRawBytes": 3443200+ "totalRawBytes": 3446690},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 114,- "scriptRawBytes": 3149173,+ "scriptRawBytes": 3150681,"scriptRequestCount": 109,- "totalRawBytes": 3477632+ "totalRawBytes": 3481157},- "routeReadyMedianMs": 1390.9000000953674,+ "routeReadyMedianMs": 1342.9000000953674,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -565,13 +565,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 136.5,+ "domContentLoadedMedianMs": 128.89999961853027,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 100.59999990463257,- "loadMedianMs": 136.59999990463257,- "longestTaskMaxMs": 188,+ "layoutSwitchMedianMs": 94,+ "loadMedianMs": 129,+ "longestTaskMaxMs": 209,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -581,24 +581,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746569,- "otherRawBytes": 143008,+ "otherRawBytes": 145005,"requestCount": 114,- "scriptRawBytes": 3117993,+ "scriptRawBytes": 3119486,"scriptRequestCount": 109,- "totalRawBytes": 3443200+ "totalRawBytes": 3446690},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 754035,- "otherRawBytes": 144439,+ "otherRawBytes": 146456,"requestCount": 114,- "scriptRawBytes": 3149173,+ "scriptRawBytes": 3150681,"scriptRequestCount": 109,- "totalRawBytes": 3477632+ "totalRawBytes": 3481157},- "routeReadyMedianMs": 1589.0999999046326,+ "routeReadyMedianMs": 1563.6999998092651,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 05fc6a288e..fbe59436db 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3004,7 +3004,42 @@"shuffleSeed": "New random seed","steps": "Steps","swapAspectRatio": "Swap orientation",- "targetResolution": "Target Resolution"+ "targetResolution": "Target Resolution",+ "dimensionSource": {+ "aspect-ratio": "from the aspect-ratio preset",+ "first-frame": "from the first frame",+ "last-frame": "from the last frame",+ "source-video": "from the initial video"+ },+ "firstFrame": "First Frame",+ "firstFrameBlocked": "Clear the initial video to start from a frame instead.",+ "firstFrameHelp": "The video starts on this image.",+ "fpsExtendLocked": "The extension inherits the source clip's frame rate.",+ "initialFrames": "Initial Video Frames",+ "initialVideo": "Initial Video",+ "initialVideoBlocked": "Clear the first frame to extend a video instead.",+ "lastFrame": "Last Frame",+ "lastFrameExtendHelp": "Optional destination: the extension ends on this image.",+ "lastFrameHelp": "Optional: the video ends on this image (interpolates from the first frame).",+ "removeClip": "Remove video",+ "removeFrame": "Remove",+ "replaceClip": "Replace the initial video",+ "replaceFrame": "Replace the frame image",+ "trimEnd": "End Frame",+ "trimHelp": "The kept range of the source clip. The extension continues from the end frame.",+ "trimStart": "Start Frame",+ "unsupportedImageFile": "Please choose a PNG, JPEG, or WebP image.",+ "unsupportedVideoFile": "Please choose a video file.",+ "uploadClip": "Upload a video",+ "uploadFrame": "Upload a frame image",+ "uploadOrDropClip": "Upload or drop a video from the Gallery",+ "uploadOrDropFrame": "Upload or drop an image from the Gallery",+ "uploadingClip": "Uploading video…",+ "uploadingFrame": "Uploading image…",+ "clearStaleMedia": "Clear",+ "staleFirstFrame": "A first frame is set, but this model does not support starting from one.",+ "staleLastFrame": "A last frame is set, but this model does not support ending on one.",+ "staleSourceVideo": "An initial video is set, but this model does not support extending videos."}},"workflowLibrary": {diff --git a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsxindex 05702499a1..d865d804f3 100644--- a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx@@ -1,8 +1,10 @@import type { VideoUiAdapter } from '@features/video';import type { ReactNode } from 'react';+import { invalidateGallery } from '@features/gallery/queries';import { areProjectPromptDraftsEqual, getPromptDraftFromValues } from '@features/generation/settings';import { VideoUiProvider } from '@features/video';+import { useQueryClient } from '@tanstack/react-query';import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';import { getProjectWidgetValues } from '@workbench/widgetState';import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';@@ -35,6 +37,7 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>(preferences) => preferences.showPromptSyntaxHighlighting);const commands = useWorkbenchCommands();+ const queryClient = useQueryClient();// The port's callbacks are keyed to the project, not to its contents: rebuilding// them whenever `rawValues` changes would hand every consumer new function// identities on each keystroke, re-rendering memoized fields that did not change.@@ -51,6 +54,7 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>(message) => commands.notifications.reportError({ area: 'video', message, namespace: 'generation' }),[commands]);+ const touchGalleryImages = useCallback(() => void invalidateGallery(queryClient), [queryClient]);const adapter = useMemo<VideoUiAdapter>(() => ({...project,@@ -58,8 +62,9 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>patchValues,reportError,showPromptSyntaxHighlighting,+ touchGalleryImages,}),- [patchPromptDraft, patchValues, project, reportError, showPromptSyntaxHighlighting]+ [patchPromptDraft, patchValues, project, reportError, showPromptSyntaxHighlighting, touchGalleryImages]);return <VideoUiProvider adapter={adapter}>{children}</VideoUiProvider>;diff --git a/invokeai/frontend/webv2/src/features/video/core/graph.test.ts b/invokeai/frontend/webv2/src/features/video/core/graph.test.tsindex 3bead64aab..9b13d76e5b 100644--- a/invokeai/frontend/webv2/src/features/video/core/graph.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/graph.test.ts@@ -31,7 +31,7 @@ const WAN_T5 = { base: 'any', key: 'umt5', name: 'UMT5-XXL', type: 'wan_t5_encodconst FIRST_FRAME = { height: 1080, image_name: 'first.png', width: 1920 };const LAST_FRAME = { height: 1080, image_name: 'last.png', width: 1920 };const SOURCE_VIDEO = {- endFrame: -2,+ endFrame: 79,fps: 16,height: 480,numFrames: 81,@@ -225,6 +225,34 @@ describe('compileVideoGraph — Wan 2.2', () => {expect(() => compileVideoGraph(settings, model)).toThrow(/whole frame numbers/);});+ it('compiles ceiling-touching trim ends as negative indices (estimate-proof)', () => {+ const model = wanModel('i2v_a14b');+ // endFrame == numFrames - 2 (the default trim): compiled as -2 so the+ // backend resolves it against the clip's REAL frame count.+ const atDefault = compileVideoGraph(settingsFor(model, { sourceVideo: SOURCE_VIDEO }), model).backendGraph;++ expect(nodeOfType(atDefault, 'extract_video_range').end_frame).toBe(-2);++ // A mid-clip pick stays positive.+ const midClip = compileVideoGraph(+ settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: 40 } }),+ model+ ).backendGraph;++ expect(nodeOfType(midClip, 'extract_video_range').end_frame).toBe(40);+ });++ it('refuses a trim shorter than two frames', () => {+ const model = wanModel('i2v_a14b');++ expect(() =>+ compileVideoGraph(settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: 10, startFrame: 10 } }), model)+ ).toThrow(/at least two frames/);+ expect(() =>+ compileVideoGraph(settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: 500 } }), model)+ ).toThrow(/at least two frames/);+ });+it('extends toward a destination image via the FLF2V end-frame channel', () => {const model = wanModel('i2v_a14b');const settings = settingsFor(model, { lastFrameImage: LAST_FRAME, sourceVideo: SOURCE_VIDEO });@@ -348,7 +376,7 @@ describe('compileVideoGraph — MiniMax H3', () => {});it('builds the extend graph with the source resampled to 24 fps', () => {- const settings = settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: -1 } });+ const settings = settingsFor(model, { sourceVideo: { ...SOURCE_VIDEO, endFrame: 80 } });const { backendGraph } = compileVideoGraph(settings, model);// H3 renders at a fixed 24 fps; the source is retimed up front so thediff --git a/invokeai/frontend/webv2/src/features/video/core/graph.ts b/invokeai/frontend/webv2/src/features/video/core/graph.tsindex 6b0d48d246..c3f14a84a5 100644--- a/invokeai/frontend/webv2/src/features/video/core/graph.ts+++ b/invokeai/frontend/webv2/src/features/video/core/graph.ts@@ -73,8 +73,16 @@ const addExtendScaffolding = (newClip: BackendInvocationContract,options: { extractFps?: number } = {}) => {+ // The panel's frame count is an estimate (duration × fps; the records store+ // no exact count, and VFR uploads can overshoot by a frame or two). A trim+ // end near the estimated ceiling therefore compiles as a NEGATIVE index —+ // resolved by the backend against the clip's REAL count — so "keep to the+ // end" can never land past it. Mid-clip picks stay positive: a negative+ // offset computed from an overshooting estimate would drift them instead.+ const tailOffset = sourceVideo.numFrames - 1 - sourceVideo.endFrame;+ const endFrameLiteral = tailOffset <= 3 ? -(tailOffset + 1) : sourceVideo.endFrame;const extract = addNode(graph, {- end_frame: sourceVideo.endFrame,+ end_frame: endFrameLiteral,id: 'source_video',is_intermediate: true,start_frame: sourceVideo.startFrame,diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts b/invokeai/frontend/webv2/src/features/video/core/settings.test.tsindex 0b99d46ff7..ac118d77c0 100644--- a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts@@ -3,19 +3,22 @@ import { describe, expect, it } from 'vitest';import type { VideoSettings } from './types';import {+ clearDeletedVideoMedia,cloneVideoWidgetValues,+ createVideoSourceClip,isVideoSettings,isVideoSourceClip,normalizeVideoSettings,normalizeVideoWidgetValues,resolveVideoMode,+ VIDEO_SOURCE_FALLBACK_FPS,} from './settings';import { getDefaultVideoSettings } from './videoPolicies';const FIRST_FRAME = { height: 1080, image_name: 'first.png', width: 1920 };const LAST_FRAME = { height: 1080, image_name: 'last.png', width: 1920 };const SOURCE_VIDEO = {- endFrame: -2,+ endFrame: 79,fps: 16,height: 480,numFrames: 81,@@ -192,3 +195,64 @@ describe('normalizeVideoWidgetValues / cloneVideoWidgetValues', () => {expect(values.model?.key).toBe('wan-key');});});++describe('createVideoSourceClip', () => {+ it('estimates frames from duration and defaults the trim to drop the final frame', () => {+ const clip = createVideoSourceClip({ durationSeconds: 5, fps: 16, height: 480, name: 'clip.mp4', width: 832 });++ expect(clip).toEqual({+ endFrame: 78,+ fps: 16,+ height: 480,+ numFrames: 80,+ startFrame: 0,+ video_name: 'clip.mp4',+ width: 832,+ });+ });++ it('falls back to 16 fps when the probe recorded none, mirroring extract_video_range', () => {+ const clip = createVideoSourceClip({ durationSeconds: 2, height: 480, name: 'clip.mp4', width: 832 });++ expect(clip.fps).toBe(VIDEO_SOURCE_FALLBACK_FPS);+ expect(clip.numFrames).toBe(32);+ });++ it('keeps the default end frame at 1 or above so the crossfade tail survives', () => {+ const clip = createVideoSourceClip({ durationSeconds: 0.1, fps: 16, height: 480, name: 'c.mp4', width: 832 });++ expect(clip.endFrame).toBeGreaterThanOrEqual(1);+ });++ it('never produces negative trim bounds for very short clips', () => {+ const clip = createVideoSourceClip({ durationSeconds: 0.05, fps: 16, height: 480, name: 'c.mp4', width: 832 });++ expect(clip.numFrames).toBeGreaterThanOrEqual(1);+ expect(clip.endFrame).toBeGreaterThanOrEqual(0);+ expect(clip.startFrame).toBe(0);+ });+});++describe('clearDeletedVideoMedia', () => {+ const withMedia = createSettings({+ firstFrameImage: FIRST_FRAME,+ lastFrameImage: LAST_FRAME,+ sourceVideo: null,+ });++ it('returns the same object when nothing referenced was deleted', () => {+ expect(clearDeletedVideoMedia(withMedia, new Set(['other.png']), new Set())).toBe(withMedia);+ });++ it('clears exactly the deleted references', () => {+ const cleared = clearDeletedVideoMedia(withMedia, new Set(['first.png']), new Set());++ expect(cleared.firstFrameImage).toBeNull();+ expect(cleared.lastFrameImage).toEqual(LAST_FRAME);++ const withClip = createSettings({ sourceVideo: SOURCE_VIDEO });+ const clipCleared = clearDeletedVideoMedia(withClip, new Set(), new Set(['clip.mp4']));++ expect(clipCleared.sourceVideo).toBeNull();+ });+});diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.ts b/invokeai/frontend/webv2/src/features/video/core/settings.tsindex 2873e878a2..9cd112c900 100644--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts@@ -266,3 +266,64 @@ export const cloneVideoWidgetValues = (values: VideoWidgetValues): VideoWidgetVawanLowNoiseModel: values.wanLowNoiseModel ? { ...values.wanLowNoiseModel } : null,wanT5EncoderModel: values.wanT5EncoderModel ? { ...values.wanT5EncoderModel } : null,});++/** Fallback frame rate when a clip's probe did not record one (mirrors extract_video_range). */+export const VIDEO_SOURCE_FALLBACK_FPS = 16;++/**+ * Builds the panel's source-clip record from a gallery video. The frame count+ * is an estimate (duration × fps — the records store no exact count); the+ * backend's extract_video_range resolves authoritative indices at run time.+ * The default trim keeps everything but the final frame (the bundled extend+ * templates' `end_frame: -2`): the extension starts on the trimmed clip's last+ * frame, so keeping the very last one would duplicate it across the seam.+ */+export const createVideoSourceClip = (item: {+ durationSeconds: number;+ fps?: number;+ height: number;+ name: string;+ width: number;+}): VideoSourceClip => {+ const fps = item.fps && Number.isFinite(item.fps) && item.fps > 0 ? item.fps : VIDEO_SOURCE_FALLBACK_FPS;+ const numFrames = Math.max(1, Math.round(item.durationSeconds * fps));++ return {+ // Never below 1: the crossfade join needs at least a two-frame trim.+ endFrame: Math.max(1, numFrames - 2),+ fps,+ height: item.height,+ numFrames,+ startFrame: 0,+ video_name: item.name,+ width: item.width,+ };+};++/** The minimum frames a trim must keep — video_concat's crossfade consumes a 2-frame tail. */+export const MIN_VIDEO_TRIM_FRAMES = 2;++/**+ * Clears conditioning media that no longer exists in the gallery. Returns the+ * input object untouched when nothing changes.+ */+export const clearDeletedVideoMedia = (+ values: VideoSettings,+ removedImageNames: ReadonlySet<string>,+ removedVideoNames: ReadonlySet<string>+): VideoSettings => {+ const clearFirst = values.firstFrameImage !== null && removedImageNames.has(values.firstFrameImage.image_name);+ const clearLast = values.lastFrameImage !== null && removedImageNames.has(values.lastFrameImage.image_name);+ const clearSource = values.sourceVideo !== null && removedVideoNames.has(values.sourceVideo.video_name);++ if (!clearFirst && !clearLast && !clearSource) {+ return values;+ }++ return {+ ...values,+ ...(clearFirst ? { firstFrameImage: null } : {}),+ ...(clearLast ? { lastFrameImage: null } : {}),+ ...(clearSource ? { sourceVideo: null } : {}),+ };+};diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.tsindex 16520fb07a..c35915443b 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts@@ -57,7 +57,7 @@ const LIGHTNING_I2V_LOW = lora('Wan 2.2 I2V Lightning Low Noise (4-step)');const FIRST_FRAME = { height: 1080, image_name: 'first.png', width: 1920 };const LAST_FRAME = { height: 1080, image_name: 'last.png', width: 1920 };const SOURCE_VIDEO = {- endFrame: -2,+ endFrame: 79,fps: 16,height: 480,numFrames: 81,diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.tsindex 40f6abf02f..827fe9a58c 100644--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts@@ -38,7 +38,7 @@ import {WAN_TI2V_PIXEL_MULTIPLE,type VideoDimensions,} from './dimensions';-import { resolveVideoMode, VIDEO_ASPECT_RATIO_IDS } from './settings';+import { MIN_VIDEO_TRIM_FRAMES, resolveVideoMode, VIDEO_ASPECT_RATIO_IDS } from './settings';// Video capabilities registry keyed by model base AND variant: unlike still-image// generation, Wan's variants differ structurally (which conditioning modes exist,@@ -1110,6 +1110,18 @@ export const getVideoValidationReasons = (model: MainModelConfig, settings: Vide(!Number.isInteger(settings.sourceVideo.startFrame) || !Number.isInteger(settings.sourceVideo.endFrame))) {reasons.push('The initial video trim bounds must be whole frame numbers.');+ } else if (settings.sourceVideo) {+ const { endFrame, numFrames, startFrame } = settings.sourceVideo;++ // The crossfade join consumes a 2-frame tail from the trimmed source, so a+ // 1-frame trim fails mid-encode; catch it (and out-of-range bounds) here.+ if (startFrame < 0 || endFrame > numFrames - 1 || endFrame - startFrame + 1 < MIN_VIDEO_TRIM_FRAMES) {+ reasons.push('The initial video trim must keep at least two frames within the clip.');+ }++ if (numFrames < MIN_VIDEO_TRIM_FRAMES) {+ reasons.push('The initial video is too short to extend.');+ }}if (!getVideoDimensions(model, settings)) {diff --git a/invokeai/frontend/webv2/src/features/video/index.ts b/invokeai/frontend/webv2/src/features/video/index.tsindex ae2f00dd3a..ffcebf28e0 100644--- a/invokeai/frontend/webv2/src/features/video/index.ts+++ b/invokeai/frontend/webv2/src/features/video/index.ts@@ -15,7 +15,9 @@ export type {WanTargetResolution,} from './core/types';export {+ clearDeletedVideoMedia,cloneVideoWidgetValues,+ createVideoSourceClip,isImageWithDims,isVideoAspectRatioId,isVideoSettings,diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoFrameImageField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoFrameImageField.tsxnew file mode 100644index 0000000000..a4ec6faaf2--- /dev/null+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoFrameImageField.tsx@@ -0,0 +1,255 @@+import type { DragEndEvent } from '@dnd-kit/core';+import type { ImageWithDims } from '@features/generation/contracts';+import type { ChangeEvent } from 'react';++import { Box, HStack, Image, Input, Spinner, Stack, Text } from '@chakra-ui/react';+import { useDndMonitor } from '@dnd-kit/core';+import { galleryImages, galleryTransfers } from '@features/gallery';+import { galleryImageUrls, isGalleryImageDragData, useGalleryImageDroppable } from '@features/gallery/utility';+import {+ assertAccountScopeCurrent,+ captureAccountScope,+ isAccountScopeCurrent,+} from '@platform/state/accountLifecycle';+import { Button } from '@platform/ui/Button';+import { DropZone } from '@platform/ui/DropZone';+import { MiddleTruncate } from '@platform/ui/MiddleTruncate';+import { ImagePlusIcon, XIcon } from 'lucide-react';+import { memo, useCallback, useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { useVideoUiActions } from './VideoUiContext';++/**+ * A conditioning keyframe (first or last frame): gallery drop target, file+ * upload, and the chosen image's row. Same async-ownership pattern as the+ * Upscale input image — this is the section that owns loading/error state.+ */++const UPLOAD_ACCEPT_TYPES = ['image/png', 'image/jpeg', 'image/webp'];+const UPLOAD_ACCEPT_ATTR = [...UPLOAD_ACCEPT_TYPES, '.png', '.jpg', '.jpeg', '.webp'].join(',');+const DROP_ZONE_FOCUS_PROPS = {+ outlineColor: 'accent.focusRing',+ outlineOffset: '2px',+ outlineStyle: 'solid',+ outlineWidth: '2px',+};+const DROP_ZONE_DISABLED_PROPS = { cursor: 'not-allowed', opacity: 0.6 };+const DROP_ZONE_BUSY_PROPS = { disabled: true };+const DROP_ZONE_HOVER_PROPS = { bg: 'bg.muted', color: 'fg' };++const areFrameImagesEquivalent = (left: ImageWithDims | null, right: ImageWithDims | null): boolean =>+ (left === null && right === null) || left?.image_name === right?.image_name;++export const VideoFrameImageField = memo(+ function VideoFrameImageField({+ disabled = false,+ disabledReason,+ dropId,+ image,+ onChange,+ }: {+ disabled?: boolean;+ /** Shown in place of the field's affordances while disabled (mutual exclusion). */+ disabledReason?: string;+ /** Unique droppable id — the first- and last-frame fields render side by side. */+ dropId: string;+ image: ImageWithDims | null;+ onChange: (image: ImageWithDims | null) => void;+ }) {+ const { t } = useTranslation();+ const { reportError, touchGalleryImages } = useVideoUiActions();+ const fileInputRef = useRef<HTMLInputElement | null>(null);+ const [isLoading, setIsLoading] = useState(false);+ const [errorMessage, setErrorMessage] = useState<string | null>(null);+ const isInert = disabled || isLoading;+ const { isOver, setNodeRef } = useGalleryImageDroppable({+ data: { kind: dropId },+ disabled: isInert,+ id: dropId,+ });++ const setGalleryImage = useCallback(+ async (imageName: string) => {+ setErrorMessage(null);+ setIsLoading(true);++ try {+ const [resolved] = await galleryImages.resolveMany([imageName]);++ if (resolved) {+ onChange({ height: resolved.height, image_name: resolved.imageName, width: resolved.width });+ }+ } catch (error) {+ const message = error instanceof Error ? error.message : String(error);+ setErrorMessage(message);+ reportError(message);+ } finally {+ setIsLoading(false);+ }+ },+ [onChange, reportError]+ );++ const handleDragEnd = useCallback(+ (event: DragEndEvent) => {+ const data = event.active.data.current;++ if (!isInert && event.over?.id === dropId && isGalleryImageDragData(data) && data.items.length === 1) {+ const imageName = data.items[0]?.name;++ if (imageName) {+ void setGalleryImage(imageName);+ }+ }+ },+ [dropId, isInert, setGalleryImage]+ );++ useDndMonitor({ onDragEnd: handleDragEnd });++ const uploadFile = useCallback(+ async (file: File) => {+ setErrorMessage(null);++ if (!UPLOAD_ACCEPT_TYPES.includes(file.type)) {+ setErrorMessage(t('widgets.video.unsupportedImageFile'));+ reportError(t('widgets.video.unsupportedImageFile'));+ return;+ }++ const owner = captureAccountScope();+ setIsLoading(true);++ try {+ const uploaded = await galleryTransfers.upload(file, 'none', { signal: owner.signal });++ assertAccountScopeCurrent(owner);+ onChange({ height: uploaded.height, image_name: uploaded.imageName, width: uploaded.width });+ touchGalleryImages();+ } catch (error) {+ if (!isAccountScopeCurrent(owner)) {+ return;+ }++ const message = error instanceof Error ? error.message : String(error);+ setErrorMessage(message);+ reportError(message);+ } finally {+ setIsLoading(false);+ }+ },+ [onChange, reportError, t, touchGalleryImages]+ );++ const handleFileChange = useCallback(+ (event: ChangeEvent<HTMLInputElement>) => {+ const file = event.currentTarget.files?.[0];++ if (file) {+ void uploadFile(file);+ }+ event.currentTarget.value = '';+ },+ [uploadFile]+ );+ const handlePickFile = useCallback(() => {+ if (!isInert) {+ fileInputRef.current?.click();+ }+ }, [isInert]);+ const handleClear = useCallback(() => onChange(null), [onChange]);++ return (+ <Stack gap="2">+ <DropZone+ ref={setNodeRef}+ as="button"+ aria-busy={isLoading}+ aria-disabled={disabled}+ aria-label={image ? t('widgets.video.replaceFrame') : t('widgets.video.uploadFrame')}+ cursor={disabled ? 'not-allowed' : 'pointer'}+ isOver={isOver}+ {...(isLoading ? DROP_ZONE_BUSY_PROPS : undefined)}+ minH="20"+ overflow="hidden"+ position="relative"+ _focusVisible={DROP_ZONE_FOCUS_PROPS}+ _disabled={DROP_ZONE_DISABLED_PROPS}+ _hover={isInert ? undefined : DROP_ZONE_HOVER_PROPS}+ opacity={disabled ? 0.6 : undefined}+ onClick={handlePickFile}+ >+ {image ? (+ <HStack align="stretch" gap="3" h="20" p="2">+ <Box bg="blackAlpha.300" boxSize="16" flexShrink="0" overflow="hidden" rounded="sm">+ <Image+ alt=""+ boxSize="full"+ objectFit="contain"+ outline="1px solid"+ outlineColor="border.image"+ outlineOffset="-1px"+ rounded="sm"+ src={galleryImageUrls.thumbnail(image.image_name)}+ />+ </Box>+ <Stack align="start" flex="1" gap="1" justify="center" minW="0">+ <MiddleTruncate color="fg" fontSize="xs" fontWeight="semibold" text={image.image_name} />+ <Text color="fg.muted" fontSize="2xs" fontVariantNumeric="tabular-nums">+ {image.width} × {image.height}+ </Text>+ </Stack>+ </HStack>+ ) : (+ <Stack align="center" color="fg.muted" gap="1.5" justify="center" minH="20" px="4">+ {isLoading ? <Spinner size="sm" /> : <ImagePlusIcon aria-hidden="true" size="18" />}+ <Text fontSize="2xs" textAlign="center">+ {disabled && disabledReason+ ? disabledReason+ : isLoading+ ? t('widgets.video.uploadingFrame')+ : t('widgets.video.uploadOrDropFrame')}+ </Text>+ </Stack>+ )}+ </DropZone>+ <HStack justify="space-between">+ {disabled && disabledReason && image ? (+ <Text color="fg.muted" fontSize="2xs">+ {disabledReason}+ </Text>+ ) : (+ <Box />+ )}+ {image ? (+ <Button disabled={isLoading} size="xs" variant="ghost" onClick={handleClear}>+ <XIcon aria-hidden="true" size="12" />+ {t('widgets.video.removeFrame')}+ </Button>+ ) : null}+ </HStack>+ {errorMessage ? (+ <Text aria-live="polite" color="fg.error" fontSize="2xs" role="alert" textWrap="pretty">+ {errorMessage}+ </Text>+ ) : null}+ <Input+ ref={fileInputRef}+ accept={UPLOAD_ACCEPT_ATTR}+ aria-hidden="true"+ display="none"+ tabIndex={-1}+ type="file"+ onChange={handleFileChange}+ />+ </Stack>+ );+ },+ (previous, next) =>+ previous.onChange === next.onChange &&+ previous.disabled === next.disabled &&+ previous.disabledReason === next.disabledReason &&+ previous.dropId === next.dropId &&+ areFrameImagesEquivalent(previous.image, next.image)+);diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsxnew file mode 100644index 0000000000..35c14590b0--- /dev/null+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx@@ -0,0 +1,350 @@+import type { DragEndEvent } from '@dnd-kit/core';+import type { VideoSourceClip } from '@features/video/core/types';+import type { ChangeEvent } from 'react';++import { Box, HStack, Input, Spinner, Stack, Text } from '@chakra-ui/react';+import { useDndContext, useDndMonitor, useDroppable } from '@dnd-kit/core';+import { galleryItems, galleryTransfers } from '@features/gallery';+import { galleryVideoUrls, isGalleryItemDragData } from '@features/gallery/utility';+import { createVideoSourceClip } from '@features/video/core/settings';+import {+ assertAccountScopeCurrent,+ captureAccountScope,+ isAccountScopeCurrent,+} from '@platform/state/accountLifecycle';+import { Field } from '@platform/ui';+import { Button } from '@platform/ui/Button';+import { DropZone } from '@platform/ui/DropZone';+import { MiddleTruncate } from '@platform/ui/MiddleTruncate';+import { SliderNumberField } from '@platform/ui/SliderNumberField';+import { FilmIcon, XIcon } from 'lucide-react';+import { memo, useCallback, useEffect, useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { useVideoUiActions } from './VideoUiContext';++/**+ * The clip to extend: gallery drop target, file upload, a live frame preview,+ * and the trim bounds. The preview is a muted `<video>` element seeked to the+ * most recently adjusted trim bound (`frame / fps`) — browsers display the+ * frame natively without a canvas roundtrip, same trick as the workflow+ * editor's frame scrubber.+ */++const DROP_ID = 'video-source-clip';+const DROP_ZONE_FOCUS_PROPS = {+ outlineColor: 'accent.focusRing',+ outlineOffset: '2px',+ outlineStyle: 'solid',+ outlineWidth: '2px',+};+const DROP_ZONE_DISABLED_PROPS = { cursor: 'not-allowed', opacity: 0.6 };+const DROP_ZONE_BUSY_PROPS = { disabled: true };+const DROP_ZONE_HOVER_PROPS = { bg: 'bg.muted', color: 'fg' };+const PREVIEW_VIDEO_STYLE = {+ display: 'block',+ height: '100%',+ objectFit: 'contain',+ width: '100%',+} as const;++const getSingleVideoDragName = (data: unknown): string | null => {+ if (!isGalleryItemDragData(data) || data.items.length !== 1) {+ return null;+ }++ const item = data.items[0];++ return item?.kind === 'video' ? item.name : null;+};++const areSourceClipsEquivalent = (left: VideoSourceClip | null, right: VideoSourceClip | null): boolean =>+ (left === null && right === null) ||+ (left?.video_name === right?.video_name &&+ left?.startFrame === right?.startFrame &&+ left?.endFrame === right?.endFrame);++export const VideoSourceClipField = memo(+ function VideoSourceClipField({+ disabled = false,+ disabledReason,+ onChange,+ sourceVideo,+ }: {+ disabled?: boolean;+ /** Shown in place of the field's affordances while disabled (mutual exclusion). */+ disabledReason?: string;+ onChange: (clip: VideoSourceClip | null) => void;+ sourceVideo: VideoSourceClip | null;+ }) {+ const { t } = useTranslation();+ const { reportError, touchGalleryImages } = useVideoUiActions();+ const fileInputRef = useRef<HTMLInputElement | null>(null);+ const [isLoading, setIsLoading] = useState(false);+ const [errorMessage, setErrorMessage] = useState<string | null>(null);+ // Which trim bound the preview follows; the last one the user moved.+ const [previewBound, setPreviewBound] = useState<'start' | 'end'>('end');+ const isInert = disabled || isLoading;++ const { active } = useDndContext();+ const acceptsActiveDrag = !isInert && getSingleVideoDragName(active?.data.current) !== null;+ const { isOver, setNodeRef } = useDroppable({ disabled: !acceptsActiveDrag, id: DROP_ID });++ const adoptVideo = useCallback(+ async (videoName: string) => {+ setErrorMessage(null);+ setIsLoading(true);++ try {+ const item = await galleryItems.resolve({ kind: 'video', name: videoName });++ if (item?.kind === 'video') {+ onChange(+ createVideoSourceClip({+ durationSeconds: item.durationSeconds,+ fps: item.fps,+ height: item.height,+ name: item.name,+ width: item.width,+ })+ );+ }+ } catch (error) {+ const message = error instanceof Error ? error.message : String(error);+ setErrorMessage(message);+ reportError(message);+ } finally {+ setIsLoading(false);+ }+ },+ [onChange, reportError]+ );++ const handleDragEnd = useCallback(+ (event: DragEndEvent) => {+ const videoName = getSingleVideoDragName(event.active.data.current);++ if (!isInert && event.over?.id === DROP_ID && videoName) {+ void adoptVideo(videoName);+ }+ },+ [adoptVideo, isInert]+ );++ useDndMonitor({ onDragEnd: handleDragEnd });++ const uploadFile = useCallback(+ async (file: File) => {+ setErrorMessage(null);++ // `accept` is advisory; an unknown type (empty string) is the server's call.+ if (file.type && !file.type.startsWith('video/')) {+ setErrorMessage(t('widgets.video.unsupportedVideoFile'));+ reportError(t('widgets.video.unsupportedVideoFile'));+ return;+ }++ const owner = captureAccountScope();+ setIsLoading(true);++ try {+ const uploaded = await galleryTransfers.uploadVideo(file, 'none', { signal: owner.signal });++ assertAccountScopeCurrent(owner);+ onChange(+ createVideoSourceClip({+ durationSeconds: uploaded.durationSeconds,+ fps: uploaded.fps,+ height: uploaded.height,+ name: uploaded.name,+ width: uploaded.width,+ })+ );+ touchGalleryImages();+ } catch (error) {+ if (!isAccountScopeCurrent(owner)) {+ return;+ }++ const message = error instanceof Error ? error.message : String(error);+ setErrorMessage(message);+ reportError(message);+ } finally {+ setIsLoading(false);+ }+ },+ [onChange, reportError, t, touchGalleryImages]+ );++ const handleFileChange = useCallback(+ (event: ChangeEvent<HTMLInputElement>) => {+ const file = event.currentTarget.files?.[0];++ if (file) {+ void uploadFile(file);+ }+ event.currentTarget.value = '';+ },+ [uploadFile]+ );+ const handlePickFile = useCallback(() => {+ if (!isInert) {+ fileInputRef.current?.click();+ }+ }, [isInert]);+ const handleClear = useCallback(() => onChange(null), [onChange]);++ const maxFrameIndex = sourceVideo ? Math.max(0, sourceVideo.numFrames - 1) : 0;+ // The crossfade join needs a 2-frame tail from the trimmed source, so the+ // setters keep at least two frames between the bounds.+ const setStartFrame = useCallback(+ (rawStart: number) => {+ if (!sourceVideo) {+ return;+ }++ const startFrame = Math.min(Math.max(0, rawStart), Math.max(0, maxFrameIndex - 1));++ setPreviewBound('start');+ onChange({ ...sourceVideo, endFrame: Math.max(startFrame + 1, sourceVideo.endFrame), startFrame });+ },+ [maxFrameIndex, onChange, sourceVideo]+ );+ const setEndFrame = useCallback(+ (rawEnd: number) => {+ if (!sourceVideo) {+ return;+ }++ const endFrame = Math.max(1, Math.min(rawEnd, maxFrameIndex));++ setPreviewBound('end');+ onChange({ ...sourceVideo, endFrame, startFrame: Math.min(sourceVideo.startFrame, endFrame - 1) });+ },+ [maxFrameIndex, onChange, sourceVideo]+ );++ const previewFrame = sourceVideo ? (previewBound === 'start' ? sourceVideo.startFrame : sourceVideo.endFrame) : 0;+ // Seek to the middle of the frame's display interval so rounding cannot+ // show the neighbouring frame. Seeking sets currentTime on one long-lived+ // element (the frame-scrubber trick) — remounting per drag tick would spawn+ // a range fetch per movement on multi-MB clips.+ const previewTime = sourceVideo ? Math.max(0, (previewFrame + 0.5) / sourceVideo.fps) : 0;+ const previewVideoRef = useRef<HTMLVideoElement | null>(null);+ const previewSrc = sourceVideo ? galleryVideoUrls.full(sourceVideo.video_name) : null;++ useEffect(() => {+ const element = previewVideoRef.current;++ if (element && Number.isFinite(previewTime)) {+ element.currentTime = previewTime;+ }+ }, [previewSrc, previewTime]);++ return (+ <Stack gap="2">+ <DropZone+ ref={setNodeRef}+ as="button"+ aria-busy={isLoading}+ aria-disabled={disabled}+ aria-label={sourceVideo ? t('widgets.video.replaceClip') : t('widgets.video.uploadClip')}+ cursor={disabled ? 'not-allowed' : 'pointer'}+ isOver={isOver}+ {...(isLoading ? DROP_ZONE_BUSY_PROPS : undefined)}+ minH="24"+ overflow="hidden"+ position="relative"+ _focusVisible={DROP_ZONE_FOCUS_PROPS}+ _disabled={DROP_ZONE_DISABLED_PROPS}+ _hover={isInert ? undefined : DROP_ZONE_HOVER_PROPS}+ opacity={disabled ? 0.6 : undefined}+ onClick={handlePickFile}+ >+ {sourceVideo && previewSrc ? (+ <Stack gap="1" p="2">+ <Box bg="blackAlpha.300" h="28" overflow="hidden" rounded="sm" w="full">+ <video+ key={previewSrc}+ ref={previewVideoRef}+ muted+ preload="metadata"+ src={previewSrc}+ style={PREVIEW_VIDEO_STYLE}+ />+ </Box>+ <HStack justify="space-between" minW="0">+ <MiddleTruncate color="fg" flex="1" fontSize="xs" fontWeight="semibold" text={sourceVideo.video_name} />+ <Text color="fg.muted" flexShrink="0" fontSize="2xs" fontVariantNumeric="tabular-nums">+ {sourceVideo.width} × {sourceVideo.height} · {sourceVideo.fps} fps+ </Text>+ </HStack>+ </Stack>+ ) : (+ <Stack align="center" color="fg.muted" gap="1.5" justify="center" minH="24" px="4">+ {isLoading ? <Spinner size="sm" /> : <FilmIcon aria-hidden="true" size="18" />}+ <Text fontSize="2xs" textAlign="center">+ {disabled && disabledReason+ ? disabledReason+ : isLoading+ ? t('widgets.video.uploadingClip')+ : t('widgets.video.uploadOrDropClip')}+ </Text>+ </Stack>+ )}+ </DropZone>+ {sourceVideo ? (+ <Stack gap="2">+ <Field helpText={t('widgets.video.trimHelp')} label={t('widgets.video.trimStart')}>+ <SliderNumberField+ ariaLabel={t('widgets.video.trimStart')}+ disabled={disabled}+ max={maxFrameIndex}+ min={0}+ step={1}+ value={sourceVideo.startFrame}+ onChange={setStartFrame}+ />+ </Field>+ <Field label={t('widgets.video.trimEnd')}>+ <SliderNumberField+ ariaLabel={t('widgets.video.trimEnd')}+ disabled={disabled}+ max={maxFrameIndex}+ min={0}+ step={1}+ value={sourceVideo.endFrame}+ onChange={setEndFrame}+ />+ </Field>+ <HStack justify="end">+ <Button disabled={isLoading} size="xs" variant="ghost" onClick={handleClear}>+ <XIcon aria-hidden="true" size="12" />+ {t('widgets.video.removeClip')}+ </Button>+ </HStack>+ </Stack>+ ) : null}+ {errorMessage ? (+ <Text aria-live="polite" color="fg.error" fontSize="2xs" role="alert" textWrap="pretty">+ {errorMessage}+ </Text>+ ) : null}+ <Input+ ref={fileInputRef}+ accept="video/*"+ aria-hidden="true"+ display="none"+ tabIndex={-1}+ type="file"+ onChange={handleFileChange}+ />+ </Stack>+ );+ },+ (previous, next) =>+ previous.onChange === next.onChange &&+ previous.disabled === next.disabled &&+ previous.disabledReason === next.disabledReason &&+ areSourceClipsEquivalent(previous.sourceVideo, next.sourceVideo)+);diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsxindex 8b40e2558f..337ca12ece 100644--- a/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoUiContext.tsx@@ -16,10 +16,14 @@ export interface VideoUiAdapter {rawValues: Record<string, unknown>;reportError(message: string): void;showPromptSyntaxHighlighting: boolean;+ touchGalleryImages(): void;}/** The adapter's callbacks, which are stable for the lifetime of a project. */-export type VideoUiActions = Pick<VideoUiAdapter, 'patchPromptDraft' | 'patchValues' | 'reportError'>;+export type VideoUiActions = Pick<+ VideoUiAdapter,+ 'patchPromptDraft' | 'patchValues' | 'reportError' | 'touchGalleryImages'+>;const VideoUiContext = createContext<VideoUiAdapter | null>(null);/**@@ -31,10 +35,10 @@ const VideoUiContext = createContext<VideoUiAdapter | null>(null);const VideoUiActionsContext = createContext<VideoUiActions | null>(null);export const VideoUiProvider = ({ adapter, children }: { adapter: VideoUiAdapter; children: ReactNode }) => {- const { patchPromptDraft, patchValues, reportError } = adapter;+ const { patchPromptDraft, patchValues, reportError, touchGalleryImages } = adapter;const actions = useMemo<VideoUiActions>(- () => ({ patchPromptDraft, patchValues, reportError }),- [patchPromptDraft, patchValues, reportError]+ () => ({ patchPromptDraft, patchValues, reportError, touchGalleryImages }),+ [patchPromptDraft, patchValues, reportError, touchGalleryImages]);return (diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsxindex 0c3d9e9d23..bceff40943 100644--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx@@ -1,5 +1,6 @@+import type { ImageWithDims } from '@features/generation/contracts';import type { ModelConfig, ModelTaxonomyType } from '@features/models';-import type { VideoWidgetValues } from '@features/video/core/types';+import type { VideoSourceClip, VideoWidgetValues } from '@features/video/core/types';import { createListCollection, HStack, NumberInput, Stack, Switch, Text } from '@chakra-ui/react';import { GenerationSettingsSection } from '@features/generation/components';@@ -7,7 +8,7 @@ import { isMainModelConfig, SEED_MAX } from '@features/generation/settings';import { ensureModelsLoaded, useModelsSelector } from '@features/models';import { ModelSelect } from '@features/models/react';import { getVideoDurationSeconds, invertVideoAspectRatioId } from '@features/video/core/dimensions';-import { normalizeVideoWidgetValues, VIDEO_ASPECT_RATIO_IDS } from '@features/video/core/settings';+import { normalizeVideoWidgetValues, resolveVideoMode, VIDEO_ASPECT_RATIO_IDS } from '@features/video/core/settings';import {getAcceleratorToggleResult,getVideoDimensions,@@ -18,6 +19,7 @@ import {import { createDefaultVideoWidgetValues, syncVideoWidgetValuesWithModels } from '@features/video/core/widgetValues';import { useMountEffect } from '@platform/react/useMountEffect';import { Field, IconButton, Select } from '@platform/ui';+import { Button } from '@platform/ui/Button';import { SliderNumberField } from '@platform/ui/SliderNumberField';import { toaster } from '@platform/ui/toaster';import { ArrowLeftRightIcon, DicesIcon } from 'lucide-react';@@ -26,6 +28,8 @@ import { useTranslation } from 'react-i18next';import { areVideoValuesEqual } from './videoComparators';import { VideoPromptFields } from './VideoFormFields';+import { VideoFrameImageField } from './VideoFrameImageField';+import { VideoSourceClipField } from './VideoSourceClipField';import { useVideoUi, useVideoUiActions } from './VideoUiContext';/**@@ -52,6 +56,27 @@ const DURATION_FORMATTER = new Intl.NumberFormat(undefined, {minimumFractionDigits: 1,});+/**+ * A media value the current model cannot consume (persisted from another+ * model's session, or restored by an optimistic rollback) would otherwise+ * block invoke invisibly — its section is policy-hidden. This stub is the+ * visible affordance to clear it.+ */+const StaleMediaStub = ({ label, onClear }: { label: string; onClear: () => void }) => {+ const { t } = useTranslation();++ return (+ <HStack bg="bg.subtle" gap="2" justify="space-between" p="2" rounded="md">+ <Text color="fg.muted" fontSize="2xs" textWrap="pretty">+ {label}+ </Text>+ <Button flexShrink="0" size="2xs" variant="outline" onClick={onClear}>+ {t('widgets.video.clearStaleMedia')}+ </Button>+ </HStack>+ );+};+const VideoModelReconciler = ({rawValues,values,@@ -103,7 +128,8 @@ export const VideoWidgetView = () => {const dimensions = useMemo(() => getVideoDimensions(values.model ?? undefined, values), [values]);const durationSeconds = getVideoDurationSeconds(values.numFrames,- policy.fps.editable ? values.fps : policy.fps.defaultValue+ // In extend mode the extension inherits the SOURCE clip's frame rate.+ policy.fps.editable ? (values.sourceVideo?.fps ?? values.fps) : policy.fps.defaultValue);const patch = useCallback((next: Partial<VideoWidgetValues>) => patchValues(next), [patchValues]);@@ -195,6 +221,25 @@ export const VideoWidgetView = () => {[patch, values.aspectRatioId]);+ // The mutual exclusion lives in the setters: a first frame and an initial+ // video are different ways to claim the same conditioning slot, so setting+ // one clears the other. A last frame combines with either — with a first+ // frame it interpolates (FLF2V); with a source video it is the destination+ // the extension should land on.+ const setFirstFrame = useCallback(+ (firstFrameImage: ImageWithDims | null) =>+ patch({ firstFrameImage, ...(firstFrameImage ? { sourceVideo: null } : {}) }),+ [patch]+ );+ const setLastFrame = useCallback((lastFrameImage: ImageWithDims | null) => patch({ lastFrameImage }), [patch]);+ const setSourceVideo = useCallback(+ (sourceVideo: VideoSourceClip | null) => patch({ sourceVideo, ...(sourceVideo ? { firstFrameImage: null } : {}) }),+ [patch]+ );+ const clearFirstFrame = useCallback(() => patch({ firstFrameImage: null }), [patch]);+ const clearLastFrame = useCallback(() => patch({ lastFrameImage: null }), [patch]);+ const clearSourceVideo = useCallback(() => patch({ sourceVideo: null }), [patch]);+const targetResolutionCollection = useMemo(() => createListCollection({ items: policy.targetResolutions.map((option) => ({ ...option, value: option.id })) }),[policy.targetResolutions]@@ -215,11 +260,18 @@ export const VideoWidgetView = () => {[policy.frames]);- // Conditioning media locks the aspect ratio in later stack PRs; today the- // preset is always the source, so this only reports the derived canvas.+ const mode = resolveVideoMode(values);+ const supportsFirstFrame = policy.modes.includes('first-frame') || policy.modes.includes('first-last');+ const supportsLastFrame = policy.modes.includes('first-last') || policy.modes.includes('last-frame');+ const supportsExtend = policy.modes.includes('extend');+ const hasConditioningMedia = Boolean(values.firstFrameImage || values.lastFrameImage || values.sourceVideo);+ const derivedSourceText = dimensions ? t(`widgets.video.dimensionSource.${dimensions.source}`) : undefined;const derivedSizeText = dimensions- ? t('widgets.video.derivedSize', { height: dimensions.height, width: dimensions.width })+ ? `${t('widgets.video.derivedSize', { height: dimensions.height, width: dimensions.width })}${+ derivedSourceText ? ` — ${derivedSourceText}` : ''+ }`: t('widgets.video.derivedSizeUnavailable');+ const fpsLockedForExtend = policy.ui.fpsVisible && mode === 'extend';const durationText =durationSeconds === null? undefined@@ -247,12 +299,67 @@ export const VideoWidgetView = () => {onPatchValues={patch}/>+ {supportsFirstFrame || supportsLastFrame ? (+ <GenerationSettingsSection label={t('widgets.video.initialFrames')} sectionId="video-frames" defaultOpen>+ <Stack gap="3" p="2">+ {supportsFirstFrame ? (+ <Field+ helpText={values.sourceVideo ? undefined : t('widgets.video.firstFrameHelp')}+ label={t('widgets.video.firstFrame')}+ >+ <VideoFrameImageField+ disabled={Boolean(values.sourceVideo)}+ disabledReason={values.sourceVideo ? t('widgets.video.firstFrameBlocked') : undefined}+ dropId="video-first-frame"+ image={values.firstFrameImage}+ onChange={setFirstFrame}+ />+ </Field>+ ) : null}+ {supportsLastFrame ? (+ <Field+ helpText={+ values.sourceVideo ? t('widgets.video.lastFrameExtendHelp') : t('widgets.video.lastFrameHelp')+ }+ label={t('widgets.video.lastFrame')}+ >+ <VideoFrameImageField dropId="video-last-frame" image={values.lastFrameImage} onChange={setLastFrame} />+ </Field>+ ) : null}+ </Stack>+ </GenerationSettingsSection>+ ) : null}++ {!supportsFirstFrame && values.firstFrameImage ? (+ <StaleMediaStub label={t('widgets.video.staleFirstFrame')} onClear={clearFirstFrame} />+ ) : null}+ {!supportsLastFrame && values.lastFrameImage ? (+ <StaleMediaStub label={t('widgets.video.staleLastFrame')} onClear={clearLastFrame} />+ ) : null}+ {!supportsExtend && values.sourceVideo ? (+ <StaleMediaStub label={t('widgets.video.staleSourceVideo')} onClear={clearSourceVideo} />+ ) : null}++ {supportsExtend ? (+ <GenerationSettingsSection label={t('widgets.video.initialVideo')} sectionId="video-source" defaultOpen>+ <Stack gap="3" p="2">+ <VideoSourceClipField+ disabled={Boolean(values.firstFrameImage)}+ disabledReason={values.firstFrameImage ? t('widgets.video.initialVideoBlocked') : undefined}+ sourceVideo={values.sourceVideo}+ onChange={setSourceVideo}+ />+ </Stack>+ </GenerationSettingsSection>+ ) : null}+<GenerationSettingsSection label={t('widgets.video.dimensions')} sectionId="video-dimensions" defaultOpen><Stack gap="3" p="2"><Field helpText={derivedSizeText} label={t('widgets.video.aspectRatio')}><HStack gap="1"><Selectcollection={ASPECT_RATIO_COLLECTION}+ disabled={hasConditioningMedia}flex="1"size="xs"value={aspectRatioValue}@@ -260,6 +367,7 @@ export const VideoWidgetView = () => {/><IconButtonaria-label={t('widgets.video.swapAspectRatio')}+ disabled={hasConditioningMedia}size="xs"variant="ghost"onClick={swapAspectRatio}@@ -287,9 +395,13 @@ export const VideoWidgetView = () => {/></Field>{policy.ui.fpsVisible ? (- <Field label={t('widgets.video.fps')}>+ <Field+ helpText={fpsLockedForExtend ? t('widgets.video.fpsExtendLocked') : undefined}+ label={t('widgets.video.fps')}+ ><SliderNumberFieldariaLabel={t('widgets.video.fps')}+ disabled={fpsLockedForExtend}max={60}min={policy.fps.min}numberInputMax={policy.fps.max}diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/galleryOptimisticRollback.ts b/invokeai/frontend/webv2/src/workbench/image-actions/galleryOptimisticRollback.tsindex 1ea9d30929..ee67c46736 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/galleryOptimisticRollback.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/galleryOptimisticRollback.ts@@ -31,6 +31,9 @@ const TRACKED_GALLERY_REMOVAL_FIELDS: ReadonlyArray<{ key: string; widgetId: Wid{ key: 'selectedImageName', widgetId: 'gallery' },{ key: 'selectedImageNames', widgetId: 'gallery' },{ key: 'inputImage', widgetId: 'upscale' },+ { key: 'firstFrameImage', widgetId: 'video' },+ { key: 'lastFrameImage', widgetId: 'video' },+ { key: 'sourceVideo', widgetId: 'video' },];const trackedFieldKey = (projectId: string, widgetId: WidgetTypeId, key: string): string =>diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex a2c1e24172..2cbd44c9a0 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -117,10 +117,12 @@ import {type UpscaleWidgetValues,} from '@features/upscale';import {+ clearDeletedVideoMedia,cloneVideoWidgetValues,compileVideoGraph,getVideoDimensions,getVideoWidgetValidationReasons,+ normalizeVideoSettings,normalizeVideoWidgetValues,resolveVideoSeed,syncVideoWidgetValuesWithModels,@@ -2570,6 +2572,13 @@ const removeGalleryItemsFromAllProjects = (return ref.kind === 'image' ? [ref.name] : [];}));+ const removedVideoNames = new Set(+ [...removedItemKeys].flatMap((key) => {+ const ref = parseGalleryItemKey(key);++ return ref.kind === 'video' ? [ref.name] : [];+ })+ );let didChange = false;const projects = state.projects.map((project) => {const withoutGalleryItems = updateProjectWidgetValues(project, 'gallery', (values) => {@@ -2620,8 +2629,31 @@ const removeGalleryItemsFromAllProjects = (return { ...clearDeletedUpscaleInput(values, removedImageNames) };});- didChange ||= withoutUpscaleInput !== project;- return withoutUpscaleInput;+ const withoutVideoMedia = updateProjectWidgetValues(withoutUpscaleInput, 'video', (rawValues) => {+ const values = normalizeVideoSettings(rawValues);++ if (!values) {+ return rawValues;+ }++ const cleared = clearDeletedVideoMedia(values, removedImageNames, removedVideoNames);++ if (cleared === values) {+ return rawValues;+ }++ // Patch only the cleared media slots: spreading the whole normalized+ // settings would rewrite every other key to its normalized form.+ return {+ ...rawValues,+ ...(cleared.firstFrameImage !== values.firstFrameImage ? { firstFrameImage: null } : {}),+ ...(cleared.lastFrameImage !== values.lastFrameImage ? { lastFrameImage: null } : {}),+ ...(cleared.sourceVideo !== values.sourceVideo ? { sourceVideo: null } : {}),+ };+ });++ didChange ||= withoutVideoMedia !== project;+ return withoutVideoMedia;});return didChange ? { ...state, projects } : state;