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.

fix(video): clear stale references when appending a frame from recall

Lincoln Stein07dd8f49a4f8
diff --git a/docs/src/content/docs/development/Guides/video-recall-api.mdx b/docs/src/content/docs/development/Guides/video-recall-api.mdx
index 55154eaa7e..6d4aec3d16 100644
--- a/docs/src/content/docs/development/Guides/video-recall-api.mdx
+++ b/docs/src/content/docs/development/Guides/video-recall-api.mdx
@@ -125,7 +125,7 @@ requested role.
| `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
+confirms that the event was emitted to the user; 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.
@@ -354,8 +354,9 @@ Send Image / Append Image:
{ "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.
+`success` means the event was emitted to the user's open sessions. It is not an
+acknowledgement: nothing is placed when no webv2 session is open, and a decline is
+reported only in the panel.
## Errors
diff --git a/invokeai/app/api/routers/video_recall.py b/invokeai/app/api/routers/video_recall.py
index 53c54ddebf..a404475845 100644
--- a/invokeai/app/api/routers/video_recall.py
+++ b/invokeai/app/api/routers/video_recall.py
@@ -736,8 +736,8 @@ def recall_video_image(
"""Place a gallery image in the current user's Video panel, where the panel's model takes images.
A model that takes reference images (e.g. MiniMax H3 Ref2VA) gets it as a reference: it replaces the reference
- images, or with `append` joins them. A model that takes frames (e.g. Wan, LTX-2) gets it as the first frame,
- clearing the last; with `append` it fills the first free frame slot, and is ignored when both are set. The
+ images, or with `append` joins them. A model that takes frames (e.g. Wan I2V, LTX-2) gets it as the first frame,
+ clearing the last; with `append` it fills the first free frame slot, and is declined when both are set. The
panel's model decides, so the outcome is reported to the user there rather than in this response.
"""
assert_image_move_maintenance_inactive()
diff --git a/invokeai/frontend/api/openapi.json b/invokeai/frontend/api/openapi.json
index 248dc58f4d..29ac9141c6 100644
--- a/invokeai/frontend/api/openapi.json
+++ b/invokeai/frontend/api/openapi.json
@@ -16711,7 +16711,7 @@
"post": {
"tags": ["recall"],
"summary": "Recall Video Image",
- "description": "Place a gallery image in the current user's Video panel, where the panel's model takes images.\n\nA model that takes reference images (e.g. MiniMax H3 Ref2VA) gets it as a reference: it replaces the reference\nimages, or with `append` joins them. A model that takes frames (e.g. Wan, LTX-2) gets it as the first frame,\nclearing the last; with `append` it fills the first free frame slot, and is ignored when both are set. The\npanel's model decides, so the outcome is reported to the user there rather than in this response.",
+ "description": "Place a gallery image in the current user's Video panel, where the panel's model takes images.\n\nA model that takes reference images (e.g. MiniMax H3 Ref2VA) gets it as a reference: it replaces the reference\nimages, or with `append` joins them. A model that takes frames (e.g. Wan I2V, LTX-2) gets it as the first frame,\nclearing the last; with `append` it fills the first free frame slot, and is declined when both are set. The\npanel's model decides, so the outcome is reported to the user there rather than in this response.",
"operationId": "recall_video_image",
"security": [
{
diff --git a/invokeai/frontend/api/schema.ts b/invokeai/frontend/api/schema.ts
index 29c8bb4e5d..cc83af75fe 100644
--- a/invokeai/frontend/api/schema.ts
+++ b/invokeai/frontend/api/schema.ts
@@ -4306,8 +4306,8 @@ export type paths = {
* @description Place a gallery image in the current user's Video panel, where the panel's model takes images.
*
* A model that takes reference images (e.g. MiniMax H3 Ref2VA) gets it as a reference: it replaces the reference
- * images, or with `append` joins them. A model that takes frames (e.g. Wan, LTX-2) gets it as the first frame,
- * clearing the last; with `append` it fills the first free frame slot, and is ignored when both are set. The
+ * images, or with `append` joins them. A model that takes frames (e.g. Wan I2V, LTX-2) gets it as the first frame,
+ * clearing the last; with `append` it fills the first free frame slot, and is declined when both are set. The
* panel's model decides, so the outcome is reported to the user there rather than in this response.
*/
post: operations["recall_video_image"];
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts
index ab586ca9ff..9599e48d22 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.placement.test.ts
@@ -382,12 +382,42 @@ describe('placeVideoImage', () => {
expect(placement).toEqual({
displaced: false,
- patch: { lastFrameImage: still('new.png') },
+ patch: { lastFrameImage: still('new.png'), references: [] },
slot: 'lastFrame',
status: 'placed',
});
});
+ it('clears stale references that would hide an appended frame, and the last frame they hid', () => {
+ const staleReferences = [{ detail: 'max' as const, image: still('ref.png'), kind: 'image' as const }];
+ const afterFirst = placeVideoImage({
+ append: true,
+ image: still('new.png'),
+ models: [LTX2],
+ videoValues: panel(LTX2, { lastFrameImage: last, references: staleReferences }),
+ });
+
+ expect(afterFirst).toMatchObject({
+ patch: { firstFrameImage: still('new.png'), lastFrameImage: null, references: [] },
+ slot: 'firstFrame',
+ });
+
+ const afterLast = placeVideoImage({
+ append: true,
+ image: still('new.png'),
+ models: [LTX2],
+ videoValues: panel(LTX2, {
+ references: staleReferences,
+ sourceVideo: { ...videoReference('source.mp4').clip },
+ }),
+ });
+
+ expect(afterLast).toMatchObject({
+ patch: { lastFrameImage: still('new.png'), references: [] },
+ slot: 'lastFrame',
+ });
+ });
+
it('declines an appended second frame on a model without a last frame', () => {
expect(
placeVideoImage({
@@ -439,7 +469,7 @@ describe('placeVideoImage', () => {
})
).toEqual({
displaced: false,
- patch: { conditioningClip: null, lastFrameImage: still('new.png') },
+ patch: { conditioningClip: null, lastFrameImage: still('new.png'), references: [] },
slot: 'lastFrame',
status: 'placed',
});
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
index 6a6d126dae..9a2e6cda90 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/executeVideoRecall.ts
@@ -698,7 +698,12 @@ export const placeVideoImage = ({
if (!values.firstFrameImage && !values.sourceVideo) {
return {
displaced: clipDisplaced,
- patch: { ...getFrameImagePatch('firstFrameImage', image, storedClip), references: [] },
+ // The visible last frame stays; one hidden behind stale references is cleared rather than resurfaced.
+ patch: {
+ ...getFrameImagePatch('firstFrameImage', image, storedClip),
+ lastFrameImage: values.lastFrameImage,
+ references: [],
+ },
slot: 'firstFrame',
status: 'placed',
};
@@ -706,7 +711,7 @@ export const placeVideoImage = ({
if (!values.lastFrameImage && policy.modes.includes('first-last')) {
return {
displaced: clipDisplaced,
- patch: getFrameImagePatch('lastFrameImage', image, storedClip),
+ patch: { ...getFrameImagePatch('lastFrameImage', image, storedClip), references: [] },
slot: 'lastFrame',
status: 'placed',
};