Skip to content

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.

Merge main into feat/video-recall-image

Lincoln Steindf8125fbcad6
diff --cc docs/src/content/docs/development/Guides/video-recall-api.mdx
index 8f189c3412,318df30e5f..55154eaa7e
--- a/docs/src/content/docs/development/Guides/video-recall-api.mdx
+++ b/docs/src/content/docs/development/Guides/video-recall-api.mdx
@@@ -1,6 -1,6 +1,6 @@@
---
title: Video Recall API
--description: REST endpoints that let an external process recall or remix video generation parameters and place gallery or uploaded videos into a user's Video panel.
++description: REST endpoints that let an external process recall or remix video generation parameters and place gallery images and gallery or uploaded videos into a user's Video panel.
---
## Overview
@@@ -19,9 -19,9 +19,14 @@@ browser, a script, another application
- **Use as Conditioning Clip** — set a video as the conditioning clip of models that
generate one half of a clip from the other (today, LTX-2): its soundtrack, to
generate a picture for it, or its picture, to generate a soundtrack for it.
++- **Send Image / Append Image** — place a gallery image wherever the panel's model
++ takes images: as a reference image (MiniMax H3 Ref2VA) or as the first or last
++ frame (Wan I2V, LTX-2, MiniMax H3 FL2VA). Send replaces the panel's images;
++ Append adds to them.
Send Video, Use as Ref Video and Use as Conditioning Clip take either the name of a video already in the
--gallery or a video file, which is uploaded into the gallery first.
++gallery or a video file, which is uploaded into the gallery first. Send Image and
++Append Image take only the name of an image already in the gallery.
## How it works
@@@ -47,6 -47,6 +52,7 @@@
| `POST /api/v1/recall/video/{queue_id}/reference-video/upload` | multipart `file` | Upload, then use as a reference |
| `POST /api/v1/recall/video/{queue_id}/conditioning-video?video_name=…&role=…` | none | Use a gallery video as the conditioning clip |
| `POST /api/v1/recall/video/{queue_id}/conditioning-video/upload?role=…` | multipart `file` | Upload, then use as the conditioning clip |
++| `POST /api/v1/recall/video/{queue_id}/image?image_name=…&append=…` | none | Send or append a gallery image |
`queue_id` is the frontend's queue, normally `default`.
@@@ -108,6 -109,6 +115,24 @@@ extend a clip, a reference video needs
with room for another, and a conditioning clip needs a model that generates in the
requested role.
++### Send Image and Append Image
++
++`POST /api/v1/recall/video/{queue_id}/image`
++
++| Query parameter | Default | Meaning |
++|---|---|---|
++| `image_name` | required | A gallery image the caller can read, 1–255 characters |
++| `append` | `false` | `false` (Send) replaces the panel's images; `true` (Append) adds the image after them |
++
++The backend cannot know which model the user's panel holds, so the response only
++confirms that the request was delivered; where the image lands, or why it was
++declined, is reported to the user in the panel. See
++[Frontend behavior](#frontend-behavior). There is no upload variant: upload the image
++with `POST /api/v1/images/upload` first, then send its name.
++
++Clients can feature-detect this route by looking for the `recall_video_image`
++operation in `/openapi.json`.
++
## Frontend behavior
webv2 applies each event, in arrival order, to the Video panel of the project that
@@@ -154,6 -157,6 +181,23 @@@ in a text field; the notification stil
file, whose picture is only a placeholder. Other settings are not changed to fit
the clip: a two-stage resolution, or a clip whose length falls outside the
model's frame range, still has to be fixed before the panel can generate.
++- **Send Image / Append Image** place the image according to the panel's model,
++ which is never switched to make it fit:
++
++ | Panel model | Send (`append=false`) | Append (`append=true`) |
++ |---|---|---|
++ | Takes reference images (MiniMax H3 Ref2VA) | Replaces the reference images; reference videos stay | Added after the references; declined when all nine image slots are taken |
++ | Takes frames (Wan I2V, LTX-2, MiniMax H3 FL2VA) | Becomes the first frame; the last frame is cleared | Fills the first frame when it is empty, otherwise the last frame; declined once both are set, or once the first is set on a model without a last frame |
++ | Takes no images (e.g. Wan T2V) | Declined | Declined |
++
++ Placement follows the panel's own fields. A reference image displaces the frame
++ slots and a conditioning clip, and the initial video too unless the panel
++ extends from its references, in which case the clip's continuity reference stays
++ last. A first frame displaces the initial video, and an initial video counts as
++ the first frame when appending. A frame displaces a conditioning clip in the
++ `video` role; a clip in the `audio` role stays, anchored by the frame. When
++ placing the image clears a conditioning clip or an initial video, the
++ notification says so.
The gallery's context menu offers the same *Extend in Video*, *Use as Reference
Video* and *Use as Conditioning Clip* actions for any video in the gallery.
@@@ -253,6 -256,6 +297,10 @@@ curl -X POST "http://localhost:9090/api
# Generate an LTX-2 picture for a song's soundtrack
curl -X POST "http://localhost:9090/api/v1/recall/video/default/conditioning-video/upload?role=audio" \
++
++# Use a gallery image as the first frame, then append another as the last frame
++curl -X POST "http://localhost:9090/api/v1/recall/video/default/image?image_name=0b6f….png"
++curl -X POST "http://localhost:9090/api/v1/recall/video/default/image?image_name=9d2a….png&append=true"
```
In multi-user mode, add `-H "Authorization: Bearer <token>"`.
@@@ -300,6 -303,6 +348,15 @@@ Send Video / Use as Ref Video / Use as
`video` is the gallery video's full record.
++Send Image / Append Image:
++
++```json
++{ "status": "success", "queue_id": "default", "image": { "image_name": "…", "width": 832, "height": 480 }, "append": false }
++```
++
++`success` means the request reached the user's panel, not that the image was
++placed; a decline is reported only in the panel.
++
## Errors
| Status | Cause |
@@@ -307,8 -310,8 +364,8 @@@
| `401` | Multi-user mode without a valid token |
| `400` | The upload ended before its body was complete |
| `403` | The caller may not read a referenced image or video, or may not add media to `board_id` |
--| `404` | `video_name` (Send Video / Use as Ref Video / Use as Conditioning Clip) is not in the gallery, or `board_id` does not exist |
--| `409` | Image storage maintenance is running (Recall / Remix) |
++| `404` | `video_name` (Send Video / Use as Ref Video / Use as Conditioning Clip) or `image_name` (Send Image / Append Image) is not in the gallery, or `board_id` does not exist |
++| `409` | Image storage maintenance is running (Recall / Remix, Send Image / Append Image) |
| `413` | The upload exceeds the video upload size limit |
| `415` | The upload is not a supported video or audio file, or could not be converted |
| `422` | Malformed JSON or multipart body, an unknown field, a value out of bounds, a missing or unknown `role` (Use as Conditioning Clip), or `metadata` that is not a JSON object |
@@@ -323,12 -326,12 +380,14 @@@
|---|---|---|
| `queue_id` | string | From the request path |
| `user_id` | string | The caller |
--| `action` | `"parameters"` \| `"initial_video"` \| `"reference_video"` \| `"conditioning_video"` | What to do |
++| `action` | `"parameters"` \| `"initial_video"` \| `"reference_video"` \| `"conditioning_video"` \| `"image"` | What to do |
| `mode` | `"recall"` \| `"remix"` \| null | `parameters` only |
| `strict` | boolean | `parameters` only |
| `parameters` | object \| null | `parameters` only: the resolved fields, with models as `{key, hash, name, base, type}` |
--| `video` | object \| null | Placements only: `{video_name, width, height, duration, fps, media_origin}` |
++| `video` | object \| null | Video placements only: `{video_name, width, height, duration, fps, media_origin}` |
| `conditioning_role` | `"audio"` \| `"video"` \| null | `conditioning_video` only: which stream of `video` is the condition |
++| `image` | object \| null | `image` only: `{image_name, width, height}` |
++| `append` | boolean | `image` only: add to the panel's images instead of replacing them; always `false` for other actions |
## Implementation
diff --cc invokeai/frontend/webv2/src/features/video/index.ts
index e57f973dc3,463d11afee..f90d9fb2cf
--- a/invokeai/frontend/webv2/src/features/video/index.ts
+++ b/invokeai/frontend/webv2/src/features/video/index.ts
@@@ -22,12 -22,15 +22,17 @@@ export
createVideoSourceClip,
getDefaultConditioningRole,
getDefaultReferenceConditioning,
+ getDefaultReferenceImageDetail,
+ areFrameImagesHeld,
+ createFrameImageSetter,
getConditioningClipPatch,
+ getFrameImagePatch,
getInitialVideoPatch,
getReferencesPatch,
+ isConditioningClipExcludingFrames,
isImageWithDims,
isVideoAspectRatioId,
++ isVideoConditioningClip,
isVideoReferenceConditioning,
isVideoReferenceItem,
isVideoSettings,
diff --cc invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts
index 3feec39628,310c52046c..ab586ca9ff
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts
@@@ -1,7 -1,7 +1,11 @@@
import type { ModelConfig } from '@features/models';
import type { VideoReferenceItem } from '@features/video';
--import { createDefaultVideoWidgetValues, createVideoReferenceEntry } from '@features/video';
++import {
++ createDefaultVideoWidgetValues,
++ createVideoConditioningClip,
++ createVideoReferenceEntry,
++} from '@features/video';
import { describe, expect, it } from 'vitest';
import {
@@@ -240,167 -253,3 +259,201 @@@ describe('placeConditioningClip', () =
});
});
});
+
+describe('placeVideoImage', () => {
+ const still = (name: string) => ({ height: 512, image_name: name, width: 512 });
+ const imageReference = (name: string): VideoReferenceItem => ({ detail: 'match', image: still(name), kind: 'image' });
+ const referenceNames = (placement: ReturnType<typeof placeVideoImage>) =>
+ (placement.status === 'placed' ? (placement.patch.references ?? []) : []).map((entry) =>
+ entry.kind === 'image' ? entry.image.image_name : entry.clip.video_name
+ );
+
+ describe('on a model that takes reference images', () => {
+ const held = [imageReference('a.png'), videoReference('dance.mp4'), imageReference('b.png')];
+
+ it('replaces the reference images, keeping the reference videos', () => {
+ const placement = placeVideoImage({
+ append: false,
+ image: still('new.png'),
+ models: [REF2VA],
+ videoValues: panel(REF2VA, { references: held }),
+ });
+
+ expect(placement).toMatchObject({ slot: 'reference', status: 'placed' });
+ expect(referenceNames(placement)).toEqual(['dance.mp4', 'new.png']);
+ });
+
+ it('appends after the held references, with the detail a later image defaults to', () => {
+ const placement = placeVideoImage({
+ append: true,
+ image: still('new.png'),
+ models: [REF2VA],
+ videoValues: panel(REF2VA, { references: held }),
+ });
+
+ expect(referenceNames(placement)).toEqual(['a.png', 'dance.mp4', 'b.png', 'new.png']);
+ expect(placement.status === 'placed' && placement.patch.references?.at(-1)).toMatchObject({ detail: 'match' });
+ });
+
+ it('gives the first reference image max detail', () => {
+ const placement = placeVideoImage({
+ append: false,
+ image: still('new.png'),
+ models: [REF2VA],
+ videoValues: panel(REF2VA, { references: held }),
+ });
+
+ expect(placement.status === 'placed' && placement.patch.references?.at(-1)).toMatchObject({ detail: 'max' });
+ });
+
+ it('keeps a reference-extend continuity anchor last', () => {
+ const anchor: VideoReferenceItem = { ...videoReference('source.mp4'), fromSourceVideo: true };
+ const placement = placeVideoImage({
+ append: true,
+ image: still('new.png'),
+ models: [REF2VA],
+ videoValues: panel(REF2VA, { references: [anchor] }),
+ });
+
+ expect(referenceNames(placement)).toEqual(['new.png', 'source.mp4']);
+ });
+
+ it('declines an append when every image slot is taken, but a send still replaces them', () => {
+ const videoValues = panel(REF2VA, {
+ references: Array.from({ length: 9 }, (_, index) => imageReference(`${index}.png`)),
+ });
+
+ expect(placeVideoImage({ append: true, image: still('new.png'), models: [REF2VA], videoValues })).toEqual({
+ status: 'full',
+ });
+ expect(
+ referenceNames(placeVideoImage({ append: false, image: still('new.png'), models: [REF2VA], videoValues }))
+ ).toEqual(['new.png']);
+ });
+ });
+
+ describe('on a model that takes frames', () => {
+ const first = { height: 480, image_name: 'first.png', width: 832 };
+ const last = { height: 480, image_name: 'last.png', width: 832 };
+
+ it('sends the image as the first frame, clearing the last frame and the initial video', () => {
+ const placement = placeVideoImage({
+ append: false,
+ image: still('new.png'),
+ models: [WAN_I2V],
+ videoValues: panel(WAN_I2V, { lastFrameImage: last, sourceVideo: { ...videoReference('source.mp4').clip } }),
+ });
+
+ expect(placement).toEqual({
+ displaced: true,
+ patch: {
- conditioningClip: null,
+ firstFrameImage: still('new.png'),
+ lastFrameImage: null,
+ references: [],
+ sourceVideo: null,
+ },
+ slot: 'firstFrame',
+ status: 'placed',
+ });
+ });
+
+ it('appends into the first frame, then the last, then declines', () => {
+ let videoValues = panel(WAN_I2V);
+ const slots: string[] = [];
+
+ for (const name of ['one.png', 'two.png', 'three.png']) {
+ const placement = placeVideoImage({ append: true, image: still(name), models: [WAN_I2V], videoValues });
+
+ slots.push(placement.status === 'placed' ? placement.slot : placement.status);
+ videoValues = placement.status === 'placed' ? { ...videoValues, ...placement.patch } : videoValues;
+ }
+
+ expect(slots).toEqual(['firstFrame', 'lastFrame', 'full']);
+ expect(videoValues).toMatchObject({ firstFrameImage: still('one.png'), lastFrameImage: still('two.png') });
+ });
+
+ it('appends into the last frame beside an initial video, which holds the first', () => {
+ const placement = placeVideoImage({
+ append: true,
+ image: still('new.png'),
+ models: [WAN_I2V],
+ videoValues: panel(WAN_I2V, { sourceVideo: { ...videoReference('source.mp4').clip } }),
+ });
+
+ expect(placement).toEqual({
+ displaced: false,
- patch: { conditioningClip: null, lastFrameImage: still('new.png') },
++ patch: { lastFrameImage: still('new.png') },
+ slot: 'lastFrame',
+ status: 'placed',
+ });
+ });
+
+ it('declines an appended second frame on a model without a last frame', () => {
+ expect(
+ placeVideoImage({
+ append: true,
+ image: still('new.png'),
+ models: [WAN_TI2V],
+ videoValues: panel(WAN_TI2V, { firstFrameImage: first }),
+ })
+ ).toEqual({ status: 'full' });
+ });
+
- it('clears a conditioning clip, as the frame fields do', () => {
- const placement = placeVideoImage({
- append: true,
- image: still('new.png'),
- models: [LTX2],
- videoValues: panel(LTX2),
- });
++ it('clears a clip that holds the picture, as the frame fields do, but keeps a soundtrack', () => {
++ const pictureClip = { ...createVideoConditioningClip(clip), role: 'video' as const };
++ const soundtrack = { ...createVideoConditioningClip(clip), role: 'audio' as const };
++
++ for (const append of [false, true]) {
++ expect(
++ placeVideoImage({
++ append,
++ image: still('new.png'),
++ models: [LTX2],
++ videoValues: panel(LTX2, { conditioningClip: pictureClip }),
++ })
++ ).toMatchObject({ displaced: true, patch: { conditioningClip: null, firstFrameImage: still('new.png') } });
++
++ const kept = placeVideoImage({
++ append,
++ image: still('new.png'),
++ models: [LTX2],
++ videoValues: panel(LTX2, { conditioningClip: soundtrack }),
++ });
+
- expect(placement).toMatchObject({ patch: { conditioningClip: null, firstFrameImage: still('new.png') } });
++ expect(kept).toMatchObject({ displaced: false, patch: { firstFrameImage: still('new.png') } });
++ expect(kept.status === 'placed' && 'conditioningClip' in kept.patch).toBe(false);
++ }
++ });
++
++ it('clears a picture clip hidden behind the first frame when appending the last', () => {
++ const pictureClip = { ...createVideoConditioningClip(clip), role: 'video' as const };
++
++ // Normalization hides the stored clip behind the first frame; left stored, it would resurface beside the last
++ // frame once the first is cleared. It was never on screen, so it isn't reported as displaced.
++ expect(
++ placeVideoImage({
++ append: true,
++ image: still('new.png'),
++ models: [LTX2],
++ videoValues: panel(LTX2, { conditioningClip: pictureClip, firstFrameImage: first }),
++ })
++ ).toEqual({
++ displaced: false,
++ patch: { conditioningClip: null, lastFrameImage: still('new.png') },
++ slot: 'lastFrame',
++ status: 'placed',
++ });
+ });
+ });
+
+ it('declines, rather than switching models, when the panel model takes no images', () => {
+ expect(
+ placeVideoImage({
+ append: false,
+ image: still('new.png'),
+ models: [WAN_T2V, WAN_I2V],
+ videoValues: panel(WAN_T2V),
+ })
+ ).toEqual({ status: 'unsupported' });
+ });
+});
diff --cc invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
index 9a345a1bce,346533ec72..6a6d126dae
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
@@@ -19,10 -18,11 +19,13 @@@ import
createVideoSourceClip,
getConditioningClipPatch,
getDefaultReferenceConditioning,
+ getDefaultReferenceImageDetail,
+ getFrameImagePatch,
getInitialVideoPatch,
getReferencesPatch,
getVideoModelPolicy,
+ isConditioningClipExcludingFrames,
++ isVideoConditioningClip,
isVideoReferenceConditioning,
normalizeVideoWidgetValues,
syncVideoWidgetValuesWithModels,
@@@ -603,102 -614,6 +617,104 @@@ export const appendReferenceVideo = (
};
};
+export type VideoImagePlacement =
+ | {
+ /** Whether placing the image cleared media it can't be used with: a conditioning clip or an initial video. */
+ displaced: boolean;
+ patch: Partial<VideoWidgetValues>;
+ slot: 'firstFrame' | 'lastFrame' | 'reference';
+ status: 'placed';
+ }
+ /** `full`: an append found every image slot the model takes already in use. */
+ | { status: 'full' | 'unsupported' };
+
+/**
+ * Place a gallery image where the Video panel's model takes images. A model with reference images gets it as one:
+ * it replaces the reference images (reference videos stay), or with `append` joins them. A frame model gets it as
+ * the first frame, clearing the last, as if the frames were a two-image list; with `append` it fills the first free
+ * frame slot, and an initial video holds the first. The panel's model is never switched to make the image fit.
+ */
+export const placeVideoImage = ({
+ append,
+ image,
+ models,
+ videoValues,
+}: {
+ append: boolean;
+ image: ImageWithDims;
+ models: readonly ModelConfig[];
+ videoValues: Record<string, unknown>;
+}): VideoImagePlacement => {
+ const values = getCurrentVideoValues({ models, videoValues });
+ const policy = values.model ? getVideoModelPolicy(values.model, values) : null;
+
+ if (!policy) {
+ return { status: 'unsupported' };
+ }
+
+ if (policy.references && policy.modes.includes('reference')) {
+ const kept = append ? values.references : values.references.filter((entry) => entry.kind === 'video');
+
+ if (kept.filter((entry) => entry.kind === 'image').length >= policy.references.maxImages) {
+ return { status: 'full' };
+ }
+ const referenceExtend = Boolean(policy.references.extend);
+
+ return {
+ displaced: Boolean(values.conditioningClip || (values.sourceVideo && !referenceExtend)),
+ patch: getReferencesPatch({
+ referenceExtend,
+ references: [...kept, { detail: getDefaultReferenceImageDetail(kept), image, kind: 'image' }],
+ }),
+ slot: 'reference',
+ status: 'placed',
+ };
+ }
+
+ const takesFirstFrame = policy.modes.includes('first-frame') || policy.modes.includes('first-last');
+
+ if (!takesFirstFrame) {
+ return { status: 'unsupported' };
+ }
+
- // The same displacements as the panel's own frame fields: a first frame shares its slot with the initial video,
- // and either frame clears a conditioning clip.
++ // Through the panel's own frame patch: a first frame displaces the initial video, and either frame displaces a
++ // clip that holds the picture, while a soundtrack stays to be anchored by it. The stored clip, not the normalized
++ // one, which hides a picture-role clip behind a first frame; only a visible clip is reported as displaced.
++ const storedClip = isVideoConditioningClip(videoValues.conditioningClip) ? videoValues.conditioningClip : null;
++ const clipDisplaced = isConditioningClipExcludingFrames(values.conditioningClip);
++
+ if (!append) {
+ return {
- displaced: Boolean(values.conditioningClip || values.sourceVideo),
++ displaced: Boolean(clipDisplaced || values.sourceVideo),
+ patch: {
- conditioningClip: null,
- firstFrameImage: image,
++ ...getFrameImagePatch('firstFrameImage', image, storedClip),
+ lastFrameImage: null,
+ references: [],
- sourceVideo: null,
+ },
+ slot: 'firstFrame',
+ status: 'placed',
+ };
+ }
+ if (!values.firstFrameImage && !values.sourceVideo) {
+ return {
- displaced: Boolean(values.conditioningClip),
- patch: { conditioningClip: null, firstFrameImage: image, references: [] },
++ displaced: clipDisplaced,
++ patch: { ...getFrameImagePatch('firstFrameImage', image, storedClip), references: [] },
+ slot: 'firstFrame',
+ status: 'placed',
+ };
+ }
+ if (!values.lastFrameImage && policy.modes.includes('first-last')) {
+ return {
- displaced: Boolean(values.conditioningClip),
- patch: { conditioningClip: null, lastFrameImage: image },
++ displaced: clipDisplaced,
++ patch: getFrameImagePatch('lastFrameImage', image, storedClip),
+ slot: 'lastFrame',
+ status: 'placed',
+ };
+ }
+
+ return { status: 'full' };
+};
+
/** The generation mode a conditioning clip in each role asks of the model. */
const CONDITIONING_ROLE_MODE = {
audio: 'audio-to-video',
diff --cc invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts
index a2f405237c,5db1da509a..9032a5f512
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts
@@@ -460,88 -494,6 +503,101 @@@ describe('createVideoRecallRuntime', (
runtime.dispose();
});
+ const imageEvent = (append: boolean, image_name = 'still.png') => ({
+ action: 'image',
+ append,
+ image: { height: 512, image_name, width: 512 },
+ queue_id: 'default',
+ user_id: 'owner',
+ });
+
+ it('sends an image as a Ref2VA reference image and appends the next one', async () => {
+ const { lastNotice, runtime, socket, videoShown, videoValues } = setup(REF2VA);
+
+ socket.emit(imageEvent(false, 'a.png'));
+ await flush();
+ socket.emit(imageEvent(true, 'b.png'));
+ await flush();
+
+ expect(videoValues().references).toEqual([
+ { detail: 'max', image: { height: 512, image_name: 'a.png', width: 512 }, kind: 'image' },
+ { detail: 'match', image: { height: 512, image_name: 'b.png', width: 512 }, kind: 'image' },
+ ]);
+ expect(lastNotice()).toMatchObject({ kind: 'success', title: 'widgets.video.placement.referenceImageAdded' });
+ expect(videoShown()).toBe(true);
+
+ runtime.dispose();
+ });
+
+ it('sends an image as the first frame of a frame model and appends the last frame', async () => {
+ const { lastNotice, runtime, socket, videoValues } = setup();
+
+ socket.emit(imageEvent(false, 'first.png'));
+ await flush();
+ expect(videoValues()).toMatchObject({ firstFrameImage: { image_name: 'first.png' }, lastFrameImage: null });
+ expect(lastNotice()).toMatchObject({ title: 'widgets.video.placement.firstFrameSet' });
+
+ socket.emit(imageEvent(true, 'last.png'));
+ await flush();
+ expect(videoValues()).toMatchObject({
+ firstFrameImage: { image_name: 'first.png' },
+ lastFrameImage: { image_name: 'last.png' },
+ });
+ expect(lastNotice()).toMatchObject({ title: 'widgets.video.placement.lastFrameSet' });
+
+ runtime.dispose();
+ });
+
- it('says so when an image clears a conditioning clip', async () => {
++ it('says so when an image clears a picture clip, and keeps a soundtrack quietly', async () => {
+ const { lastNotice, runtime, socket, videoValues } = setup(LTX2);
- socket.emit({ ...placementEvent('conditioning_video'), conditioning_role: 'audio' });
++ socket.emit({ ...placementEvent('conditioning_video'), conditioning_role: 'video' });
+ await flush();
- expect(videoValues()).toMatchObject({ conditioningClip: { role: 'audio' } });
++ expect(videoValues()).toMatchObject({ conditioningClip: { role: 'video' } });
+
+ socket.emit(imageEvent(true));
+ await flush();
+
+ expect(videoValues()).toMatchObject({ conditioningClip: null, firstFrameImage: { image_name: 'still.png' } });
+ expect(lastNotice()).toMatchObject({
+ kind: 'info',
+ message: 'widgets.video.placement.imageDisplaced',
+ title: 'widgets.video.placement.firstFrameSet',
+ });
+
++ // A soundtrack is anchored by the frames, so the next image lands beside it.
++ socket.emit({ ...placementEvent('conditioning_video'), conditioning_role: 'audio' });
++ await flush();
++ socket.emit(imageEvent(true, 'last.png'));
++ await flush();
++
++ expect(videoValues()).toMatchObject({
++ conditioningClip: { role: 'audio' },
++ firstFrameImage: { image_name: 'still.png' },
++ lastFrameImage: { image_name: 'last.png' },
++ });
++ expect(lastNotice()).toMatchObject({ kind: 'success', title: 'widgets.video.placement.lastFrameSet' });
++
+ runtime.dispose();
+ });
+
+ it.each([
+ [WAN_T2V, false, 'widgets.video.placement.imageUnsupported'],
+ [WAN_I2V, true, 'widgets.video.placement.imageFull'],
+ ])('declines an image with nowhere to go, leaving the panel alone', async (panelModel, append, message) => {
+ const { lastNotice, projectId, runtime, socket, store, videoShown, videoValues } = setup(panelModel);
+ store.commands.widgets.patchValues('video', { lastFrameImage: heldFrame }, projectId);
+ const before = videoValues();
+
+ socket.emit(imageEvent(append));
+ await flush();
+
+ expect(videoValues()).toBe(before);
+ expect(lastNotice()).toMatchObject({ kind: 'info', message, title: 'widgets.video.placement.imageNotPlaced' });
+ expect(videoShown()).toBe(false);
+
+ runtime.dispose();
+ });
+
it('declines an initial video a Ref2VA panel has no reference slot to anchor', async () => {
const { lastNotice, runtime, socket, videoValues } = setup(REF2VA);