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(webv2): add diagnostics notifications and preview widgets

joshistoastd0a59d1e1154
diff --git a/invokeai/frontend/webv2/src/workbench/components/WorkbenchNotificationToaster.tsx b/invokeai/frontend/webv2/src/workbench/components/WorkbenchNotificationToaster.tsx
new file mode 100644
index 0000000000..97a17ed75c
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/components/WorkbenchNotificationToaster.tsx
@@ -0,0 +1,40 @@
+import { useEffect, useRef } from 'react';
+
+import type { WorkbenchNotificationKind } from '../types';
+import { useWorkbench } from '../WorkbenchContext';
+import { toaster } from './ui/toaster';
+
+const notificationToastType: Record<WorkbenchNotificationKind, 'error' | 'info' | 'success'> = {
+ error: 'error',
+ info: 'info',
+ success: 'success',
+};
+
+export const WorkbenchNotificationToaster = () => {
+ const { state } = useWorkbench();
+ const toastedNotificationIdsRef = useRef<Set<string> | null>(null);
+
+ useEffect(() => {
+ if (toastedNotificationIdsRef.current === null) {
+ toastedNotificationIdsRef.current = new Set(state.notifications.map((notification) => notification.id));
+ return;
+ }
+
+ for (const notification of [...state.notifications].reverse()) {
+ if (toastedNotificationIdsRef.current.has(notification.id)) {
+ continue;
+ }
+
+ toastedNotificationIdsRef.current.add(notification.id);
+ queueMicrotask(() => {
+ toaster.create({
+ description: notification.message,
+ title: notification.title,
+ type: notificationToastType[notification.kind],
+ });
+ });
+ }
+ }, [state.notifications]);
+
+ return null;
+};
diff --git a/invokeai/frontend/webv2/src/workbench/components/ui/toaster.tsx b/invokeai/frontend/webv2/src/workbench/components/ui/toaster.tsx
new file mode 100644
index 0000000000..292a14d923
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/components/ui/toaster.tsx
@@ -0,0 +1,39 @@
+import {
+ Box,
+ HStack,
+ Portal,
+ Stack,
+ ToastCloseTrigger,
+ ToastDescription,
+ Toaster as ChakraToaster,
+ ToastIndicator,
+ ToastRoot,
+ ToastTitle,
+ createToaster,
+} from '@chakra-ui/react';
+
+export const toaster = createToaster({
+ offsets: { bottom: '1rem', left: '1rem', right: '1rem', top: '1rem' },
+ placement: 'bottom-end',
+ pauseOnPageIdle: true,
+});
+
+export const AppToaster = () => (
+ <Portal>
+ <ChakraToaster toaster={toaster}>
+ {(toast) => (
+ <ToastRoot maxW="calc(100vw - 2rem)" overflowWrap="anywhere" w="24rem">
+ <HStack align="start" gap="3">
+ <ToastIndicator />
+ <Stack gap="1" flex="1">
+ {toast.title ? <ToastTitle>{toast.title}</ToastTitle> : null}
+ {toast.description ? <ToastDescription>{toast.description}</ToastDescription> : null}
+ </Stack>
+ <ToastCloseTrigger />
+ </HStack>
+ <Box display="none" />
+ </ToastRoot>
+ )}
+ </ChakraToaster>
+ </Portal>
+);
diff --git a/invokeai/frontend/webv2/src/workbench/iconResolver.tsx b/invokeai/frontend/webv2/src/workbench/iconResolver.tsx
index c6c5703830..f4e91aa91f 100644
--- a/invokeai/frontend/webv2/src/workbench/iconResolver.tsx
+++ b/invokeai/frontend/webv2/src/workbench/iconResolver.tsx
@@ -7,7 +7,10 @@ import type { WidgetIconId } from './types';
type IconImporter = () => Promise<{ default: ComponentType }>;
const iconImporters = {
+ 'lucide-react:bug': () => import('lucide-react/dist/esm/icons/bug.mjs'),
'lucide-react:cloud-check': () => import('lucide-react/dist/esm/icons/cloud-check.mjs'),
+ 'lucide-react:bell': () => import('lucide-react/dist/esm/icons/bell.mjs'),
+ 'lucide-react:eye': () => import('lucide-react/dist/esm/icons/eye.mjs'),
'lucide-react:image': () => import('lucide-react/dist/esm/icons/image.mjs'),
'lucide-react:info': () => import('lucide-react/dist/esm/icons/info.mjs'),
'lucide-react:layers': () => import('lucide-react/dist/esm/icons/layers.mjs'),
diff --git a/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts b/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts
index fb49274837..11bbc10689 100644
--- a/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts
@@ -2,11 +2,14 @@ import { isSupportedIconId } from './iconResolver';
import type { RegisteredWidget, WidgetFailure, WidgetId, WidgetManifest, WorkbenchRegion } from './types';
import { autosaveStatusWidgetManifest } from './widgets/autosave-status';
import { canvasWidgetManifest } from './widgets/canvas';
+import { diagnosticsWidgetManifest } from './widgets/diagnostics';
import { galleryWidgetManifest } from './widgets/gallery';
import { generateWidgetManifest } from './widgets/generate';
import { historyControlsWidgetManifest } from './widgets/history-controls';
import { layoutActionsWidgetManifest } from './widgets/layout-actions';
import { layersWidgetManifest } from './widgets/layers';
+import { notificationsWidgetManifest } from './widgets/notifications';
+import { previewWidgetManifest } from './widgets/preview';
import { queueWidgetManifest } from './widgets/queue';
import { serverStatusWidgetManifest } from './widgets/server-status';
import { versionStatusWidgetManifest } from './widgets/version-status';
@@ -16,9 +19,12 @@ const firstPartyWidgetManifests: WidgetManifest[] = [
generateWidgetManifest,
workflowWidgetManifest,
canvasWidgetManifest,
+ diagnosticsWidgetManifest,
galleryWidgetManifest,
+ previewWidgetManifest,
layersWidgetManifest,
queueWidgetManifest,
+ notificationsWidgetManifest,
serverStatusWidgetManifest,
autosaveStatusWidgetManifest,
historyControlsWidgetManifest,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/DiagnosticsHeaderActions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/DiagnosticsHeaderActions.tsx
new file mode 100644
index 0000000000..987816dbc4
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/DiagnosticsHeaderActions.tsx
@@ -0,0 +1,27 @@
+import { Badge, Button } from '@chakra-ui/react';
+import { PiBugBold } from 'react-icons/pi';
+
+import { useWorkbench } from '../../WorkbenchContext';
+
+export const DiagnosticsHeaderActions = () => {
+ const { dispatch, state } = useWorkbench();
+
+ return (
+ <>
+ {state.errorLog.length ? (
+ <Badge colorPalette="red" size="xs">
+ <PiBugBold />
+ {state.errorLog.length}
+ </Badge>
+ ) : null}
+ <Button
+ disabled={state.errorLog.length === 0}
+ size="2xs"
+ variant="outline"
+ onClick={() => dispatch({ type: 'clearErrorLog' })}
+ >
+ Clear
+ </Button>
+ </>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/DiagnosticsWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/DiagnosticsWidgetView.tsx
new file mode 100644
index 0000000000..a89223ec66
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/DiagnosticsWidgetView.tsx
@@ -0,0 +1,57 @@
+import { Button, HStack, Stack, Text } from '@chakra-ui/react';
+import { PiBugBold, PiClipboardTextBold } from 'react-icons/pi';
+
+import { StatusWidgetChip } from '../../components/WidgetFrames';
+import type { WidgetViewProps } from '../../types';
+import { useWorkbench } from '../../WorkbenchContext';
+
+export const DiagnosticsWidgetView = ({ presentation, region }: WidgetViewProps) => {
+ const { state } = useWorkbench();
+ const errorCount = state.errorLog.length;
+ const label = errorCount === 0 ? 'Clean' : `${errorCount} issue${errorCount === 1 ? '' : 's'}`;
+
+ if (region === 'bottom' && presentation !== 'expanded') {
+ return (
+ <StatusWidgetChip icon={errorCount > 0 ? PiBugBold : PiClipboardTextBold}>Diagnostics: {label}</StatusWidgetChip>
+ );
+ }
+
+ return <DiagnosticsPanel />;
+};
+
+const DiagnosticsPanel = () => {
+ const { state } = useWorkbench();
+
+ return (
+ <Stack gap="3">
+ {state.errorLog.length === 0 ? (
+ <Text color="fg.subtle" fontSize="2xs">
+ Shell errors and debugging details will appear here without covering the workbench.
+ </Text>
+ ) : (
+ <Stack gap="2">
+ {state.errorLog.map((message, index) => (
+ <Stack
+ key={`${message}-${index}`}
+ bg="bg.surface"
+ borderWidth="1px"
+ borderColor="border.subtle"
+ gap="2"
+ p="2"
+ rounded="md"
+ >
+ <Text color="fg.muted" fontFamily="mono" fontSize="2xs" whiteSpace="pre-wrap">
+ {message}
+ </Text>
+ <HStack justify="end">
+ <Button size="2xs" variant="outline" onClick={() => void navigator.clipboard?.writeText(message)}>
+ Copy
+ </Button>
+ </HStack>
+ </Stack>
+ ))}
+ </Stack>
+ )}
+ </Stack>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/index.ts
new file mode 100644
index 0000000000..e26f7c5a1d
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/diagnostics/index.ts
@@ -0,0 +1,16 @@
+import type { WidgetManifest } from '../../types';
+import { DiagnosticsHeaderActions } from './DiagnosticsHeaderActions';
+import { DiagnosticsWidgetView } from './DiagnosticsWidgetView';
+
+export const diagnosticsWidgetManifest: WidgetManifest = {
+ bottomPanel: 'expandable',
+ failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },
+ headerActions: DiagnosticsHeaderActions,
+ icon: 'lucide-react:bug',
+ id: 'diagnostics',
+ label: 'Diagnostics',
+ labelText: 'Diagnostics',
+ regions: ['bottom', 'right'],
+ version: 1,
+ view: DiagnosticsWidgetView,
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsHeaderActions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsHeaderActions.tsx
new file mode 100644
index 0000000000..d494b33a29
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsHeaderActions.tsx
@@ -0,0 +1,18 @@
+import { Button, HStack } from '@chakra-ui/react';
+
+import { useWorkbench } from '../../WorkbenchContext';
+
+export const NotificationsHeaderActions = () => {
+ const { dispatch } = useWorkbench();
+
+ return (
+ <HStack gap="2">
+ <Button size="2xs" variant="outline" onClick={() => dispatch({ type: 'markAllNotificationsRead' })}>
+ Mark Read
+ </Button>
+ <Button size="2xs" variant="outline" onClick={() => dispatch({ type: 'clearNotifications' })}>
+ Clear
+ </Button>
+ </HStack>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx
new file mode 100644
index 0000000000..238e9582b0
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/notifications/NotificationsWidgetView.tsx
@@ -0,0 +1,84 @@
+import { Badge, HStack, Icon, Stack, Text } from '@chakra-ui/react';
+import { PiBellBold, PiCheckCircleBold, PiInfoBold, PiWarningBold, PiXCircleBold } from 'react-icons/pi';
+
+import { StatusWidgetChip } from '../../components/WidgetFrames';
+import type { WidgetViewProps, WorkbenchNotificationKind } from '../../types';
+import { useWorkbench } from '../../WorkbenchContext';
+
+const kindColorPalette: Record<WorkbenchNotificationKind, string> = {
+ error: 'red',
+ info: 'blue',
+ success: 'green',
+};
+
+const kindIcon = {
+ error: PiXCircleBold,
+ info: PiInfoBold,
+ success: PiCheckCircleBold,
+} satisfies Record<WorkbenchNotificationKind, typeof PiInfoBold>;
+
+export const NotificationsWidgetView = ({ presentation, region }: WidgetViewProps) => {
+ const { state } = useWorkbench();
+ const unreadCount = state.notifications.filter((notification) => !notification.isRead).length;
+ const errorCount = state.notifications.filter((notification) => notification.kind === 'error').length;
+ const label = unreadCount > 0 ? `${unreadCount} new` : `${state.notifications.length} total`;
+ const icon = errorCount > 0 ? PiWarningBold : PiBellBold;
+
+ if (region === 'bottom' && presentation !== 'expanded') {
+ return <StatusWidgetChip icon={icon}>Notifications: {label}</StatusWidgetChip>;
+ }
+
+ return <NotificationsPanel />;
+};
+
+const NotificationsPanel = () => {
+ const { state } = useWorkbench();
+
+ return (
+ <Stack flex="1" gap="3" minH="0">
+ {state.notifications.length === 0 ? (
+ <Text color="fg.subtle" fontSize="2xs">
+ Successful operations, errors, and system messages appear here.
+ </Text>
+ ) : (
+ <Stack gap="2">
+ {state.notifications.map((notification) => {
+ const IconComponent = kindIcon[notification.kind];
+
+ return (
+ <Stack
+ key={notification.id}
+ bg={notification.isRead ? 'bg.surface' : 'bg.surfaceRaised'}
+ borderWidth="1px"
+ borderColor={notification.isRead ? 'border.subtle' : 'border.emphasis'}
+ gap="1"
+ p="2"
+ rounded="md"
+ >
+ <HStack align="start" justify="space-between">
+ <HStack gap="2" minW="0">
+ <Icon as={IconComponent} color={`${kindColorPalette[notification.kind]}.300`} boxSize="3.5" />
+ <Text fontSize="2xs" fontWeight="700">
+ {notification.title}
+ </Text>
+ </HStack>
+ <Badge colorPalette={kindColorPalette[notification.kind]} size="xs">
+ {notification.kind}
+ </Badge>
+ </HStack>
+ {notification.message ? (
+ <Text color="fg.subtle" fontSize="2xs">
+ {notification.message}
+ </Text>
+ ) : null}
+ <Text color="fg.subtle" fontSize="2xs">
+ {notification.createdAt}
+ </Text>
+ </Stack>
+ );
+ })}
+ </Stack>
+ )}
+ </Stack>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/notifications/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/notifications/index.ts
new file mode 100644
index 0000000000..37d856512b
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/notifications/index.ts
@@ -0,0 +1,16 @@
+import type { WidgetManifest } from '../../types';
+import { NotificationsHeaderActions } from './NotificationsHeaderActions';
+import { NotificationsWidgetView } from './NotificationsWidgetView';
+
+export const notificationsWidgetManifest: WidgetManifest = {
+ bottomPanel: 'expandable',
+ failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },
+ headerActions: NotificationsHeaderActions,
+ icon: 'lucide-react:bell',
+ id: 'notifications',
+ label: 'Notifications',
+ labelText: 'Notifications',
+ regions: ['bottom'],
+ version: 1,
+ view: NotificationsWidgetView,
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
new file mode 100644
index 0000000000..8b6ec96987
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
@@ -0,0 +1,295 @@
+import { Badge, Box, Button, Flex, HStack, Stack, Text } from '@chakra-ui/react';
+import { useEffect, useMemo, useState } from 'react';
+import { PiCaretLeftBold, PiCaretRightBold } from 'react-icons/pi';
+
+import {
+ listGalleryBoards,
+ listGalleryImages,
+ type GalleryBoard,
+ type GalleryImage,
+ type GalleryView,
+} from '../../gallery/api';
+import type { GeneratedImageContract, WidgetViewProps } from '../../types';
+import { useWorkbench } from '../../WorkbenchContext';
+
+type PreviewImage = GeneratedImageContract & Partial<Pick<GalleryImage, 'boardId' | 'imageCategory'>>;
+
+const getImageAspectRatio = (image: GeneratedImageContract): number => image.width / image.height;
+
+const fallbackBoards: GalleryBoard[] = [
+ { assetCount: 0, id: 'none', imageCount: 0, isVirtual: true, name: 'Uncategorized' },
+];
+
+const getGalleryImages = (values: Record<string, unknown>): PreviewImage[] =>
+ Array.isArray(values.recentImages)
+ ? (values.recentImages as GeneratedImageContract[]).map((image) => ({
+ ...image,
+ boardId: 'none',
+ imageCategory: 'general' as const,
+ }))
+ : [];
+
+const getSelectedImage = (values: Record<string, unknown>): PreviewImage | null => {
+ const images = getGalleryImages(values);
+ const selectedImage = values.selectedImage;
+ const selectedImageName = typeof values.selectedImageName === 'string' ? values.selectedImageName : null;
+
+ if (
+ selectedImage &&
+ typeof selectedImage === 'object' &&
+ typeof (selectedImage as GeneratedImageContract).imageName === 'string'
+ ) {
+ return selectedImage as PreviewImage;
+ }
+
+ return images.find((image) => image.imageName === selectedImageName) ?? images[0] ?? null;
+};
+
+const getImageBoardId = (image: PreviewImage, values: Record<string, unknown>): string => {
+ if (typeof image.boardId === 'string') {
+ return image.boardId;
+ }
+
+ const selectedBoardId = typeof values.selectedBoardId === 'string' ? values.selectedBoardId : 'none';
+
+ return selectedBoardId;
+};
+
+const getImageGalleryView = (image: PreviewImage): GalleryView => {
+ if (
+ image.imageCategory === 'control' ||
+ image.imageCategory === 'mask' ||
+ image.imageCategory === 'user' ||
+ image.imageCategory === 'other'
+ ) {
+ return 'assets';
+ }
+
+ return 'images';
+};
+
+const getBoardName = (boards: GalleryBoard[], boardId: string): string =>
+ boards.find((board) => board.id === boardId)?.name ?? (boardId === 'none' ? 'Uncategorized' : 'Unknown board');
+
+const shouldLoadBackendBoard = (image: PreviewImage): boolean => image.sourceQueueItemId === 'backend-gallery';
+
+export const PreviewWidgetView = ({ region }: WidgetViewProps) => {
+ const { activeProject, dispatch } = useWorkbench();
+ const galleryValues = activeProject.widgetStates.gallery.values;
+ const selectedImage = useMemo(() => getSelectedImage(galleryValues), [galleryValues]);
+ const selectedBoardId = selectedImage ? getImageBoardId(selectedImage, galleryValues) : 'none';
+ const selectedGalleryView = selectedImage ? getImageGalleryView(selectedImage) : 'images';
+ const localImages = useMemo(
+ () => getGalleryImages(galleryValues).filter((image) => image.boardId === selectedBoardId),
+ [galleryValues, selectedBoardId]
+ );
+ const [boards, setBoards] = useState<GalleryBoard[]>(fallbackBoards);
+ const [boardImages, setBoardImages] = useState<PreviewImage[]>(localImages);
+ const [isLoadingBoard, setIsLoadingBoard] = useState(false);
+ const isSidePanel = region === 'left' || region === 'right';
+ const selectedIndex = selectedImage
+ ? boardImages.findIndex((image) => image.imageName === selectedImage.imageName)
+ : -1;
+ const boardName = getBoardName(boards, selectedBoardId);
+
+ useEffect(() => {
+ if (!selectedImage) {
+ setBoardImages([]);
+ setIsLoadingBoard(false);
+ return;
+ }
+
+ if (!shouldLoadBackendBoard(selectedImage)) {
+ setBoardImages(localImages);
+ setIsLoadingBoard(false);
+ return;
+ }
+
+ let isStale = false;
+
+ setIsLoadingBoard(true);
+ Promise.all([
+ listGalleryBoards().catch(() => fallbackBoards),
+ listGalleryImages({ boardId: selectedBoardId, galleryView: selectedGalleryView, searchTerm: '' }).catch(() => []),
+ ])
+ .then(([nextBoards, nextImages]) => {
+ if (isStale) {
+ return;
+ }
+
+ setBoards(nextBoards);
+ setBoardImages(nextImages.length ? nextImages : [selectedImage]);
+ })
+ .catch((error: unknown) => {
+ if (!isStale) {
+ dispatch({ message: error instanceof Error ? error.message : String(error), type: 'recordError' });
+ setBoardImages([selectedImage]);
+ }
+ })
+ .finally(() => {
+ if (!isStale) {
+ setIsLoadingBoard(false);
+ }
+ });
+
+ return () => {
+ isStale = true;
+ };
+ }, [dispatch, localImages, selectedBoardId, selectedGalleryView, selectedImage]);
+
+ const selectByOffset = (offset: -1 | 1) => {
+ if (selectedIndex === -1) {
+ return;
+ }
+
+ const nextImage = boardImages[selectedIndex + offset];
+
+ if (nextImage) {
+ dispatch({ image: nextImage, type: 'selectGalleryImage' });
+ }
+ };
+
+ return selectedImage ? (
+ <SelectedImagePreview
+ boardImageCount={boardImages.length}
+ boardName={boardName}
+ image={selectedImage}
+ isCompact={isSidePanel}
+ isLoadingBoard={isLoadingBoard}
+ selectedIndex={selectedIndex}
+ onNext={() => selectByOffset(1)}
+ onPrevious={() => selectByOffset(-1)}
+ />
+ ) : (
+ <EmptyPreview />
+ );
+};
+
+const SelectedImagePreview = ({
+ boardImageCount,
+ boardName,
+ image,
+ isCompact,
+ isLoadingBoard,
+ selectedIndex,
+ onNext,
+ onPrevious,
+}: {
+ boardImageCount: number;
+ boardName: string;
+ image: GeneratedImageContract;
+ isCompact: boolean;
+ isLoadingBoard: boolean;
+ selectedIndex: number;
+ onNext: () => void;
+ onPrevious: () => void;
+}) => (
+ <Stack
+ gap="3"
+ h="full"
+ minH="0"
+ tabIndex={0}
+ w="full"
+ onKeyDown={(event) => {
+ if (event.key === 'ArrowLeft') {
+ event.preventDefault();
+ onPrevious();
+ }
+
+ if (event.key === 'ArrowRight') {
+ event.preventDefault();
+ onNext();
+ }
+ }}
+ >
+ <Flex align="center" flex="1" justify="center" minH="0" w="full">
+ <Box
+ aspectRatio={getImageAspectRatio(image)}
+ bg="bg.panel"
+ borderWidth="1px"
+ borderColor="border.emphasis"
+ 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'}
+ >
+ <img
+ alt={image.imageName}
+ src={image.imageUrl}
+ style={{
+ display: 'block',
+ height: '100%',
+ inset: 0,
+ objectFit: 'contain',
+ position: 'absolute',
+ width: '100%',
+ }}
+ />
+ </Box>
+ </Flex>
+ <Stack bg="bg.surfaceRaised" 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}
+ >
+ <PiCaretLeftBold />
+ </Button>
+ <Button
+ aria-label="Next image in board"
+ disabled={selectedIndex === -1 || selectedIndex >= boardImageCount - 1}
+ size="2xs"
+ variant="outline"
+ onClick={onNext}
+ >
+ <PiCaretRightBold />
+ </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">
+ {image.width} x {image.height}
+ </Text>
+ </Stack>
+ </Stack>
+ </Stack>
+);
+
+const EmptyPreview = () => (
+ <Flex align="center" h="full" justify="center" w="full">
+ <Stack align="center" 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
new file mode 100644
index 0000000000..150486acae
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts
@@ -0,0 +1,13 @@
+import type { WidgetManifest } from '../../types';
+import { PreviewWidgetView } from './PreviewWidgetView';
+
+export const previewWidgetManifest: WidgetManifest = {
+ failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },
+ icon: 'lucide-react:eye',
+ id: 'preview',
+ label: 'Preview',
+ labelText: 'Preview',
+ regions: ['center', 'right'],
+ version: 1,
+ view: PreviewWidgetView,
+};