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(webv2): keep node-boarded workflow images off the selected board

Josh Corbett5b83931e4969
diff --git a/invokeai/frontend/webv2/src/features/gallery/core/types.ts b/invokeai/frontend/webv2/src/features/gallery/core/types.ts
index da7163f7f7..35490875de 100644
--- a/invokeai/frontend/webv2/src/features/gallery/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/core/types.ts
@@ -1,4 +1,6 @@
export interface GeneratedImageContract {
+ /** Board the backend saved the image to, when known. */
+ boardId?: string;
/** Backend creation timestamp, when known; `queuedAt` is the (earlier)
* submission instant, so ordering must prefer this field. */
createdAt?: string;
diff --git a/invokeai/frontend/webv2/src/features/queue/core/types.ts b/invokeai/frontend/webv2/src/features/queue/core/types.ts
index 8096d9705c..beb5f67e30 100644
--- a/invokeai/frontend/webv2/src/features/queue/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/queue/core/types.ts
@@ -119,6 +119,8 @@ export interface QueueBackendItem {
}
export interface QueueResultImage {
+ /** Board the backend saved the image to (a node's explicit board); unset when uncategorized. */
+ boardId?: string;
/** Backend creation timestamp; `queuedAt` is the submission instant. */
createdAt?: string;
height: number;
diff --git a/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts b/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts
index eda6b43f45..4b2230a476 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/serverTypes.ts
@@ -35,6 +35,7 @@ export interface QueueServerItemDTO {
}
export interface QueueImageDTO {
+ board_id: string | null;
created_at: string;
height: number;
image_name: string;
diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
index da840c1574..4c9e1d39cb 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
@@ -187,6 +187,7 @@ const getResultImage = async (
const image = await apiFetchJson<QueueImageDTO>(`/api/v1/images/i/${encodeURIComponent(imageName)}`, { signal });
return {
+ ...(image.board_id ? { boardId: image.board_id } : {}),
createdAt: normalizeServerTimestamp(image.created_at),
height: image.height,
imageName: image.image_name,
diff --git a/invokeai/frontend/webv2/src/features/queue/runtime.test.ts b/invokeai/frontend/webv2/src/features/queue/runtime.test.ts
index 2800e6e5ca..8ae3947ab9 100644
--- a/invokeai/frontend/webv2/src/features/queue/runtime.test.ts
+++ b/invokeai/frontend/webv2/src/features/queue/runtime.test.ts
@@ -2152,6 +2152,52 @@ describe('queue runtime video board routing', () => {
runtime.dispose();
});
+
+ it('leaves an image on the board its node saved it to and attaches only unassigned images', async () => {
+ // A workflow node with an explicit board writes the image there server-side; re-attaching
+ // it to the active board would move it, and the recents overlay must show its real board.
+ const nodeBoardImage = { ...resultImage('node-board.png'), boardId: 'board-b' };
+ const { commands, destinations, runtime } = createHarness({
+ getResultImages: vi.fn().mockResolvedValue([nodeBoardImage, resultImage('unassigned.png')]),
+ getResultVideoNames: vi.fn().mockResolvedValue([]),
+ });
+
+ runtime.start();
+
+ await vi.waitFor(() => {
+ expect(destinations.addImagesToGalleryBoard).toHaveBeenCalledWith('board-1', ['unassigned.png']);
+ expect(commands.routeResults).toHaveBeenCalledWith(
+ expect.objectContaining({
+ images: [
+ expect.objectContaining({ boardId: 'board-b' }),
+ expect.objectContaining({ imageName: 'unassigned.png' }),
+ ],
+ })
+ );
+ });
+ expect(destinations.addImagesToGalleryBoard).not.toHaveBeenCalledWith(
+ expect.anything(),
+ expect.arrayContaining(['node-board.png'])
+ );
+
+ runtime.dispose();
+ });
+
+ it('skips the board attach call when every image already has a board', async () => {
+ const { commands, destinations, runtime } = createHarness({
+ getResultImages: vi.fn().mockResolvedValue([{ ...resultImage('node-board.png'), boardId: 'board-b' }]),
+ getResultVideoNames: vi.fn().mockResolvedValue([]),
+ });
+
+ runtime.start();
+
+ await vi.waitFor(() => {
+ expect(commands.routeResults).toHaveBeenCalled();
+ });
+ expect(destinations.addImagesToGalleryBoard).not.toHaveBeenCalled();
+
+ runtime.dispose();
+ });
});
describe('queue runtime workflow run capture', () => {
diff --git a/invokeai/frontend/webv2/src/features/queue/runtime.ts b/invokeai/frontend/webv2/src/features/queue/runtime.ts
index 32ee5f3bd4..35cd1bcac7 100644
--- a/invokeai/frontend/webv2/src/features/queue/runtime.ts
+++ b/invokeai/frontend/webv2/src/features/queue/runtime.ts
@@ -778,14 +778,16 @@ export const createQueueRuntime = ({
scheduleResultReadFlush();
});
- const addImagesToDestination = async (queueItem: QueueItem, imageNames: string[]): Promise<void> => {
+ // An image a node saved to its own board stays there; only unassigned images land on the active board.
+ const addImagesToDestination = async (queueItem: QueueItem, images: QueueResultImage[]): Promise<void> => {
if (!isActive() || queueItem.snapshot.destination !== 'gallery') {
return;
}
const boardId = queueItem.snapshot.galleryBoardId;
+ const imageNames = images.filter((image) => !image.boardId).map((image) => image.imageName);
- if (boardId && boardId !== 'none') {
+ if (boardId && boardId !== 'none' && imageNames.length > 0) {
await destinations.addImagesToGalleryBoard(boardId, imageNames);
}
};
@@ -874,10 +876,7 @@ export const createQueueRuntime = ({
? producedImages.filter((image) => !image.isIntermediate)
: producedImages;
- await addImagesToDestination(
- queueItem,
- images.map((image) => image.imageName)
- );
+ await addImagesToDestination(queueItem, images);
return images;
};
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 489d32a338..00962e76da 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -4066,6 +4066,29 @@ describe('workbenchReducer Phase 5 generation flow', () => {
});
});
+ it('keeps the board a result image was saved to instead of the run destination board', () => {
+ let state = primeGenerate();
+
+ state = workbenchReducer(state, { boardId: 'board-1', type: 'selectGalleryBoard' });
+ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });
+ state = submitGenerate(state);
+
+ const project = getActiveProject(state);
+ const queueItem = project.queue.items[0];
+ const image = { ...createImage('node-board-image.png', queueItem.id), boardId: 'board-b' };
+ state = workbenchReducer(state, {
+ images: [image],
+ projectId: project.id,
+ queueItemId: queueItem.id,
+ type: 'routeQueueItemResults',
+ });
+
+ const galleryValues = getProjectWidgetValues(getActiveProject(state), 'gallery');
+
+ expect((galleryValues.recentImages as Array<{ boardId: string }>)[0]?.boardId).toBe('board-b');
+ expect(galleryValues.selectedImage).toMatchObject({ boardId: 'board-b', name: image.imageName });
+ });
+
it('appends Gallery destination results for local fallback while backend owns boards', () => {
let state = primeGenerate();