Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(workbench): show progress images in gallery and preview

joshistoast785c21212d60
diff --git a/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx b/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx
index 6a9d36e14d..d203542bb5 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx
+++ b/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx
@@ -420,14 +420,12 @@ const ProjectSection = () => {
/>
<SettingToggle
checked={settings.antialiasProgressImages}
- comingSoon
description="Smooth progress previews instead of rendering them pixelated."
label="Antialias progress images"
onChange={(checked) => updateProjectSettings({ antialiasProgressImages: checked })}
/>
<SettingToggle
checked={settings.showProgressImagesInViewer}
- comingSoon
description="Show progress images in the viewer when an image is still generating."
label="Show progress images in viewer"
onChange={(checked) => updateProjectSettings({ showProgressImagesInViewer: checked })}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx
index 1a51a6cb1a..263df42163 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx
@@ -1,10 +1,13 @@
import type { GalleryImage } from '@workbench/gallery/api';
import type { GalleryThumbnailFit } from '@workbench/gallery/settings';
-import { Badge, Box, Flex, ScrollArea, Skeleton, Spinner, Text } from '@chakra-ui/react';
+import { Badge, Box, Flex, ProgressCircle, ScrollArea, Skeleton, Spinner, Text } from '@chakra-ui/react';
import { useVirtualizer } from '@tanstack/react-virtual';
+import { useQueueItemProgressImage } from '@workbench/backend/progressImageStore';
+import { useQueueItemProgress } from '@workbench/backend/progressStore';
import { ImageContextMenu, type ImageContextMenuTarget } from '@workbench/components/ImageContextMenu';
import { IconButton } from '@workbench/components/ui/Button';
+import { useActiveProjectSelector, useWorkbenchDispatch } from '@workbench/WorkbenchContext';
import { StarIcon, UploadIcon } from 'lucide-react';
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type DragEvent, type MouseEvent } from 'react';
@@ -32,6 +35,7 @@ type GridCell =
export const GalleryImageGrid = ({ layout }: { layout: 'stacked' | 'wide' }) => {
const { actions, gallery, imageActions } = useGalleryWidget();
+ const dispatch = useWorkbenchDispatch();
const [contextMenuTarget, setContextMenuTarget] = useState<ImageContextMenuTarget | null>(null);
const [isDropActive, setIsDropActive] = useState(false);
const [viewportWidth, setViewportWidth] = useState(() => viewportWidthCache.get(layout) ?? 0);
@@ -39,6 +43,7 @@ export const GalleryImageGrid = ({ layout }: { layout: 'stacked' | 'wide' }) =>
const viewportRef = useRef<HTMLDivElement | null>(null);
const { imageDensityPercent, imageOrderDir, paginationMode, showImageDimensions, starredFirst, thumbnailFit } =
gallery.settings;
+ const antialiasProgressImages = useActiveProjectSelector((project) => project.settings.antialiasProgressImages);
const columnCount = getGalleryColumnCount(imageDensityPercent, layout);
const selectedNames = useMemo(() => new Set(gallery.selectedImageNames), [gallery.selectedImageNames]);
const isComparisonActive =
@@ -302,34 +307,43 @@ export const GalleryImageGrid = ({ layout }: { layout: 'stacked' | 'wide' }) =>
transform={`translateY(${virtualRow.start}px)`}
w="full"
>
- {cells
- .slice(virtualRow.index * columnCount, (virtualRow.index + 1) * columnCount)
- .map((cell) =>
- cell.kind === 'placeholder' ? (
- <Skeleton key={cell.placeholder.id} aspectRatio={1} minW="0" rounded="md" w="full" />
- ) : (
- <GalleryThumbnail
- key={cell.image.imageName}
- alwaysShowDimensions={showImageDimensions}
- compareRole={
- isComparisonActive && cell.image.imageName === gallery.selectedImageName
- ? 'Viewing'
- : isComparisonActive && cell.image.imageName === gallery.compareImageName
- ? 'Compare'
- : null
- }
- fit={thumbnailFit}
- image={cell.image}
- isPrimary={cell.image.imageName === gallery.selectedImageName}
- isSelected={selectedNames.has(cell.image.imageName)}
- onClick={handleThumbnailClick}
- onContextMenu={handleThumbnailContextMenu}
- onToggleStarred={(image) =>
- void imageActions.setImagesStarred([image.imageName], !image.starred)
- }
- />
- )
- )}
+ {cells.slice(virtualRow.index * columnCount, (virtualRow.index + 1) * columnCount).map((cell) =>
+ cell.kind === 'placeholder' ? (
+ <GalleryQueuePlaceholderCell
+ key={cell.placeholder.id}
+ antialiasProgressImages={antialiasProgressImages}
+ fit={thumbnailFit}
+ placeholder={cell.placeholder}
+ onClick={() =>
+ dispatch({
+ settings: { showProgressImagesInViewer: true },
+ type: 'setActiveProjectSettings',
+ })
+ }
+ />
+ ) : (
+ <GalleryThumbnail
+ key={cell.image.imageName}
+ alwaysShowDimensions={showImageDimensions}
+ compareRole={
+ isComparisonActive && cell.image.imageName === gallery.selectedImageName
+ ? 'Viewing'
+ : isComparisonActive && cell.image.imageName === gallery.compareImageName
+ ? 'Compare'
+ : null
+ }
+ fit={thumbnailFit}
+ image={cell.image}
+ isPrimary={cell.image.imageName === gallery.selectedImageName}
+ isSelected={selectedNames.has(cell.image.imageName)}
+ onClick={handleThumbnailClick}
+ onContextMenu={handleThumbnailContextMenu}
+ onToggleStarred={(image) =>
+ void imageActions.setImagesStarred([image.imageName], !image.starred)
+ }
+ />
+ )
+ )}
</Box>
))}
</Box>
@@ -377,6 +391,87 @@ export const GalleryImageGrid = ({ layout }: { layout: 'stacked' | 'wide' }) =>
);
};
+const GalleryQueuePlaceholderCell = ({
+ antialiasProgressImages,
+ fit,
+ onClick,
+ placeholder,
+}: {
+ antialiasProgressImages: boolean;
+ fit: GalleryThumbnailFit;
+ onClick: () => void;
+ placeholder: GalleryQueuePlaceholder;
+}) => {
+ const progressImage = useQueueItemProgressImage(placeholder.queueItemId, placeholder.itemIndex);
+ const progress = useQueueItemProgress(placeholder.queueItemId);
+ const isActive = progress?.activeItemIndex === placeholder.itemIndex;
+ const percentage = typeof progress?.percentage === 'number' ? Math.round(progress.percentage * 100) : null;
+
+ return (
+ <Box
+ as="button"
+ aria-label="Show in-progress diffusion in Preview"
+ aspectRatio={1}
+ bg="bg.emphasized"
+ borderColor={isActive ? 'accent.solid' : 'border.subtle'}
+ borderWidth="1px"
+ cursor="pointer"
+ minW="0"
+ overflow="hidden"
+ position="relative"
+ rounded="md"
+ w="full"
+ onClick={onClick}
+ >
+ {progressImage ? (
+ <img
+ alt="In-progress diffusion preview"
+ draggable={false}
+ src={progressImage.dataUrl}
+ style={{
+ display: 'block',
+ height: '100%',
+ imageRendering: antialiasProgressImages ? 'auto' : 'pixelated',
+ inset: 0,
+ maxWidth: 'none',
+ objectFit: fit === 'aspect' ? 'contain' : 'cover',
+ position: 'absolute',
+ width: '100%',
+ }}
+ />
+ ) : (
+ <Skeleton h="full" w="full" />
+ )}
+ {/*<Badge left="1" pointerEvents="none" position="absolute" size="xs" top="1" variant="solid" zIndex="1">
+ {isActive ? 'Generating' : 'Queued'}
+ </Badge>*/}
+ {isActive ? <GalleryPlaceholderCircularProgress percentage={percentage} /> : null}
+ </Box>
+ );
+};
+
+const GalleryPlaceholderCircularProgress = ({ percentage }: { percentage: number | null }) => {
+ return (
+ <Flex
+ align="center"
+ aria-label={percentage === null ? 'Generation progress' : `Generation ${percentage}%`}
+ justify="center"
+ alignItems="center"
+ pointerEvents="none"
+ position="absolute"
+ inset="0"
+ zIndex="1"
+ >
+ <ProgressCircle.Root value={percentage} size="xs" bg="bg/85" rounded="full" borderWidth={1} p={0.5}>
+ <ProgressCircle.Circle>
+ <ProgressCircle.Track />
+ <ProgressCircle.Range />
+ </ProgressCircle.Circle>
+ </ProgressCircle.Root>
+ </Flex>
+ );
+};
+
const GalleryThumbnail = ({
alwaysShowDimensions,
compareRole,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.test.ts
index d65600f215..e0f47ab729 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.test.ts
@@ -29,18 +29,24 @@ const createQueueItem = ({
backendItemIds,
batchCount = 1,
boardId = 'none',
+ completedBackendItemIds,
+ cancelledBackendItemIds,
destination = 'gallery',
status = 'pending',
}: {
backendItemIds?: number[];
batchCount?: number;
boardId?: string;
+ completedBackendItemIds?: number[];
+ cancelledBackendItemIds?: number[];
destination?: 'gallery' | 'canvas';
status?: QueueItemStatus;
}): QueueItem =>
({
backendItemIds,
cancellable: true,
+ cancelledBackendItemIds,
+ completedBackendItemIds,
id: `queue-item-${status}-${boardId}`,
snapshot: {
destination,
@@ -117,7 +123,51 @@ describe('gallery state view', () => {
});
expect(placeholders).toHaveLength(5);
- expect(placeholders[0]).toMatchObject({ height: 768, width: 512 });
+ expect(placeholders[0]).toMatchObject({
+ height: 768,
+ itemIndex: 1,
+ queueItemId: 'queue-item-pending-board-1',
+ width: 512,
+ });
+ });
+
+ it('skips completed backend item slots when creating placeholders', () => {
+ const queueItems = [
+ createQueueItem({
+ backendItemIds: [11, 12, 13],
+ boardId: 'board-1',
+ completedBackendItemIds: [11],
+ status: 'running',
+ }),
+ ];
+
+ const placeholders = getGalleryQueuePlaceholders(queueItems, {
+ galleryView: 'images',
+ searchTerm: '',
+ selectedBoardId: 'board-1',
+ });
+
+ expect(placeholders.map((placeholder) => placeholder.itemIndex)).toEqual([2, 3]);
+ });
+
+ it('skips cancelled backend item slots when creating placeholders', () => {
+ const queueItems = [
+ createQueueItem({
+ backendItemIds: [11, 12, 13],
+ boardId: 'board-1',
+ cancelledBackendItemIds: [12],
+ completedBackendItemIds: [11],
+ status: 'running',
+ }),
+ ];
+
+ const placeholders = getGalleryQueuePlaceholders(queueItems, {
+ galleryView: 'images',
+ searchTerm: '',
+ selectedBoardId: 'board-1',
+ });
+
+ expect(placeholders.map((placeholder) => placeholder.itemIndex)).toEqual([3]);
});
it('does not create placeholders for other boards, finished items, or canvas runs', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.ts b/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.ts
index c4704a8f24..380647475c 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/gallery/galleryStateView.ts
@@ -19,6 +19,8 @@ const UNCATEGORIZED_BOARD: GalleryBoard = {
*/
export interface GalleryQueuePlaceholder {
id: string;
+ queueItemId: string;
+ itemIndex: number;
width: number;
height: number;
}
@@ -139,9 +141,29 @@ export const getGalleryQueuePlaceholders = (
: sanitizeBatchCount(generateValues.batchCount);
const width = getFiniteNumber(generateValues.width, 1024);
const height = getFiniteNumber(generateValues.height, 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({ height, id: `${item.id}:${index}`, itemIndex: index + 1, queueItemId: item.id, width });
+ }
+
+ continue;
+ }
for (let index = 0; index < expectedImageCount; index++) {
- placeholders.push({ height, id: `${item.id}:${index}`, width });
+ placeholders.push({ height, id: `${item.id}:${index}`, itemIndex: index + 1, queueItemId: item.id, width });
}
}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsx
new file mode 100644
index 0000000000..06d1d3c0a6
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsx
@@ -0,0 +1,31 @@
+import { Icon } from '@chakra-ui/react';
+import { useProgressImage } from '@workbench/backend/progressImageStore';
+import { IconButton } from '@workbench/components/ui/Button';
+import { useActiveProjectSelector, useWorkbenchDispatch } from '@workbench/WorkbenchContext';
+import { HourglassIcon } from 'lucide-react';
+
+export const PreviewHeaderActions = () => {
+ const showProgressImagesInViewer = useActiveProjectSelector((project) => project.settings.showProgressImagesInViewer);
+ const hasProgressImage = useProgressImage() !== null;
+ const dispatch = useWorkbenchDispatch();
+ const label = showProgressImagesInViewer ? 'Hide in-progress diffusion' : 'Show in-progress diffusion';
+
+ return (
+ <IconButton
+ aria-label={label}
+ colorPalette={showProgressImagesInViewer ? 'accent' : 'gray'}
+ opacity={hasProgressImage || showProgressImagesInViewer ? 1 : 0.7}
+ size="2xs"
+ title={label}
+ variant={showProgressImagesInViewer ? 'solid' : 'ghost'}
+ onClick={() =>
+ dispatch({
+ settings: { showProgressImagesInViewer: !showProgressImagesInViewer },
+ type: 'setActiveProjectSettings',
+ })
+ }
+ >
+ <Icon as={HourglassIcon} boxSize="3.5" />
+ </IconButton>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
index 31890ec6b4..3f0f8e25dc 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
@@ -1,6 +1,7 @@
import type { GeneratedImageContract, WidgetViewProps } from '@workbench/types';
import { Badge, Box, Flex, HStack, Stack, Text } from '@chakra-ui/react';
+import { useProgressImage, type ProgressImageSnapshot } from '@workbench/backend/progressImageStore';
import { ImageContextMenu, type ImageContextMenuTarget } from '@workbench/components/ImageContextMenu';
import { Button } from '@workbench/components/ui/Button';
import { useImageActions } from '@workbench/components/useImageActions';
@@ -25,8 +26,6 @@ import { PreviewCompare } from './PreviewCompare';
type PreviewImage = GeneratedImageContract & Partial<Pick<GalleryImage, 'boardId' | 'imageCategory' | 'starred'>>;
-const getImageAspectRatio = (image: GeneratedImageContract): number => image.width / image.height;
-
const fallbackBoards: GalleryBoard[] = [
{ archived: false, assetCount: 0, id: 'none', imageCount: 0, kind: 'uncategorized', name: 'Uncategorized' },
];
@@ -100,6 +99,10 @@ const previewGridCss = {
export const PreviewWidgetView = ({ region }: WidgetViewProps) => {
const galleryValues = useActiveProjectSelector((project) => project.widgetStates.gallery.values);
const generateValues = useActiveProjectSelector((project) => project.widgetStates.generate.values);
+ const { antialiasProgressImages, showProgressImagesInViewer } = useActiveProjectSelector(
+ (project) => project.settings
+ );
+ const progressImage = useProgressImage();
const dispatch = useWorkbenchDispatch();
const selectedImage = useMemo(() => getSelectedImage(galleryValues), [galleryValues]);
const compareImage = getGalleryCompareImage(galleryValues);
@@ -260,6 +263,7 @@ export const PreviewWidgetView = ({ region }: WidgetViewProps) => {
}, [boardImages, displayBoardId, selectedImage]);
const isComparing =
selectedImage !== null && compareImage !== null && compareImage.imageName !== selectedImage.imageName;
+ const shouldShowProgressImage = showProgressImagesInViewer && progressImage !== null && !isComparing;
return (
<Box p="2" h="full">
@@ -282,7 +286,9 @@ export const PreviewWidgetView = ({ region }: WidgetViewProps) => {
image={selectedImage}
isCompact={isSidePanel}
isLoadingBoard={isLoadingBoard}
+ progressImage={shouldShowProgressImage ? progressImage : null}
selectedIndex={selectedIndex}
+ shouldAntialiasProgressImage={antialiasProgressImages}
onContextMenu={(x, y) => {
if (contextMenuImage) {
setContextMenuTarget({ images: [contextMenuImage], x, y });
@@ -300,7 +306,10 @@ export const PreviewWidgetView = ({ region }: WidgetViewProps) => {
/>
</>
) : (
- <EmptyPreview />
+ <EmptyPreview
+ progressImage={shouldShowProgressImage ? progressImage : null}
+ shouldAntialiasProgressImage={antialiasProgressImages}
+ />
)}
</Box>
);
@@ -312,7 +321,9 @@ const SelectedImagePreview = ({
image,
isCompact,
isLoadingBoard,
+ progressImage,
selectedIndex,
+ shouldAntialiasProgressImage,
onContextMenu,
onNext,
onPrevious,
@@ -322,142 +333,198 @@ const SelectedImagePreview = ({
image: GeneratedImageContract;
isCompact: boolean;
isLoadingBoard: boolean;
+ progressImage: ProgressImageSnapshot | null;
selectedIndex: number;
+ shouldAntialiasProgressImage: boolean;
onContextMenu: (x: number, y: number) => void;
onNext: () => void;
onPrevious: () => void;
-}) => (
- <Stack
- gap="3"
- h="full"
- minH="0"
- tabIndex={0}
- w="full"
- onKeyDown={(event) => {
- if (event.key === 'ArrowLeft') {
- event.preventDefault();
- onPrevious();
+}) => {
+ const previewImage = progressImage
+ ? {
+ alt: 'In-progress diffusion preview',
+ height: progressImage.height,
+ isProgress: true,
+ src: progressImage.dataUrl,
+ width: progressImage.width,
}
+ : { alt: image.imageName, height: image.height, isProgress: false, src: image.imageUrl, width: image.width };
- if (event.key === 'ArrowRight') {
- event.preventDefault();
- onNext();
- }
- }}
- >
- <Flex
- align="center"
- borderWidth="1px"
- borderColor="border.subtle"
- color="fg.grid"
- css={previewGridCss}
- flex="1"
- justify="center"
+ return (
+ <Stack
+ gap="3"
+ h="full"
minH="0"
- overflow="hidden"
- p={isCompact ? '3' : '6'}
- rounded="lg"
+ tabIndex={0}
w="full"
+ onKeyDown={(event) => {
+ if (event.key === 'ArrowLeft') {
+ event.preventDefault();
+ onPrevious();
+ }
+
+ if (event.key === 'ArrowRight') {
+ event.preventDefault();
+ onNext();
+ }
+ }}
>
+ <Flex
+ align="center"
+ borderWidth="1px"
+ borderColor="border.subtle"
+ color="fg.grid"
+ css={previewGridCss}
+ flex="1"
+ justify="center"
+ minH="0"
+ overflow="hidden"
+ p={isCompact ? '3' : '6'}
+ rounded="lg"
+ w="full"
+ >
+ <Box
+ aspectRatio={previewImage.width / previewImage.height}
+ bg="transparent"
+ borderWidth="1px"
+ borderColor={previewImage.isProgress ? 'accent.solid' : 'border.emphasized'}
+ boxShadow="0 24px 80px rgba(0,0,0,0.42)"
+ h={isCompact ? 'auto' : 'full'}
+ maxH={isCompact ? undefined : 'full'}
+ maxW="full"
+ overflow="hidden"
+ position="relative"
+ rounded="lg"
+ w={isCompact ? 'full' : 'auto'}
+ onContextMenu={(event) => {
+ event.preventDefault();
+ onContextMenu(event.clientX, event.clientY);
+ }}
+ >
+ <img
+ alt={previewImage.alt}
+ src={previewImage.src}
+ style={{
+ display: 'block',
+ height: '100%',
+ imageRendering: previewImage.isProgress && !shouldAntialiasProgressImage ? 'pixelated' : 'auto',
+ inset: 0,
+ objectFit: 'contain',
+ position: 'absolute',
+ width: '100%',
+ }}
+ />
+ {previewImage.isProgress ? (
+ <Badge left="2" pointerEvents="none" position="absolute" size="xs" top="2" variant="solid">
+ Generating
+ </Badge>
+ ) : null}
+ </Box>
+ </Flex>
+ <Stack borderWidth="1px" borderColor="border.subtle" gap="2" p="3" rounded="lg">
+ <HStack align="center" justify="space-between">
+ <HStack gap="2" minW="0">
+ <Badge flexShrink={0} size="xs" variant="subtle">
+ {boardName}
+ </Badge>
+ <Text color="fg.subtle" fontSize="2xs" truncate>
+ {isLoadingBoard
+ ? 'Loading board'
+ : selectedIndex === -1
+ ? `${boardImageCount} image${boardImageCount === 1 ? '' : 's'}`
+ : `${selectedIndex + 1} of ${boardImageCount}`}
+ </Text>
+ </HStack>
+ <HStack flexShrink={0} gap="1">
+ <Button
+ aria-label="Previous image in board"
+ disabled={selectedIndex <= 0}
+ size="2xs"
+ variant="outline"
+ onClick={onPrevious}
+ >
+ <ChevronLeftIcon />
+ </Button>
+ <Button
+ aria-label="Next image in board"
+ disabled={selectedIndex === -1 || selectedIndex >= boardImageCount - 1}
+ size="2xs"
+ variant="outline"
+ onClick={onNext}
+ >
+ <ChevronRightIcon />
+ </Button>
+ </HStack>
+ </HStack>
+ <Stack>
+ <Text fontSize="xs" fontWeight="800" truncate>
+ {image.imageName}
+ </Text>
+ <Text color="fg.subtle" fontSize="2xs">
+ Source run {image.sourceQueueItemId}
+ </Text>
+ <Text color="fg.subtle" flexShrink={0} fontSize="2xs">
+ {previewImage.isProgress ? 'Generating' : `${image.width} x ${image.height}`}
+ </Text>
+ </Stack>
+ </Stack>
+ </Stack>
+ );
+};
+
+const EmptyPreview = ({
+ progressImage,
+ shouldAntialiasProgressImage,
+}: {
+ progressImage: ProgressImageSnapshot | null;
+ shouldAntialiasProgressImage: boolean;
+}) => (
+ <Flex
+ align="center"
+ backgroundColor="bg.inset"
+ color="fg.grid"
+ css={previewGridCss}
+ h="full"
+ justify="center"
+ w="full"
+ >
+ {progressImage ? (
<Box
- aspectRatio={getImageAspectRatio(image)}
- bg="transparent"
+ aspectRatio={progressImage.width / progressImage.height}
+ borderColor="accent.solid"
borderWidth="1px"
- borderColor="border.emphasized"
boxShadow="0 24px 80px rgba(0,0,0,0.42)"
- h={isCompact ? 'auto' : 'full'}
- maxH={isCompact ? undefined : 'full'}
+ maxH="full"
maxW="full"
overflow="hidden"
position="relative"
rounded="lg"
- w={isCompact ? 'full' : 'auto'}
- onContextMenu={(event) => {
- event.preventDefault();
- onContextMenu(event.clientX, event.clientY);
- }}
>
<img
- alt={image.imageName}
- src={image.imageUrl}
+ alt="In-progress diffusion preview"
+ draggable={false}
+ src={progressImage.dataUrl}
style={{
display: 'block',
height: '100%',
- inset: 0,
+ imageRendering: shouldAntialiasProgressImage ? 'auto' : 'pixelated',
objectFit: 'contain',
- position: 'absolute',
width: '100%',
}}
/>
+ <Badge left="2" pointerEvents="none" position="absolute" size="xs" top="2" variant="solid">
+ Generating
+ </Badge>
</Box>
- </Flex>
- <Stack borderWidth="1px" borderColor="border.subtle" gap="2" p="3" rounded="lg">
- <HStack align="center" justify="space-between">
- <HStack gap="2" minW="0">
- <Badge flexShrink={0} size="xs" variant="subtle">
- {boardName}
- </Badge>
- <Text color="fg.subtle" fontSize="2xs" truncate>
- {isLoadingBoard
- ? 'Loading board'
- : selectedIndex === -1
- ? `${boardImageCount} image${boardImageCount === 1 ? '' : 's'}`
- : `${selectedIndex + 1} of ${boardImageCount}`}
- </Text>
- </HStack>
- <HStack flexShrink={0} gap="1">
- <Button
- aria-label="Previous image in board"
- disabled={selectedIndex <= 0}
- size="2xs"
- variant="outline"
- onClick={onPrevious}
- >
- <ChevronLeftIcon />
- </Button>
- <Button
- aria-label="Next image in board"
- disabled={selectedIndex === -1 || selectedIndex >= boardImageCount - 1}
- size="2xs"
- variant="outline"
- onClick={onNext}
- >
- <ChevronRightIcon />
- </Button>
- </HStack>
- </HStack>
- <Stack>
- <Text fontSize="xs" fontWeight="800" truncate>
- {image.imageName}
+ ) : (
+ <Stack align="center" color="fg" gap="2" maxW="18rem" textAlign="center">
+ <Text fontSize="sm" fontWeight="800">
+ No gallery selection
</Text>
<Text color="fg.subtle" fontSize="2xs">
- Source run {image.sourceQueueItemId}
- </Text>
- <Text color="fg.subtle" flexShrink={0} fontSize="2xs">
- {image.width} x {image.height}
+ Generate to Gallery, then select a thumbnail in the Gallery widget to inspect it here.
</Text>
</Stack>
- </Stack>
- </Stack>
-);
-
-const EmptyPreview = () => (
- <Flex
- align="center"
- backgroundColor="bg.inset"
- color="fg.grid"
- css={previewGridCss}
- h="full"
- justify="center"
- w="full"
- >
- <Stack align="center" color="fg" gap="2" maxW="18rem" textAlign="center">
- <Text fontSize="sm" fontWeight="800">
- No gallery selection
- </Text>
- <Text color="fg.subtle" fontSize="2xs">
- Generate to Gallery, then select a thumbnail in the Gallery widget to inspect it here.
- </Text>
- </Stack>
+ )}
</Flex>
);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts
index 97b619e78f..c78ebbb0f0 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts
@@ -1,9 +1,11 @@
import type { WidgetManifest } from '@workbench/types';
+import { PreviewHeaderActions } from './PreviewHeaderActions';
import { PreviewWidgetView } from './PreviewWidgetView';
export const previewWidgetManifest: WidgetManifest = {
failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },
+ headerActions: PreviewHeaderActions,
icon: 'lucide-react:eye',
id: 'preview',
label: 'Preview',