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(gallery): send results to the project board by default
Josh Corbettb7bae935d89a
diff --git a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsxindex ec09518925..c3067b4559 100644--- a/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/VideoUiAdapter.tsx@@ -1,7 +1,7 @@import type { VideoUiAdapter } from '@features/video';import type { ReactNode } from 'react';-import { toGalleryItemKey } from '@features/gallery/contracts';+import { getGalleryDestinationBoardId, toGalleryItemKey } from '@features/gallery/contracts';import { invalidateGallery } from '@features/gallery/queries';import { VideoUiProvider } from '@features/video';import { useQueryClient } from '@tanstack/react-query';@@ -40,15 +40,11 @@ export const VideoUiAdapterProvider = ({ children }: { children: ReactNode }) =>const showPromptSyntaxHighlighting = useWorkbenchPreferenceSelector((preferences) => preferences.showPromptSyntaxHighlighting);- // Uploads from the video panel land on the gallery's currently selected board. This- // deliberately reads the RAW selectedBoardId — the same value the queue snapshots as- // galleryBoardId for generation results — so uploads and generations land on the same- // board, rather than replicating the gallery view's display-side fallbacks.- const uploadBoardId = useActiveProjectSelector((activeProject) => {- const selectedBoardId = getProjectWidgetValues(activeProject, 'gallery').selectedBoardId;-- return typeof selectedBoardId === 'string' ? selectedBoardId : 'none';- });+ // Uploads from the video panel land where generation results do — the same+ // destination the queue snapshots as galleryBoardId.+ const uploadBoardId = useActiveProjectSelector(+ (activeProject) => getGalleryDestinationBoardId(getProjectWidgetValues(activeProject, 'gallery')) ?? 'none'+ );// Ref-backed so the port's actions keep their stable-for-the-project identity: a// board click must not re-render every useVideoUiActions consumer in the panel.const uploadBoardIdRef = useRef(uploadBoardId);diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.tsindex 16a667236a..08bcbd6706 100644--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts@@ -54,6 +54,7 @@ export {} from './core/settings';export {getGalleryCompareImage,+ getGalleryDestinationBoardId,getGalleryPage,getGallerySelectedImagePage,getGallerySelectedImageQuery,diff --git a/invokeai/frontend/webv2/src/features/gallery/core/boardLabels.ts b/invokeai/frontend/webv2/src/features/gallery/core/boardLabels.tsindex 8ba9b97735..fad96a2d85 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/boardLabels.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/boardLabels.ts@@ -5,3 +5,8 @@ export type GalleryBoardTranslate = (key: string) => string;/** Resolves the localized display label for synthesized and stored boards. */export const getGalleryBoardLabel = (board: GalleryBoard, t: GalleryBoardTranslate): string =>board.kind === 'uncategorized' ? t('widgets.gallery.uncategorized') : board.name;++/** Virtual "by date" boards (`by_date:<YYYY-MM-DD>`) list items but can never receive them. */+export const DATE_BOARD_ID_PREFIX = 'by_date:';++export const isDateBoardId = (boardId: string): boolean => boardId.startsWith(DATE_BOARD_ID_PREFIX);diff --git a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts b/invokeai/frontend/webv2/src/features/gallery/data/backend.tsindex 1d820ad921..fe1104f3d8 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/backend.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/backend.ts@@ -19,6 +19,7 @@ import type {GalleryView,} from '@features/gallery/core/types';+import { DATE_BOARD_ID_PREFIX, isDateBoardId } from '@features/gallery/core/boardLabels';import { parseGalleryItemKey } from '@features/gallery/core/items';import { getExternalImageFile, getImageCluster } from '@features/gallery/core/semanticImageQuery';import { isTimestampInRange } from '@platform/search/dateTokens';@@ -67,10 +68,9 @@ interface BackendBoardDTO {* unassigned images (board_id 'none'); 'date' is a read-only virtual board* grouping images by creation date (id 'by_date:YYYY-MM-DD').*/-const DATE_BOARD_ID_PREFIX = 'by_date:';export const ALL_READABLE_BOARDS_ID = 'all';-export const isDateBoardId = (boardId: string): boolean => boardId.startsWith(DATE_BOARD_ID_PREFIX);+export { isDateBoardId };const getDateFromBoardId = (boardId: string): string => boardId.slice(DATE_BOARD_ID_PREFIX.length);diff --git a/invokeai/frontend/webv2/src/features/gallery/index.ts b/invokeai/frontend/webv2/src/features/gallery/index.tsindex 1958787cb4..5fc40a1e4e 100644--- a/invokeai/frontend/webv2/src/features/gallery/index.ts+++ b/invokeai/frontend/webv2/src/features/gallery/index.ts@@ -49,7 +49,6 @@ import {getGalleryItemByRef,getGalleryVideoMetadata,getGalleryVideoWorkflow,- isDateBoardId,isInvalidGalleryBoardDestination,listGalleryBoards,makeImageCanvasAsset,@@ -251,8 +250,6 @@ export const galleryDestinations = {list: listGalleryBoards,} as const;-export const isGalleryVirtualBoard = isDateBoardId;-/*** Whether a board id can actually receive item attachments. Virtual destinations* (date buckets, `generated`/`assets`) and `none` cannot: the organizationdiff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.tsindex 1972207c25..72afda45ab 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts@@ -5,6 +5,7 @@ import { describe, expect, it } from 'vitest';import {getBoardCounts,+ getGalleryDestinationBoardId,getGallerySelectedBoardId,getGallerySelectedImageQuery,getGallerySemanticImageQuery,@@ -341,3 +342,18 @@ describe('gallery state view', () => {expect(getGalleryStateView({ selectedBoardId: 'board-1' }, boards, [], false).semanticImageQuery).toBeNull();});});++describe('getGalleryDestinationBoardId', () => {+ it('sends results to the picked board, keeping an explicit Uncategorized choice', () => {+ expect(getGalleryDestinationBoardId({ projectBoardId: 'project', selectedBoardId: 'picked' })).toBe('picked');+ expect(getGalleryDestinationBoardId({ projectBoardId: 'project', selectedBoardId: 'none' })).toBe('none');+ });++ it('falls back to the project board when nothing is picked or a date bucket is', () => {+ expect(getGalleryDestinationBoardId({ projectBoardId: 'project' })).toBe('project');+ expect(getGalleryDestinationBoardId({ projectBoardId: 'project', selectedBoardId: 'by_date:2026-07-15' })).toBe(+ 'project'+ );+ expect(getGalleryDestinationBoardId({})).toBeNull();+ });+});diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.tsindex 08454393d2..4c25f72a60 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts@@ -1,5 +1,6 @@import type { GalleryBoard, GalleryImage, GalleryOrderDir, GalleryView } from '@features/gallery/core/types';+import { isDateBoardId } from '@features/gallery/core/boardLabels';import {legacyGeneratedImageToGalleryItem,toGalleryItemKey,@@ -91,6 +92,19 @@ export const getGallerySemanticSearchText = (values: Record<string, unknown>): sexport const getGalleryRawSelectedBoardId = (values: Record<string, unknown>): string | null =>typeof values.selectedBoardId === 'string' ? values.selectedBoardId : null;+/**+ * Where new results and uploads land: the board the person picked, else the+ * project's own board. A date bucket cannot hold items, so it defers to the+ * project board too; an explicit Uncategorized (`'none'`) choice is kept.+ */+export const getGalleryDestinationBoardId = (values: Record<string, unknown>): string | null => {+ const selectedBoardId = getGalleryRawSelectedBoardId(values);++ return selectedBoardId !== null && !isDateBoardId(selectedBoardId)+ ? selectedBoardId+ : getGalleryProjectBoardId(values);+};+/*** Where new results land, resolved against the boards this install actually has.*diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.test.tsindex 1c9fd63d7d..96c26a53dc 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.test.ts@@ -184,6 +184,26 @@ describe('saveCanvasToGallery', () => {expect(harness.uploadImage.mock.calls[0]?.[1]?.boardId).toBe(expectedBoardId);});+ it.each([+ ['no board is selected', undefined],+ ['a date bucket is selected', 'by_date:2026-07-15'],+ ])('saves to the project board when %s', async (_case, selectedBoardId) => {+ const harness = createHarness();+ const project = createProject();+ const gallery = getProjectWidgetInstance(project, 'gallery')!;++ gallery.state.values = { ...gallery.state.values, projectBoardId: 'project-board', selectedBoardId };++ await saveCanvasToGallery({+ engine: harness.engine,+ project,+ region: 'canvas',+ uploadImage: harness.uploadImage,+ });++ expect(harness.uploadImage.mock.calls[0]?.[1]?.boardId).toBe('project-board');+ });+it('omits disabled negative prompts and unsupported models from metadata', async () => {const unsupportedModel: GenerateModelConfig = {base: 'unsupported',diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.tsindex f01c74cb12..87d90c080a 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/saveCanvasToGallery.ts@@ -1,7 +1,7 @@import type { Rect } from '@workbench/canvas-engine/types';import type { Project } from '@workbench/projectContracts';-import { isGalleryVirtualBoard } from '@features/gallery';+import { getGalleryDestinationBoardId } from '@features/gallery/contracts';import { toModelIdentifier } from '@features/generation/graph';import {getEffectivePrompts,@@ -49,11 +49,9 @@ const buildCanvasSaveMetadata = (project: Project, rect: Rect): Record<string, u};const getCanvasSaveBoardId = (project: Project): string | undefined => {- const selectedBoardId = getProjectWidgetValues(project, 'gallery').selectedBoardId;+ const boardId = getGalleryDestinationBoardId(getProjectWidgetValues(project, 'gallery'));- return typeof selectedBoardId === 'string' && selectedBoardId !== 'none' && !isGalleryVirtualBoard(selectedBoardId)- ? selectedBoardId- : undefined;+ return boardId !== null && boardId !== 'none' ? boardId : undefined;};export const saveCanvasToGallery = async (options: {diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 38e669e50c..a61075fab5 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -4731,6 +4731,21 @@ describe('workbenchReducer Phase 5 generation flow', () => {expect(queueItem.snapshot.galleryBoardId).toBe('backend-board-id');});+ it('sends gallery submissions to the project board until a board is picked', () => {+ let state = createInitialWorkbenchState();++ state = workbenchReducer(state, {+ boardId: 'project-board',+ projectId: getActiveProject(state).id,+ type: 'setGalleryProjectBoardId',+ });+ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });+ state = primeGenerate(state);+ state = submitGenerate(state);++ expect(getActiveProject(state).queue.items[0]?.snapshot.galleryBoardId).toBe('project-board');+ });+it('stores full selected gallery image data for Preview widget', () => {let state = createInitialWorkbenchState();const image = createGalleryImageItem('backend-selected.png');diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex eb8bb7ea6e..1b3fa5a26a 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -59,6 +59,7 @@ import {getGallerySettings,parseGallerySemanticReference,toGallerySemanticTextReference,+ getGalleryDestinationBoardId,getSelectedGalleryItemFromValues,legacyGeneratedImageToGalleryItem,normalizeGalleryImage,@@ -3228,7 +3229,7 @@ const enqueueCompiledSnapshot = (seedStep: seedPlan?.step ?? 0,}: { error: `${route.sourceId} queue item is missing source submission metadata.`, kind: 'invalid' };- const selectedGalleryBoardId = widgetStates.gallery?.values.selectedBoardId;+ const galleryBoardId = getGalleryDestinationBoardId(widgetStates.gallery?.values ?? {});const generatePresentationSettings = normalizeGenerateSettings(widgetStates.generate?.values);const videoPresentationDimensions =route.sourceId === 'video' && videoSettings?.model ? getVideoDimensions(videoSettings.model, videoSettings) : null;@@ -3269,7 +3270,7 @@ const enqueueCompiledSnapshot = (},destination: route.destination,filterIntermediateResults: route.sourceId === 'workflow',- galleryBoardId: typeof selectedGalleryBoardId === 'string' ? selectedGalleryBoardId : null,+ galleryBoardId,graph: { id: graph.id, label: graph.label },presentation: {// Placeholder sizing only: superseded by the backend's real item ids as