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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(webv2): finalize mixed gallery review fixes
joshistoast0d39ebd42b57
diff --git a/.superpowers/sdd/mixed-media-gallery-parity/final-review-fix-report.md b/.superpowers/sdd/mixed-media-gallery-parity/final-review-fix-report.mdnew file mode 100644index 0000000000..0914e37496--- /dev/null+++ b/.superpowers/sdd/mixed-media-gallery-parity/final-review-fix-report.md@@ -0,0 +1,103 @@+# Mixed-media gallery parity: final review fix report++Base reviewed: `0b7acabad952597073a2ea1b3298e8848351aba3`++## Findings resolved++### Upload completion uses the latest gallery context++- `GalleryWidgetView` now exposes a render-assigned, stable live-read port for+ the current board and Images/Assets view. No `useEffect` was added.+- An upload still captures its transport target and target-board name when it+ starts.+- After all image/video requests settle and the account scope is revalidated,+ selection visibility is evaluated against the latest board and view.+- Switching either board or view while an upload is pending no longer selects+ media that is invisible in the new context.+- Existing concurrent image uploads, sequential video uploads, settled+ outcomes, newest-item comparator, one invalidation, and one summary+ notification are preserved.++Strict TDD evidence:++- RED: the deferred view-switch browser test received one `selectItem` call for+ `photo.png` when it expected none.+- GREEN: the deferred board-switch and view-switch cases both pass, including+ assertions that transport still targets the launch board and completion+ emits one invalidation and one summary.++### Persisted selection-key compatibility is centralized++- Added `getPersistedSelectedGalleryItemKeys()` to Gallery core and exported it+ through the existing Gallery contract.+- The reader preserves the established precedence:+ `selectedImageNames` → `selectedImageName` → canonical/legacy+ `selectedImage`.+- Bare image names and qualified mixed-media keys are canonicalized through the+ existing parser.+- Both `galleryStateView` and `workbenchState` now use the shared reader.++Strict TDD evidence:++- RED: all three new cases received `undefined` before the shared reader+ existed.+- GREEN: qualified/bare arrays, legacy singular selection, and canonical+ selected-video fallback pass.++### Unused temporary adapters are removed++- Removed only `patchImages`, `removeImages`, `setMultiSelection`, and+ `toggleImageSelection`.+- Removed matching `GalleryCommandsPort` members and test scaffolding.+- Retained the still-used image-only `selectImage` and `setCompareImage`+ compatibility seams.++Strict TDD evidence:++- Removing `setMultiSelection` from the adapter fixture first produced+ `TS2741`: the property was still required by `GalleryCommandsPort`; removing+ the port/store adapter restored the typecheck.+- The same RED/GREEN cycle was repeated for `toggleImageSelection`.+- Repository production search confirms none of the four adapter definitions+ remain.++## Verification++- Focused core/state tests: 3 files, 193 tests passed.+- Focused Gallery browser tests: 2 files, 28 tests passed.+- `pnpm lint`: passed, including 34 architecture tests.+- `pnpm test:all`: passed:+ - 376 unit files / 5,008 tests+ - 70 browser files / 360 tests+ - 10 mock-fixture tests+- `pnpm test:performance:architecture`: passed without updating baselines.+- `pnpm check:release`: passed end-to-end on the final rerun, including all+ nine accessibility journeys.++The first `check:release` attempt reached its final accessibility command and+reported a canvas-only `Raster Layers (64)` contrast violation. No source was+changed. An immediate unchanged `pnpm test:accessibility:browser` reproduction+passed all nine journeys, and the complete unchanged `pnpm check:release`+rerun also passed. This was treated as a transient journey-state failure, not+masked or baseline-recorded.++## Independent review++An independent read-only review of+`0b7acabad952597073a2ea1b3298e8848351aba3..working tree` returned:++- Standards: 0 Critical, 0 Important, 0 Minor findings.+- Specification: 0 Critical, 0 Important, 0 Minor findings.++The reviewer specifically confirmed the launch/completion upload-context+split, the exact persisted-reader precedence, removal of only the four unused+adapters, retention of `selectImage`/`setCompareImage`, Gallery-core purity,+and dependency direction.++## Invariants++- `GeneratedImageContract` is unchanged.+- No production module or existing file was added/renamed for this fix.+- No `useEffect` was added.+- No new `@platform/ui` barrel importer was added.+- No performance baseline or importer cap was updated.diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.tsindex 23b9db8f79..a030d43c1e 100644--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts@@ -54,4 +54,8 @@ export {type GalleryQueuePlaceholder,type GallerySelectedImageQuery,} from './ui/galleryStateView';-export { getSelectedGalleryImageFromValues, getSelectedGalleryItemFromValues } from './core/selection';+export {+ getPersistedSelectedGalleryItemKeys,+ getSelectedGalleryImageFromValues,+ getSelectedGalleryItemFromValues,+} from './core/selection';diff --git a/invokeai/frontend/webv2/src/features/gallery/core/selection.test.ts b/invokeai/frontend/webv2/src/features/gallery/core/selection.test.tsindex 31beef0c45..9a34f5248e 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/selection.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/selection.test.ts@@ -46,11 +46,14 @@ const videoItem: GalleryVideoItem = {};type SelectionModule = typeof selection & {+ getPersistedSelectedGalleryItemKeys?: (values: Record<string, unknown>) => string[];getSelectedGalleryItemFromValues?: (values: Record<string, unknown>) => GalleryItem | null;};const getSelectedGalleryItemFromValues = (values: Record<string, unknown>): GalleryItem | null | undefined =>(selection as SelectionModule).getSelectedGalleryItemFromValues?.(values);+const getPersistedSelectedGalleryItemKeys = (values: Record<string, unknown>): string[] | undefined =>+ (selection as SelectionModule).getPersistedSelectedGalleryItemKeys?.(values);describe('persisted Gallery selection readers', () => {it('returns a canonical selected image item unchanged', () => {@@ -121,4 +124,22 @@ describe('persisted Gallery selection readers', () => {width: imageItem.width,});});++ it('canonicalizes qualified and bare keys from a persisted multi-selection', () => {+ expect(+ getPersistedSelectedGalleryItemKeys({+ selectedImageNames: ['video:clip.mp4', 'legacy.png', 'image:a:b.png', 42],+ selectedImageName: 'ignored.png',+ selectedImage: videoItem,+ })+ ).toEqual(['video:clip.mp4', 'image:legacy.png', 'image:a:b.png']);+ });++ it('falls back to the legacy singular persisted selection key', () => {+ expect(getPersistedSelectedGalleryItemKeys({ selectedImageName: 'legacy.png' })).toEqual(['image:legacy.png']);+ });++ it('falls back to the canonical selected item object when persisted keys are absent', () => {+ expect(getPersistedSelectedGalleryItemKeys({ selectedImage: videoItem })).toEqual(['video:shared']);+ });});diff --git a/invokeai/frontend/webv2/src/features/gallery/core/selection.ts b/invokeai/frontend/webv2/src/features/gallery/core/selection.tsindex c7f4e1f461..368e32bb21 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/selection.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/selection.ts@@ -5,7 +5,9 @@ import {isGalleryImageItem,legacyGeneratedImageToGalleryItem,parseGalleryItemKey,+ toGalleryItemKey,type GalleryItem,+ type GalleryItemKey,} from './items';const isRecord = (value: unknown): value is Record<string, unknown> => Boolean(value) && typeof value === 'object';@@ -74,3 +76,21 @@ export const getSelectedGalleryImageFromValues = (galleryValues: Record<string,return item && isGalleryImageItem(item) ? galleryImageItemToGalleryImage(item) : null;};++const canonicalizePersistedItemKey = (key: string): GalleryItemKey => toGalleryItemKey(parseGalleryItemKey(key));++export const getPersistedSelectedGalleryItemKeys = (galleryValues: Record<string, unknown>): GalleryItemKey[] => {+ if (Array.isArray(galleryValues.selectedImageNames)) {+ return (galleryValues.selectedImageNames as unknown[])+ .filter((name): name is string => typeof name === 'string')+ .map(canonicalizePersistedItemKey);+ }++ if (typeof galleryValues.selectedImageName === 'string') {+ return [canonicalizePersistedItemKey(galleryValues.selectedImageName)];+ }++ const selectedItem = getSelectedGalleryItemFromValues(galleryValues);++ return selectedItem ? [toGalleryItemKey(selectedItem)] : [];+};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.tsxindex 3772502df2..ef819fd024 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@@ -287,13 +287,11 @@ const createAdapter = (): GalleryUiAdapter =>setCompareImage: noop,setCompareItem: noop,setItemMultiSelection: noop,- setMultiSelection: noop,setPage: noop,setPageInfo: noop,setProjectBoard: noop,setSearchTerm: noop,setView: noop,- toggleImageSelection: noop,toggleItemSelection: noop,updateSettings: noop,},diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsxindex dccb3424df..4faaca4b66 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx@@ -52,14 +52,12 @@ export interface GalleryCommandsPort {setCompareItem(image: GalleryImageItem | null): void;setCompareImage(image: GalleryImage | null): void;setItemMultiSelection(itemKeys: GalleryItemKey[], primaryItem: GalleryItem): void;- setMultiSelection(imageNames: string[], primaryImage: GalleryImage): void;setPage(page: number): void;setPageInfo(totalImages: number): void;setProjectBoard(boardId: string): void;setSearchTerm(searchTerm: string): void;setView(view: GalleryView): void;toggleItemSelection(item: GalleryItem, nextPrimaryItem: GalleryItem | null): void;- toggleImageSelection(image: GalleryImage, nextPrimaryItem: GalleryItem | null): void;updateSettings(settings: Partial<GallerySettings>): void;}diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsxindex 34fc969b43..4b0210cafd 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx@@ -105,6 +105,7 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidg[data.filter, queryClient]);const itemActionContextRef = useRef<GalleryItemActionContext | null>(null);+ const galleryLocationRef = useRef({ galleryView, selectedBoardId });// This ref is a live read port for an in-flight deletion. An effect would// leave a commit-sized stale window, while the action must compare against@@ -116,12 +117,18 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidgloadOrderedRefs: loadOrderedItemRefs,selectedItemKey: gallery.selectedItemKey,};+ // This is the matching live read port for in-flight uploads. The upload+ // target is captured at launch, while completion visibility must use the+ // board and view from the latest render.+ // eslint-disable-next-line react/react-compiler+ galleryLocationRef.current = { galleryView, selectedBoardId };const getItemActionContext = useCallback(() => itemActionContextRef.current, []);+ const getCurrentGalleryLocation = useCallback(() => galleryLocationRef.current, []);const actions = useGalleryActions({boards: data.boards,- galleryView,+ getCurrentGalleryLocation,loadMore,projectBoardId: getGalleryProjectBoardId(galleryValues),projectName,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.tsindex 792a33e4cd..ef992d5b69 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts@@ -3,13 +3,16 @@ import type { QueueItem } from '@features/queue/contracts';import {legacyGeneratedImageToGalleryItem,- parseGalleryItemKey,toGalleryItemKey,type GalleryItem,type GalleryItemKey,} from '@features/gallery/core/items';import { getBoundedRecentImages } from '@features/gallery/core/recentImages';-import { getSelectedGalleryImageFromValues, getSelectedGalleryItemFromValues } from '@features/gallery/core/selection';+import {+ getPersistedSelectedGalleryItemKeys,+ getSelectedGalleryImageFromValues,+ getSelectedGalleryItemFromValues,+} from '@features/gallery/core/selection';import { getGallerySettings, type GallerySettings } from '@features/gallery/core/settings';import { getQueueItemSnapshotBatchCount, getQueueItemSnapshotDimensions } from '@features/queue/contracts';@@ -227,24 +230,6 @@ export const getGallerySelectedBoardId = (values: Record<string, unknown>, backereturn 'none';};-const canonicalizePersistedItemKey = (key: string): GalleryItemKey => toGalleryItemKey(parseGalleryItemKey(key));--export const getGallerySelectedItemKeys = (values: Record<string, unknown>): GalleryItemKey[] => {- if (Array.isArray(values.selectedImageNames)) {- return (values.selectedImageNames as unknown[])- .filter((name): name is string => typeof name === 'string')- .map(canonicalizePersistedItemKey);- }-- if (typeof values.selectedImageName === 'string') {- return [canonicalizePersistedItemKey(values.selectedImageName)];- }-- const selectedItem = getSelectedGalleryItemFromValues(values);-- return selectedItem ? [toGalleryItemKey(selectedItem)] : [];-};-export const getGalleryPage = (values: Record<string, unknown>): number =>typeof values.galleryPage === 'number' && Number.isFinite(values.galleryPage)? Math.max(0, Math.floor(values.galleryPage))@@ -364,7 +349,7 @@ export const getGalleryStateView = (const selectedItem = getSelectedGalleryItemFromValues(values);const persistedSelectedItemKey =typeof values.selectedImageName === 'string'- ? canonicalizePersistedItemKey(values.selectedImageName)+ ? (getPersistedSelectedGalleryItemKeys({ selectedImageName: values.selectedImageName })[0] ?? null): selectedItem? toGalleryItemKey(selectedItem): null;@@ -372,7 +357,7 @@ export const getGalleryStateView = (persistedSelectedItemKey && items.some((item) => toGalleryItemKey(item) === persistedSelectedItemKey)? persistedSelectedItemKey: null;- const selectedItemKeys = getGallerySelectedItemKeys(values);+ const selectedItemKeys = getPersistedSelectedGalleryItemKeys(values);const galleryView = getGalleryView(values);const settings = getGallerySettings(values);const searchTerm = getGallerySearchTerm(values);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.tsxindex 29c691584b..e269d9b5a2 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@@ -3,7 +3,7 @@ import type { GalleryUiAdapter } from '@features/gallery/react';import { GalleryUiProvider } from '@features/gallery/react';import { accountLifecycle } from '@platform/state/accountLifecycle';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';-import { act, createRef, type Ref, type ReactNode, useImperativeHandle } from 'react';+import { act, createRef, type Ref, type ReactNode, useCallback, useImperativeHandle, useRef } from 'react';import { createRoot, type Root } from 'react-dom/client';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';@@ -104,6 +104,12 @@ const Probe = ({ref: Ref<GalleryActions>;selectedBoardId: string;}) => {+ const currentGalleryLocationRef = useRef({ galleryView, selectedBoardId });++ // Match GalleryWidgetView's render-assigned live-read port.+ // eslint-disable-next-line react/react-compiler+ currentGalleryLocationRef.current = { galleryView, selectedBoardId };+ const getCurrentGalleryLocation = useCallback(() => currentGalleryLocationRef.current, []);const actions = useGalleryActions({boards: [{@@ -120,7 +126,7 @@ const Probe = ({projectBoardId: null,projectName: 'Project',selectedBoardId,- galleryView,+ getCurrentGalleryLocation,});useImperativeHandle(ref, () => actions, [actions]);@@ -144,13 +150,11 @@ const adapter: GalleryUiAdapter = {setCompareImage: noop,setCompareItem: noop,setItemMultiSelection,- setMultiSelection: noop,setPage: noop,setPageInfo: noop,setProjectBoard: noop,setSearchTerm: noop,setView: noop,- toggleImageSelection: noop,toggleItemSelection: noop,updateSettings: noop,},@@ -427,6 +431,73 @@ describe('mixed gallery upload', () => {);});+ it('does not select an upload from the launch board after the active board changes in flight', async () => {+ let resolveUpload: ((value: ReturnType<typeof imageUpload>) => void) | undefined;+ mocks.uploadGalleryImage.mockReturnValueOnce(+ new Promise<ReturnType<typeof imageUpload>>((resolve) => {+ resolveUpload = resolve;+ })+ );++ let upload: Promise<void> | undefined;+ act(() => {+ upload = actionsRef.current?.uploadFiles([new File(['image'], 'photo.png', { type: 'image/png' })]);+ });++ await vi.waitFor(() => {+ expect(mocks.uploadGalleryImage).toHaveBeenCalledOnce();+ });+ expect(mocks.uploadGalleryImage).toHaveBeenCalledWith(+ expect.any(File),+ 'board-1',+ expect.objectContaining({ signal: expect.any(AbortSignal) })+ );++ selectedBoardId = 'none';+ await renderProbe();+ resolveUpload?.(imageUpload('photo.png', '2026-07-30T12:00:04.000Z'));++ await act(async () => {+ await upload;+ });++ expect(selectItem).not.toHaveBeenCalled();+ expect(mocks.invalidateGallery).toHaveBeenCalledOnce();+ expect(mocks.notificationsAdd).toHaveBeenCalledOnce();+ });++ it('does not select an upload hidden by a view change while the upload is in flight', async () => {+ galleryView = 'assets';+ await renderProbe();+ let resolveUpload: ((value: ReturnType<typeof imageUpload>) => void) | undefined;+ mocks.uploadGalleryImage.mockReturnValueOnce(+ new Promise<ReturnType<typeof imageUpload>>((resolve) => {+ resolveUpload = resolve;+ })+ );++ let upload: Promise<void> | undefined;+ act(() => {+ upload = actionsRef.current?.uploadFiles([new File(['image'], 'photo.png', { type: 'image/png' })]);+ });++ await vi.waitFor(() => {+ expect(mocks.uploadGalleryImage).toHaveBeenCalledOnce();+ });++ galleryView = 'images';+ await renderProbe();+ resolveUpload?.(imageUpload('photo.png', '2026-07-30T12:00:04.000Z'));++ await act(async () => {+ await upload;+ });++ expect(selectItem).not.toHaveBeenCalled();+ expect(mocks.invalidateGallery).toHaveBeenCalledOnce();+ expect(mocks.notificationsAdd).toHaveBeenCalledOnce();+ });+it('reports unsupported and rejected files once without aborting supported uploads', async () => {mocks.uploadGalleryVideo.mockRejectedValue(new Error('corrupt video'));diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.tsindex de6a4cceb7..231286be47 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts@@ -31,14 +31,14 @@ const toErrorMessage = (error: unknown): string => (error instanceof Error ? errexport const useGalleryActions = ({boards,+ getCurrentGalleryLocation,loadMore,- galleryView,projectBoardId,projectName,selectedBoardId,}: {boards: GalleryBoard[];- galleryView: GalleryView;+ getCurrentGalleryLocation: () => { galleryView: GalleryView; selectedBoardId: string };loadMore: () => void;projectBoardId: string | null;projectName: string;@@ -253,6 +253,7 @@ export const useGalleryActions = ({try {const targetBoardId = getBoard(selectedBoardId)?.kind === 'board' ? selectedBoardId : 'none';+ const targetBoardName = getBoardName(selectedBoardId);const imageUploads = accepted.filter((upload) => upload.kind === 'image');const videoUploads = accepted.filter((upload) => upload.kind === 'video');const imageResultsPromise = Promise.allSettled(@@ -301,10 +302,11 @@ export const useGalleryActions = ({return;}+ const currentGalleryLocation = getCurrentGalleryLocation();const visibleUploads = uploadedItems.filter((item) =>- item.boardId === targetBoardId &&- (galleryView === 'images'+ item.boardId === currentGalleryLocation.selectedBoardId &&+ (currentGalleryLocation.galleryView === 'images'? item.category === 'general': item.category === 'control' || item.category === 'mask' || item.category === 'user'));@@ -321,7 +323,7 @@ export const useGalleryActions = ({refresh();const summary = t('widgets.gallery.uploadSummary', {- board: getBoardName(selectedBoardId),+ board: targetBoardName,failed: failedCount,images: formatImageCount(uploadedImages.length),videos: formatVideoCount(uploadedVideos.length),@@ -349,7 +351,7 @@ export const useGalleryActions = ({}, [boards,gallery,- galleryView,+ getCurrentGalleryLocation,loadMore,notifications,projectBoardId,diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex a083b2eddf..57bf13c9e9 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -42,6 +42,7 @@ import type {import {getBoundedRecentImages,+ getPersistedSelectedGalleryItemKeys,getGallerySettings,getSelectedGalleryItemFromValues,legacyGeneratedImageToGalleryItem,@@ -708,22 +709,6 @@ const getGalleryImages = (values: Record<string, unknown>): GeneratedImageContraconst canonicalizeGalleryItemKey = (key: string): GalleryItemKey => toGalleryItemKey(parseGalleryItemKey(key));-const getGallerySelectedItemKeys = (values: Record<string, unknown>): GalleryItemKey[] => {- if (Array.isArray(values.selectedImageNames)) {- return (values.selectedImageNames as unknown[])- .filter((name): name is string => typeof name === 'string')- .map(canonicalizeGalleryItemKey);- }-- if (typeof values.selectedImageName === 'string') {- return [canonicalizeGalleryItemKey(values.selectedImageName)];- }-- const selectedItem = getSelectedGalleryItemFromValues(values);-- return selectedItem ? [toGalleryItemKey(selectedItem)] : [];-};-const getGalleryItemFromPersistedValue = (values: Record<string, unknown>, value: unknown): GalleryItem | null =>getSelectedGalleryItemFromValues({selectedBoardId: values.selectedBoardId,@@ -1898,7 +1883,7 @@ const removeGalleryItemsFromAllProjects = (const compareImage = values.compareImage;const selectedImageName = typeof values.selectedImageName === 'string' ? values.selectedImageName : null;const recentImages = getGalleryImages(values);- const selectedItemKeys = getGallerySelectedItemKeys(values);+ const selectedItemKeys = getPersistedSelectedGalleryItemKeys(values);const selectedItem = getGalleryItemFromPersistedValue(values, selectedImage);const compareItem = getGalleryItemFromPersistedValue(values, compareImage);const selectedImageKey = selectedItem ? toGalleryItemKey(selectedItem) : null;@@ -2104,7 +2089,9 @@ const updateGalleryWithResultImages = (project: Project, images: GeneratedImageCrecentImages: getBoundedRecentImages([...newImages, ...previousImages]),selectedImage: nextSelectedItem ?? galleryValues.selectedImage,selectedImageName: nextSelectedItemKey ?? galleryValues.selectedImageName,- selectedImageNames: nextSelectedItemKey ? [nextSelectedItemKey] : getGallerySelectedItemKeys(galleryValues),+ selectedImageNames: nextSelectedItemKey+ ? [nextSelectedItemKey]+ : getPersistedSelectedGalleryItemKeys(galleryValues),...(nextSelectedImage? {selectedImagePage: 0,@@ -3107,7 +3094,7 @@ export const __workbenchReducerInternal = (state,(values) => {const itemKey = toGalleryItemKey(action.item);- const selectedItemKeys = getGallerySelectedItemKeys(values);+ const selectedItemKeys = getPersistedSelectedGalleryItemKeys(values);if (!selectedItemKeys.includes(itemKey)) {const settings = getGallerySettings(values);diff --git a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts b/invokeai/frontend/webv2/src/workbench/workbenchStore.tsindex ecdc89d509..a7bd722f4a 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchStore.ts@@ -3,7 +3,6 @@ import type { Project, WorkbenchState } from '@workbench/projectContracts';import {legacyGeneratedImageToGalleryItem,- toGalleryItemKey,type GalleryImage,type GeneratedImageContract,} from '@features/gallery/contracts';@@ -102,18 +101,6 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchSt'reconcileDeletedGalleryBoard',(outcome: ActionPayload<'reconcileDeletedGalleryBoard'>['outcome']) => ({ outcome })),- /** TODO(Task 7): Remove these image adapters with the mixed-media action port. */- patchImages: (imageNames: string[], changes: ActionPayload<'patchGalleryItems'>['changes']): void =>- dispatch({- changes,- itemKeys: imageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),- type: 'patchGalleryItems',- }),- removeImages: (imageNames: string[]): void =>- dispatch({- itemKeys: imageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),- type: 'removeGalleryItems',- }),selectItem: command('selectGalleryItem',(@@ -175,28 +162,6 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchStprojectId,type: 'setGalleryCompareImage',}),- setMultiSelection: (- imageNames: string[],- primaryImage: GeneratedImageContract & Partial<GalleryImage>,- projectId?: string- ): void =>- dispatch({- itemKeys: imageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),- primaryItem: legacyGeneratedImageToGalleryItem(primaryImage),- projectId,- type: 'setGalleryMultiSelection',- }),- toggleImageSelection: (- image: GeneratedImageContract & Partial<GalleryImage>,- nextPrimaryItem: ActionPayload<'toggleGalleryItemInSelection'>['nextPrimaryItem'],- projectId?: string- ): void =>- dispatch({- item: legacyGeneratedImageToGalleryItem(image),- nextPrimaryItem,- projectId,- type: 'toggleGalleryItemInSelection',- }),selectBoard: command('selectGalleryBoard', (boardId: string, projectId?: string) => ({ boardId, projectId })),setPage: command('setGalleryPage', (page: number, projectId?: string) => ({ page, projectId })),setPageInfo: command('setGalleryPageInfo', (totalImages: number, projectId?: string) => ({