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
fix(webv2): pin the continuity anchor during normalization, before the cap trim
Lincoln Stein8ce1d3b0607e
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts b/invokeai/frontend/webv2/src/features/video/core/settings.test.tsindex be775970d8..5201bc3e69 100644--- a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts+++ b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts@@ -376,6 +376,37 @@ describe('references', () => {]);});+ it('normalization heals a panel saved with the anchor prepended', () => {+ // The build before the anchor was pinned PREPENDED it, so those projects+ // load with it at index 0. Normalization must move it last -- otherwise the+ // generated frames continue from whatever reference follows it -- and it+ // must do so BEFORE the cap trim, or the front-drop deletes the anchor.+ const anchor = {+ ...VIDEO_REFERENCE,+ clip: { ...VIDEO_REFERENCE.clip, video_name: 'anchor.mp4' },+ fromSourceVideo: true,+ };+ const named = (entry: { kind: string; clip?: { video_name: string } }) =>+ entry.kind === 'video' ? entry.clip!.video_name : 'img';++ const healed = normalizeVideoSettings(createSettings({ references: [anchor, IMAGE_REFERENCE] as never }));++ expect(healed?.references.map(named as never)).toEqual(['img', 'anchor.mp4']);++ // Over the cap, with the anchor in the position the old build left it.+ const stale = [+ anchor,+ ...Array.from({ length: 3 }, (_unused, index) => ({+ ...VIDEO_REFERENCE,+ clip: { ...VIDEO_REFERENCE.clip, video_name: `v${index}.mp4` },+ })),+ ];+ const trimmed = normalizeVideoSettings(createSettings({ references: stale as never }));++ expect(trimmed?.references.map(named as never)).toEqual(['v1.mp4', 'v2.mp4', 'anchor.mp4']);+ expect(trimmed?.references.at(-1)).toMatchObject({ fromSourceVideo: true });+ });+it('isVideoSettings rejects references combined with frame media', () => {expect(isVideoSettings(createSettings({ firstFrameImage: FIRST_FRAME, references: [IMAGE_REFERENCE] }))).toBe(falsediff --git a/invokeai/frontend/webv2/src/features/video/core/settings.ts b/invokeai/frontend/webv2/src/features/video/core/settings.tsindex da3d3eb07f..de562521d2 100644--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts@@ -118,7 +118,13 @@ const sanitizeVideoReferences = (value: unknown): VideoReferenceItem[] => {if (!Array.isArray(value)) {return [];}- const valid = value.filter((entry) => isVideoReferenceItem(entry));+ // Pin BEFORE the cap trim. The front-drop below assumes the anchor is last,+ // but a project saved by the build that PREPENDED it loads with the anchor+ // first -- so without this the overflow rule deletes the one entry it exists+ // to protect. Pinning here also heals those panels on load: normalization+ // runs on every read, whereas `setReferences` only fires once the user+ // touches the reference list.+ const valid = pinReferenceExtendAnchor(value.filter((entry) => isVideoReferenceItem(entry)));let videosToDrop = Math.max(0, valid.filter((entry) => entry.kind === 'video').length - VIDEO_REFERENCE_MAX_VIDEOS);const result: VideoReferenceItem[] = [];let images = 0;