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(preview): let Edit on Canvas ingest without a live canvas engine

Josh Corbett878ccd7e916d
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.test.ts
index e53d6bc05c..3155b5ffe6 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.test.ts
@@ -382,6 +382,23 @@ describe('importGalleryImagesToCanvas', () => {
expect(dispatch).not.toHaveBeenCalled();
});
+ it('ingests through the reducer when the active project has no live engine', async () => {
+ const { project, state } = withProject();
+ const dispatch = vi.fn<(action: WorkbenchAction) => void>();
+ const result = await importGalleryImagesToCanvas({
+ destination: 'raster',
+ applyCanvasMutation: (projectId, mutation) =>
+ dispatch({ mutation, projectId, type: 'applyCanvasProjectMutation' }),
+ engine: null,
+ ...queriesFor(() => state),
+ images: [image('a.png')],
+ project,
+ });
+ expect(result.status).toBe('imported');
+ expect(dispatch).toHaveBeenCalledOnce();
+ expect(getForwardLayers(dispatch.mock.calls[0]![0]).map((layer) => layer.type)).toEqual(['raster']);
+ });
+
it('blocks a locked matching engine before resized preprocessing', async () => {
const { project, state } = withProject();
const fetchImage = vi.fn<typeof fetch>();
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.ts
index 266408b440..15fe07f9bf 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/importGalleryImages.ts
@@ -321,13 +321,14 @@ export const importGalleryImagesToCanvas = async (options: {
return { status: 'stale-document' };
}
- if (isActiveProject(project.id)) {
- const committed = matchingProjectEngine?.layers.commitStructural('Import gallery images', forward, inverse);
- if (committed?.status !== 'committed') {
+ if (matchingProjectEngine && isActiveProject(project.id)) {
+ const committed = matchingProjectEngine.layers.commitStructural('Import gallery images', forward, inverse);
+ if (committed.status !== 'committed') {
return { status: 'blocked' };
}
} else {
- // A background project has no live editing session; the import lands as ingestion.
+ // No live editing session — a background project, or the active project
+ // with its canvas closed — so the import lands as ingestion.
applyCanvasMutation(project.id, forward);
}
return { failedImageNames, layerIds: layers.map((layer) => layer.id), status: 'imported' };