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): route generated videos to the active board; honor ui_model_format in workflow model fields

Lincoln Stein899106e3f1a4
diff --git a/invokeai/frontend/webv2/src/app/QueueRuntimeAdapter.tsx b/invokeai/frontend/webv2/src/app/QueueRuntimeAdapter.tsx
index 9db0a58e7e..135d84f637 100644
--- a/invokeai/frontend/webv2/src/app/QueueRuntimeAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/QueueRuntimeAdapter.tsx
@@ -27,6 +27,18 @@ export const QueueRuntimeAdapter = () => {
await galleryOrganization.addToBoard(boardId, imageNames, owner.signal);
assertAccountScopeCurrent(owner);
},
+ addVideosToGalleryBoard: async (boardId, videoNames) => {
+ assertAccountScopeCurrent(owner);
+ const { galleryItemOrganization } = await import('@features/gallery');
+
+ assertAccountScopeCurrent(owner);
+ await galleryItemOrganization.moveToBoard(
+ videoNames.map((name) => ({ kind: 'video' as const, name })),
+ boardId,
+ owner.signal
+ );
+ assertAccountScopeCurrent(owner);
+ },
},
ensureTemplatesLoaded: ensureInvocationTemplatesLoaded,
history: {
diff --git a/invokeai/frontend/webv2/src/features/queue/core/types.ts b/invokeai/frontend/webv2/src/features/queue/core/types.ts
index 9fc1f4929d..4ffeb86f9a 100644
--- a/invokeai/frontend/webv2/src/features/queue/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/queue/core/types.ts
@@ -248,6 +248,8 @@ export interface QueueBackendPort extends QueueFeatureCommands {
queuedAt: string,
options?: QueueResultImageOptions
): Promise<QueueResultImage[]>;
+ /** Names of the videos a completed backend item produced (no DTO hydration needed). */
+ getResultVideoNames(itemId: number, options?: QueueResultImageOptions): Promise<string[]>;
listItems(): Promise<QueueBackendItem[]>;
readCurrent(scope?: QueueQueryScope, signal?: AbortSignal): Promise<QueueItemReadModel | null>;
readItemIds(order: 'asc' | 'desc', scope?: QueueQueryScope, signal?: AbortSignal): Promise<QueueItemIdsReadModel>;
diff --git a/invokeai/frontend/webv2/src/features/queue/data/httpRealtimeQueueBackend.ts b/invokeai/frontend/webv2/src/features/queue/data/httpRealtimeQueueBackend.ts
index 2a53660a35..4b78f441d8 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/httpRealtimeQueueBackend.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/httpRealtimeQueueBackend.ts
@@ -22,7 +22,7 @@ import {
retryItemsById,
resumeQueueProcessor,
} from './serverApi';
-import { enqueueGenerate, enqueueWorkflow, getResultImages } from './submissionApi';
+import { enqueueGenerate, enqueueWorkflow, getResultImages, getResultVideoNames } from './submissionApi';
/** Production adapter for the queue backend port. */
export const queueBackend: QueueBackendPort = {
@@ -42,6 +42,7 @@ export const queueBackend: QueueBackendPort = {
enqueueWorkflow,
getItem: async (itemId) => mapQueueBackendItemDTO(await getQueueItem(itemId)),
getResultImages,
+ getResultVideoNames,
listItems: async () => (await listAllQueueItems()).map(mapQueueBackendItemDTO),
on: socketHub.on,
onConnectionChange: socketHub.onConnectionChange,
diff --git a/invokeai/frontend/webv2/src/features/queue/data/queries.test.ts b/invokeai/frontend/webv2/src/features/queue/data/queries.test.ts
index 1f008aa561..0ea4822466 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/queries.test.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/queries.test.ts
@@ -19,6 +19,7 @@ const createBackend = (): QueueBackendPort => ({
enqueueWorkflow: vi.fn(),
getItem: vi.fn(),
getResultImages: vi.fn(),
+ getResultVideoNames: vi.fn().mockResolvedValue([]),
listItems: vi.fn(),
on: vi.fn(),
onConnectionChange: vi.fn(),
diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts
index e04fff0cdd..7349524797 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts
@@ -311,3 +311,55 @@ describe('getResultImages', () => {
expect(mocks.apiFetchJson).toHaveBeenCalledTimes(1);
});
});
+
+describe('getResultVideoNames', () => {
+ beforeEach(() => {
+ accountLifecycle.activate('test-account');
+ mocks.apiFetchJson.mockReset();
+ });
+
+ it('extracts video names from video outputs, ignoring image outputs', async () => {
+ mocks.apiFetchJson.mockResolvedValue({
+ item_id: 1,
+ session: {
+ results: {
+ decode: { image: { image_name: 'frame.png' }, type: 'image_output' },
+ l2v: {
+ duration: 5.17,
+ type: 'video_output',
+ video: { video_name: 'clip-1.mp4' },
+ },
+ l2v_again: { type: 'video_output', video: { video_name: 'clip-1.mp4' } },
+ },
+ },
+ status: 'completed',
+ });
+
+ const { getResultVideoNames } = await import('./submissionApi');
+
+ await expect(getResultVideoNames(1)).resolves.toEqual(['clip-1.mp4']);
+ // Names only — no per-video DTO hydration requests.
+ expect(mocks.apiFetchJson).toHaveBeenCalledTimes(1);
+ });
+
+ it('can restrict video extraction to explicit result node ids', async () => {
+ mocks.apiFetchJson.mockResolvedValue({
+ item_id: 1,
+ session: {
+ prepared_source_mapping: {
+ exec_final: 'final_l2v',
+ exec_intermediate: 'intermediate_l2v',
+ },
+ results: {
+ exec_final: { type: 'video_output', video: { video_name: 'final.mp4' } },
+ exec_intermediate: { type: 'video_output', video: { video_name: 'intermediate.mp4' } },
+ },
+ },
+ status: 'completed',
+ });
+
+ const { getResultVideoNames } = await import('./submissionApi');
+
+ await expect(getResultVideoNames(1, { resultNodeIds: ['final_l2v'] })).resolves.toEqual(['final.mp4']);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
index 564f09cb79..06a8a91ae2 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
@@ -176,3 +176,40 @@ export const getResultImages = async (
assertAccountScopeCurrent(owner);
return images.filter((image): image is QueueResultImage => image !== null);
};
+
+const collectResultVideoNames = (queueItem: QueueServerItemDTO, options?: QueueResultImageOptions): string[] => {
+ const videoNames = new Set<string>();
+ const results = queueItem.session?.results ?? {};
+ const preparedSourceMapping = queueItem.session?.prepared_source_mapping ?? {};
+ const resultValues = options?.resultNodeIds
+ ? Object.entries(results)
+ .filter(([nodeId]) => options.resultNodeIds?.includes(preparedSourceMapping[nodeId] ?? nodeId))
+ .map(([, result]) => result)
+ : Object.values(results);
+
+ for (const result of resultValues) {
+ if (!result || typeof result !== 'object') {
+ continue;
+ }
+
+ // VideoOutput shape: { video: { video_name }, width, height, ... }.
+ const videoName = (result as { video?: { video_name?: unknown } }).video?.video_name;
+ if (typeof videoName === 'string') {
+ videoNames.add(videoName);
+ }
+ }
+
+ return [...videoNames];
+};
+
+/**
+ * The names of the videos a completed backend item produced. Videos need no DTO
+ * hydration here — the queue runtime only routes them onto the destination board.
+ */
+export const getResultVideoNames = async (itemId: number, options?: QueueResultImageOptions): Promise<string[]> => {
+ const owner = captureAccountScope();
+ const item = await getQueueItem(itemId, owner.signal);
+
+ assertAccountScopeCurrent(owner);
+ return collectResultVideoNames(item, options);
+};
diff --git a/invokeai/frontend/webv2/src/features/queue/runtime.test.ts b/invokeai/frontend/webv2/src/features/queue/runtime.test.ts
index fbc8c32599..4459a3c586 100644
--- a/invokeai/frontend/webv2/src/features/queue/runtime.test.ts
+++ b/invokeai/frontend/webv2/src/features/queue/runtime.test.ts
@@ -70,6 +70,7 @@ describe('queue runtime', () => {
enqueueWorkflow: vi.fn(),
getItem: vi.fn(),
getResultImages: vi.fn(),
+ getResultVideoNames: vi.fn().mockResolvedValue([]),
listItems,
on: vi.fn(() => vi.fn()),
onConnectionChange: vi.fn((listener) => {
@@ -101,7 +102,7 @@ describe('queue runtime', () => {
};
const runtime = createQueueRuntime({
backend,
- destinations: { addImagesToGalleryBoard: vi.fn() },
+ destinations: { addImagesToGalleryBoard: vi.fn(), addVideosToGalleryBoard: vi.fn() },
ensureTemplatesLoaded: vi.fn(),
history: {
commands,
diff --git a/invokeai/frontend/webv2/src/features/queue/runtime.ts b/invokeai/frontend/webv2/src/features/queue/runtime.ts
index bcaf9023be..037e02d9fb 100644
--- a/invokeai/frontend/webv2/src/features/queue/runtime.ts
+++ b/invokeai/frontend/webv2/src/features/queue/runtime.ts
@@ -23,6 +23,7 @@ import { getApiErrorMessage } from '@platform/transport/http';
export interface QueueResultDestinationPort {
addImagesToGalleryBoard(boardId: string, imageNames: string[]): Promise<void>;
+ addVideosToGalleryBoard(boardId: string, videoNames: string[]): Promise<void>;
}
export interface QueueRuntime {
@@ -203,6 +204,38 @@ export const createQueueRuntime = ({
}
};
+ /**
+ * Land result videos on the destination board, like images. Videos are born
+ * unassigned server-side (the compiled graph carries no board unless a node
+ * sets one explicitly), so without this step every generated video sits in
+ * Uncategorized regardless of the active board. Only names are fetched — the
+ * gallery hydrates the video itself on its own refresh. Re-attaching a video
+ * that another settlement path already routed is a no-op server-side.
+ */
+ const addResultVideosToDestination = async (queueItem: QueueItem, backendItemIds: number[]): Promise<void> => {
+ if (!isActive() || queueItem.snapshot.destination !== 'gallery' || backendItemIds.length === 0) {
+ return;
+ }
+
+ const boardId = queueItem.snapshot.galleryBoardId;
+
+ if (!boardId || boardId === 'none') {
+ return;
+ }
+
+ const options = getQueueItemResultImageOptions(queueItem);
+ const namesPerItem = await Promise.all(
+ backendItemIds.map((backendItemId) => backend.getResultVideoNames(backendItemId, options))
+ );
+ const videoNames = [...new Set(namesPerItem.flat())];
+
+ if (videoNames.length === 0 || !isActive()) {
+ return;
+ }
+
+ await destinations.addVideosToGalleryBoard(boardId, videoNames);
+ };
+
/** Drop intermediates when the item asks for it, then land what remains on its destination. */
const deliverVisibleImages = async (
queueItem: QueueItem,
@@ -237,6 +270,9 @@ export const createQueueRuntime = ({
}
const images = await deliverVisibleImages(queueItem, allImages);
+ // The live path routes videos per backend item (routeBackendItemResults); this covers
+ // resumed/adopted runs, where only the persisted ids are available.
+ await addResultVideosToDestination(queueItem, queueItem.backendItemIds ?? []);
if (!isActive()) {
return;
@@ -283,6 +319,7 @@ export const createQueueRuntime = ({
}
const visibleImages = await deliverVisibleImages(queueItem, images);
+ await addResultVideosToDestination(queueItem, [backendItemId]);
if (!isActive()) {
return;
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
index d62d6b79ae..1f40f1491f 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
@@ -29,6 +29,7 @@ const input = (name: string, overrides: Partial<FieldInputTemplate> = {}): Field
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
...overrides,
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts
index 6f6f30edbe..2fea6f6e21 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts
@@ -34,6 +34,7 @@ const template: InvocationTemplate = {
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
},
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts
index 68f38b8e13..73836317e5 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts
@@ -24,6 +24,7 @@ const input = (overrides: Partial<FieldInputTemplate> = {}): FieldInputTemplate
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
...overrides,
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/layerWorkflow.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/layerWorkflow.test.ts
index b417e68f3c..76bbe1837d 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/layerWorkflow.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/layerWorkflow.test.ts
@@ -42,6 +42,7 @@ const input = (name: string, overrides: Partial<FieldInputTemplate> = {}): Field
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
...overrides,
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/properties.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/properties.test.ts
index 2579492b4f..6005588e48 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/properties.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/properties.test.ts
@@ -34,6 +34,7 @@ const template: InvocationTemplate = {
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
},
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/types.ts b/invokeai/frontend/webv2/src/features/workflow/core/types.ts
index 660e9843fc..8ea8c2575b 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/types.ts
@@ -40,6 +40,7 @@ export interface FieldInputTemplate {
exclusiveMaximum: number | null;
multipleOf: number | null;
uiModelBase: string[] | null;
+ uiModelFormat: string[] | null;
uiModelType: string[] | null;
}
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/validation.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/validation.test.ts
index 912ddcda68..a5e2b60de6 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/validation.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/validation.test.ts
@@ -127,6 +127,7 @@ const templates: InvocationTemplates = {
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
},
@@ -163,6 +164,7 @@ const templates: InvocationTemplates = {
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
},
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/workflowJson.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/workflowJson.test.ts
index a7f9130b52..f1968155be 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/workflowJson.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/workflowJson.test.ts
@@ -36,6 +36,7 @@ const template: InvocationTemplate = {
uiComponent: 'textarea',
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
},
diff --git a/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts b/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts
index bfe435ddee..33d3cf9130 100644
--- a/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts
@@ -32,6 +32,7 @@ const openApiFixture = {
type: 'integer',
ui_component: 'video-frame-index',
ui_hidden: false,
+ ui_model_format: ['diffusers'],
},
id: { field_kind: 'internal', title: 'Id', type: 'string' },
is_intermediate: { default: false, field_kind: 'internal', type: 'boolean' },
@@ -130,6 +131,9 @@ describe('parseOpenApiToTemplates', () => {
// Unknown ui_component values collapse to null; known ones pass through.
expect(add?.inputs.a?.uiComponent).toBeNull();
expect(add?.inputs.b?.uiComponent).toBe('video-frame-index');
+ // ui_model_format passes through so model pickers can filter by install format.
+ expect(add?.inputs.a?.uiModelFormat).toBeNull();
+ expect(add?.inputs.b?.uiModelFormat).toEqual(['diffusers']);
});
it('parses ref, nullable-anyOf, single-or-collection, and enum field types', () => {
diff --git a/invokeai/frontend/webv2/src/features/workflow/data/templates.ts b/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
index 7474f00973..7cf5de1c61 100644
--- a/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
@@ -234,6 +234,7 @@ const buildInputTemplate = (name: string, property: JsonObject, type: FieldType)
: null,
uiHidden: property.ui_hidden === true,
uiModelBase: getStringArrayOrNull(property.ui_model_base),
+ uiModelFormat: getStringArrayOrNull(property.ui_model_format),
uiModelType: getStringArrayOrNull(property.ui_model_type),
uiOrder: getNumberOrNull(property.ui_order),
};
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts b/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts
index a2c01cfbb6..837040b3c5 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts
@@ -44,6 +44,7 @@ const createTemplate = (outputType: FieldType = single('IntegerField')): Invocat
uiComponent: null,
uiHidden: false,
uiModelBase: null,
+ uiModelFormat: null,
uiModelType: null,
uiOrder: null,
},
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
index cfa6490ed0..5f76dbe65b 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
@@ -274,9 +274,16 @@ const ModelIdentifierInput = ({ id, invalid, onChange, template, value }: Workfl
typeof (value as { key?: unknown } | null)?.key === 'string' ? (value as { key: string }).key : null;
const modelTypes = (template.uiModelType ?? DEFAULT_MODEL_TYPES) as ModelTaxonomyType[];
const allowedBases = template.uiModelBase;
+ // ui_model_format narrows further within a base/type — e.g. a loader's main-model field
+ // that accepts only diffusers-folder installs while its override fields take the
+ // single-file checkpoints. Offering the wrong format here would enqueue a graph that
+ // fails deep inside the model loader instead of at selection time.
+ const allowedFormats = template.uiModelFormat;
const filter = useCallback(
- (model: ModelConfig) => (allowedBases ? allowedBases.includes(model.base) : true),
- [allowedBases]
+ (model: ModelConfig) =>
+ (allowedBases ? allowedBases.includes(model.base) : true) &&
+ (allowedFormats ? allowedFormats.includes(model.format) : true),
+ [allowedBases, allowedFormats]
);
const onModelChange = useCallback(
(model: ModelConfig | null) =>
@@ -290,7 +297,7 @@ const ModelIdentifierInput = ({ id, invalid, onChange, template, value }: Workfl
<Suspense fallback={MODEL_SELECT_FALLBACK}>
<ModelSelect
className="nodrag nowheel"
- filter={allowedBases ? filter : undefined}
+ filter={allowedBases || allowedFormats ? filter : undefined}
id={id ? `${id}-model-combobox` : undefined}
invalid={invalid}
isClearable={false}