Skip to content

Commit e72e2f9

Browse files
feat(ui): make save all images to gallery option also bypass canvas
1 parent 413337b commit e72e2f9

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@
23322332
"alert": "Preserving Masked Region"
23332333
},
23342334
"saveAllImagesToGallery": {
2335-
"alert": "Saving All Images to Gallery"
2335+
"alert": "Sending images to Gallery, bypassing Canvas"
23362336
},
23372337
"isolatedStagingPreview": "Isolated Staging Preview",
23382338
"isolatedPreview": "Isolated Preview",

invokeai/frontend/web/src/features/controlLayers/components/CanvasAlerts/CanvasAlertsSaveAllImagesToGallery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const CanvasAlertsSaveAllImagesToGallery = memo(() => {
1313
}
1414

1515
return (
16-
<Alert status="info" borderRadius="base" fontSize="sm" shadow="md" w="fit-content">
16+
<Alert status="warning" borderRadius="base" fontSize="sm" shadow="md" w="fit-content">
1717
<AlertIcon />
1818
<AlertTitle>{t('controlLayers.settings.saveAllImagesToGallery.alert')}</AlertTitle>
1919
</Alert>

invokeai/frontend/web/src/features/controlLayers/components/CanvasAlerts/CanvasAlertsSelectedEntityStatus.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ const CanvasAlertsSelectedEntityStatusContent = memo(({ entityIdentifier, adapte
5757
const alert = useMemo<AlertData | null>(() => {
5858
if (isFiltering) {
5959
return {
60-
status: 'info',
60+
status: 'warning',
6161
title: t('controlLayers.HUD.entityStatus.isFiltering', { title }),
6262
};
6363
}
6464

6565
if (isTransforming) {
6666
return {
67-
status: 'info',
67+
status: 'warning',
6868
title: t('controlLayers.HUD.entityStatus.isTransforming', { title }),
6969
};
7070
}
7171

7272
if (isEmpty) {
7373
return {
74-
status: 'info',
74+
status: 'warning',
7575
title: t('controlLayers.HUD.entityStatus.isEmpty', { title }),
7676
};
7777
}

invokeai/frontend/web/src/features/nodes/util/graph/graphBuilderUtils.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';
22
import type { RootState } from 'app/store/store';
33
import { getPrefixedId } from 'features/controlLayers/konva/util';
44
import { selectSaveAllImagesToGallery } from 'features/controlLayers/store/canvasSettingsSlice';
5+
import { selectCanvasSessionId } from 'features/controlLayers/store/canvasStagingAreaSlice';
56
import {
67
selectImg2imgStrength,
78
selectMainModelConfig,
@@ -42,9 +43,8 @@ export const getBoardField = (state: RootState): BoardField | undefined => {
4243
* - board
4344
*/
4445
export const selectCanvasOutputFields = (state: RootState) => {
45-
// Advanced session means working on canvas - images are not saved to gallery or added to a board.
46-
// Simple session means working in YOLO mode - images are saved to gallery & board.
4746
const tab = selectActiveTab(state);
47+
// This flag also has an effect on the canvas destination - see selectCanvasDestination below.
4848
const saveAllImagesToGallery = selectSaveAllImagesToGallery(state);
4949

5050
// If we're on canvas and the save all images setting is enabled, save to gallery
@@ -59,6 +59,23 @@ export const selectCanvasOutputFields = (state: RootState) => {
5959
};
6060
};
6161

62+
/**
63+
* Select the destination to use for canvas queue items.
64+
*
65+
*/
66+
export const selectCanvasDestination = (state: RootState) => {
67+
// The canvas will stage images that have its session ID as the destination. When the user has enabled saving all
68+
// images to gallery, we want to bypass the staging area. So we use 'canvas' as a generic destination. Images will
69+
// go directly to the gallery.
70+
//
71+
// This flag also has an effect on the canvas output fields - see selectCanvasOutputFields above.
72+
const saveAllImagesToGallery = selectSaveAllImagesToGallery(state);
73+
if (saveAllImagesToGallery) {
74+
return 'canvas';
75+
}
76+
return selectCanvasSessionId(state);
77+
};
78+
6279
/**
6380
* Gets the prompts, modified for the active style preset.
6481
*/

invokeai/frontend/web/src/features/queue/hooks/useEnqueueCanvas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { extractMessageFromAssertionError } from 'common/util/extractMessageFrom
77
import { withResult, withResultAsync } from 'common/util/result';
88
import { useCanvasManagerSafe } from 'features/controlLayers/contexts/CanvasManagerProviderGate';
99
import type { CanvasManager } from 'features/controlLayers/konva/CanvasManager';
10-
import { selectCanvasSessionId } from 'features/controlLayers/store/canvasStagingAreaSlice';
1110
import { prepareLinearUIBatch } from 'features/nodes/util/graph/buildLinearBatchConfig';
1211
import { buildChatGPT4oGraph } from 'features/nodes/util/graph/generation/buildChatGPT4oGraph';
1312
import { buildCogView4Graph } from 'features/nodes/util/graph/generation/buildCogView4Graph';
@@ -18,6 +17,7 @@ import { buildImagen4Graph } from 'features/nodes/util/graph/generation/buildIma
1817
import { buildSD1Graph } from 'features/nodes/util/graph/generation/buildSD1Graph';
1918
import { buildSD3Graph } from 'features/nodes/util/graph/generation/buildSD3Graph';
2019
import { buildSDXLGraph } from 'features/nodes/util/graph/generation/buildSDXLGraph';
20+
import { selectCanvasDestination } from 'features/nodes/util/graph/graphBuilderUtils';
2121
import type { GraphBuilderArg } from 'features/nodes/util/graph/types';
2222
import { UnsupportedGenerationModeError } from 'features/nodes/util/graph/types';
2323
import { toast } from 'features/toast/toast';
@@ -36,7 +36,7 @@ const enqueueCanvas = async (store: AppStore, canvasManager: CanvasManager, prep
3636

3737
const state = getState();
3838

39-
const destination = selectCanvasSessionId(state);
39+
const destination = selectCanvasDestination(state);
4040

4141
const buildGraphResult = await withResultAsync(async () => {
4242
const model = state.params.model;

invokeai/frontend/web/src/features/ui/layouts/CanvasWorkspacePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export const CanvasWorkspacePanel = memo(() => {
8585
alignItems="flex-start"
8686
>
8787
{showHUD && <CanvasHUD />}
88+
<CanvasAlertsSaveAllImagesToGallery />
8889
<CanvasAlertsSelectedEntityStatus />
8990
<CanvasAlertsPreserveMask />
90-
<CanvasAlertsSaveAllImagesToGallery />
9191
<CanvasAlertsInvocationProgress />
9292
</Flex>
9393
<Flex position="absolute" top={1} insetInlineEnd={1}>

0 commit comments

Comments
 (0)