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): honor authoritative gallery outcomes
joshistoast202aca404900
diff --git a/.superpowers/sdd/mixed-media-gallery-parity/task-5-report.md b/.superpowers/sdd/mixed-media-gallery-parity/task-5-report.mdindex f47a18766d..623ccc99f7 100644--- a/.superpowers/sdd/mixed-media-gallery-parity/task-5-report.md+++ b/.superpowers/sdd/mixed-media-gallery-parity/task-5-report.md@@ -222,9 +222,7 @@ The remaining adapters are deliberately narrow and type-safe:before dispatch.3. Preview's mixed-query image projection is marked `TODO(Task 8)` and filtersbefore converting.-4. The boolean board-deletion adapter is marked `TODO(Task 7)`; the canonical- outcome command and reducer already require the four authoritative arrays.-5. `CurrentImageFlowNode` remains intentionally image-only by reading only+4. `CurrentImageFlowNode` remains intentionally image-only by reading only`recentImages`.No adapter accepts a video as an image or relies on an unsafe mixed-to-image@@ -276,3 +274,142 @@ cast.- `invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.test.ts`- `invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewNavigation.browser.test.tsx`- `invokeai/frontend/webv2/src/workbench/workbenchState.test.ts`++## Review follow-up: authoritative mutation outcomes++The review of `a86b7cba25..8ac2a4fff0` identified three correctness gaps. This+follow-up fixes all three without adding the Task 7 mixed/video action ports.++### Follow-up RED evidence++The primary-toggle regression reproduced the inconsistent mixed selection:++```sh+pnpm test src/workbench/workbenchState.test.ts -t "atomically promotes"+```++```text+Test Files 1 failed (1)+Tests 1 failed | 158 skipped (159)+```++The reducer retained `selectedImageName: "video:shared"` while clearing the+primary object and retaining the stale image comparison.++The board deletion transport regressions reproduced the discarded response:++```sh+pnpm test src/features/gallery/data/backend.test.ts \+ -t "deleteGalleryBoard outcomes"+```++```text+Test Files 1 failed (1)+Tests 2 failed | 36 skipped (38)+```++Both `include_images=true` and `include_images=false` returned `undefined`+instead of the backend outcome.++The image move/star transport regressions reproduced the other discarded+responses:++```sh+pnpm test src/features/gallery/data/backend.test.ts \+ -t "image mutation outcomes"+```++```text+Test Files 1 failed (1)+Tests 2 failed | 38 skipped (40)+```++The action-level browser regressions then reproduced the manufactured+all-requested success:++```sh+pnpm test:browser \+ src/workbench/image-actions/useImageActions.browser.test.tsx+```++```text+Test Files 1 failed (1)+Tests 2 failed (2)+```++Both move and star patches included the backend-unconfirmed image.++### Follow-up fixes++- Primary toggle now receives the canonical next-primary item at the+ action/command boundary. The reducer validates its qualified key and updates+ object, key, ordered selection, and compare state atomically. Promoting a+ video clears compare; an unresolved primary clears the leftover selection+ instead of persisting orphan keys.+- Board deletion maps `board_id`, `deleted_board_images`,+ `deleted_board_videos`, `deleted_images`, `deleted_videos`, `failed_images`,+ and `failed_videos` into `GalleryBoardDeletionResult`. The UI forwards that+ exact outcome to Workbench. Confirmed media deletes are removed; failed,+ relationship-only, and otherwise locally known survivors move to `none`.+- The boolean board-deletion compatibility action and command were removed.+- Board add/remove and star/unstar map their authoritative success arrays.+ Image actions compute success as the intersection of requested and confirmed+ names, treat missing requested names as failed/ambiguous, and patch cache and+ Workbench state only for confirmed names.+- Star/unstar no longer applies an optimistic all-requested patch.++### Follow-up GREEN and full verification++Focused integration:++```text+Unit: 2 files passed, 200 tests passed+Browser: 2 files passed, 3 tests passed+```++Full gates from `invokeai/frontend/webv2`:++```text+pnpm test+ Test Files 374 passed (374)+ Tests 4944 passed (4944)++pnpm test:browser+ Test Files 60 passed (60)+ Tests 243 passed (243)++pnpm test:fixtures+ Tests 4 passed (4)++pnpm architecture:check+ Test Files 3 passed (3)+ Tests 34 passed (34)++pnpm format:check+ all matched files correctly formatted++pnpm lint:oxc+ zero warnings/errors++pnpm lint:tsc+ tsc --noEmit passed+```++Relative to the pre-follow-up full verification, the suites increased from+4,938 to 4,944 unit tests and from 240 to 243 browser tests. The full browser+run retained the repository's existing React `act(...)`, missing-i18n-instance,+and intentional error-boundary console output and exited successfully.++### Follow-up self-review and concerns++- Confirmed the canonical board result preserves both relationship arrays, so+ `include_images=false` moves retained images and videos rather than removing+ them.+- Confirmed every requested-but-unconfirmed image remains in cache/state for+ partial move and star outcomes.+- Confirmed the queue organization adapter type-checks while intentionally+ ignoring the newly returned image success arrays.+- Confirmed the legacy boolean board action/command has no remaining callers.+- Confirmed no mixed/video image-action port was added; that remains Task 7.+- Confirmed no `useEffect` was added.+- No unresolved implementation concern.diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.tsindex 8b6a4563f9..f423d038ad 100644--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts@@ -1,5 +1,6 @@export type {GalleryBoard,+ GalleryBoardDeletionResult,GalleryBoardKind,GalleryBoardOrderBy,GalleryImage,diff --git a/invokeai/frontend/webv2/src/features/gallery/core/types.ts b/invokeai/frontend/webv2/src/features/gallery/core/types.tsindex 702bcfc35c..07b2da0f33 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/types.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/types.ts@@ -51,6 +51,21 @@ export interface GalleryDeletionResult {failedImageNames: string[];}+/**+ * Authoritative outcome of deleting a board. Deleting the board with its+ * contents reports deleted/failed media; retaining its contents reports the+ * removed board relationships instead.+ */+export interface GalleryBoardDeletionResult {+ boardId: string;+ deletedBoardImageNames: string[];+ deletedBoardVideoNames: string[];+ deletedImageNames: string[];+ deletedVideoNames: string[];+ failedImageNames: string[];+ failedVideoNames: string[];+}+export interface GalleryImagesPage {images: GalleryImage[];total: number;diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.test.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.test.tsindex 51333fd4f0..611edb4ab3 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.test.ts@@ -17,6 +17,8 @@ vi.mock('@platform/transport/http', () => ({}));import {+ addImagesToGalleryBoard,+ deleteGalleryBoard,deleteGalleryImages,downloadGalleryArchive,getGalleryImageByName,@@ -29,8 +31,91 @@ import {listGalleryBoards,listGalleryItems,listPaletteImages,+ removeImagesFromGalleryBoard,+ starGalleryImages,+ unstarGalleryImages,} from './backend';+describe('deleteGalleryBoard outcomes', () => {+ beforeEach(() => {+ accountLifecycle.activate('user-a');+ mocks.apiFetchJson.mockReset();+ });++ it('maps confirmed and failed media when deleting a board with its contents', async () => {+ mocks.apiFetchJson.mockResolvedValue({+ board_id: 'board-1',+ deleted_board_images: [],+ deleted_board_videos: [],+ deleted_images: ['gone.png'],+ deleted_videos: ['gone.mp4'],+ failed_images: ['locked.png'],+ failed_videos: ['locked.mp4'],+ });++ await expect(deleteGalleryBoard('board-1', true)).resolves.toEqual({+ boardId: 'board-1',+ deletedBoardImageNames: [],+ deletedBoardVideoNames: [],+ deletedImageNames: ['gone.png'],+ deletedVideoNames: ['gone.mp4'],+ failedImageNames: ['locked.png'],+ failedVideoNames: ['locked.mp4'],+ });+ });++ it('maps removed board relationships when retaining the board contents', async () => {+ mocks.apiFetchJson.mockResolvedValue({+ board_id: 'board-1',+ deleted_board_images: ['moved.png'],+ deleted_board_videos: ['moved.mp4'],+ deleted_images: [],+ deleted_videos: [],+ failed_images: [],+ failed_videos: [],+ });++ await expect(deleteGalleryBoard('board-1', false)).resolves.toEqual({+ boardId: 'board-1',+ deletedBoardImageNames: ['moved.png'],+ deletedBoardVideoNames: ['moved.mp4'],+ deletedImageNames: [],+ deletedVideoNames: [],+ failedImageNames: [],+ failedVideoNames: [],+ });+ expect(mocks.apiFetchJson).toHaveBeenCalledWith('/api/v1/boards/board-1?include_images=false', {+ method: 'DELETE',+ signal: undefined,+ });+ });+});++describe('image mutation outcomes', () => {+ beforeEach(() => {+ accountLifecycle.activate('user-a');+ mocks.apiFetchJson.mockReset();+ });++ it('returns only images confirmed added to or removed from a board', async () => {+ mocks.apiFetchJson+ .mockResolvedValueOnce({ added_images: ['moved.png'] })+ .mockResolvedValueOnce({ removed_images: ['removed.png'] });++ await expect(addImagesToGalleryBoard('board-1', ['moved.png', 'locked.png'])).resolves.toEqual(['moved.png']);+ await expect(removeImagesFromGalleryBoard(['removed.png', 'locked.png'])).resolves.toEqual(['removed.png']);+ });++ it('returns only images confirmed starred or unstarred', async () => {+ mocks.apiFetchJson+ .mockResolvedValueOnce({ starred_images: ['starred.png'] })+ .mockResolvedValueOnce({ unstarred_images: ['unstarred.png'] });++ await expect(starGalleryImages(['starred.png', 'locked.png'])).resolves.toEqual(['starred.png']);+ await expect(unstarGalleryImages(['unstarred.png', 'locked.png'])).resolves.toEqual(['unstarred.png']);+ });+});+describe('downloadGalleryArchive', () => {beforeEach(() => {accountLifecycle.activate('user-a');diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.tsindex e949b94945..f550595bc1 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.ts@@ -8,6 +8,7 @@ import type {} from '@features/gallery/core/items';import type {GalleryBoard,+ GalleryBoardDeletionResult,GalleryBoardOrderBy,GalleryDeletionResult,GalleryImage,@@ -19,7 +20,7 @@ import type {import { isTimestampInRange } from '@platform/search/dateTokens';import { assertAccountScopeCurrent, captureAccountScope } from '@platform/state/accountLifecycle';-import { absolutizeApiUrl, ApiError, apiFetch, apiFetchJson, apiFetchRaw, sleep } from '@platform/transport/http';+import { absolutizeApiUrl, ApiError, apiFetchJson, apiFetchRaw, sleep } from '@platform/transport/http';import { getGalleryImageThumbnailUrl } from './imageUrls';import { getGalleryVideoThumbnailUrl } from './videoUrls';@@ -882,17 +883,34 @@ export const deleteGalleryBoard = async (boardId: string,includeImages: boolean,signal?: AbortSignal-): Promise<void> => {+): Promise<GalleryBoardDeletionResult> => {const query = toSearchParams({ include_images: includeImages });+ const body = await apiFetchJson<{+ board_id: string;+ deleted_board_images: string[];+ deleted_board_videos?: string[];+ deleted_images: string[];+ deleted_videos?: string[];+ failed_images?: string[];+ failed_videos?: string[];+ }>(`/api/v1/boards/${encodeURIComponent(boardId)}?${query}`, { method: 'DELETE', signal });- await apiFetch(`/api/v1/boards/${encodeURIComponent(boardId)}?${query}`, { method: 'DELETE', signal });+ return {+ boardId: body.board_id,+ deletedBoardImageNames: body.deleted_board_images,+ deletedBoardVideoNames: body.deleted_board_videos ?? [],+ deletedImageNames: body.deleted_images,+ deletedVideoNames: body.deleted_videos ?? [],+ failedImageNames: body.failed_images ?? [],+ failedVideoNames: body.failed_videos ?? [],+ };};export const addImagesToGalleryBoard = async (boardId: string,imageNames: string[],signal?: AbortSignal-): Promise<void> => {+): Promise<string[]> => {if (boardId === 'none' ||boardId === 'generated' ||@@ -900,44 +918,57 @@ export const addImagesToGalleryBoard = async (isDateBoardId(boardId) ||imageNames.length === 0) {- return;+ return [];}- await apiFetchJson('/api/v1/board_images/batch', {+ const body = await apiFetchJson<{ added_images: string[] }>('/api/v1/board_images/batch', {body: JSON.stringify({ board_id: boardId, image_names: imageNames }),method: 'POST',signal,});++ return body.added_images;};-export const removeImagesFromGalleryBoard = async (imageNames: string[], signal?: AbortSignal): Promise<void> => {+export const removeImagesFromGalleryBoard = async (imageNames: string[], signal?: AbortSignal): Promise<string[]> => {if (imageNames.length === 0) {- return;+ return [];}- await apiFetchJson('/api/v1/board_images/batch/delete', {+ const body = await apiFetchJson<{ removed_images: string[] }>('/api/v1/board_images/batch/delete', {body: JSON.stringify({ image_names: imageNames }),method: 'POST',signal,});++ return body.removed_images;};-const setGalleryImagesStarred = async (imageNames: string[], starred: boolean, signal?: AbortSignal): Promise<void> => {+const setGalleryImagesStarred = async (+ imageNames: string[],+ starred: boolean,+ signal?: AbortSignal+): Promise<string[]> => {if (imageNames.length === 0) {- return;+ return [];}- await apiFetchJson(`/api/v1/images/${starred ? 'star' : 'unstar'}`, {- body: JSON.stringify({ image_names: imageNames }),- method: 'POST',- signal,- });+ const body = await apiFetchJson<{ starred_images?: string[]; unstarred_images?: string[] }>(+ `/api/v1/images/${starred ? 'star' : 'unstar'}`,+ {+ body: JSON.stringify({ image_names: imageNames }),+ method: 'POST',+ signal,+ }+ );++ return (starred ? body.starred_images : body.unstarred_images) ?? [];};-export const starGalleryImages = (imageNames: string[], signal?: AbortSignal): Promise<void> =>+export const starGalleryImages = (imageNames: string[], signal?: AbortSignal): Promise<string[]> =>setGalleryImagesStarred(imageNames, true, signal);-export const unstarGalleryImages = (imageNames: string[], signal?: AbortSignal): Promise<void> =>+export const unstarGalleryImages = (imageNames: string[], signal?: AbortSignal): Promise<string[]> =>setGalleryImagesStarred(imageNames, false, signal);interface DeleteImagesResponse {diff --git a/invokeai/frontend/webv2/src/features/gallery/index.ts b/invokeai/frontend/webv2/src/features/gallery/index.tsindex 76acd62150..fd41934c28 100644--- a/invokeai/frontend/webv2/src/features/gallery/index.ts+++ b/invokeai/frontend/webv2/src/features/gallery/index.ts@@ -1,5 +1,6 @@export type {GalleryBoard,+ GalleryBoardDeletionResult,GalleryBoardKind,GalleryBoardOrderBy,GalleryImage,@@ -86,7 +87,7 @@ export const galleryOrganization = {addToBoard: addImagesToGalleryBoard,deleteImages: deleteGalleryImages,removeFromBoard: removeImagesFromGalleryBoard,- setStarred: (imageNames: string[], starred: boolean, signal?: AbortSignal): Promise<void> =>+ setStarred: (imageNames: string[], starred: boolean, signal?: AbortSignal): Promise<string[]> =>starred ? starGalleryImages(imageNames, signal) : unstarGalleryImages(imageNames, signal),} as const;diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsxindex cba1187d98..862ac28180 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx@@ -4,6 +4,7 @@ import type { GalleryImage } from '@features/gallery/core/types';import { Badge, Box, Flex, ProgressCircle, ScrollArea, Skeleton, Spinner, Text } from '@chakra-ui/react';import { useDraggable } from '@dnd-kit/core';import { CSS } from '@dnd-kit/utilities';+import { toGalleryItemKey } from '@features/gallery/contracts';import { useQueueItemProgress, useQueueItemProgressImage } from '@features/queue/react';import { DropZone, IconButton } from '@platform/ui';import { StreamingImageFrame } from '@platform/ui/streaming-image/StreamingImageFrame';@@ -204,12 +205,28 @@ export const GalleryImageGrid = ({ layout }: { layout: 'stacked' | 'wide' }) =>}if (event.ctrlKey || event.metaKey) {- actions.toggleImageInSelection(image);+ const itemKey = toGalleryItemKey({ kind: 'image', name: image.imageName });+ const remainingItemKeys = galleryState.selectedItemKeys.filter((key) => key !== itemKey);+ const nextPrimaryItem =+ galleryState.selectedItemKey === itemKey+ ? (galleryState.items.find(+ (item) => toGalleryItemKey(item) === remainingItemKeys[remainingItemKeys.length - 1]+ ) ?? null)+ : null;++ actions.toggleImageInSelection(image, nextPrimaryItem);} else {actions.selectImage(image);}},- [actions, gallery.images, gallery.selectedImageName]+ [+ actions,+ gallery.images,+ gallery.selectedImageName,+ galleryState.items,+ galleryState.selectedItemKey,+ galleryState.selectedItemKeys,+ ]);const handleThumbnailContextMenu = useCallback(diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsxindex ff167c099c..5f6e749af6 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx@@ -1,5 +1,6 @@+import type { GalleryItem } from '@features/gallery/contracts';import type { GallerySettings } from '@features/gallery/core/settings';-import type { GalleryBoard, GalleryImage, GalleryView } from '@features/gallery/core/types';+import type { GalleryBoard, GalleryBoardDeletionResult, GalleryImage, GalleryView } from '@features/gallery/core/types';import type { QueueItem } from '@features/queue/contracts';import { createContext, use, type ComponentType, type ReactNode } from 'react';@@ -33,7 +34,7 @@ export interface GalleryImageContextMenuProps {}export interface GalleryCommandsPort {- reconcileDeletedBoard(boardId: string, includeImages: boolean): void;+ reconcileDeletedBoardOutcome(outcome: GalleryBoardDeletionResult): void;selectBoard(boardId: string): void;selectImage(image: GalleryImage): void;setCompareImage(image: GalleryImage | null): void;@@ -43,7 +44,7 @@ export interface GalleryCommandsPort {setProjectBoard(boardId: string): void;setSearchTerm(searchTerm: string): void;setView(view: GalleryView): void;- toggleImageSelection(image: GalleryImage): void;+ toggleImageSelection(image: GalleryImage, nextPrimaryItem: GalleryItem | null): void;updateSettings(settings: Partial<GallerySettings>): void;}diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsxindex 8bf6f3d074..2b26dbc2c5 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx@@ -1,3 +1,4 @@+import type { GalleryItem } from '@features/gallery/contracts';import type { GallerySettings } from '@features/gallery/core/settings';import type { GalleryImage, GalleryView } from '@features/gallery/core/types';@@ -26,7 +27,7 @@ export interface GalleryActions {selectProjectBoard: () => Promise<void>;setSearchTerm: (searchTerm: string) => void;setView: (galleryView: GalleryView) => void;- toggleImageInSelection: (image: GalleryImage) => void;+ toggleImageInSelection: (image: GalleryImage, nextPrimaryItem: GalleryItem | null) => void;updateSettings: (settings: Partial<GallerySettings>) => void;uploadFiles: (files: File[]) => Promise<void>;}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.tsxnew file mode 100644index 0000000000..130358d90c--- /dev/null+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx@@ -0,0 +1,139 @@+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 { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import type { GalleryActions } from './GalleryWidgetContext';++import { useGalleryActions } from './useGalleryActions';++const mocks = vi.hoisted(() => ({+ deleteGalleryBoard: vi.fn(),+ invalidateGallery: vi.fn(),+}));++vi.mock('@features/gallery/data/backend', () => ({+ createGalleryBoard: vi.fn(),+ deleteGalleryBoard: (...args: unknown[]) => mocks.deleteGalleryBoard(...args),+ downloadGalleryArchive: vi.fn(),+ updateGalleryBoard: vi.fn(),+ uploadGalleryImage: vi.fn(),+}));++vi.mock('@features/gallery/data/queryCache', () => ({+ invalidateGallery: (...args: unknown[]) => mocks.invalidateGallery(...args),+}));++let host: HTMLDivElement | null = null;+let root: Root | null = null;+const actionsRef = createRef<GalleryActions>();+const reconcileDeletedBoardOutcome = vi.fn();+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const Probe = ({ ref }: { ref: Ref<GalleryActions> }) => {+ const actions = useGalleryActions({+ boards: [+ {+ archived: false,+ assetCount: 0,+ id: 'board-1',+ imageCount: 2,+ kind: 'board',+ name: 'Board 1',+ videoCount: 1,+ },+ ],+ loadMore: vi.fn(),+ projectBoardId: null,+ projectName: 'Project',+ selectedBoardId: 'board-1',+ });++ useImperativeHandle(ref, () => actions, [actions]);++ return null;+};++const NoopProvider = ({ children }: { children: ReactNode }) => children;+const NoopContextMenu = () => null;+const noop = vi.fn();+const adapter: GalleryUiAdapter = {+ ImageActionsProvider: NoopProvider,+ ImageContextMenu: NoopContextMenu,+ account: { enableLiveFollow: noop },+ antialiasProgressImages: false,+ gallery: {+ reconcileDeletedBoardOutcome,+ selectBoard: noop,+ selectImage: noop,+ setCompareImage: noop,+ setMultiSelection: noop,+ setPage: noop,+ setPageInfo: noop,+ setProjectBoard: noop,+ setSearchTerm: noop,+ setView: noop,+ toggleImageSelection: noop,+ updateSettings: noop,+ },+ galleryValues: {},+ generateValues: {},+ liveFollowEnabled: false,+ liveProgressTarget: null,+ notifications: { add: noop, reportError: noop },+ projectId: 'project-1',+ projectName: 'Project',+ queueItems: [],+ widgets: { patchGalleryValues: noop },+};++beforeEach(async () => {+ vi.clearAllMocks();+ accountLifecycle.activate('user-a');+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await act(() => {+ root?.render(+ <QueryClientProvider client={new QueryClient()}>+ <GalleryUiProvider adapter={adapter}>+ <Probe ref={actionsRef} />+ </GalleryUiProvider>+ </QueryClientProvider>+ );+ });+});++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('deleteBoard', () => {+ it('forwards the authoritative backend outcome to the Workbench command', async () => {+ const outcome = {+ boardId: 'board-1',+ deletedBoardImageNames: ['retained.png'],+ deletedBoardVideoNames: ['retained.mp4'],+ deletedImageNames: [],+ deletedVideoNames: [],+ failedImageNames: [],+ failedVideoNames: [],+ };+ mocks.deleteGalleryBoard.mockResolvedValue(outcome);++ await act(async () => {+ await actionsRef.current?.deleteBoard('board-1', false);+ });++ expect(reconcileDeletedBoardOutcome).toHaveBeenCalledOnce();+ expect(reconcileDeletedBoardOutcome).toHaveBeenCalledWith(outcome);+ });+});diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.tsindex 7f7a58a600..1b658933bd 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts@@ -95,7 +95,7 @@ export const useGalleryActions = ({try {const boardName = getBoardName(boardId);- await deleteGalleryBoard(boardId, includeImages, owner.signal);+ const outcome = await deleteGalleryBoard(boardId, includeImages, owner.signal);assertAccountScopeCurrent(owner);recordSuccess(@@ -103,7 +103,7 @@ export const useGalleryActions = ({includeImages ? 'Its images were permanently deleted.' : 'Its images were moved to Uncategorized.');- gallery.reconcileDeletedBoard(boardId, includeImages);+ gallery.reconcileDeletedBoardOutcome(outcome);refresh();} catch (error: unknown) {if (!isAccountScopeCurrent(owner)) {diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.browser.test.tsxnew file mode 100644index 0000000000..5a6cc0d9e2--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.browser.test.tsx@@ -0,0 +1,161 @@+import { accountLifecycle } from '@platform/state/accountLifecycle';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { act, createRef, type Ref, useImperativeHandle } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import type { ImageActions } from './useImageActions';++import { useImageActions } from './useImageActions';++const mocks = vi.hoisted(() => ({+ addToBoard: vi.fn(),+ deleteImages: vi.fn(),+ galleryPatchItems: vi.fn(),+ invalidateGallery: vi.fn(),+ invalidateGalleryItems: vi.fn(),+ openWorkbenchWidget: vi.fn(),+ patchGalleryItemCaches: vi.fn((..._args: unknown[]) => vi.fn()),+ removeFromBoard: vi.fn(),+ reportError: vi.fn(),+ setStarred: vi.fn(),+}));++vi.mock('@features/gallery', () => ({+ galleryImages: { metadata: vi.fn() },+ galleryOrganization: {+ addToBoard: (...args: unknown[]) => mocks.addToBoard(...args),+ deleteImages: (...args: unknown[]) => mocks.deleteImages(...args),+ removeFromBoard: (...args: unknown[]) => mocks.removeFromBoard(...args),+ setStarred: (...args: unknown[]) => mocks.setStarred(...args),+ },+ galleryTransfers: { downloadArchive: vi.fn() },+ toGalleryItemKey: ({ kind, name }: { kind: string; name: string }) => `${kind}:${name}`,+}));++vi.mock('@features/gallery/queries', () => ({+ invalidateGallery: (...args: unknown[]) => mocks.invalidateGallery(...args),+ invalidateGalleryItems: (...args: unknown[]) => mocks.invalidateGalleryItems(...args),+ patchGalleryItemCaches: (...args: unknown[]) => mocks.patchGalleryItemCaches(...args),+}));++vi.mock('@features/models', () => ({+ ensureModelsLoaded: vi.fn(() => Promise.resolve()),+ getModelsSnapshot: () => ({ models: [] }),+ useModelsSelector: (selector: (snapshot: { models: never[] }) => unknown) => selector({ models: [] }),+}));++vi.mock('@workbench/useOpenWorkbenchWidget', () => ({+ useOpenWorkbenchWidget: () => mocks.openWorkbenchWidget,+}));++vi.mock('@workbench/canvas-operations/api', () => ({+ getCanvasEngine: vi.fn(),+ getCanvasImportNotice: vi.fn(),+ importGalleryImagesToCanvas: vi.fn(),+}));++vi.mock('@workbench/WorkbenchContext', () => ({+ useWorkbenchCommands: () => ({+ canvas: { apply: vi.fn() },+ gallery: {+ patchItems: (...args: unknown[]) => mocks.galleryPatchItems(...args),+ removeItems: vi.fn(),+ selectImage: vi.fn(),+ setCompareImage: vi.fn(),+ },+ generation: { patchSettings: vi.fn() },+ notifications: { add: vi.fn(), reportError: (...args: unknown[]) => mocks.reportError(...args) },+ }),+ useWorkbenchQueries: () => ({+ getProject: vi.fn(),+ getSnapshot: () => ({ activeProject: { id: 'project-1' }, projects: [] }),+ isActiveProject: vi.fn(() => true),+ }),+}));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++let host: HTMLDivElement | null = null;+let root: Root | null = null;+const actionsRef = createRef<ImageActions>();+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const Probe = ({ ref }: { ref: Ref<ImageActions> }) => {+ const actions = useImageActions({+ boards: [],+ generateValues: {},+ projectId: 'project-1',+ });++ useImperativeHandle(ref, () => actions, [actions]);++ return null;+};++beforeEach(async () => {+ vi.clearAllMocks();+ accountLifecycle.activate('user-a');+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await act(() => {+ root?.render(+ <QueryClientProvider client={new QueryClient()}>+ <Probe ref={actionsRef} />+ </QueryClientProvider>+ );+ });+});++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('partial image mutation outcomes', () => {+ it('moves and patches only images confirmed by the backend', async () => {+ mocks.addToBoard.mockResolvedValue(['moved.png']);++ await act(async () => {+ await actionsRef.current?.moveImagesToBoard(['moved.png', 'locked.png'], 'board-1');+ });++ const result = {+ failed: [{ kind: 'image', name: 'locked.png' }],+ succeeded: [{ kind: 'image', name: 'moved.png' }],+ };++ expect(mocks.patchGalleryItemCaches).toHaveBeenCalledWith(expect.anything(), {+ boardId: 'board-1',+ kind: 'move',+ result,+ });+ expect(mocks.galleryPatchItems).toHaveBeenCalledWith(['image:moved.png'], { boardId: 'board-1' });+ });++ it('stars and patches only images confirmed by the backend', async () => {+ mocks.setStarred.mockResolvedValue(['starred.png']);++ await act(async () => {+ await actionsRef.current?.setImagesStarred(['starred.png', 'locked.png'], true);+ });++ const result = {+ failed: [{ kind: 'image', name: 'locked.png' }],+ succeeded: [{ kind: 'image', name: 'starred.png' }],+ };++ expect(mocks.patchGalleryItemCaches).toHaveBeenCalledWith(expect.anything(), {+ kind: 'star',+ result,+ starred: true,+ });+ expect(mocks.galleryPatchItems).toHaveBeenCalledWith(['image:starred.png'], { starred: true });+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.ts b/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.tsindex 2e18119926..afc021def6 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.ts+++ b/invokeai/frontend/webv2/src/workbench/image-actions/useImageActions.ts@@ -78,6 +78,19 @@ const getImageMutationResult = (succeeded: succeededImageNames.map((name) => ({ kind: 'image', name })),});+const getConfirmedImageMutationResult = (+ requestedImageNames: readonly string[],+ confirmedImageNames: readonly string[]+): GalleryItemMutationResult => {+ const confirmed = new Set(confirmedImageNames);+ const requested = [...new Set(requestedImageNames)];++ return getImageMutationResult(+ requested.filter((name) => confirmed.has(name)),+ requested.filter((name) => !confirmed.has(name))+ );+};+const toPngBlob = async (blob: Blob): Promise<Blob> => {if (blob.type === 'image/png') {return blob;@@ -310,22 +323,34 @@ export const useImageActions = ({const owner = captureAccountScope();try {- if (boardId === 'none') {- await galleryOrganization.removeFromBoard(imageNames, owner.signal);- } else {- await galleryOrganization.addToBoard(boardId, imageNames, owner.signal);- }+ const confirmedImageNames =+ boardId === 'none'+ ? await galleryOrganization.removeFromBoard(imageNames, owner.signal)+ : await galleryOrganization.addToBoard(boardId, imageNames, owner.signal);assertAccountScopeCurrent(owner);- const result = getImageMutationResult(imageNames);-- patchGalleryItemCaches(queryClient, { boardId, kind: 'move', result });- gallery.patchItems(result.succeeded.map(toGalleryItemKey), { boardId });- recordSuccess(- imageNames.length === 1- ? `Moved image to ${getBoardName(boardId)}`- : `Moved ${imageNames.length} images to ${getBoardName(boardId)}`- );+ const result = getConfirmedImageMutationResult(imageNames, confirmedImageNames);++ if (result.succeeded.length > 0) {+ patchGalleryItemCaches(queryClient, { boardId, kind: 'move', result });+ gallery.patchItems(result.succeeded.map(toGalleryItemKey), { boardId });+ }++ if (result.failed.length > 0) {+ recordError(+ new Error(+ result.failed.length === 1+ ? `Could not move ${result.failed[0]?.name}`+ : `Could not move ${result.failed.length} of ${imageNames.length} images`+ )+ );+ } else {+ recordSuccess(+ imageNames.length === 1+ ? `Moved image to ${getBoardName(boardId)}`+ : `Moved ${imageNames.length} images to ${getBoardName(boardId)}`+ );+ }void invalidateGallery(queryClient);} catch (error: unknown) {if (!isAccountScopeCurrent(owner)) {@@ -403,18 +428,29 @@ export const useImageActions = ({},setImagesStarred: async (imageNames, starred) => {const owner = captureAccountScope();- const result = getImageMutationResult(imageNames);- const rollback = patchGalleryItemCaches(queryClient, { kind: 'star', result, starred });try {- await galleryOrganization.setStarred(imageNames, starred, owner.signal);+ const confirmedImageNames = await galleryOrganization.setStarred(imageNames, starred, owner.signal);assertAccountScopeCurrent(owner);- gallery.patchItems(result.succeeded.map(toGalleryItemKey), { starred });+ const result = getConfirmedImageMutationResult(imageNames, confirmedImageNames);++ if (result.succeeded.length > 0) {+ patchGalleryItemCaches(queryClient, { kind: 'star', result, starred });+ gallery.patchItems(result.succeeded.map(toGalleryItemKey), { starred });+ }++ if (result.failed.length > 0) {+ recordError(+ new Error(+ result.failed.length === 1+ ? `Could not ${starred ? 'star' : 'unstar'} ${result.failed[0]?.name}`+ : `Could not ${starred ? 'star' : 'unstar'} ${result.failed.length} of ${imageNames.length} images`+ )+ );+ }void invalidateGalleryItems(queryClient);} catch (error: unknown) {- rollback();-if (!isAccountScopeCurrent(owner)) {return;}diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex ec4e657251..00318f953c 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -2431,7 +2431,7 @@ describe('workbench backend connection recovery', () => {expect(values.selectedImageNames).toEqual(['video:shared']);expect(values.compareImage).toBeNull();- state = workbenchReducer(state, { item: image, type: 'toggleGalleryItemInSelection' });+ state = workbenchReducer(state, { item: image, nextPrimaryItem: null, type: 'toggleGalleryItemInSelection' });values = getProjectWidgetValues(getActiveProject(state), 'gallery');expect(values.selectedImage).toBe(image);@@ -2451,6 +2451,31 @@ describe('workbench backend connection recovery', () => {expect(values.compareImage).toBeNull();});+ it('atomically promotes the remaining video when the image primary is toggled off', () => {+ const image = createGalleryImageItem('shared');+ const video = createGalleryVideoItem('shared');+ let state = createInitialWorkbenchState();++ state = workbenchReducer(state, {+ itemKeys: ['video:shared', 'image:shared'],+ primaryItem: image,+ type: 'setGalleryMultiSelection',+ });+ state = workbenchReducer(state, { image, type: 'setGalleryCompareImage' });+ state = workbenchReducer(state, {+ item: image,+ nextPrimaryItem: video,+ type: 'toggleGalleryItemInSelection',+ });++ expect(getProjectWidgetValues(getActiveProject(state), 'gallery')).toMatchObject({+ compareImage: null,+ selectedImage: video,+ selectedImageName: 'video:shared',+ selectedImageNames: ['video:shared'],+ });+ });+it('prunes qualified items across projects without treating a same-name video as an image input', () => {const image = createGalleryImageItem('shared');const video = createGalleryVideoItem('shared');@@ -2567,11 +2592,15 @@ describe('workbench backend connection recovery', () => {}state = workbenchReducer(state, {- boardId,- deletedImageNames: [deletedImage.name],- deletedVideoNames: [deletedVideo.name],- failedImageNames: [failedImage.name],- failedVideoNames: [failedVideo.name],+ outcome: {+ boardId,+ deletedBoardImageNames: [],+ deletedBoardVideoNames: [],+ deletedImageNames: [deletedImage.name],+ deletedVideoNames: [deletedVideo.name],+ failedImageNames: [failedImage.name],+ failedVideoNames: [failedVideo.name],+ },type: 'reconcileDeletedGalleryBoard',});@@ -2601,6 +2630,47 @@ describe('workbench backend connection recovery', () => {}});+ it('moves image and video board relationships to Uncategorized when board contents are retained', () => {+ const boardId = 'deleted-board';+ const image = createGalleryImageItem('retained-image', boardId);+ const video = createGalleryVideoItem('retained-video', boardId);+ let state = createInitialWorkbenchState();++ state = workbenchReducer(state, {+ type: 'patchWidgetValues',+ values: {+ recentImages: [galleryItemToRecentImage(image)],+ selectedBoardId: boardId,+ selectedImage: video,+ selectedImageName: `video:${video.name}`,+ selectedImageNames: [`image:${image.name}`, `video:${video.name}`],+ },+ widgetId: 'gallery',+ });+ state = workbenchReducer(state, {+ outcome: {+ boardId,+ deletedBoardImageNames: [image.name],+ deletedBoardVideoNames: [video.name],+ deletedImageNames: [],+ deletedVideoNames: [],+ failedImageNames: [],+ failedVideoNames: [],+ },+ type: 'reconcileDeletedGalleryBoard',+ });++ const values = getProjectWidgetValues(getActiveProject(state), 'gallery');++ expect(values).toMatchObject({+ recentImages: [{ ...galleryItemToRecentImage(image), boardId: 'none' }],+ selectedBoardId: 'none',+ selectedImage: { ...video, boardId: 'none' },+ selectedImageName: `video:${video.name}`,+ selectedImageNames: [`image:${image.name}`, `video:${video.name}`],+ });+ });+it('reconciles moved and starred metadata across every project recent-image overlay', () => {let state = createInitialWorkbenchState();const image = createImage('patched.png', 'backend-gallery');diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 2b3d9fe4a0..a083b2eddf 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -52,6 +52,7 @@ import {type GalleryImageItem,type GalleryItem,type GalleryItemKey,+ type GalleryBoardDeletionResult,type GallerySettings,type GeneratedImageContract,} from '@features/gallery/contracts';@@ -260,7 +261,12 @@ type WorkbenchReducerAction =projectId?: string;selectionPage?: number;}- | { type: 'toggleGalleryItemInSelection'; item: GalleryItem; projectId?: string }+ | {+ type: 'toggleGalleryItemInSelection';+ item: GalleryItem;+ nextPrimaryItem: GalleryItem | null;+ projectId?: string;+ }| { type: 'setGalleryMultiSelection'; itemKeys: GalleryItemKey[]; primaryItem: GalleryItem; projectId?: string }| { type: 'setGalleryCompareImage'; image: GalleryImageItem | null; projectId?: string }| { type: 'selectGalleryBoard'; boardId: string; projectId?: string }@@ -277,17 +283,8 @@ type WorkbenchReducerAction =| { type: 'removeGalleryItems'; itemKeys: GalleryItemKey[] }| {type: 'reconcileDeletedGalleryBoard';- boardId: string;- deletedImageNames: string[];- deletedVideoNames: string[];- failedImageNames: string[];- failedVideoNames: string[];- }- /**- * TODO(Task 7): Remove after board deletion returns and forwards the- * authoritative per-kind outcome arrays.- */- | { type: 'reconcileDeletedGalleryBoardLegacy'; boardId: string; includeImages: boolean }+ outcome: GalleryBoardDeletionResult;+ }| { type: 'setGalleryProjectBoardId'; boardId: string; projectId?: string }| {type: 'applyCanvasProjectMutation';@@ -1954,10 +1951,13 @@ const removeGalleryItemsFromAllProjects = (const reconcileDeletedGalleryBoard = (state: WorkbenchState,boardId: string,- deletedItemKeys: ReadonlySet<GalleryItemKey>+ deletedItemKeys: ReadonlySet<GalleryItemKey>,+ confirmedMovedItemKeys: ReadonlySet<GalleryItemKey>): WorkbenchState => {const survivingItemKeys = new Set(- [...getLocallyKnownGalleryItemsOnBoard(state, boardId).keys()].filter((key) => !deletedItemKeys.has(key))+ [...getLocallyKnownGalleryItemsOnBoard(state, boardId).keys(), ...confirmedMovedItemKeys].filter(+ (key) => !deletedItemKeys.has(key)+ ));const withoutDeletedItems = removeGalleryItemsFromAllProjects(state, deletedItemKeys);const withSurvivorsMoved = patchGalleryItemsAcrossProjects(withoutDeletedItems, survivingItemKeys, {@@ -3145,13 +3145,28 @@ export const __workbenchReducerInternal = (: null;const wasPrimary = selectedItemKey === itemKey;+ if (!wasPrimary) {+ return {+ ...values,+ selectedImageNames: remainingItemKeys,+ };+ }++ const expectedNextPrimaryKey = remainingItemKeys[remainingItemKeys.length - 1] ?? null;+ const nextPrimaryItem =+ expectedNextPrimaryKey &&+ action.nextPrimaryItem &&+ toGalleryItemKey(action.nextPrimaryItem) === expectedNextPrimaryKey+ ? action.nextPrimaryItem+ : null;+ const nextPrimaryKey = nextPrimaryItem ? toGalleryItemKey(nextPrimaryItem) : null;+return {...values,- selectedImage: wasPrimary ? null : values.selectedImage,- selectedImageName: wasPrimary- ? (remainingItemKeys[remainingItemKeys.length - 1] ?? null)- : values.selectedImageName,- selectedImageNames: remainingItemKeys,+ ...(nextPrimaryItem?.kind === 'image' ? {} : { compareImage: null }),+ selectedImage: nextPrimaryItem,+ selectedImageName: nextPrimaryKey,+ selectedImageNames: expectedNextPrimaryKey && !nextPrimaryItem ? [] : remainingItemKeys,};},action.projectId@@ -3275,21 +3290,21 @@ export const __workbenchReducerInternal = (return removeGalleryItemsFromAllProjects(state, new Set(action.itemKeys));}case 'reconcileDeletedGalleryBoard': {+ const { outcome } = action;const deletedItemKeys = new Set<GalleryItemKey>([- ...action.deletedImageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),- ...action.deletedVideoNames.map((name) => toGalleryItemKey({ kind: 'video', name })),+ ...outcome.deletedImageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),+ ...outcome.deletedVideoNames.map((name) => toGalleryItemKey({ kind: 'video', name })),+ ]);+ const confirmedMovedItemKeys = new Set<GalleryItemKey>([+ ...outcome.deletedBoardImageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),+ ...outcome.deletedBoardVideoNames.map((name) => toGalleryItemKey({ kind: 'video', name })),+ ...outcome.failedImageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),+ ...outcome.failedVideoNames.map((name) => toGalleryItemKey({ kind: 'video', name })),]);// Failed and otherwise unconfirmed local items survive. The reconciler// moves every locally known key not confirmed deleted to Uncategorized.- return reconcileDeletedGalleryBoard(state, action.boardId, deletedItemKeys);- }- case 'reconcileDeletedGalleryBoardLegacy': {- const deletedItemKeys = action.includeImages- ? new Set(getLocallyKnownGalleryItemsOnBoard(state, action.boardId).keys())- : new Set<GalleryItemKey>();-- return reconcileDeletedGalleryBoard(state, action.boardId, deletedItemKeys);+ return reconcileDeletedGalleryBoard(state, outcome.boardId, deletedItemKeys, confirmedMovedItemKeys);}case 'setGalleryProjectBoardId': {return updateGalleryValues(state, (values) => ({ ...values, projectBoardId: action.boardId }), action.projectId);diff --git a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts b/invokeai/frontend/webv2/src/workbench/workbenchStore.tsindex 5b3f21cfc6..ecdc89d509 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchStore.ts@@ -100,15 +100,9 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchSt})),reconcileDeletedBoardOutcome: command('reconcileDeletedGalleryBoard',- (boardId: string, outcome: Omit<ActionPayload<'reconcileDeletedGalleryBoard'>, 'boardId'>) => ({- boardId,- ...outcome,- })+ (outcome: ActionPayload<'reconcileDeletedGalleryBoard'>['outcome']) => ({ outcome })),- /**- * TODO(Task 7): Remove these image/boolean adapters when image actions- * and board deletion dispatch confirmed mixed-media outcomes directly.- */+ /** TODO(Task 7): Remove these image adapters with the mixed-media action port. */patchImages: (imageNames: string[], changes: ActionPayload<'patchGalleryItems'>['changes']): void =>dispatch({changes,@@ -120,13 +114,6 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchStitemKeys: imageNames.map((name) => toGalleryItemKey({ kind: 'image', name })),type: 'removeGalleryItems',}),- reconcileDeletedBoard: command(- 'reconcileDeletedGalleryBoardLegacy',- (boardId: string, includeImages: boolean) => ({- boardId,- includeImages,- })- ),selectItem: command('selectGalleryItem',(@@ -155,8 +142,13 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchSt),toggleItemSelection: command('toggleGalleryItemInSelection',- (item: ActionPayload<'toggleGalleryItemInSelection'>['item'], projectId?: string) => ({+ (+ item: ActionPayload<'toggleGalleryItemInSelection'>['item'],+ nextPrimaryItem: ActionPayload<'toggleGalleryItemInSelection'>['nextPrimaryItem'],+ projectId?: string+ ) => ({item,+ nextPrimaryItem,projectId,})),@@ -194,9 +186,14 @@ const createCommands = (dispatch: WorkbenchDispatch, getState: () => WorkbenchStprojectId,type: 'setGalleryMultiSelection',}),- toggleImageSelection: (image: GeneratedImageContract & Partial<GalleryImage>, projectId?: string): void =>+ toggleImageSelection: (+ image: GeneratedImageContract & Partial<GalleryImage>,+ nextPrimaryItem: ActionPayload<'toggleGalleryItemInSelection'>['nextPrimaryItem'],+ projectId?: string+ ): void =>dispatch({item: legacyGeneratedImageToGalleryItem(image),+ nextPrimaryItem,projectId,type: 'toggleGalleryItemInSelection',}),