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.

fix(workbench): preserve live progress images while streaming

joshistoasteccc112ae365
diff --git a/invokeai/frontend/webv2/src/workbench/backend/itemProgressStore.test.ts b/invokeai/frontend/webv2/src/workbench/backend/itemProgressStore.test.ts
new file mode 100644
index 0000000000..91e23d338d
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/backend/itemProgressStore.test.ts
@@ -0,0 +1,48 @@
+import { beforeEach, describe, expect, it } from 'vitest';
+
+import { itemProgressStore } from './itemProgressStore';
+
+describe('itemProgressStore', () => {
+ beforeEach(() => {
+ itemProgressStore.clearAll();
+ });
+
+ it('preserves the previous live preview image when a progress update has no image payload', () => {
+ itemProgressStore.set(42, {
+ image: { dataUrl: 'data:image/png;base64,step-1', height: 64, width: 64 },
+ message: 'Denoising 1/20',
+ percentage: 0.05,
+ });
+
+ itemProgressStore.set(42, {
+ message: 'Denoising 2/20',
+ percentage: 0.1,
+ });
+
+ expect(itemProgressStore.get(42)).toEqual({
+ image: { dataUrl: 'data:image/png;base64,step-1', height: 64, width: 64 },
+ message: 'Denoising 2/20',
+ percentage: 0.1,
+ });
+ });
+
+ it('clears the live preview image when a progress update explicitly sets image to null', () => {
+ itemProgressStore.set(42, {
+ image: { dataUrl: 'data:image/png;base64,step-1', height: 64, width: 64 },
+ message: 'Denoising 1/20',
+ percentage: 0.05,
+ });
+
+ itemProgressStore.set(42, {
+ image: null,
+ message: '',
+ percentage: null,
+ });
+
+ expect(itemProgressStore.get(42)).toEqual({
+ image: null,
+ message: '',
+ percentage: null,
+ });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/backend/itemProgressStore.ts b/invokeai/frontend/webv2/src/workbench/backend/itemProgressStore.ts
new file mode 100644
index 0000000000..dee301fff1
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/backend/itemProgressStore.ts
@@ -0,0 +1,41 @@
+import { createKeyedTransientStore } from '@workbench/externalStore';
+import { mergeDenoiseProgressImage, type DenoiseProgressImage } from '@workbench/images/streamingImageSource';
+
+/**
+ * Live progress for in-flight queue items keyed by the backend `item_id`. The
+ * sibling `progressStore` keys by the *local* submission id, which only exists
+ * for items this client enqueued; the Queue widget shows the whole server queue,
+ * so its NOW & NEXT card needs progress addressable by the backend id carried on
+ * the socket's `invocation_started`/`invocation_progress` events.
+ */
+
+export interface ItemProgress {
+ message: string;
+ /** 0..1, or null while indeterminate. */
+ percentage: number | null;
+ image?: DenoiseProgressImage | null;
+}
+
+const progressByItemId = createKeyedTransientStore<number, ItemProgress>();
+
+export const itemProgressStore = {
+ get(itemId: number): ItemProgress | null {
+ return progressByItemId.get(itemId) ?? null;
+ },
+ set(itemId: number, progress: ItemProgress): void {
+ const current = progressByItemId.get(itemId);
+ const image = mergeDenoiseProgressImage(current?.image, progress.image);
+ const next = image === undefined ? progress : { ...progress, image };
+
+ progressByItemId.set(itemId, next);
+ },
+ clear(itemId: number): void {
+ progressByItemId.delete(itemId);
+ },
+ clearAll(): void {
+ progressByItemId.clear();
+ },
+};
+
+export const useItemProgress = (itemId: number | null | undefined): ItemProgress | null =>
+ progressByItemId.useValue(itemId ?? -1) ?? null;
diff --git a/invokeai/frontend/webv2/src/workbench/backend/progressImageStore.ts b/invokeai/frontend/webv2/src/workbench/backend/progressImageStore.ts
index b80aa68238..6646bb251b 100644
--- a/invokeai/frontend/webv2/src/workbench/backend/progressImageStore.ts
+++ b/invokeai/frontend/webv2/src/workbench/backend/progressImageStore.ts
@@ -1,3 +1,5 @@
+import type { DenoiseProgressImage } from '@workbench/images/streamingImageSource';
+
import { createExternalStore, createKeyedTransientStore } from '@workbench/externalStore';
/**
@@ -6,11 +8,7 @@ import { createExternalStore, createKeyedTransientStore } from '@workbench/exter
* Current Image node, progress surfaces) fall back to the last real output.
*/
-export interface ProgressImageSnapshot {
- dataUrl: string;
- width: number;
- height: number;
-}
+export type ProgressImageSnapshot = DenoiseProgressImage;
export interface ProgressImageTarget {
queueItemId: string;
diff --git a/invokeai/frontend/webv2/src/workbench/images/StreamingImageFrame.tsx b/invokeai/frontend/webv2/src/workbench/images/StreamingImageFrame.tsx
new file mode 100644
index 0000000000..a8228b51aa
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/images/StreamingImageFrame.tsx
@@ -0,0 +1,47 @@
+import { Box, type BoxProps } from '@chakra-ui/react';
+import { useMemo, type CSSProperties, type ReactNode } from 'react';
+
+import type { StreamingImageSource } from './streamingImageSource';
+
+import { useStreamingImageSource } from './useStreamingImageSource';
+
+export const StreamingImageFrame = ({
+ badge,
+ fallbackImage,
+ finalImage,
+ fit = 'cover',
+ liveImage,
+ shouldAntialiasLiveImage = true,
+ children,
+ ...boxProps
+}: {
+ badge?: ReactNode | ((source: StreamingImageSource) => ReactNode);
+ fallbackImage?: StreamingImageSource | null;
+ finalImage?: StreamingImageSource | null;
+ fit?: 'contain' | 'cover';
+ liveImage?: StreamingImageSource | null;
+ shouldAntialiasLiveImage?: boolean;
+} & BoxProps) => {
+ const source = useStreamingImageSource({ fallbackImage, finalImage, liveImage });
+ const renderedBadge: ReactNode = typeof badge === 'function' ? (source ? badge(source) : null) : badge;
+ const imageStyle = useMemo<CSSProperties>(
+ () => ({
+ display: 'block',
+ height: '100%',
+ imageRendering: source?.kind === 'live' && !shouldAntialiasLiveImage ? 'pixelated' : 'auto',
+ inset: 0,
+ maxWidth: 'none',
+ objectFit: fit,
+ position: 'absolute',
+ width: '100%',
+ }),
+ [fit, shouldAntialiasLiveImage, source?.kind]
+ );
+
+ return (
+ <Box overflow="hidden" position="relative" {...boxProps}>
+ {source ? <img alt={source.alt} draggable={false} src={source.src} style={imageStyle} /> : children}
+ {renderedBadge}
+ </Box>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/images/streamingImageSource.test.ts b/invokeai/frontend/webv2/src/workbench/images/streamingImageSource.test.ts
new file mode 100644
index 0000000000..0fdb55fbcc
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/images/streamingImageSource.test.ts
@@ -0,0 +1,91 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ mergeDenoiseProgressImage,
+ progressImageToStreamingSource,
+ resolveStreamingImageSource,
+ type DenoiseProgressImage,
+ type StreamingImageSource,
+} from './streamingImageSource';
+
+const liveImage: StreamingImageSource = {
+ alt: 'Live preview',
+ height: 32,
+ kind: 'live',
+ src: 'data:image/png;base64,live',
+ width: 64,
+};
+const heldLiveImage: StreamingImageSource = {
+ alt: 'Held preview',
+ height: 32,
+ kind: 'live',
+ src: 'data:image/png;base64,held',
+ width: 64,
+};
+const finalImage: StreamingImageSource = {
+ alt: 'Final image',
+ height: 512,
+ kind: 'final',
+ src: '/api/final.png',
+ width: 512,
+};
+const fallbackImage: StreamingImageSource = {
+ alt: 'Fallback image',
+ height: 512,
+ kind: 'fallback',
+ src: '/api/fallback.png',
+ width: 512,
+};
+
+describe('resolveStreamingImageSource', () => {
+ it('prioritizes final images over live and fallback images', () => {
+ expect(resolveStreamingImageSource({ fallbackImage, finalImage, heldLiveImage, liveImage })).toBe(finalImage);
+ });
+
+ it('uses the current live image before a held live image', () => {
+ expect(resolveStreamingImageSource({ fallbackImage, heldLiveImage, liveImage })).toBe(liveImage);
+ });
+
+ it('keeps the held live image while waiting for final image data', () => {
+ expect(resolveStreamingImageSource({ fallbackImage, heldLiveImage })).toBe(heldLiveImage);
+ });
+
+ it('falls back when no final or live image is available', () => {
+ expect(resolveStreamingImageSource({ fallbackImage })).toBe(fallbackImage);
+ });
+});
+
+describe('mergeDenoiseProgressImage', () => {
+ it('keeps the previous denoise image when the next update is omitted', () => {
+ const previous: DenoiseProgressImage = { dataUrl: 'data:image/png;base64,old', height: 32, width: 64 };
+
+ expect(mergeDenoiseProgressImage(previous, undefined)).toBe(previous);
+ });
+
+ it('replaces the previous denoise image when a next update is provided', () => {
+ const previous: DenoiseProgressImage = { dataUrl: 'data:image/png;base64,old', height: 32, width: 64 };
+ const next: DenoiseProgressImage = { dataUrl: 'data:image/png;base64,next', height: 48, width: 96 };
+
+ expect(mergeDenoiseProgressImage(previous, next)).toBe(next);
+ });
+
+ it('clears the previous denoise image when the next update is null', () => {
+ const previous: DenoiseProgressImage = { dataUrl: 'data:image/png;base64,old', height: 32, width: 64 };
+
+ expect(mergeDenoiseProgressImage(previous, null)).toBeNull();
+ });
+});
+
+describe('progressImageToStreamingSource', () => {
+ it('maps a denoise progress image to a live streaming source', () => {
+ expect(
+ progressImageToStreamingSource({ dataUrl: 'data:image/png;base64,abc', height: 32, width: 64 }, 'Preview')
+ ).toEqual({
+ alt: 'Preview',
+ height: 32,
+ kind: 'live',
+ src: 'data:image/png;base64,abc',
+ width: 64,
+ });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/images/streamingImageSource.ts b/invokeai/frontend/webv2/src/workbench/images/streamingImageSource.ts
new file mode 100644
index 0000000000..87de536f6b
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/images/streamingImageSource.ts
@@ -0,0 +1,69 @@
+export type StreamingImageKind = 'fallback' | 'final' | 'live';
+
+export interface DenoiseProgressImage {
+ dataUrl: string;
+ height: number;
+ width: number;
+}
+
+export interface StreamingImageSource {
+ alt: string;
+ height?: number;
+ kind: StreamingImageKind;
+ src: string;
+ width?: number;
+}
+
+export const mergeDenoiseProgressImage = <Image extends DenoiseProgressImage>(
+ previous: Image | null | undefined,
+ next: Image | null | undefined
+): Image | null | undefined => (next === undefined ? previous : next);
+
+export const progressImageToStreamingSource = (
+ image: DenoiseProgressImage | null | undefined,
+ alt = 'In-progress diffusion preview'
+): StreamingImageSource | null =>
+ image
+ ? {
+ alt,
+ height: image.height,
+ kind: 'live',
+ src: image.dataUrl,
+ width: image.width,
+ }
+ : null;
+
+export const imageUrlToStreamingSource = ({
+ alt,
+ height,
+ kind = 'final',
+ src,
+ width,
+}: {
+ alt: string;
+ height?: number;
+ kind?: Exclude<StreamingImageKind, 'live'>;
+ src: string | null | undefined;
+ width?: number;
+}): StreamingImageSource | null =>
+ src
+ ? {
+ alt,
+ height,
+ kind,
+ src,
+ width,
+ }
+ : null;
+
+export const resolveStreamingImageSource = ({
+ fallbackImage,
+ finalImage,
+ heldLiveImage,
+ liveImage,
+}: {
+ fallbackImage?: StreamingImageSource | null;
+ finalImage?: StreamingImageSource | null;
+ heldLiveImage?: StreamingImageSource | null;
+ liveImage?: StreamingImageSource | null;
+}): StreamingImageSource | null => finalImage ?? liveImage ?? heldLiveImage ?? fallbackImage ?? null;
diff --git a/invokeai/frontend/webv2/src/workbench/images/useStreamingImageSource.ts b/invokeai/frontend/webv2/src/workbench/images/useStreamingImageSource.ts
new file mode 100644
index 0000000000..9c84119fc5
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/images/useStreamingImageSource.ts
@@ -0,0 +1,11 @@
+import { resolveStreamingImageSource, type StreamingImageSource } from './streamingImageSource';
+
+export const useStreamingImageSource = ({
+ fallbackImage,
+ finalImage,
+ liveImage,
+}: {
+ fallbackImage?: StreamingImageSource | null;
+ finalImage?: StreamingImageSource | null;
+ liveImage?: StreamingImageSource | null;
+}): StreamingImageSource | null => resolveStreamingImageSource({ fallbackImage, finalImage, liveImage });
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx
index 7da41a6e78..ac33042b22 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/gallery/GalleryImageGrid.tsx
@@ -8,6 +8,8 @@ import { useQueueItemProgressImage } from '@workbench/backend/progressImageStore
import { useQueueItemProgress } from '@workbench/backend/progressStore';
import { IconButton } from '@workbench/components/ui';
import { ImageContextMenu, type ImageContextMenuTarget } from '@workbench/image-actions';
+import { StreamingImageFrame } from '@workbench/images/StreamingImageFrame';
+import { progressImageToStreamingSource } from '@workbench/images/streamingImageSource';
import { useActiveProjectSelector, useWorkbenchDispatch } from '@workbench/WorkbenchContext';
import { StarIcon, UploadIcon } from 'lucide-react';
import {
@@ -543,34 +545,19 @@ const GalleryQueuePlaceholderCell = ({
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%',
- }}
- />
- ) : (
+ <StreamingImageFrame
+ fit={fit === 'aspect' ? 'contain' : 'cover'}
+ h="full"
+ liveImage={progressImageToStreamingSource(progressImage)}
+ shouldAntialiasLiveImage={antialiasProgressImages}
+ w="full"
+ >
<Skeleton h="full" w="full" />
- )}
- {/*<Badge left="1" pointerEvents="none" position="absolute" size="xs" top="1" variant="solid" zIndex="1">
- {isActive ? 'Generating' : 'Queued'}
- </Badge>*/}
+ </StreamingImageFrame>
{isActive ? <GalleryPlaceholderCircularProgress percentage={percentage} /> : null}
</Box>
);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
index 88d9c11388..a5196deaba 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx
@@ -13,6 +13,8 @@ import {
} from '@workbench/gallery/api';
import { getGallerySettings } from '@workbench/gallery/settings';
import { ImageContextMenu, useImageActions, type ImageContextMenuTarget } from '@workbench/image-actions';
+import { imageUrlToStreamingSource, progressImageToStreamingSource } from '@workbench/images/streamingImageSource';
+import { useStreamingImageSource } from '@workbench/images/useStreamingImageSource';
import {
getGalleryCompareImage,
getGalleryImagesRefreshToken,
@@ -446,19 +448,19 @@ const SelectedImagePreview = ({
onNext: () => void;
onPrevious: () => void;
}) => {
- const previewImage = useMemo(
- () =>
- 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 },
- [image.height, image.imageName, image.imageUrl, image.width, progressImage]
- );
+ const previewImage = useStreamingImageSource({
+ fallbackImage: imageUrlToStreamingSource({
+ alt: image.imageName,
+ height: image.height,
+ kind: 'fallback',
+ src: image.imageUrl,
+ width: image.width,
+ }),
+ liveImage: progressImageToStreamingSource(progressImage),
+ });
+ const isProgressImage = previewImage?.kind === 'live';
+ const previewWidth = previewImage?.width ?? image.width;
+ const previewHeight = previewImage?.height ?? image.height;
const handleKeyDown = useCallback(
(event: KeyboardEvent<HTMLDivElement>) => {
if (event.key === 'ArrowLeft') {
@@ -484,13 +486,13 @@ const SelectedImagePreview = ({
() => ({
display: 'block',
height: '100%',
- imageRendering: previewImage.isProgress && !shouldAntialiasProgressImage ? 'pixelated' : 'auto',
+ imageRendering: isProgressImage && !shouldAntialiasProgressImage ? 'pixelated' : 'auto',
inset: 0,
objectFit: 'contain',
position: 'absolute',
width: '100%',
}),
- [previewImage.isProgress, shouldAntialiasProgressImage]
+ [isProgressImage, shouldAntialiasProgressImage]
);
return (
@@ -510,10 +512,10 @@ const SelectedImagePreview = ({
w="full"
>
<Box
- aspectRatio={previewImage.width / previewImage.height}
+ aspectRatio={previewWidth / previewHeight}
bg="transparent"
borderWidth="1px"
- borderColor={previewImage.isProgress ? 'accent.solid' : 'border.emphasized'}
+ borderColor={isProgressImage ? 'accent.solid' : 'border.emphasized'}
boxShadow="0 24px 80px rgba(0,0,0,0.42)"
h={isCompact ? 'auto' : 'full'}
maxH={isCompact ? undefined : 'full'}
@@ -524,8 +526,8 @@ const SelectedImagePreview = ({
w={isCompact ? 'full' : 'auto'}
onContextMenu={handleContextMenu}
>
- <img alt={previewImage.alt} src={previewImage.src} style={imageStyle} />
- {previewImage.isProgress ? (
+ {previewImage ? <img alt={previewImage.alt} src={previewImage.src} style={imageStyle} /> : null}
+ {isProgressImage ? (
<Badge left="2" pointerEvents="none" position="absolute" size="xs" top="2" variant="solid">
Generating
</Badge>
@@ -575,7 +577,7 @@ const SelectedImagePreview = ({
Source run {image.sourceQueueItemId}
</Text>
<Text color="fg.subtle" flexShrink={0} fontSize="2xs">
- {previewImage.isProgress ? 'Generating' : `${image.width} x ${image.height}`}
+ {isProgressImage ? 'Generating' : `${image.width} x ${image.height}`}
</Text>
</Stack>
</Stack>
@@ -589,53 +591,59 @@ const EmptyPreview = ({
}: {
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={progressImage.width / progressImage.height}
- borderColor="accent.solid"
- borderWidth="1px"
- boxShadow="0 24px 80px rgba(0,0,0,0.42)"
- maxH="full"
- maxW="full"
- overflow="hidden"
- position="relative"
- rounded="lg"
- >
- <img
- alt="In-progress diffusion preview"
- draggable={false}
- src={progressImage.dataUrl}
- style={{
- display: 'block',
- height: '100%',
- imageRendering: shouldAntialiasProgressImage ? 'auto' : 'pixelated',
- objectFit: 'contain',
- width: '100%',
- }}
- />
- <Badge left="2" pointerEvents="none" position="absolute" size="xs" top="2" variant="solid">
- Generating
- </Badge>
- </Box>
- ) : (
- <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>
-);
+}) => {
+ const previewImage = useStreamingImageSource({
+ liveImage: progressImageToStreamingSource(progressImage),
+ });
+
+ return (
+ <Flex
+ align="center"
+ backgroundColor="bg.inset"
+ color="fg.grid"
+ css={previewGridCss}
+ h="full"
+ justify="center"
+ w="full"
+ >
+ {previewImage ? (
+ <Box
+ aspectRatio={(previewImage.width ?? 1) / (previewImage.height ?? 1)}
+ borderColor="accent.solid"
+ borderWidth="1px"
+ boxShadow="0 24px 80px rgba(0,0,0,0.42)"
+ maxH="full"
+ maxW="full"
+ overflow="hidden"
+ position="relative"
+ rounded="lg"
+ >
+ <img
+ alt={previewImage.alt}
+ draggable={false}
+ src={previewImage.src}
+ style={{
+ display: 'block',
+ height: '100%',
+ imageRendering: shouldAntialiasProgressImage ? 'auto' : 'pixelated',
+ objectFit: 'contain',
+ width: '100%',
+ }}
+ />
+ <Badge left="2" pointerEvents="none" position="absolute" size="xs" top="2" variant="solid">
+ Generating
+ </Badge>
+ </Box>
+ ) : (
+ <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/workflow/editor/CurrentImageFlowNode.tsx b/invokeai/frontend/webv2/src/workbench/widgets/workflow/editor/CurrentImageFlowNode.tsx
index f534767183..f3bf429901 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/workflow/editor/CurrentImageFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/workflow/editor/CurrentImageFlowNode.tsx
@@ -1,8 +1,10 @@
import type { GeneratedImageContract } from '@workbench/types';
import type { NodeProps } from '@xyflow/react';
-import { Box, Flex, Image, Text } from '@chakra-ui/react';
+import { Box, Flex, Text } from '@chakra-ui/react';
import { useProgressImage } from '@workbench/backend/progressImageStore';
+import { StreamingImageFrame } from '@workbench/images/StreamingImageFrame';
+import { imageUrlToStreamingSource, progressImageToStreamingSource } from '@workbench/images/streamingImageSource';
import { getProjectWidgetValues } from '@workbench/widgetState';
import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
import { memo } from 'react';
@@ -28,7 +30,6 @@ const CurrentImageFlowNodeComponent = ({ data, selected }: NodeProps<CurrentImag
const progressImage = useProgressImage();
const node = data.documentNode;
const latestImage = getLatestImage(galleryValues);
- const src = progressImage?.dataUrl ?? latestImage?.imageUrl ?? null;
return (
<Box bg="bg" fontSize="xs" overflow="hidden" rounded="lg" w="20rem" {...getWorkflowNodeChromeProps({ selected })}>
@@ -40,13 +41,23 @@ const CurrentImageFlowNodeComponent = ({ data, selected }: NodeProps<CurrentImag
</Text>
) : null}
</Flex>
- {src ? (
- <Image alt="Current image" draggable={false} h="18rem" objectFit="contain" src={src} w="full" />
- ) : (
- <Flex align="center" color="fg.subtle" fontSize="2xs" h="18rem" justify="center" px="4" textAlign="center">
+ <StreamingImageFrame
+ fallbackImage={imageUrlToStreamingSource({
+ alt: latestImage?.imageName ?? 'Current image',
+ height: latestImage?.height,
+ kind: 'fallback',
+ src: latestImage?.imageUrl,
+ width: latestImage?.width,
+ })}
+ fit="contain"
+ h="18rem"
+ liveImage={progressImageToStreamingSource(progressImage)}
+ w="full"
+ >
+ <Flex align="center" color="fg.subtle" fontSize="2xs" h="full" justify="center" px="4" textAlign="center">
No image yet — the latest generation will appear here.
</Flex>
- )}
+ </StreamingImageFrame>
</Box>
);
};