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(gallery): fetch the same board the state view resolves

Josh Corbett5c4d204e2a29
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx
index 1a00c01f0d..4e8fe09b6b 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx
@@ -74,6 +74,7 @@ const createGallery = (settings: Partial<GallerySettings> = {}): GalleryStateVie
compareImageKey: null,
currentItem: null,
galleryView: 'images',
+ isComparisonActive: false,
isLoading: false,
items: [],
page: 0,
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
index 517f21c8d0..0dad294788 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
@@ -217,6 +217,7 @@ const createGallery = (overrides: Partial<GalleryStateView> = {}): GalleryStateV
compareImageKey: null,
currentItem: { itemKey: 'image:first.png', kind: 'item' },
galleryView: 'images',
+ isComparisonActive: false,
isLoading: false,
items,
page: 0,
@@ -315,6 +316,7 @@ const createAdapter = (): GalleryUiAdapter =>
account: { enableLiveFollow: noop },
antialiasProgressImages: false,
gallery: {
+ clearSelection: noop,
reconcileDeletedBoardOutcome: noop,
selectBoard: noop,
selectImage: noop,
@@ -751,6 +753,7 @@ describe('GalleryImageGrid mixed item cells', () => {
await renderGallery(
createGallery({
compareImageKey: 'image:compare.png',
+ isComparisonActive: true,
items: [image, video],
selectedItemKey: 'image:first.png',
selectedItemKeys: ['image:first.png'],
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
index 9bb95f166e..933246f5f4 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
@@ -154,11 +154,7 @@ export const GalleryImageGrid = () => {
const columnCount = getGalleryColumnCount({ imageDensityPercent, widthPx: viewportWidth });
const isFollowingLive = gallery.currentItem?.kind === 'placeholder';
- const isComparisonActive =
- gallery.selectedItemKey?.startsWith('image:') === true &&
- gallery.compareImageKey !== null &&
- gallery.selectedItemKey !== null &&
- gallery.compareImageKey !== gallery.selectedItemKey;
+ const isComparisonActive = gallery.isComparisonActive;
const selectedBoard = gallery.boards.find((board) => board.id === gallery.selectedBoardId);
const selectedBoardName = selectedBoard
? getGalleryBoardLabel(selectedBoard, t)
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx
index f2db1a3a3e..ac5137988e 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx
@@ -54,6 +54,7 @@ export interface GalleryItemContextMenuProps {
}
export interface GalleryCommandsPort {
+ clearSelection(): void;
reconcileDeletedBoardOutcome(outcome: GalleryBoardDeletionResult): void;
selectBoard(boardId: string): void;
selectItem(item: GalleryItem): void;
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx
index e1597454b5..d72e087d8b 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx
@@ -15,8 +15,9 @@ import { GalleryBoardDragMonitor } from './GalleryBoardDragMonitor';
import { GalleryLayout } from './GalleryLayout';
import {
getGalleryPage,
+ getGalleryProjectBoardId,
+ getGalleryRawSelectedBoardId,
getGallerySearchTerm,
- getGallerySelectedBoardId,
getGallerySemanticImageQuery,
getGalleryStateView,
getGalleryTotalImages,
@@ -84,9 +85,10 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidg
const data = useGalleryData({
galleryView,
page,
+ projectBoardId: getGalleryProjectBoardId(galleryValues),
recentImages,
searchTerm,
- selectedBoardId: getGallerySelectedBoardId(galleryValues, []),
+ selectedBoardId: getGalleryRawSelectedBoardId(galleryValues),
semanticQuery,
settings,
});
@@ -108,16 +110,19 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidg
});
}, [notifications, semanticError]);
- const { loadMore, total } = data;
- const selectedBoardId = getGallerySelectedBoardId(galleryValues, data.boards);
- const gallery = getGalleryStateView(
- galleryValues,
- data.boards,
- data.items,
- data.isLoadingItems,
- queueItems,
- liveFollowEnabled,
- liveProgressTarget
+ const { loadMore, selectedBoardId, total } = data;
+ const gallery = useMemo(
+ () =>
+ getGalleryStateView(
+ galleryValues,
+ data.boards,
+ data.items,
+ data.isLoadingItems,
+ queueItems,
+ liveFollowEnabled,
+ liveProgressTarget
+ ),
+ [data.boards, data.isLoadingItems, data.items, galleryValues, liveFollowEnabled, liveProgressTarget, queueItems]
);
const lastPublishedTotalRef = useRef<number | null>(null);
const itemActionFilterIdentity = useMemo(() => JSON.stringify(data.filter), [data.filter]);
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 aca14bd9ba..be35a4a1af 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts
@@ -9,7 +9,6 @@ import {
getGalleryCurrentItem,
getGalleryGenerationSequence,
getGalleryLiveSlots,
- getGalleryQueuePlaceholders,
getGallerySelectedBoardId,
getGallerySemanticImageQuery,
getGalleryStateView,
@@ -112,6 +111,9 @@ const createQueueItem = ({
status,
});
+const getPendingPlaceholders = (queueItems: QueueItem[], values: Record<string, unknown>) =>
+ getGalleryStateView(values, boards, [], false, queueItems).pendingPlaceholders;
+
describe('gallery state view', () => {
it('preserves a selected backend board id while boards are still loading', () => {
const values = { selectedBoardId: 'board-1' };
@@ -203,6 +205,27 @@ describe('gallery state view', () => {
});
});
+ it('exposes comparison state only while an image selection differs from the compare image', () => {
+ const selected = createImageItem('selected.png');
+ const values = {
+ compareImage: createImageItem('compare.png'),
+ selectedBoardId: 'none',
+ selectedImageName: 'image:selected.png',
+ };
+
+ expect(getGalleryStateView(values, boards, [selected], false).isComparisonActive).toBe(true);
+ expect(
+ getGalleryStateView({ ...values, compareImage: selected }, boards, [selected], false).isComparisonActive
+ ).toBe(false);
+ expect(getGalleryStateView(values, boards, [], false).isComparisonActive).toBe(false);
+
+ const video = createVideoItem('clip');
+
+ expect(
+ getGalleryStateView({ ...values, selectedImageName: 'video:clip' }, boards, [video], false).isComparisonActive
+ ).toBe(false);
+ });
+
it('exposes the selection page only when its stamp names the listing the grid shows', () => {
const stamped = {
galleryPage: 0,
@@ -358,11 +381,7 @@ describe('gallery state view', () => {
createQueueItem({ batchCount: 2, boardId: 'board-1', status: 'pending' }),
createQueueItem({ backendItemIds: [11, 12, 13], boardId: 'board-1', status: 'running' }),
];
- const placeholders = getGalleryQueuePlaceholders(queueItems, {
- galleryView: 'images',
- searchTerm: '',
- selectedBoardId: 'board-1',
- });
+ const placeholders = getPendingPlaceholders(queueItems, { imageOrderDir: 'ASC', selectedBoardId: 'board-1' });
expect(placeholders).toHaveLength(5);
expect(placeholders[0]).toMatchObject({
@@ -383,11 +402,7 @@ describe('gallery state view', () => {
}),
];
- const placeholders = getGalleryQueuePlaceholders(queueItems, {
- galleryView: 'images',
- searchTerm: '',
- selectedBoardId: 'board-1',
- });
+ const placeholders = getPendingPlaceholders(queueItems, { imageOrderDir: 'ASC', selectedBoardId: 'board-1' });
expect(placeholders.map((placeholder) => placeholder.itemIndex)).toEqual([2, 3]);
});
@@ -475,10 +490,8 @@ describe('gallery state view', () => {
status: 'running',
});
- const placeholders = getGalleryQueuePlaceholders([newerBatch, earlierBatch], {
- galleryView: 'images',
+ const placeholders = getPendingPlaceholders([newerBatch, earlierBatch], {
imageOrderDir: 'DESC',
- searchTerm: '',
selectedBoardId: 'board-1',
});
@@ -546,11 +559,7 @@ describe('gallery state view', () => {
}),
];
- const placeholders = getGalleryQueuePlaceholders(queueItems, {
- galleryView: 'images',
- searchTerm: '',
- selectedBoardId: 'board-1',
- });
+ const placeholders = getPendingPlaceholders(queueItems, { imageOrderDir: 'ASC', selectedBoardId: 'board-1' });
expect(placeholders.map((placeholder) => placeholder.itemIndex)).toEqual([3]);
});
@@ -562,20 +571,14 @@ describe('gallery state view', () => {
createQueueItem({ boardId: 'board-1', destination: 'canvas', status: 'pending' }),
];
- expect(
- getGalleryQueuePlaceholders(queueItems, { galleryView: 'images', searchTerm: '', selectedBoardId: 'board-1' })
- ).toEqual([]);
+ expect(getPendingPlaceholders(queueItems, { selectedBoardId: 'board-1' })).toEqual([]);
});
it('hides placeholders while searching or browsing assets', () => {
const queueItems = [createQueueItem({ boardId: 'none', status: 'pending' })];
- expect(
- getGalleryQueuePlaceholders(queueItems, { galleryView: 'images', searchTerm: 'cat', selectedBoardId: 'none' })
- ).toEqual([]);
- expect(
- getGalleryQueuePlaceholders(queueItems, { galleryView: 'assets', searchTerm: '', selectedBoardId: 'none' })
- ).toEqual([]);
+ expect(getPendingPlaceholders(queueItems, { searchTerm: 'cat', selectedBoardId: 'none' })).toEqual([]);
+ expect(getPendingPlaceholders(queueItems, { galleryView: 'assets', selectedBoardId: 'none' })).toEqual([]);
expect(
getGalleryStateView({ selectedBoardId: 'none' }, boards, [], false, queueItems).pendingPlaceholders
).toHaveLength(1);
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts
index 173dbd02fc..81ab7108d4 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts
@@ -84,6 +84,8 @@ export interface GalleryStateView {
compareImageKey: GalleryItemKey | null;
currentItem: GalleryCurrentItem;
galleryView: GalleryView;
+ /** A compare image is set and differs from the visible image selection. */
+ isComparisonActive: boolean;
items: GalleryItem[];
isLoading: boolean;
/** The grid's current page in paginated mode; the window anchor otherwise. */
@@ -253,6 +255,10 @@ export const getGallerySearchTerm = (values: Record<string, unknown>): string =>
export const getGallerySemanticImageQuery = (values: Record<string, unknown>): GallerySemanticReference | null =>
parseGallerySemanticReference(values.semanticImageQuery);
+/** The saved board choice as persisted, before any resolution against loaded boards. */
+export const getGalleryRawSelectedBoardId = (values: Record<string, unknown>): string | null =>
+ typeof values.selectedBoardId === 'string' ? values.selectedBoardId : null;
+
/**
* Where new results land, resolved against the boards this install actually has.
*
@@ -263,9 +269,10 @@ export const getGallerySemanticImageQuery = (values: Record<string, unknown>): G
*
* An empty board list means "still loading", not "no such board", so nothing resolves yet.
*/
-export const getGallerySelectedBoardId = (values: Record<string, unknown>, backendBoards: GalleryBoard[]): string => {
- const selectedBoardId = typeof values.selectedBoardId === 'string' ? values.selectedBoardId : null;
-
+export const resolveGallerySelectedBoardId = (
+ { projectBoardId, selectedBoardId }: { projectBoardId: string | null; selectedBoardId: string | null },
+ backendBoards: GalleryBoard[]
+): string => {
if (backendBoards.length === 0) {
return selectedBoardId ?? 'none';
}
@@ -274,8 +281,6 @@ export const getGallerySelectedBoardId = (values: Record<string, unknown>, backe
return selectedBoardId;
}
- const projectBoardId = getGalleryProjectBoardId(values);
-
if (projectBoardId !== null && backendBoards.some((board) => board.id === projectBoardId)) {
return projectBoardId;
}
@@ -283,6 +288,12 @@ export const getGallerySelectedBoardId = (values: Record<string, unknown>, backe
return 'none';
};
+export const getGallerySelectedBoardId = (values: Record<string, unknown>, backendBoards: GalleryBoard[]): string =>
+ resolveGallerySelectedBoardId(
+ { projectBoardId: getGalleryProjectBoardId(values), selectedBoardId: getGalleryRawSelectedBoardId(values) },
+ backendBoards
+ );
+
export const getGalleryPage = (values: Record<string, unknown>): number =>
typeof values.galleryPage === 'number' && Number.isFinite(values.galleryPage)
? Math.max(0, Math.floor(values.galleryPage))
@@ -351,23 +362,6 @@ export const getGalleryCompareImage = (values: Record<string, unknown>): Gallery
selectedImageName: null,
});
-export const getGalleryQueuePlaceholders = (
- queueItems: QueueItem[],
- {
- galleryView,
- imageOrderDir = 'ASC',
- searchTerm,
- selectedBoardId,
- }: { galleryView: GalleryView; imageOrderDir?: GalleryOrderDir; searchTerm: string; selectedBoardId: string }
-): GalleryQueuePlaceholder[] => {
- return getVisibleGalleryQueuePlaceholders(getGalleryGenerationSequence(queueItems, null).chronologicalSlots, {
- galleryView,
- imageOrderDir,
- searchTerm,
- selectedBoardId,
- });
-};
-
const getVisibleGalleryQueuePlaceholders = (
chronologicalSlots: GalleryQueuePlaceholder[],
{
@@ -491,6 +485,7 @@ export const getGalleryStateView = (
compareImageKey,
currentItem,
galleryView,
+ isComparisonActive,
items,
isLoading,
page,
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx
index caa1876bbb..5475f2db37 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx
@@ -159,6 +159,7 @@ const adapter: GalleryUiAdapter = {
antialiasProgressImages: false,
exportProject: vi.fn(),
gallery: {
+ clearSelection: noop,
reconcileDeletedBoardOutcome,
selectBoard,
selectImage: noop,
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts
index f06abada1d..7d76dfaeb5 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts
@@ -18,11 +18,15 @@ import { parseDateTokens } from '@platform/search/dateTokens';
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
import { useCallback, useMemo } from 'react';
+import { resolveGallerySelectedBoardId } from './galleryStateView';
+
export interface GalleryData {
boards: GalleryBoard[];
filter: GalleryItemsFilter;
hasMore: boolean;
isLoadingItems: boolean;
+ /** The resolved board the items were fetched for. */
+ selectedBoardId: string;
/**
* True when the infinite window is full *and* the board holds more images
* than it can reach. `hasMore` is false in that case exactly as it is at the
@@ -38,6 +42,8 @@ export interface GalleryData {
total: number | null;
}
+const EMPTY_BOARDS: GalleryBoard[] = [];
+
const useGalleryBoards = ({ settings }: { settings: GallerySettings }) => {
const query = useQuery(
galleryBoardsOptions({
@@ -48,7 +54,7 @@ const useGalleryBoards = ({ settings }: { settings: GallerySettings }) => {
})
);
- return { boards: query.data ?? [] };
+ return { boards: query.data ?? EMPTY_BOARDS };
};
const isRecentItemVisible = (item: GalleryItem, filter: GalleryItemsFilter): boolean => {
@@ -136,6 +142,7 @@ export const isGalleryWindowTruncated = ({
export const useGalleryData = ({
galleryView,
page,
+ projectBoardId,
recentImages,
searchTerm,
selectedBoardId,
@@ -144,16 +151,16 @@ export const useGalleryData = ({
}: {
galleryView: GalleryView;
page: number;
+ projectBoardId: string | null;
recentImages: readonly GeneratedImageContract[];
searchTerm: string;
- selectedBoardId: string;
+ selectedBoardId: string | null;
/** When set, items come from semantic search (similarity order) instead of the board listing. */
semanticQuery?: GallerySemanticReference | null;
settings: GallerySettings;
}): GalleryData => {
const { boards } = useGalleryBoards({ settings });
- const boardId =
- boards.length === 0 || boards.some((board) => board.id === selectedBoardId) ? selectedBoardId : 'none';
+ const boardId = resolveGallerySelectedBoardId({ projectBoardId, selectedBoardId }, boards);
const isPaginated = settings.paginationMode === 'paginated';
const dateParse = useMemo(() => parseDateTokens(searchTerm), [searchTerm]);
const filter = useMemo<GalleryItemsFilter>(
@@ -241,5 +248,16 @@ export const useGalleryData = ({
void fetchNextPage();
}, [fetchNextPage, hasMore, isFetchingNextPage]);
- return { boards, filter, hasMore, isLoadingItems: isFetching, isWindowTruncated, items, loadMore, queryError, total };
+ return {
+ boards,
+ filter,
+ hasMore,
+ isLoadingItems: isFetching,
+ isWindowTruncated,
+ items,
+ loadMore,
+ queryError,
+ selectedBoardId: boardId,
+ total,
+ };
};
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryGridHotkeys.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryGridHotkeys.ts
index fa9d67450a..b1bfe862d0 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryGridHotkeys.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryGridHotkeys.ts
@@ -42,7 +42,7 @@ export const useGalleryGridHotkeys = ({
}) => {
const { t } = useTranslation();
const { actions, gallery, itemActions, runtime } = useGalleryWidget();
- const { widgets } = useGalleryUi();
+ const { gallery: galleryCommands } = useGalleryUi();
const navigate = useEffectEvent((direction: GalleryNavDirection) => {
const itemCount = gallery.items.length;
@@ -75,11 +75,7 @@ export const useGalleryGridHotkeys = ({
}
if (commandId === 'gallery.clearSelection') {
- widgets.patchGalleryValues({
- selectedImage: null,
- selectedImageName: null,
- selectedImageNames: [],
- });
+ galleryCommands.clearSelection();
return;
}
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx
index 244d9a536b..5d4aac5781 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx
@@ -80,6 +80,7 @@ const adapter: GalleryUiAdapter = {
antialiasProgressImages: false,
exportProject: vi.fn(),
gallery: {
+ clearSelection: noop,
reconcileDeletedBoardOutcome: noop,
selectBoard: noop,
selectImage: noop,
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index e2b63e6c05..967bf828f7 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -3694,6 +3694,25 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(getProjectWidgetValues(getActiveProject(state), 'gallery').selectedImageName).toBe('image:selected.png');
});
+ it('clears the Gallery selection while keeping the compare image and navigation stamp', () => {
+ let state = createInitialWorkbenchState();
+
+ state = workbenchReducer(state, { item: createGalleryImageItem('selected.png'), type: 'selectGalleryItem' });
+ state = workbenchReducer(state, {
+ image: createGalleryImageItem('compare.png'),
+ type: 'setGalleryCompareImage',
+ });
+ state = workbenchReducer(state, { type: 'clearGallerySelection' });
+
+ const values = getProjectWidgetValues(getActiveProject(state), 'gallery');
+
+ expect(values.selectedImage).toBeNull();
+ expect(values.selectedImageName).toBeNull();
+ expect(values.selectedImageNames).toEqual([]);
+ expect(values.compareImage).toMatchObject({ name: 'compare.png' });
+ expect(values.selectedImageQuery).toBeDefined();
+ });
+
it('preserves a manually selected image when later Gallery results arrive', () => {
let state = primeGenerate();
state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index d1940a095a..3ff9f36227 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -348,6 +348,7 @@ type WorkbenchReducerAction =
}
| { type: 'setGalleryCompareImage'; image: GalleryImageItem | null; projectId?: string }
| { type: 'selectGalleryBoard'; boardId: string; projectId?: string }
+ | { type: 'clearGallerySelection'; projectId?: string }
| { type: 'setGalleryView'; galleryView: 'images' | 'assets'; projectId?: string }
| { type: 'setGallerySearchTerm'; searchTerm: string; projectId?: string }
| { type: 'updateGallerySettings'; settings: Partial<Omit<GallerySettings, 'starredFirst'>>; projectId?: string }
@@ -4655,6 +4656,13 @@ export const __workbenchReducerInternal = (
action.projectId
);
}
+ case 'clearGallerySelection': {
+ return updateGalleryValues(
+ state,
+ (values) => ({ ...values, selectedImage: null, selectedImageName: null, selectedImageNames: [] }),
+ action.projectId
+ );
+ }
case 'setGalleryView': {
return updateGalleryValues(
state,
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts b/invokeai/frontend/webv2/src/workbench/workbenchStore.ts
index 9664602eb7..3ba92be276 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchStore.ts
@@ -94,6 +94,7 @@ const createCommands = (
appendStagingCandidate: command('appendCanvasStagingCandidate'),
},
gallery: {
+ clearSelection: command('clearGallerySelection', (projectId?: string) => ({ projectId })),
patchItems: command(
'patchGalleryItems',
(