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): reconcile board grouping with sparse paging

Josh Corbett9f68170b9c8e
diff --cc invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx
index 402e3479de,14da4cff55..ef1ea04805
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx
@@@ -81,7 -78,8 +81,8 @@@ const createGallery = (settings: Partia
items: [],
page: 0,
pendingPlaceholders: [],
+ primarySelectedItemKey: null,
- projectBoardId: null,
+ projectBoardId: 'mine',
revealTargetPage: null,
searchTerm: '',
selectedBoardId: 'dogs',
diff --cc invokeai/frontend/webv2/src/features/gallery/ui/GallerySelectionBar.tsx
index 994ede754f,38e3444dd3..3f0f8edcc2
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GallerySelectionBar.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GallerySelectionBar.tsx
@@@ -1,8 -1,8 +1,8 @@@
import type { GalleryBoard } from '@features/gallery/core/types';
import { HStack, Icon, Menu, Portal, Text } from '@chakra-ui/react';
-import { getGalleryBoardLabel } from '@features/gallery/core/boardLabels';
+import { getGalleryBoardDestinationGroups, getGalleryBoardLabel } from '@features/gallery/core/boardLabels';
- import { parseGalleryItemKey, shouldStarSelection } from '@features/gallery/core/items';
+ import { parseGalleryItemKey } from '@features/gallery/core/items';
import { IconButton } from '@platform/ui/Button';
import { MenuContent } from '@platform/ui/Menu';
import { Tooltip } from '@platform/ui/Tooltip';
diff --cc invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx
index c74809c971,356563f7cc..f4ab08e0cc
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx
@@@ -78,11 -79,14 +83,17 @@@ export interface GalleryWidgetContextVa
listing: GalleryListingState;
/** Everything on hand — strip first, then the listing, without repeats — for lookups by key. */
loadedItems: GalleryItem[];
+ /** Main Gallery's absolute page slots. Other Gallery surfaces continue to use a dense loaded projection. */
+ sparseListing?: GallerySparseListing;
+ /** Reports the grid's virtual item range so only intersecting page queries stay subscribed. */
+ setVisibleRange?: (range: { endIndexExclusive: number; startIndex: number }) => void;
+ /** See `GalleryData.pinRevealIndex`; offered for sparse infinite listings only. */
+ pinRevealIndex?: (absoluteIndex: number) => void;
starredStrip: GalleryStarredStrip;
+ projectId: string;
projectName: string;
+ /** Names for the projects other boards belong to, keyed by project id. */
+ projectNames: ReadonlyMap<string, string>;
/** Placement, used only to scope cached viewport measurements. */
region: GalleryWidgetProps['region'];
runtime: GalleryWidgetRuntime;
diff --cc invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.browser.test.tsx
index 93355fb0fd,d824a6c20d..731cfc2138
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.browser.test.tsx
@@@ -30,6 -53,81 +53,82 @@@ afterEach(async () =>
root = null;
});
+ const createImageItem = (name: string): GalleryImageItem => ({
+ boardId: 'none',
+ category: 'general',
+ createdAt: '2026-10-05T00:00:00.000Z',
+ fullUrl: `/api/v1/images/i/${name}/full`,
+ height: 768,
+ isIntermediate: false,
+ kind: 'image',
+ name,
+ starred: false,
+ thumbnailUrl: `/api/v1/images/i/${name}/thumbnail`,
+ width: 512,
+ });
+
+ const itemActions = {
+ deleteItems: vi.fn(),
+ downloadItem: vi.fn(),
+ downloadItems: vi.fn(),
+ moveItemsToBoard: vi.fn(),
+ openItemInNewTab: vi.fn(),
+ openItemInPreview: vi.fn(),
+ setItemsStarred: vi.fn(),
+ };
+ const noop = vi.fn();
+
+ const CapturingItemActionsProvider = ({
+ children,
+ getItemActionContext,
+ }: ComponentProps<GalleryUiAdapter['ItemActionsProvider']>) => {
+ // eslint-disable-next-line react/immutability -- The browser test reads the props supplied to this provider.
+ mocks.getItemActionContext = getItemActionContext ?? null;
+ return <GalleryItemActionsProvider actions={itemActions}>{children}</GalleryItemActionsProvider>;
+ };
+
+ const adapter: GalleryUiAdapter = {
+ ItemActionsProvider: CapturingItemActionsProvider,
+ ImageContextMenu: () => null,
+ antialiasProgressImages: false,
+ exportProject: noop,
+ followedProgressSessionId: null,
+ followProgressSession: noop,
+ gallery: {
+ clearSelection: noop,
+ clearSearch: noop,
+ commitSemanticSearch: noop,
+ reconcileDeletedBoardOutcome: noop,
+ selectBoard: noop,
+ selectImage: noop,
+ selectItem: noop,
+ setCompareImage: noop,
+ setCompareItem: noop,
+ setItemMultiSelection: noop,
+ setPage: noop,
+ setPageInfo: noop,
+ setSearchTerm: noop,
+ setSemanticSearchMode: noop,
+ setSemanticSearchText: noop,
+ setStarredOnly: noop,
+ setView: noop,
+ toggleItemSelection: noop,
+ updateSettings: noop,
+ },
+ galleryValues: { galleryPage: 0, selectedBoardId: 'none' },
+ generateValues: {},
+ getItemLabel: () => Promise.resolve(null),
+ liveFollowEnabled: false,
+ notifications: { add: noop, reportError: noop },
+ pinnedProgressSessionId: null,
+ progressSessions: [],
+ projectId: 'project-1',
+ projectName: 'Project',
++ projects: [],
+ widgets: { openGallery: () => true, patchGalleryValues: noop },
+ };
+ const runtime = { commands: { register: noop }, hotkeys: { register: noop } };
+
it('renders the compact gallery status through the localized status-chip key', async () => {
await act(() =>
root?.render(
diff --cc invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx
index fecb194ac7,d5d7893807..94f2339835
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx
@@@ -232,11 -247,12 +249,14 @@@ export const GalleryWidgetView = ({ pre
isWindowTruncated={data.isWindowTruncated}
listing={data.listing}
loadedItems={loadedItems}
+ projectId={projectId}
projectName={projectName}
+ projects={projects}
region={region}
runtime={runtime}
+ pinRevealIndex={data.pinRevealIndex}
+ setVisibleRange={data.setVisibleRange}
+ sparseListing={data.sparseListing}
starredStrip={starredStrip}
/>
</ItemActionsProvider>
@@@ -281,11 -297,12 +301,14 @@@ const GalleryWidgetContent = (
isWindowTruncated,
listing,
loadedItems,
+ pinRevealIndex,
+ projectId,
projectName,
+ projects,
region,
runtime,
+ setVisibleRange,
+ sparseListing,
starredStrip,
}: {
actions: GalleryActions;
@@@ -295,11 -312,12 +318,14 @@@
isWindowTruncated: boolean;
listing: GalleryListingState;
loadedItems: GalleryItem[];
+ pinRevealIndex: GalleryData['pinRevealIndex'];
+ projectId: string;
projectName: string;
+ projects: readonly GalleryProjectRef[];
region: GalleryWidgetProps['region'];
runtime: GalleryWidgetRuntime;
+ setVisibleRange: ((range: { endIndexExclusive: number; startIndex: number }) => void) | undefined;
+ sparseListing: GalleryData['sparseListing'];
starredStrip: GalleryStarredStrip;
}) => {
const { t } = useTranslation();
@@@ -315,11 -332,12 +341,14 @@@
itemActions,
listing,
loadedItems,
+ pinRevealIndex,
+ projectId,
projectName,
+ projectNames,
region,
runtime,
+ setVisibleRange,
+ sparseListing,
starredStrip,
}),
[
@@@ -331,11 -349,12 +360,14 @@@
itemActions,
listing,
loadedItems,
+ pinRevealIndex,
+ projectId,
projectName,
+ projectNames,
region,
runtime,
+ setVisibleRange,
+ sparseListing,
starredStrip,
]
);
diff --cc invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsx
index 396c3f6055,f6c55f4a62..f2ef5c7769
--- a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsx
@@@ -2,8 -3,9 +3,9 @@@ import type { GallerySparseListing } fr
import type { KeyboardEvent, RefObject } from 'react';
import { Box, HStack, Icon, Stack, Text } from '@chakra-ui/react';
-import { getGalleryBoardLabel } from '@features/gallery/core/boardLabels';
+import { getGalleryProjectGroupLabel, getGalleryBoardLabel } from '@features/gallery/core/boardLabels';
import { getGalleryUploadAccept, toGalleryItemKey } from '@features/gallery/core/items';
+ import { GALLERY_PAGE_SIZE, galleryItemsPageOptions } from '@features/gallery/data/queries';
import { BoardCover, BoardCoverIcon } from '@features/gallery/ui/GalleryBoardCover';
import { getGalleryBoardGroups } from '@features/gallery/ui/galleryBoardGroups';
import { GalleryAnnouncer, GalleryLoadErrorState, GalleryLoadNotice } from '@features/gallery/ui/GalleryLoadError';