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): follow active denoising sequence
joshistoast2aff0ff97ff0
diff --git a/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx b/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsxindex b8e97967b7..f4c56ee721 100644--- a/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx+++ b/invokeai/frontend/webv2/src/app/GalleryUiAdapter.tsx@@ -2,6 +2,7 @@ import type { GalleryUiAdapter } from '@features/gallery/react';import type { ReactNode } from 'react';import { GalleryUiProvider } from '@features/gallery/react';+import { useProgressImage } from '@features/queue/react';import { getProjectWidgetValues } from '@workbench/widgetState';import {useActiveProjectId,@@ -33,6 +34,7 @@ export const GalleryUiAdapterProvider = ({ children }: { children: ReactNode })const queueItems = useActiveProjectSelector((project) => project.queue.items);const antialiasProgressImages = useActiveProjectSelector((project) => project.settings.antialiasProgressImages);const liveFollowEnabled = useActiveProjectSelector((project) => project.settings.showProgressImagesInViewer);+ const liveProgressTarget = useProgressImage()?.target ?? null;const { account, gallery, notifications, widgets } = useWorkbenchCommands();const adapter = useMemo<GalleryUiAdapter>(() => ({@@ -46,6 +48,7 @@ export const GalleryUiAdapterProvider = ({ children }: { children: ReactNode })ImageActionsProvider: GalleryImageActionsAdapter,ImageContextMenu: GalleryImageContextMenu,liveFollowEnabled,+ liveProgressTarget,notifications,projectId,projectName,@@ -59,6 +62,7 @@ export const GalleryUiAdapterProvider = ({ children }: { children: ReactNode })galleryValues,generateValues,liveFollowEnabled,+ liveProgressTarget,notifications,projectId,projectName,diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.tsindex 41bfa52cae..5dc6ea4eba 100644--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts@@ -17,13 +17,15 @@ export {type GalleryThumbnailFit,} from './core/settings';export {- getActiveGalleryQueuePlaceholder,getGalleryCompareImage,getGalleryCurrentItem,+ getGalleryGenerationSequence,getGalleryImagesRefreshToken,getGalleryRecentImagesKey,getGalleryRefreshToken,type GalleryCurrentItem,+ type GalleryGenerationSequence,+ type GalleryLiveTarget,type GalleryQueuePlaceholder,} from './ui/galleryStateView';export { getSelectedGalleryImageFromValues } from './core/selection';diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsxindex ea9dec2bdf..59565c9f46 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx@@ -4,6 +4,8 @@ import type { QueueItem } from '@features/queue/contracts';import { createContext, use, type ComponentType, type ReactNode } from 'react';+import type { GalleryLiveTarget } from './galleryStateView';+export interface GalleryImageActions {deleteImages(imageNames: string[]): Promise<void>;moveImagesToBoard(imageNames: string[], boardId: string): Promise<void>;@@ -83,6 +85,7 @@ export interface GalleryUiAdapter {projectName: string;queueItems: QueueItem[];liveFollowEnabled: boolean;+ liveProgressTarget: GalleryLiveTarget | null;widgets: { patchGalleryValues(values: Record<string, unknown>): void };}diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsxindex fd973dda8b..0f85650037 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx@@ -45,6 +45,7 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidggalleryValues,generateValues,liveFollowEnabled,+ liveProgressTarget,projectId,projectName,queueItems,@@ -77,7 +78,8 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidgdata.images,data.isLoadingImages,queueItems,- liveFollowEnabled+ liveFollowEnabled,+ liveProgressTarget);const onStarredChange = useCallback(diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.tsindex 30356f6a0a..c04aef81d6 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.test.ts@@ -4,9 +4,9 @@ import type { QueueHistoryItemStatus, QueueItem } from '@features/queue/contractimport { describe, expect, it } from 'vitest';import {- getActiveGalleryQueuePlaceholder,getBoardCounts,getGalleryCurrentItem,+ getGalleryGenerationSequence,getGalleryImagesRefreshToken,getGalleryQueuePlaceholders,getGallerySelectedBoardId,@@ -36,6 +36,7 @@ const createQueueItem = ({cancelledBackendItemIds,destination = 'gallery',status = 'pending',+ localId,}: {backendItemIds?: number[];batchCount?: number;@@ -44,12 +45,13 @@ const createQueueItem = ({cancelledBackendItemIds?: number[];destination?: 'gallery' | 'canvas';status?: QueueHistoryItemStatus;+ localId?: string;}): QueueItem => ({backendItemIds,cancellable: true,cancelledBackendItemIds,completedBackendItemIds,- id: `queue-item-${status}-${boardId}`,+ id: localId ?? `queue-item-${status}-${boardId}`,snapshot: {backendSubmission: {batchCount,@@ -180,20 +182,85 @@ describe('gallery state view', () => {expect(placeholders.map((placeholder) => placeholder.itemIndex)).toEqual([2, 3]);});- it('derives the active gallery placeholder from the running queue item before a progress image arrives', () => {- const pending = createQueueItem({ backendItemIds: [1], boardId: 'none', status: 'pending' });- const running = createQueueItem({- backendItemIds: [11, 12, 13],+ it('resolves the live slot from the exact denoising target instead of the newest submitted batch', () => {+ const newerBatch = createQueueItem({+ backendItemIds: [21, 22],+ boardId: 'board-1',+ localId: 'newer-batch',+ status: 'running',+ });+ const activeEarlierBatch = createQueueItem({+ backendItemIds: [11, 12],boardId: 'board-1',completedBackendItemIds: [11],+ localId: 'active-earlier-batch',status: 'running',});- expect(getActiveGalleryQueuePlaceholder([pending, running])).toMatchObject({+ expect(+ getGalleryGenerationSequence([newerBatch, activeEarlierBatch], {+ itemIndex: 2,+ queueItemId: activeEarlierBatch.id,+ }).liveSlot+ ).toMatchObject({boardId: 'board-1',itemIndex: 2,- queueItemId: running.id,+ queueItemId: activeEarlierBatch.id,+ });+ });++ it('flattens pending slots from multiple batches into one global execution order', () => {+ const newerBatch = createQueueItem({+ backendItemIds: [21, 22],+ boardId: 'board-1',+ localId: 'newer-batch',+ status: 'running',+ });+ const earlierBatch = createQueueItem({+ backendItemIds: [11, 12],+ boardId: 'board-1',+ localId: 'earlier-batch',+ status: 'running',});++ const sequence = getGalleryGenerationSequence([newerBatch, earlierBatch], null);++ expect(sequence.chronologicalSlots.map((slot) => slot.id)).toEqual([+ 'earlier-batch:0',+ 'earlier-batch:1',+ 'newer-batch:0',+ 'newer-batch:1',+ ]);+ expect(sequence.liveSlot).toBeNull();+ });++ it('reverses the complete flattened sequence for newest-first galleries', () => {+ const newerBatch = createQueueItem({+ backendItemIds: [21, 22],+ boardId: 'board-1',+ localId: 'newer-batch',+ status: 'running',+ });+ const earlierBatch = createQueueItem({+ backendItemIds: [11, 12],+ boardId: 'board-1',+ localId: 'earlier-batch',+ status: 'running',+ });++ const placeholders = getGalleryQueuePlaceholders([newerBatch, earlierBatch], {+ galleryView: 'images',+ imageOrderDir: 'DESC',+ searchTerm: '',+ selectedBoardId: 'board-1',+ });++ expect(placeholders.map((slot) => slot.id)).toEqual([+ 'newer-batch:1',+ 'newer-batch:0',+ 'earlier-batch:1',+ 'earlier-batch:0',+ ]);});it('uses one derived current item while live-follow is active', () => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.tsindex bf498e018d..5767624293 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts@@ -1,4 +1,10 @@-import type { GalleryBoard, GalleryImage, GalleryView, GeneratedImageContract } from '@features/gallery/core/types';+import type {+ GalleryBoard,+ GalleryImage,+ GalleryOrderDir,+ GalleryView,+ GeneratedImageContract,+} from '@features/gallery/core/types';import type { QueueItem } from '@features/queue/contracts';import { getGallerySettings, type GallerySettings } from '@features/gallery/core/settings';@@ -26,6 +32,16 @@ export interface GalleryQueuePlaceholder {height: number;}+export interface GalleryLiveTarget {+ queueItemId: string;+ itemIndex: number;+}++export interface GalleryGenerationSequence {+ chronologicalSlots: GalleryQueuePlaceholder[];+ liveSlot: GalleryQueuePlaceholder | null;+}+export type GalleryCurrentItem =| { kind: 'image'; imageName: string }| { kind: 'placeholder'; placeholder: GalleryQueuePlaceholder }@@ -47,9 +63,20 @@ export interface GalleryStateView {settings: GallerySettings;}-export const getActiveGalleryQueuePlaceholder = (queueItems: QueueItem[]): GalleryQueuePlaceholder | null => {+interface SortableGalleryQueueSlot {+ backendItemId: number | null;+ placeholder: GalleryQueuePlaceholder;+ submittedAt: string;+}++export const getGalleryGenerationSequence = (+ queueItems: QueueItem[],+ liveTarget: GalleryLiveTarget | null+): GalleryGenerationSequence => {+ const sortableSlots: SortableGalleryQueueSlot[] = [];+for (const item of queueItems) {- if (item.status !== 'running' || item.snapshot.destination !== 'gallery') {+ if ((item.status !== 'pending' && item.status !== 'running') || item.snapshot.destination !== 'gallery') {continue;}@@ -57,27 +84,53 @@ export const getActiveGalleryQueuePlaceholder = (queueItems: QueueItem[]): Galleconst { width, height } = getQueueItemSnapshotDimensions(item, { height: 1024, width: 1024 });const completedBackendItemIds = new Set(item.completedBackendItemIds ?? []);const cancelledBackendItemIds = new Set(item.cancelledBackendItemIds ?? []);+ const slotCount = item.backendItemIds?.length ?? getQueueItemSnapshotBatchCount(item);- if (item.backendItemIds?.length) {- const index = item.backendItemIds.findIndex(- (backendItemId) => !completedBackendItemIds.has(backendItemId) && !cancelledBackendItemIds.has(backendItemId)- );+ for (let index = 0; index < slotCount; index += 1) {+ const backendItemId = item.backendItemIds?.[index] ?? null;- if (index !== -1) {- return { boardId, height, id: `${item.id}:${index}`, itemIndex: index + 1, queueItemId: item.id, width };+ if (+ backendItemId !== null &&+ (completedBackendItemIds.has(backendItemId) || cancelledBackendItemIds.has(backendItemId))+ ) {+ continue;}- continue;+ sortableSlots.push({+ backendItemId,+ placeholder: {+ boardId,+ height,+ id: `${item.id}:${index}`,+ itemIndex: index + 1,+ queueItemId: item.id,+ width,+ },+ submittedAt: item.snapshot.submittedAt,+ });}+ }- const expectedImageCount = getQueueItemSnapshotBatchCount(item);-- if (expectedImageCount > 0) {- return { boardId, height, id: `${item.id}:0`, itemIndex: 1, queueItemId: item.id, width };+ sortableSlots.sort((a, b) => {+ if (a.backendItemId !== null && b.backendItemId !== null) {+ return a.backendItemId - b.backendItemId;}- }- return null;+ return (+ a.submittedAt.localeCompare(b.submittedAt) ||+ a.placeholder.itemIndex - b.placeholder.itemIndex ||+ a.placeholder.queueItemId.localeCompare(b.placeholder.queueItemId)+ );+ });++ const chronologicalSlots = sortableSlots.map(({ placeholder }) => placeholder);+ const liveSlot = liveTarget+ ? (chronologicalSlots.find(+ (slot) => slot.queueItemId === liveTarget.queueItemId && slot.itemIndex === liveTarget.itemIndex+ ) ?? null)+ : null;++ return { chronologicalSlots, liveSlot };};export const getGalleryCurrentItem = ({@@ -169,76 +222,20 @@ export const getGalleryQueuePlaceholders = (queueItems: QueueItem[],{galleryView,+ imageOrderDir = 'ASC',searchTerm,selectedBoardId,- }: { galleryView: GalleryView; searchTerm: string; selectedBoardId: string }+ }: { galleryView: GalleryView; imageOrderDir?: GalleryOrderDir; searchTerm: string; selectedBoardId: string }): GalleryQueuePlaceholder[] => {if (galleryView !== 'images' || searchTerm.trim() !== '') {return [];}- const placeholders: GalleryQueuePlaceholder[] = [];-- for (const item of queueItems) {- if (item.status !== 'pending' && item.status !== 'running') {- continue;- }-- if (item.snapshot.destination !== 'gallery') {- continue;- }-- const targetBoardId = item.snapshot.galleryBoardId ?? 'none';-- if (targetBoardId !== selectedBoardId) {- continue;- }-- const expectedImageCount = item.backendItemIds?.length- ? item.backendItemIds.length- : getQueueItemSnapshotBatchCount(item);- const { width, height } = getQueueItemSnapshotDimensions(item, { height: 1024, width: 1024 });- const completedBackendItemIds = new Set(item.completedBackendItemIds ?? []);- const cancelledBackendItemIds = new Set(item.cancelledBackendItemIds ?? []);-- if (item.backendItemIds?.length) {- for (let index = 0; index < item.backendItemIds.length; index += 1) {- const backendItemId = item.backendItemIds[index];-- if (- backendItemId === undefined ||- completedBackendItemIds.has(backendItemId) ||- cancelledBackendItemIds.has(backendItemId)- ) {- continue;- }-- placeholders.push({- boardId: targetBoardId,- height,- id: `${item.id}:${index}`,- itemIndex: index + 1,- queueItemId: item.id,- width,- });- }-- continue;- }-- for (let index = 0; index < expectedImageCount; index++) {- placeholders.push({- boardId: targetBoardId,- height,- id: `${item.id}:${index}`,- itemIndex: index + 1,- queueItemId: item.id,- width,- });- }- }+ const placeholders = getGalleryGenerationSequence(queueItems, null).chronologicalSlots.filter(+ (placeholder) => placeholder.boardId === selectedBoardId+ );- return placeholders;+ return imageOrderDir === 'DESC' ? [...placeholders].reverse() : placeholders;};export const getGalleryStateView = (@@ -247,7 +244,8 @@ export const getGalleryStateView = (backendImages: GalleryImage[] | null,isLoading: boolean,queueItems: QueueItem[] = [],- liveFollowEnabled = false+ liveFollowEnabled = false,+ liveTarget: GalleryLiveTarget | null = null): GalleryStateView => {const localImages = Array.isArray(values.recentImages)? (values.recentImages as GeneratedImageContract[]).map((image) => ({@@ -273,7 +271,7 @@ export const getGalleryStateView = (const isComparisonActive =visibleSelectedImageName !== null && compareImageName !== null && compareImageName !== visibleSelectedImageName;const currentItem = getGalleryCurrentItem({- activePlaceholder: getActiveGalleryQueuePlaceholder(queueItems),+ activePlaceholder: getGalleryGenerationSequence(queueItems, liveTarget).liveSlot,isComparisonActive,liveFollowEnabled,selectedImageName: visibleSelectedImageName,@@ -287,7 +285,12 @@ export const getGalleryStateView = (images,isLoading,pendingPlaceholders: settings.showPendingItems- ? getGalleryQueuePlaceholders(queueItems, { galleryView, searchTerm, selectedBoardId })+ ? getGalleryQueuePlaceholders(queueItems, {+ galleryView,+ imageOrderDir: settings.imageOrderDir,+ searchTerm,+ selectedBoardId,+ }): [],projectBoardId: getGalleryProjectBoardId(values),searchTerm,diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsxindex 84a00c6d25..2864d211d3 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx@@ -10,8 +10,8 @@ import {type GeneratedImageContract,} from '@features/gallery';import {- getActiveGalleryQueuePlaceholder,getGalleryCompareImage,+ getGalleryGenerationSequence,getGalleryImagesRefreshToken,getGalleryRecentImagesKey,getGalleryRefreshToken,@@ -52,7 +52,6 @@ import { PreviewFilmstrip } from './PreviewFilmstrip';import { PreviewFooter } from './PreviewFooter';import { PreviewFrame } from './PreviewFrame';import { previewHeaderStore } from './previewHeaderStore';-import { PreviewLiveStatusLine } from './PreviewLiveReadout';import {getPreviewComparisonMode,getPreviewFilmstripVisible,@@ -291,9 +290,12 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {}, [boardImages, displayBoardId, selectedImage]);const isComparing =selectedImage !== null && compareImage !== null && compareImage.imageName !== selectedImage.imageName;- const activeGalleryPlaceholder = useMemo(() => getActiveGalleryQueuePlaceholder(queueItems), [queueItems]);- const shouldFollowLive = showProgressImagesInViewer && activeGalleryPlaceholder !== null && !isComparing;+ const activeGalleryPlaceholder = useMemo(+ () => getGalleryGenerationSequence(queueItems, progressImage?.target ?? null).liveSlot,+ [progressImage?.target, queueItems]+ );const matchingProgressImage = getMatchingProgressImage(progressImage, activeGalleryPlaceholder);+ const shouldFollowLive = showProgressImagesInViewer && matchingProgressImage !== null && !isComparing;const exitCompare = useCallback(() => gallery.setCompareImage(null), [gallery]);const swapCompareImages = useCallback(() => {if (selectedImage && compareImage) {@@ -444,7 +446,7 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {return (<Box ref={rootRef} p="2" h="full">- {shouldFollowLive && activeGalleryPlaceholder ? (+ {shouldFollowLive && activeGalleryPlaceholder && matchingProgressImage ? (<LivePreviewplaceholder={activeGalleryPlaceholder}progressImage={matchingProgressImage}@@ -606,7 +608,7 @@ const LivePreview = ({shouldAntialiasProgressImage,}: {placeholder: GalleryQueuePlaceholder;- progressImage: LatestProgressImageSnapshot | null;+ progressImage: LatestProgressImageSnapshot;shouldAntialiasProgressImage: boolean;}) => {const { t } = useTranslation();@@ -624,14 +626,7 @@ const LivePreview = ({shouldAntialiasLiveImage={shouldAntialiasProgressImage}source={previewImage}variant="inset"- >- <Stack align="center" color="fg" gap="2" maxW="18rem" textAlign="center">- <Text fontSize="sm" fontWeight="800">- {t('common.generating')}- </Text>- <PreviewLiveStatusLine queueItemId={placeholder.queueItemId} />- </Stack>- </PreviewFrame>+ />);};diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 0ef533a551..af1c4dd6d1 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -1877,6 +1877,50 @@ describe('workbenchReducer Phase 5 generation flow', () => {expect(getProjectWidgetValues(getActiveProject(state), 'gallery').selectedImageName).toBe('gallery-image-3.png');});+ it('does not reorder existing results when an older batch final aggregate arrives late', () => {+ let state = primeGenerate(undefined, { batchCount: 2 });++ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });+ state = submitGenerate(state);++ const projectId = getActiveProject(state).id;+ const olderQueueItem = getActiveProject(state).queue.items[0];+ const olderImage1 = createImage('older-1.png', olderQueueItem.id);+ const olderImage2 = createImage('older-2.png', olderQueueItem.id);++ state = workbenchReducer(state, {+ backendItemId: 11,+ images: [olderImage1],+ projectId,+ queueItemId: olderQueueItem.id,+ type: 'routeQueueItemPartialResults',+ });+ state = submitGenerate(state);++ const newerQueueItem = getActiveProject(state).queue.items[0];+ const newerImage = createImage('newer-1.png', newerQueueItem.id);++ state = workbenchReducer(state, {+ backendItemId: 21,+ images: [newerImage],+ projectId,+ queueItemId: newerQueueItem.id,+ type: 'routeQueueItemPartialResults',+ });+ state = workbenchReducer(state, {+ images: [olderImage1, olderImage2],+ projectId,+ queueItemId: olderQueueItem.id,+ type: 'routeQueueItemResults',+ });++ expect(+ (getProjectWidgetValues(getActiveProject(state), 'gallery').recentImages as GeneratedImageContract[]).map(+ (image) => image.imageName+ )+ ).toEqual(['older-2.png', 'newer-1.png', 'older-1.png']);+ });+it('selects the last image from a final-only Gallery batch', () => {let state = primeGenerate(undefined, { batchCount: 3 });diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 81954377ef..a0fa8a093d 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -1712,14 +1712,11 @@ const updateGalleryWithResultImages = (project: Project, images: GeneratedImageCconst previousImages = getGalleryImages(galleryValues);const previousImageNames = new Set(previousImages.map((image) => image.imageName));const newImages = images.filter((image) => !previousImageNames.has(image.imageName));- const existingImages = previousImages.filter(- (image) => !images.some((incomingImage) => incomingImage.imageName === image.imageName)- );const nextSelectedImage = newImages.at(-1);return updateProjectWidgetValues(project, 'gallery', () => ({...galleryValues,- recentImages: [...images, ...existingImages],+ recentImages: [...[...newImages].reverse(), ...previousImages],selectedImage: nextSelectedImage ?? galleryValues.selectedImage,selectedImageName: nextSelectedImage?.imageName ?? galleryValues.selectedImageName,selectedImageNames: nextSelectedImage ? [nextSelectedImage.imageName] : getGallerySelectedImageNames(galleryValues),