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.

feat(webv2): add an auto-add board and keep None workflow results uncategorized

Josh Corbettfbfbdaf84b0e
diff --git a/docs/src/content/docs/features/gallery.mdx b/docs/src/content/docs/features/gallery.mdx
index 941e5accc6..71a24f2130 100644
--- a/docs/src/content/docs/features/gallery.mdx
+++ b/docs/src/content/docs/features/gallery.mdx
@@ -30,9 +30,9 @@ The **settings button** opens a list of customization options:
- **Image Size:** A slider that lets you control the size of the image previews in the gallery.
- **Auto-Switch to New Images:** When enabled, newly generated images will automatically load into the current image panel (on the Text to Image tab) or the result panel (on the Image to Image tab). This happens invisibly even if you are on a different tab during generation.
-- **Auto-Assign Board on Click:** Whenever an image is generated or saved, it is placed into a board. The destination board is marked with an `AUTO` badge.
+- **Send New Results to the Selected Board:** New generations, canvas saves and pasted uploads go to the auto-add board. Workflow nodes whose board is set to **Auto** use it too; **None** always saves to Uncategorized, as do workflow outputs from nodes that have no board input.
- *When enabled:* The board selected at the moment you click **Invoke** becomes the destination. This allows you to queue multiple generations into different boards without waiting for them to finish.
- - *When disabled:* An **Auto-Add Board** dropdown appears, allowing you to set one specific board as the permanent destination for all new images.
+ - *When disabled:* One fixed board is the destination, marked with an `Auto` badge. Turning the setting off keeps the current destination; choose another with **Auto-add to this Board**.
- **Always Show Image Size Badge:** Toggles whether the resolution (e.g., 512x512) is displayed on each image preview thumbnail.
Below these buttons is the **Search Boards** text entry area, allowing you to quickly find specific boards by name. Next to it is the **Add Board (+)** button for creating new boards.
@@ -49,7 +49,7 @@ Each board has a context menu accessible via right-click (or Ctrl+click).
![Thumbnail Menu](./assets/thumbnail_menu.png)
-- **Auto-add to this Board:** If *Auto-Assign Board on Click* is disabled in settings, use this option to quickly set the selected board as the default destination for new images.
+- **Auto-add to this Board:** Makes this board the fixed destination for new results, and turns off *Send New Results to the Selected Board*. On the auto-add board itself, **Stop auto-adding here** turns following back on.
- **Download Board Images:** Packages all images within the board into a `.zip` file. A notification link will be provided when the download is ready. Videos are not included; download them individually from the gallery or viewer.
- **Delete Board:** Opens a confirmation dialog. **Delete Board Only** removes the board and leaves its contents uncategorized; **Delete Board and Assets** permanently removes the board, its images, and its videos.
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 68a3594b77..ca61a11b35 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -3778,6 +3778,10 @@
"alwaysShowDimensions": "Always show dimensions",
"archiveBoard": "Archive Board",
"archivedBoards": "Archived boards",
+ "autoAddBadge": "Auto",
+ "autoAddBadgeTooltip": "New generations, canvas saves and pasted uploads land here, as do workflow nodes whose board is Auto.",
+ "autoAddToBoard": "Auto-add to this board",
+ "stopAutoAdd": "Stop auto-adding here",
"assetCount_one": "{{count}} upload",
"assetCount_other": "{{count}} uploads",
"boardActionsForBoard": "Board actions for {{name}}",
@@ -3795,6 +3799,8 @@
"boardRenamed": "Renamed board to \"{{name}}\"",
"boardUnarchived": "Unarchived board \"{{name}}\"",
"boardVisibility": "Board visibility",
+ "destination": "Destination",
+ "followSelectedBoard": "Send new results to the selected board",
"commands": {
"clearSelection": "Clear gallery selection",
"deleteSelection": "Delete gallery selection",
diff --git a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx
index 01c6b45cbc..2a79609357 100644
--- a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx
@@ -1,7 +1,7 @@
import type { VideoUiAdapter } from '@features/video';
import type { ReactNode } from 'react';
-import { getGalleryDestinationBoardId, toGalleryItemKey } from '@features/gallery/contracts';
+import { getGalleryAutoAddBoardId, toGalleryItemKey } from '@features/gallery/contracts';
import { invalidateGallery } from '@features/gallery/queries';
import { VideoUiProvider } from '@features/video';
import { useQueryClient } from '@tanstack/react-query';
@@ -34,9 +34,9 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>
const showPromptSyntaxHighlighting = useWorkbenchPreferenceSelector(
(preferences) => preferences.showPromptSyntaxHighlighting
);
- // Use the queue's galleryBoardId destination for panel uploads too.
+ // Panel uploads land where new results do: the auto-add board.
const uploadBoardId = useActiveProjectSelector(
- (activeProject) => getGalleryDestinationBoardId(getProjectWidgetValues(activeProject, 'gallery')) ?? 'none'
+ (activeProject) => getGalleryAutoAddBoardId(getProjectWidgetValues(activeProject, 'gallery')) ?? 'none'
);
// Read the current board through a ref so board selection does not recreate project actions.
const uploadBoardIdRef = useRef(uploadBoardId);
diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.ts
index 038b4407c1..49554255de 100644
--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts
@@ -50,12 +50,14 @@ export {
} from './core/semanticImageQuery';
export {
DEFAULT_GALLERY_SETTINGS,
+ GALLERY_AUTO_ADD_FOLLOW,
getGallerySettings,
type GalleryPaginationMode,
type GallerySettings,
type GalleryThumbnailFit,
} from './core/settings';
export {
+ getGalleryAutoAddBoardId,
getGalleryCompareImage,
getGalleryDestinationBoardId,
getGalleryPage,
diff --git a/invokeai/frontend/webv2/src/features/gallery/core/settings.ts b/invokeai/frontend/webv2/src/features/gallery/core/settings.ts
index 42a71db2e2..71849cc231 100644
--- a/invokeai/frontend/webv2/src/features/gallery/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/core/settings.ts
@@ -16,8 +16,16 @@ export const GALLERY_MIN_GRID_HEIGHT_PX = 128;
export const GALLERY_BOARD_PANEL_MIN_WIDTH_PX = 180;
export const GALLERY_BOARD_PANEL_MAX_WIDTH_PX = 420;
+/** The auto-add choice that sends results to whichever board the gallery has selected. */
+export const GALLERY_AUTO_ADD_FOLLOW = 'follow';
+
/** User-tunable gallery settings, persisted in the widget's `values` record. */
export interface GallerySettings {
+ /**
+ * Where results without a board of their own go: `follow` (the selected board), `none` (Uncategorized), or a
+ * board id. Workflow nodes set to Auto use it too.
+ */
+ autoAddBoardId: string;
boardOrderBy: GalleryBoardOrderBy;
boardOrderDir: GalleryOrderDir;
/** Board panel disclosure controlled by the region-independent widget header. */
@@ -41,6 +49,7 @@ export interface GallerySettings {
}
export const DEFAULT_GALLERY_SETTINGS: GallerySettings = {
+ autoAddBoardId: GALLERY_AUTO_ADD_FOLLOW,
boardOrderBy: 'created_at',
boardOrderDir: 'DESC',
boardPanelCollapsed: false,
@@ -87,6 +96,10 @@ export const getGallerySettings = (values: Record<string, unknown>): GallerySett
values.paginationMode === 'paginated' ? 'paginated' : DEFAULT_GALLERY_SETTINGS.paginationMode;
return {
+ autoAddBoardId:
+ typeof values.autoAddBoardId === 'string' && values.autoAddBoardId !== ''
+ ? values.autoAddBoardId
+ : DEFAULT_GALLERY_SETTINGS.autoAddBoardId,
boardOrderBy: isBoardOrderBy(values.boardOrderBy) ? values.boardOrderBy : DEFAULT_GALLERY_SETTINGS.boardOrderBy,
boardOrderDir: isOrderDir(values.boardOrderDir) ? values.boardOrderDir : DEFAULT_GALLERY_SETTINGS.boardOrderDir,
boardPanelCollapsed:
diff --git a/invokeai/frontend/webv2/src/features/gallery/settingsContribution.ts b/invokeai/frontend/webv2/src/features/gallery/settingsContribution.ts
index ff1528511a..6a46be869a 100644
--- a/invokeai/frontend/webv2/src/features/gallery/settingsContribution.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/settingsContribution.ts
@@ -64,6 +64,14 @@ export const gallerySettingsContribution: SettingsContribution = {
],
scope: 'instance',
},
+ {
+ id: 'followSelectedBoard',
+ kind: 'boolean',
+ label: (t) => t('widgets.gallery.followSelectedBoard'),
+ group: (t) => t('widgets.gallery.destination'),
+ keywords: 'auto add board destination results workflow',
+ scope: 'instance',
+ },
{
id: 'showDateBoards',
kind: 'boolean',
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.browser.test.tsx
index fa15d37244..0af55503bf 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.browser.test.tsx
@@ -54,11 +54,17 @@ const context = {
deleteBoard: vi.fn(),
downloadBoard: vi.fn(),
renameBoard: vi.fn(),
+ updateSettings: vi.fn(),
},
gallery: {
projectBoardId: null,
+ settings: { autoAddBoardId: 'follow' },
},
} as unknown as GalleryWidgetContextValue;
+const targetContext = {
+ ...context,
+ gallery: { ...context.gallery, settings: { autoAddBoardId: 'board-1' } },
+} as unknown as GalleryWidgetContextValue;
let host: HTMLDivElement | null = null;
let root: Root | null = null;
@@ -105,3 +111,32 @@ it('shows image, video, and asset counts before deleting a mixed-media board', a
});
expect(document.body.textContent).toContain('Delete Board and Media');
});
+
+it('makes the board the auto-add destination', async () => {
+ const autoAddItem = document.querySelector<HTMLElement>('[role="menuitem"][data-value="auto-add-board"]');
+
+ expect(autoAddItem?.textContent).toBe('widgets.gallery.autoAddToBoard');
+ await act(() => userEvent.click(autoAddItem!));
+
+ expect(context.actions.updateSettings).toHaveBeenCalledExactlyOnceWith({ autoAddBoardId: 'board-1' });
+});
+
+it('hands results back to the selected board from the auto-add board itself', async () => {
+ await act(async () => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <GalleryWidgetContext value={targetContext}>
+ <GalleryBoardMenu target={target} onClose={noop} />
+ </GalleryWidgetContext>
+ </ChakraProvider>
+ );
+ await Promise.resolve();
+ });
+
+ const item = document.querySelector<HTMLElement>('[role="menuitem"][data-value="auto-add-board"]');
+
+ expect(item?.textContent).toBe('widgets.gallery.stopAutoAdd');
+ await act(() => userEvent.click(item!));
+
+ expect(context.actions.updateSettings).toHaveBeenLastCalledWith({ autoAddBoardId: 'follow' });
+});
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx
index 390754e2a5..751a43b955 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx
@@ -1,9 +1,18 @@
import type { GalleryBoard } from '@features/gallery/core/types';
import { Dialog, HStack, Icon, Input, Menu, Portal, Stack, Text } from '@chakra-ui/react';
+import { GALLERY_AUTO_ADD_FOLLOW } from '@features/gallery/core/settings';
import { Button } from '@platform/ui/Button';
import { MenuContent } from '@platform/ui/Menu';
-import { ArchiveIcon, DownloadIcon, FileDownIcon, PencilIcon, Trash2Icon, type LucideIcon } from 'lucide-react';
+import {
+ ArchiveIcon,
+ DownloadIcon,
+ FileDownIcon,
+ PencilIcon,
+ SquareArrowDownIcon,
+ Trash2Icon,
+ type LucideIcon,
+} from 'lucide-react';
import { useCallback, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -134,6 +143,11 @@ export const GalleryBoardMenu = ({
<Menu.Separator />
</>
)}
+ {board.id === gallery.settings.autoAddBoardId ? (
+ <BoardAutoAddMenuItem boardId={GALLERY_AUTO_ADD_FOLLOW} label={t('widgets.gallery.stopAutoAdd')} />
+ ) : board.kind !== 'date' && !board.archived ? (
+ <BoardAutoAddMenuItem boardId={board.id} label={t('widgets.gallery.autoAddToBoard')} />
+ ) : null}
<BoardDownloadMenuItem board={board} />
{isManagedBoard && (
<>
@@ -247,6 +261,14 @@ const BoardExportProjectMenuItem = ({ board }: { board: GalleryBoard }) => {
);
};
+/** Sets the auto-add board; `follow` hands results back to the selected board. */
+const BoardAutoAddMenuItem = ({ boardId, label }: { boardId: string; label: string }) => {
+ const { actions } = useGalleryWidget();
+ const handleClick = useCallback(() => actions.updateSettings({ autoAddBoardId: boardId }), [actions, boardId]);
+
+ return <BoardMenuItem icon={SquareArrowDownIcon} label={label} value="auto-add-board" onClick={handleClick} />;
+};
+
const BoardDownloadMenuItem = ({ board }: { board: GalleryBoard }) => {
const { t } = useTranslation();
const { actions } = useGalleryWidget();
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx
index f342f7b8a3..14502fc16d 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRow.tsx
@@ -24,6 +24,7 @@ import { getBoardCounts } from './galleryStateView';
export const GalleryBoardRow = ({
board,
+ isAutoAddTarget = false,
isMenuOpen,
isSelected,
loadedItemBoardIds,
@@ -31,6 +32,8 @@ export const GalleryBoardRow = ({
onSelectBoard,
}: {
board: GalleryBoard;
+ /** Results without a board of their own land here (the gallery is not following its selection). */
+ isAutoAddTarget?: boolean;
/** Its own menu is showing, so the trigger must not fade out from under it. */
isMenuOpen?: boolean;
isSelected: boolean;
@@ -156,6 +159,13 @@ export const GalleryBoardRow = ({
onContextMenu={onOpenMenu ? handleContextMenu : undefined}
onSelect={handleSelect}
>
+ {isAutoAddTarget ? (
+ <Tooltip content={t('widgets.gallery.autoAddBadgeTooltip')}>
+ <Badge colorPalette={isSelected ? undefined : 'accent'} flexShrink={0} size="xs" variant="subtle">
+ {t('widgets.gallery.autoAddBadge')}
+ </Badge>
+ </Tooltip>
+ ) : null}
{board.projectId !== null ? (
<Badge colorPalette={isSelected ? undefined : 'accent'} flexShrink={0} size="xs" variant="subtle">
{t('common.project')}
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx
index 6e1b6f7626..78b485da90 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx
@@ -159,6 +159,7 @@ export const GalleryBoardsPanel = () => {
<GalleryBoardRow
key={board.id}
board={board}
+ isAutoAddTarget={board.id === gallery.settings.autoAddBoardId}
isMenuOpen={boardMenuTarget?.board.id === board.id}
isSelected={board.id === gallery.selectedBoardId}
loadedItemBoardIds={loadedItemBoardIds}
@@ -207,6 +208,7 @@ export const GalleryBoardsPanel = () => {
<GalleryBoardRow
key={board.id}
board={board}
+ isAutoAddTarget={board.id === gallery.settings.autoAddBoardId}
isMenuOpen={boardMenuTarget?.board.id === board.id}
isSelected={board.id === gallery.selectedBoardId}
loadedItemBoardIds={loadedItemBoardIds}
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.browser.test.tsx
index 140b81dbf7..e15a662b09 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.browser.test.tsx
@@ -25,10 +25,19 @@ vi.mock('react-i18next', () => ({
let host: HTMLDivElement | null = null;
let root: Root | null = null;
const STALE_TARGET = { projectId: 'old-project' };
+const PICKED_BOARD_VALUES = { selectedBoardId: 'picked' };
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
-const Harness = ({ id, target }: { id: string; target?: SettingFieldProps['target'] }) => {
- const [values, setValues] = useState<Record<string, unknown>>({ imageDensityPercent: 25 });
+const Harness = ({
+ id,
+ initialValues = { imageDensityPercent: 25 },
+ target,
+}: {
+ id: string;
+ initialValues?: Record<string, unknown>;
+ target?: SettingFieldProps['target'];
+}) => {
+ const [values, setValues] = useState<Record<string, unknown>>(initialValues);
const updateSettings = useCallback(
(patch: Record<string, unknown>) => setValues((current) => ({ ...current, ...patch })),
[]
@@ -96,6 +105,21 @@ describe('Gallery settings contribution bindings', () => {
expect(host?.querySelector('output')?.textContent).toContain('"showPendingItems":false');
});
+ it('pins the current destination when results stop following the selected board', async () => {
+ await act(() => root?.render(<Harness id="followSelectedBoard" initialValues={PICKED_BOARD_VALUES} />));
+ const toggle = host?.querySelector<HTMLInputElement>('[data-surface="quick"] input');
+
+ expect(toggle?.checked).toBe(true);
+ await act(() => toggle?.click());
+
+ expect(toggle?.checked).toBe(false);
+ expect(host?.querySelector('output')?.textContent).toContain('"autoAddBoardId":"picked"');
+
+ await act(() => toggle?.click());
+
+ expect(host?.querySelector('output')?.textContent).toContain('"autoAddBoardId":"follow"');
+ });
+
it('disables edits for a target belonging to another project', async () => {
await act(() => root?.render(<Harness id="showPendingItems" target={STALE_TARGET} />));
const quick = host?.querySelector<HTMLInputElement>('[data-surface="quick"] input');
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.tsx
index 125624ca46..6973f020fe 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GallerySettingField.tsx
@@ -1,9 +1,10 @@
import type { SettingFieldProps } from '@platform/ui/settings/contracts';
-import { DEFAULT_GALLERY_SETTINGS, getGallerySettings } from '@features/gallery/core/settings';
+import { DEFAULT_GALLERY_SETTINGS, GALLERY_AUTO_ADD_FOLLOW, getGallerySettings } from '@features/gallery/core/settings';
import { SettingControl } from '@platform/ui/settings/SettingControl';
import { useCallback } from 'react';
+import { getGalleryDestinationBoardId } from './galleryStateView';
import { useGalleryUi } from './GalleryUiContext';
export const GallerySettingField = ({ field, surface, target }: SettingFieldProps) => {
@@ -16,7 +17,12 @@ export const GallerySettingField = ({ field, surface, target }: SettingFieldProp
return;
}
- if (field.id === 'imageSize' && typeof value === 'number') {
+ if (field.id === 'followSelectedBoard' && typeof value === 'boolean') {
+ // Leaving follow pins today's destination, so nothing moves until another board is chosen.
+ gallery.updateSettings({
+ autoAddBoardId: value ? GALLERY_AUTO_ADD_FOLLOW : (getGalleryDestinationBoardId(galleryValues) ?? 'none'),
+ });
+ } else if (field.id === 'imageSize' && typeof value === 'number') {
gallery.updateSettings({ imageDensityPercent: 100 - value });
} else if (field.id === 'thumbnailFit' && (value === 'square' || value === 'aspect')) {
gallery.updateSettings({ thumbnailFit: value });
@@ -40,19 +46,25 @@ export const GallerySettingField = ({ field, surface, target }: SettingFieldProp
gallery.updateSettings({ [field.id]: value });
}
},
- [disabled, field.id, gallery]
+ [disabled, field.id, gallery, galleryValues]
);
const value =
- field.id === 'imageSize' ? 100 - settings.imageDensityPercent : settings[field.id as keyof typeof settings];
+ field.id === 'followSelectedBoard'
+ ? settings.autoAddBoardId === GALLERY_AUTO_ADD_FOLLOW
+ : field.id === 'imageSize'
+ ? 100 - settings.imageDensityPercent
+ : settings[field.id as keyof typeof settings];
if (typeof value !== 'boolean' && typeof value !== 'number' && typeof value !== 'string') {
return null;
}
const defaultValue =
- field.id === 'imageSize'
- ? 100 - DEFAULT_GALLERY_SETTINGS.imageDensityPercent
- : DEFAULT_GALLERY_SETTINGS[field.id as keyof typeof DEFAULT_GALLERY_SETTINGS];
+ field.id === 'followSelectedBoard'
+ ? true
+ : field.id === 'imageSize'
+ ? 100 - DEFAULT_GALLERY_SETTINGS.imageDensityPercent
+ : DEFAULT_GALLERY_SETTINGS[field.id as keyof typeof DEFAULT_GALLERY_SETTINGS];
return (
<SettingControl
isModified={value !== defaultValue}
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts
index 3dbab8eed9..7e8f033bb8 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts
@@ -5,6 +5,7 @@ import { describe, expect, it } from 'vitest';
import {
getBoardCounts,
+ getGalleryAutoAddBoardId,
getGalleryDestinationBoardId,
getGallerySelectedBoardId,
getGallerySelectedImageQuery,
@@ -144,6 +145,7 @@ describe('gallery state view', () => {
);
expect(gallery.settings).toEqual({
+ autoAddBoardId: 'follow',
boardOrderBy: 'board_name',
boardOrderDir: 'DESC',
boardPanelCollapsed: false,
@@ -353,3 +355,15 @@ describe('getGalleryDestinationBoardId', () => {
expect(getGalleryDestinationBoardId({})).toBeNull();
});
});
+
+describe('getGalleryAutoAddBoardId', () => {
+ it('follows the gallery destination until a board is fixed', () => {
+ expect(getGalleryAutoAddBoardId({ projectBoardId: 'project', selectedBoardId: 'picked' })).toBe('picked');
+ expect(getGalleryAutoAddBoardId({ autoAddBoardId: 'follow', projectBoardId: 'project' })).toBe('project');
+ });
+
+ it('uses a fixed board, including Uncategorized, whatever the selection', () => {
+ expect(getGalleryAutoAddBoardId({ autoAddBoardId: 'fixed', selectedBoardId: 'picked' })).toBe('fixed');
+ expect(getGalleryAutoAddBoardId({ autoAddBoardId: 'none', selectedBoardId: 'picked' })).toBe('none');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts
index 24bc6bb332..3daf1cf3b6 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts
@@ -17,7 +17,7 @@ import {
parseGallerySemanticReference,
type GallerySemanticReference,
} from '@features/gallery/core/semanticImageQuery';
-import { getGallerySettings, type GallerySettings } from '@features/gallery/core/settings';
+import { GALLERY_AUTO_ADD_FOLLOW, getGallerySettings, type GallerySettings } from '@features/gallery/core/settings';
/** Leave the placeholder name empty; getGalleryBoardLabel localizes it from kind. */
const UNCATEGORIZED_BOARD: GalleryBoard = {
@@ -98,6 +98,13 @@ export const getGalleryDestinationBoardId = (values: Record<string, unknown>): s
: getGalleryProjectBoardId(values);
};
+/** Where results without a board of their own go: the auto-add board, or the destination above while following. */
+export const getGalleryAutoAddBoardId = (values: Record<string, unknown>): string | null => {
+ const { autoAddBoardId } = getGallerySettings(values);
+
+ return autoAddBoardId === GALLERY_AUTO_ADD_FOLLOW ? getGalleryDestinationBoardId(values) : autoAddBoardId;
+};
+
/**
* Preserve valid destinations, otherwise use the project board. An empty board list means loading, so defer
* resolution.
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 513c93ffb2..cde68b1ccc 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.test.ts
@@ -364,6 +364,35 @@ describe('compileProjectGraph', () => {
});
});
+ it('resolves Auto and an unset board to the auto-add board and leaves None Uncategorized', () => {
+ const { doc, sinkId } = buildDocument();
+ const withBoard = (value: unknown) =>
+ compileProjectGraph(
+ projectGraphReducer(doc, { fieldName: 'board', nodeId: sinkId, type: 'setFieldValue', value }),
+ templates,
+ {
+ autoBoardId: 'auto-board',
+ }
+ ).backendGraph?.nodes[sinkId];
+
+ expect(withBoard('auto')).toMatchObject({ board: { board_id: 'auto-board' } });
+ expect(withBoard(undefined)).toMatchObject({ board: { board_id: 'auto-board' } });
+ expect(withBoard('none')).not.toHaveProperty('board');
+ expect(withBoard({ board_id: 'board-1' })).toMatchObject({ board: { board_id: 'board-1' } });
+
+ // An auto-add board of Uncategorized resolves Auto to no board at all.
+ const toUncategorized = projectGraphReducer(doc, {
+ fieldName: 'board',
+ nodeId: sinkId,
+ type: 'setFieldValue',
+ value: 'auto',
+ });
+
+ expect(
+ compileProjectGraph(toUncategorized, templates, { autoBoardId: 'none' }).backendGraph?.nodes[sinkId]
+ ).not.toHaveProperty('board');
+ });
+
it('preserves auto/none board sentinels only in Call Saved Workflow inputs', () => {
const callTemplate = template('call_saved_workflow', {
workflow_id: input('workflow_id', { type: { batch: false, cardinality: 'SINGLE', name: 'StringField' } }),
@@ -383,6 +412,23 @@ describe('compileProjectGraph', () => {
expect(graph.nodes[callNode.id]).toMatchObject({
workflow_inputs: { [dynamicBoardName]: 'auto' },
});
+ // The child workflow's Auto resolves like this workflow's own; None stays a sentinel for its builder.
+ const resolved = compileProjectGraph(
+ document,
+ { call_saved_workflow: callTemplate },
+ { autoBoardId: 'auto-board' }
+ );
+
+ expect(resolved.backendGraph.nodes[callNode.id]).toMatchObject({
+ workflow_inputs: { [dynamicBoardName]: { board_id: 'auto-board' } },
+ });
+
+ callNode.data.inputs[dynamicBoardName] = { label: 'Board', name: dynamicBoardName, value: 'none' };
+
+ expect(
+ compileProjectGraph(document, { call_saved_workflow: callTemplate }, { autoBoardId: 'auto-board' }).backendGraph
+ .nodes[callNode.id]
+ ).toMatchObject({ workflow_inputs: { [dynamicBoardName]: 'none' } });
});
it('resolves connector chains into executable backend edges', () => {
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
index c50f4b7492..f99edcc98d 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
@@ -59,9 +59,22 @@ const getNodeInputTemplates = (
template: InvocationTemplates[string]
): FieldInputTemplate[] => Object.values({ ...template.inputs, ...node.data.dynamicInputTemplates });
-const toBoardGraphValue = (value: unknown): unknown => {
- if (isEmptyValue(value) || value === 'auto' || value === 'none') {
- return undefined;
+export interface CompileProjectGraphOptions {
+ /**
+ * The board Auto (and an unset board field) resolves to; `none` or null leaves the node unboarded, which the
+ * backend saves as Uncategorized.
+ */
+ autoBoardId?: string | null;
+}
+
+/** None is Uncategorized; Auto takes the auto-add board, if there is one. */
+const resolveBoardSentinel = (value: unknown, autoBoardId: string | null | undefined): unknown => {
+ if (value === 'none') {
+ return value;
+ }
+
+ if (isEmptyValue(value) || value === 'auto') {
+ return autoBoardId && autoBoardId !== 'none' ? { board_id: autoBoardId } : 'auto';
}
return value;
@@ -230,19 +243,23 @@ export const getProjectGraphReadiness = (
const toGraphInputValue = (
inputTemplate: FieldInputTemplate,
value: unknown,
- options: { preserveBoardSentinel?: boolean } = {}
+ options: { autoBoardId?: string | null; preserveBoardSentinel?: boolean }
): unknown => {
- if (inputTemplate.type.name === 'BoardField') {
- return options.preserveBoardSentinel ? value : toBoardGraphValue(value);
+ if (inputTemplate.type.name !== 'BoardField') {
+ return value;
}
- return value;
+ const resolved = resolveBoardSentinel(value, options.autoBoardId);
+
+ // A saved workflow's own builder reads the sentinels; a direct field leaves an unresolved one out.
+ return options.preserveBoardSentinel || (resolved !== 'auto' && resolved !== 'none') ? resolved : undefined;
};
/** Compiles the document into a `GraphContract` carrying the executable backend graph. */
export const compileProjectGraph = (
document: ProjectGraphState,
- templates: InvocationTemplates
+ templates: InvocationTemplates,
+ { autoBoardId }: CompileProjectGraphOptions = {}
): CompiledWorkflowGraph => {
const forLoopError = validateForLoopGraph(document);
@@ -269,13 +286,15 @@ export const compileProjectGraph = (
for (const instance of Object.values(node.data.inputs)) {
const inputTemplate = node.data.dynamicInputTemplates?.[instance.name] ?? template.inputs[instance.name];
- if (!inputTemplate || instance.value === undefined) {
+ // An unset board shows as Auto, so it resolves like one.
+ if (!inputTemplate || (instance.value === undefined && inputTemplate.type.name !== 'BoardField')) {
continue;
}
const isSavedWorkflowInput =
node.data.type === 'call_saved_workflow' && instance.name.startsWith(CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX);
const value = toGraphInputValue(inputTemplate, instance.value, {
+ autoBoardId,
preserveBoardSentinel: isSavedWorkflowInput,
});
@@ -498,7 +517,7 @@ export interface WorkflowSubmissionPlan extends WorkflowSeedPlan {
graph: CompiledWorkflowGraph;
}
-export interface WorkflowSubmissionPlanOptions {
+export interface WorkflowSubmissionPlanOptions extends CompileProjectGraphOptions {
/** Runs per submission; already sanitized to a positive integer by the caller. */
batchCount: number;
/** Async generator outputs resolved by the submitter; the plan is null while any are still pending. */
@@ -513,7 +532,7 @@ export interface WorkflowSubmissionPlanOptions {
export const planWorkflowSubmission = (
document: ProjectGraphState,
templates: InvocationTemplates,
- { batchCount, generators, random }: WorkflowSubmissionPlanOptions
+ { autoBoardId, batchCount, generators, random }: WorkflowSubmissionPlanOptions
): WorkflowSubmissionPlan | null => {
const batchPlan = planWorkflowBatch(document, templates, { generators, random });
@@ -533,6 +552,6 @@ export const planWorkflowSubmission = (
batchCount,
batchData: batchPlan.groups,
batchSize: batchPlan.batchSize,
- graph: applyWorkflowSeeds(compileProjectGraph(document, templates), seedPlan.seeds),
+ graph: applyWorkflowSeeds(compileProjectGraph(document, templates, { autoBoardId }), seedPlan.seeds),
};
};
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts
index c189c829c6..2da08513d4 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts
@@ -1,7 +1,7 @@
import type { Rect } from '@workbench/canvas-engine/types';
import type { Project } from '@workbench/projectContracts';
-import { getGalleryDestinationBoardId } from '@features/gallery/contracts';
+import { getGalleryAutoAddBoardId } from '@features/gallery/contracts';
import { toModelIdentifier } from '@features/generation/graph';
import {
getEffectivePrompts,
@@ -47,7 +47,7 @@ const buildCanvasSaveMetadata = (project: Project, rect: Rect): Record<string, u
};
const getCanvasSaveBoardId = (project: Project): string | undefined => {
- const boardId = getGalleryDestinationBoardId(getProjectWidgetValues(project, 'gallery'));
+ const boardId = getGalleryAutoAddBoardId(getProjectWidgetValues(project, 'gallery'));
return boardId !== null && boardId !== 'none' ? boardId : undefined;
};
diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts
index 6201b5696e..d0b245c14d 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts
@@ -339,7 +339,14 @@ describe('stripInstallationState', () => {
const stripped = stripInstallationState({
widgetInstances: {
'gallery-1': {
- state: { values: { galleryView: 'images', projectBoardId: 'board-1', selectedBoardId: 'board-2' } },
+ state: {
+ values: {
+ autoAddBoardId: 'board-3',
+ galleryView: 'images',
+ projectBoardId: 'board-1',
+ selectedBoardId: 'board-2',
+ },
+ },
typeId: 'gallery',
},
},
@@ -348,6 +355,7 @@ describe('stripInstallationState', () => {
expect(JSON.stringify(stripped)).not.toContain('board-1');
expect(JSON.stringify(stripped)).not.toContain('board-2');
+ expect(JSON.stringify(stripped)).not.toContain('board-3');
// Everything else the widget holds survives.
expect(JSON.stringify(stripped)).toContain('galleryView');
});
diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts
index 5cb3f3f8e3..b146393c98 100644
--- a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts
@@ -25,8 +25,15 @@ export const GALLERY_SELECTION_KEYS: ReadonlySet<string> = new Set([
'selectedImageNames',
]);
-/** Strip gallery board IDs while preserving authored workflow board inputs. */
-export const GALLERY_INSTALLATION_KEYS: ReadonlySet<string> = new Set(['projectBoardId', 'selectedBoardId']);
+/**
+ * Strip gallery board IDs while preserving authored workflow board inputs. A dropped auto-add board falls back to
+ * following the selected board.
+ */
+export const GALLERY_INSTALLATION_KEYS: ReadonlySet<string> = new Set([
+ 'autoAddBoardId',
+ 'projectBoardId',
+ 'selectedBoardId',
+]);
/** Clear pagination/window anchors when transferred board IDs change. */
export const GALLERY_POSITION_KEYS: ReadonlySet<string> = new Set(['galleryPage']);
diff --git a/invokeai/frontend/webv2/src/workbench/shell/PasteMediaDialog.tsx b/invokeai/frontend/webv2/src/workbench/shell/PasteMediaDialog.tsx
index f602fa94e7..da73c72402 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/PasteMediaDialog.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/PasteMediaDialog.tsx
@@ -6,7 +6,7 @@ import {
classifyGalleryUpload,
galleryImageItemToGalleryImage,
getGalleryBoardLabel,
- getGalleryDestinationBoardId,
+ getGalleryAutoAddBoardId,
getGallerySelectedBoardId,
getGallerySettings,
getGalleryView,
@@ -115,9 +115,9 @@ export const PasteMediaDialog = ({ request }: { request: PasteMediaRequest }) =>
orderDir: gallerySettings.boardOrderDir,
})
).data ?? EMPTY_BOARDS;
- // Uploads land where generation results do: the picked board, else the
- // project board — never a date bucket, which cannot hold items.
- const destinationBoardId = getGalleryDestinationBoardId(galleryValues) ?? 'none';
+ // Uploads land where generation results do: the auto-add board — never a
+ // date bucket, which cannot hold items.
+ const destinationBoardId = getGalleryAutoAddBoardId(galleryValues) ?? 'none';
const selectedBoardId = getGallerySelectedBoardId(galleryValues, boards);
const galleryView = getGalleryView(galleryValues);
const getCurrentGalleryLocation = useCallback(
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index ec22119a72..c6d4d40331 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -3406,6 +3406,65 @@ describe('workbenchReducer Phase 5 generation flow', () => {
return node?.type === 'invocation' ? node.data.inputs.seed?.value : undefined;
};
+ it('compiles Auto boards to the auto-add board, leaves None unboarded, and keeps results off the selection', () => {
+ const boardTemplate = {
+ ...seedTemplate,
+ inputs: {
+ board: {
+ ...(seedTemplate.inputs.seed as NonNullable<(typeof seedTemplate.inputs)['seed']>),
+ maximum: null,
+ minimum: null,
+ name: 'board',
+ title: 'Board',
+ type: { batch: false, cardinality: 'SINGLE' as const, name: 'BoardField' },
+ },
+ },
+ outputType: 'image_output',
+ title: 'Save Image',
+ type: 'save_image',
+ };
+ const boardNode = (id: string, board: unknown) => ({
+ data: {
+ inputs: { board: { label: '', name: 'board', value: board } },
+ isIntermediate: false,
+ isOpen: true,
+ label: '',
+ nodePack: 'invokeai',
+ notes: '',
+ type: 'save_image',
+ useCache: true,
+ version: '1.0.0',
+ },
+ id,
+ position: { x: 0, y: 0 },
+ type: 'invocation' as const,
+ });
+ let state = workbenchReducer(createInitialWorkbenchState(), { presetId: 'automate', type: 'applyPreset' });
+
+ workflowTemplatesMock.snapshot = { error: null, status: 'loaded', templates: { save_image: boardTemplate } };
+ state = workbenchReducer(state, { boardId: 'selected-board', type: 'selectGalleryBoard' });
+ state = workbenchReducer(state, { settings: { autoAddBoardId: 'auto-board' }, type: 'updateGallerySettings' });
+
+ for (const [id, board] of [
+ ['auto-node', 'auto'],
+ ['none-node', 'none'],
+ ] as const) {
+ state = workbenchReducer(state, {
+ action: { node: boardNode(id, board), type: 'addNode' },
+ type: 'applyWorkflowAction',
+ });
+ }
+
+ state = submitWorkflow(state);
+
+ const graph = (readSubmission(state) as { graph: { nodes: Record<string, Record<string, unknown>> } }).graph;
+
+ expect(graph.nodes['auto-node']).toMatchObject({ board: { board_id: 'auto-board' } });
+ expect(graph.nodes['none-node']).not.toHaveProperty('board');
+ // Boards are settled in the graph, so nothing is re-filed onto the selected board afterwards.
+ expect(getActiveProject(state).queue.items[0]?.snapshot.galleryBoardId).toBeNull();
+ });
+
it('carries batch-node groups on the submission and sizes the placeholders for every session', () => {
const floatField = {
...(seedTemplate.inputs.seed as NonNullable<(typeof seedTemplate.inputs)['seed']>),
@@ -5148,6 +5207,7 @@ describe('workbenchReducer Phase 5 generation flow', () => {
let state = createInitialWorkbenchState();
state = workbenchReducer(state, { boardId: 'doomed-board', type: 'selectGalleryBoard' });
+ state = workbenchReducer(state, { settings: { autoAddBoardId: 'doomed-board' }, type: 'updateGallerySettings' });
state = workbenchReducer(state, {
type: 'patchWidgetValues',
values: { semanticImageQuery: { kind: 'text', query: 'sunset' } },
@@ -5171,6 +5231,8 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(values.selectedBoardId).toBe('none');
expect(values.semanticImageQuery).toBeNull();
+ // A deleted auto-add board hands results back to the selection.
+ expect(values.autoAddBoardId).toBe('follow');
});
it('stores selected backend board id for gallery submissions', () => {
@@ -5186,6 +5248,18 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(queueItem.snapshot.galleryBoardId).toBe('backend-board-id');
});
+ it('sends gallery submissions to a fixed auto-add board rather than the selected one', () => {
+ let state = createInitialWorkbenchState();
+
+ state = workbenchReducer(state, { boardId: 'selected-board', type: 'selectGalleryBoard' });
+ state = workbenchReducer(state, { settings: { autoAddBoardId: 'auto-board' }, type: 'updateGallerySettings' });
+ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });
+ state = primeGenerate(state);
+ state = submitGenerate(state);
+
+ expect(getActiveProject(state).queue.items[0]?.snapshot.galleryBoardId).toBe('auto-board');
+ });
+
it('sends gallery submissions to the project board until a board is picked', () => {
let state = createInitialWorkbenchState();
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 1c97358ddc..b63d944385 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -55,11 +55,12 @@ import {
getPersistedSelectedGalleryItemKeys,
stripInfiniteWindowAnchor,
stripUnresolvableGallerySearch,
+ GALLERY_AUTO_ADD_FOLLOW,
gallerySemanticReferenceKey,
getGallerySettings,
parseGallerySemanticReference,
toGallerySemanticTextReference,
- getGalleryDestinationBoardId,
+ getGalleryAutoAddBoardId,
getSelectedGalleryItemFromValues,
legacyGeneratedImageToGalleryItem,
normalizeGalleryImage,
@@ -2443,6 +2444,7 @@ const compileInvocationSnapshot = (
}
const plan = planWorkflowSubmission(workflowDocument, templatesSnapshot.templates, {
+ autoBoardId: getGalleryAutoAddBoardId(widgetStates.gallery?.values ?? {}),
batchCount: sanitizeBatchCount(widgetStates.workflow?.values.batchCount),
generators: workflowGenerators,
});
@@ -2808,8 +2810,9 @@ const reconcileDeletedGalleryBoard = (
const withBoardReferencesCleared = updateAllProjectGalleryValues(withSurvivorsMoved, (values) => {
const selectedBoardWasDeleted = values.selectedBoardId === boardId;
const projectBoardWasDeleted = values.projectBoardId === boardId;
+ const autoAddBoardWasDeleted = values.autoAddBoardId === boardId;
- if (!selectedBoardWasDeleted && !projectBoardWasDeleted) {
+ if (!selectedBoardWasDeleted && !projectBoardWasDeleted && !autoAddBoardWasDeleted) {
return values;
}
@@ -2819,6 +2822,7 @@ const reconcileDeletedGalleryBoard = (
? { galleryPage: 0, selectedBoardId: 'none', semanticImageQuery: null, semanticSearchText: null }
: {}),
...(projectBoardWasDeleted ? { projectBoardId: null } : {}),
+ ...(autoAddBoardWasDeleted ? { autoAddBoardId: GALLERY_AUTO_ADD_FOLLOW } : {}),
};
});
let didChangeQueue = false;
@@ -3272,7 +3276,9 @@ const enqueueCompiledSnapshot = (
seedStep: seedPlan?.step ?? 0,
}
: { error: `${route.sourceId} queue item is missing source submission metadata.`, kind: 'invalid' };
- const galleryBoardId = getGalleryDestinationBoardId(widgetStates.gallery?.values ?? {});
+ // A workflow compiles every node's board in (Auto included), so its board-less results stay Uncategorized.
+ const galleryBoardId =
+ route.sourceId === 'workflow' ? null : getGalleryAutoAddBoardId(widgetStates.gallery?.values ?? {});
const generatePresentationSettings = normalizeGenerateSettings(widgetStates.generate?.values);
const videoPresentationDimensions =
route.sourceId === 'video' && videoSettings?.model ? getVideoDimensions(videoSettings.model, videoSettings) : null;