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(workflow): preserve titles and source previews in snapshots

JPPhoto76e6cdc4778b
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/CurrentImageFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/CurrentImageFlowNode.tsx
index df1a81160a..e293a7c2db 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/CurrentImageFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/CurrentImageFlowNode.tsx
@@ -9,6 +9,7 @@ import {
useIsWorkflowImageExport,
} from '@features/workflow/ui/nodeChrome';
import { useWorkflowProjectSelector } from '@features/workflow/ui/WorkflowUiContext';
+import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { StreamingImageFrame } from '@platform/ui/streaming-image/StreamingImageFrame';
import {
imageUrlToStreamingSource,
@@ -78,17 +79,14 @@ const CurrentImageSnapshotNode = ({ data, selected }: NodeProps<CurrentImageFlow
{...getWorkflowNodeShellProps({ selected })}
>
<Flex {...getWorkflowNodeHeaderProps()}>
- <Text
+ <MiddleTruncate
data-workflow-export-node-title="true"
data-workflow-export-static-node-content="true"
flex="1"
fontWeight="700"
minW="0"
- overflowWrap="anywhere"
- whiteSpace="pre-wrap"
- >
- {node.data.label || 'Current Image'}
- </Text>
+ text={node.data.label || 'Current Image'}
+ />
</Flex>
</Box>
);
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.browser.test.tsx
index 9b14dbe4f8..e5bc215b0d 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.browser.test.tsx
@@ -7,9 +7,15 @@ import type {
import type { WorkflowNodeExecutionState } from '@features/workflow/ui/contracts';
import type { WorkflowUiAdapter } from '@features/workflow/ui/WorkflowUiContext';
import type { ProjectGraphAction } from '@features/workflow/utility';
+import type { toBlob as RasterizeBlob } from 'html-to-image';
/* eslint-disable react-perf/jsx-no-new-object-as-prop, react-perf/jsx-no-new-array-as-prop -- each render mounts a fresh flow on purpose */
import { ChakraProvider } from '@chakra-ui/react';
+import { galleryImageUrls } from '@features/gallery/utility';
+import {
+ savedWorkflowDetailQueryKey,
+ savedWorkflowPickerQueryOptions,
+} from '@features/workflow/data/savedWorkflowQueries';
import { WorkflowImageExportProvider } from '@features/workflow/ui/nodeChrome';
import { WorkflowUiProvider } from '@features/workflow/ui/WorkflowUiContext';
import { setNodePreviewCollapsed } from '@features/workflow/ui/workflowUiStore';
@@ -590,7 +596,7 @@ describe('InvocationFlowNode output preview', () => {
expect(capturedClone?.querySelector('button[aria-label="Collapse node"]')).toBeNull();
});
- it('wraps and measures long authored node labels in the static export', async () => {
+ it('keeps long authored node titles on one line in the static export', async () => {
const invocationLabel = 'Authored invocation label '.repeat(24);
const currentImageLabel = `Authored current image ${'unbroken-label-'.repeat(24)}`;
const invocationNode: WorkflowInvocationNode = {
@@ -603,7 +609,18 @@ describe('InvocationFlowNode output preview', () => {
data: { label: currentImageLabel },
id: 'long-current-image-node',
};
- const graph = { ...projectGraph, nodes: [invocationNode, imageNode] };
+ const unknownNode: WorkflowInvocationNode = {
+ ...invocationNode,
+ data: { ...invocationNode.data, type: 'unknown-node-type' },
+ id: 'long-unknown-node',
+ position: { x: 20, y: 200 },
+ };
+ const notesNode = {
+ ...buildNotesNode({ x: 420, y: 200 }),
+ data: { label: invocationLabel, notes: 'Authored note body' },
+ id: 'long-notes-node',
+ };
+ const graph = { ...projectGraph, nodes: [invocationNode, imageNode, unknownNode, notesNode] };
const nodes = toFlowNodes(graph, [], { preview: template });
const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
let capturedClone: HTMLElement | undefined;
@@ -621,9 +638,19 @@ describe('InvocationFlowNode output preview', () => {
'.react-flow__node[data-id="long-current-image-node"] [data-workflow-export-node-title="true"]'
);
expect(invocationTitle?.textContent).toBe(invocationLabel);
- expect(getComputedStyle(invocationTitle!).whiteSpace).not.toBe('nowrap');
+ expect(getComputedStyle(invocationTitle!).whiteSpace).toBe('nowrap');
expect(imageTitle?.textContent).toBe(currentImageLabel);
- expect(getComputedStyle(imageTitle!).overflowWrap).toBe('anywhere');
+ expect(getComputedStyle(imageTitle!).whiteSpace).toBe('nowrap');
+ const titles = host.querySelectorAll<HTMLElement>('[data-workflow-export-node-title="true"]');
+ expect(titles).toHaveLength(4);
+ for (const title of titles) {
+ expect(getComputedStyle(title).whiteSpace).toBe('nowrap');
+ expect(title.textContent?.length).toBeGreaterThan(100);
+ expect(title.scrollHeight).toBeLessThanOrEqual(title.clientHeight);
+ }
+ const truncatedHead = invocationTitle!.firstElementChild as HTMLElement;
+ expect(getComputedStyle(truncatedHead).textOverflow).toBe('ellipsis');
+ expect(truncatedHead.scrollWidth).toBeGreaterThan(truncatedHead.clientWidth);
expect(invocationTitle?.dataset.workflowExportStaticNodeContent).toBe('true');
expect(imageTitle?.dataset.workflowExportStaticNodeContent).toBe('true');
@@ -640,6 +667,184 @@ describe('InvocationFlowNode output preview', () => {
expect(capturedClone?.textContent).toContain(currentImageLabel);
});
+ it.each(['detail', 'owned', 'shared', 'unavailable', 'refreshed'] as const)(
+ 'exports the selected saved workflow name from %s metadata without picker controls',
+ async (source) => {
+ const workflowId = 'selected-child';
+ const name = 'Landscape child workflow';
+ const initialName = source === 'refreshed' ? 'Previous child workflow' : name;
+ if (source === 'refreshed') {
+ queryClient.setQueryData(
+ savedWorkflowDetailQueryKey(workflowId),
+ { name: initialName, workflow_id: workflowId },
+ { updatedAt: 100 }
+ );
+ queryClient.setQueryData(
+ savedWorkflowPickerQueryOptions({ page: 0, query: 'Previous' }).queryKey,
+ {
+ pageParams: [0],
+ pages: [{ items: [{ name: initialName, workflow_id: workflowId }], page: 0, pages: 1, total: 1 }],
+ },
+ { updatedAt: 200 }
+ );
+ } else if (source === 'detail') {
+ queryClient.setQueryData(savedWorkflowDetailQueryKey(workflowId), { name, workflow_id: workflowId });
+ } else if (source !== 'unavailable') {
+ const params = { page: 0, query: 'Landscape', isPublic: source === 'shared' };
+ queryClient.setQueryData(savedWorkflowPickerQueryOptions(params).queryKey, {
+ pageParams: [0],
+ pages: [{ items: [{ name, workflow_id: workflowId }], page: 0, pages: 1, total: 1 }],
+ });
+ }
+ const namedCallTemplate: InvocationTemplate = {
+ ...callTemplate,
+ inputs: {
+ workflow_id: {
+ ...template.inputs.a!,
+ input: 'direct',
+ name: 'workflow_id',
+ title: 'Workflow',
+ type: { batch: false, cardinality: 'SINGLE', name: 'SavedWorkflowField' },
+ },
+ },
+ };
+ const namedCallNode: WorkflowInvocationNode = {
+ ...callNode,
+ data: {
+ ...callNode.data,
+ inputs: { workflow_id: { label: '', name: 'workflow_id', value: workflowId } },
+ },
+ };
+ const graph = { ...callProjectGraph, nodes: [namedCallNode] };
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ const fetchSpy = vi.spyOn(globalThis, 'fetch');
+ try {
+ await render(adapter, 1, true, toFlowNodes(graph, [], { call_saved_workflow: namedCallTemplate }));
+ const titleHead = host.querySelector<HTMLElement>('[data-workflow-export-node-title="true"] > span');
+ expect(titleHead).not.toBeNull();
+ expect(titleHead!.scrollWidth).toBeLessThanOrEqual(titleHead!.clientWidth);
+ expect(host.querySelector('[data-workflow-export-field-value="true"]')?.textContent).toBe(
+ source === 'unavailable' ? workflowId : initialName
+ );
+ if (source === 'refreshed') {
+ await act(() => {
+ queryClient.setQueryData(
+ savedWorkflowPickerQueryOptions({ page: 0, query: 'Landscape' }).queryKey,
+ {
+ pageParams: [0],
+ pages: [{ items: [{ name, workflow_id: workflowId }], page: 0, pages: 1, total: 1 }],
+ },
+ { updatedAt: 300 }
+ );
+ });
+ expect(host.querySelector('[data-workflow-export-field-value="true"]')?.textContent).toBe(name);
+ await act(() => {
+ queryClient.setQueryData(
+ savedWorkflowDetailQueryKey(workflowId),
+ {
+ name: 'Renamed child workflow',
+ workflow_id: workflowId,
+ },
+ { updatedAt: 400 }
+ );
+ });
+ expect(host.querySelector('[data-workflow-export-field-value="true"]')?.textContent).toBe(
+ 'Renamed child workflow'
+ );
+ }
+ if (source === 'unavailable') {
+ await act(() => {
+ queryClient.setQueryData(savedWorkflowDetailQueryKey(workflowId), { name, workflow_id: workflowId });
+ });
+ expect(host.querySelector('[data-workflow-export-field-value="true"]')?.textContent).toBe(name);
+ }
+ expect(host.querySelector('.react-flow__node button')).toBeNull();
+ expect(fetchSpy).not.toHaveBeenCalled();
+ expect(adapter.commands.editGraph).not.toHaveBeenCalled();
+ } finally {
+ fetchSpy.mockRestore();
+ }
+ }
+ );
+
+ it.each(['SINGLE', 'COLLECTION'] as const)(
+ 'exports scaled authored source images for %s fields',
+ async (cardinality) => {
+ const source = outputImage(800, 400);
+ const thumbnailSpy = vi.spyOn(galleryImageUrls, 'thumbnail').mockReturnValue(source);
+ const value = { image_name: 'authored-source.png' };
+ const imageTemplate: InvocationTemplate = {
+ ...template,
+ inputs: {
+ a: {
+ ...template.inputs.a!,
+ input: 'any',
+ title: 'Source Image',
+ type: { batch: false, cardinality, name: 'ImageField' },
+ },
+ },
+ };
+ const imageNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: {
+ ...documentNode.data,
+ inputs: { a: { label: '', name: 'a', value: cardinality === 'SINGLE' ? value : [value] } },
+ },
+ };
+ const graph = { ...projectGraph, nodes: [imageNode] };
+ const execution = createExecutionPort();
+ execution.set(completed(outputImage(100, 100)));
+ const adapter = createAdapter(execution.port, projectSnapshotFor(graph));
+ let capturedClone: HTMLElement | undefined;
+ let exportedBlob: Blob | null | undefined;
+ exportMocks.toBlob.mockImplementation(async (clone: HTMLElement, options: unknown) => {
+ capturedClone = clone;
+ const { toBlob } = await vi.importActual<{ toBlob: typeof RasterizeBlob }>('html-to-image');
+ exportedBlob = await toBlob(clone, options as Parameters<typeof toBlob>[1]);
+ return exportedBlob;
+ });
+ try {
+ await render(adapter, 1, true, toFlowNodes(graph, [], { preview: imageTemplate }));
+ const sourceImage = host.querySelector<HTMLImageElement>('[data-workflow-export-field-value="true"] img');
+ expect(sourceImage).not.toBeNull();
+ await vi.waitFor(() => expect(sourceImage!.naturalWidth).toBe(800));
+ expect(getComputedStyle(sourceImage!).objectFit).toBe(cardinality === 'SINGLE' ? 'contain' : 'cover');
+ expect(sourceImage!.getBoundingClientRect().width).toBeLessThan(800);
+ expect(sourceImage!.getBoundingClientRect().height).toBeLessThanOrEqual(128);
+ await exportWorkflowAsPng({
+ bounds: { x: 20, y: 20, width: 300, height: 260 },
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,
+ workflowName: 'Authored source image',
+ });
+ expect(exportedBlob?.type).toBe('image/png');
+ const bitmap = await createImageBitmap(exportedBlob!);
+ const canvas = document.createElement('canvas');
+ canvas.width = bitmap.width;
+ canvas.height = bitmap.height;
+ const context = canvas.getContext('2d')!;
+ context.drawImage(bitmap, 0, 0);
+ const pixels = context.getImageData(0, 0, bitmap.width, bitmap.height).data;
+ let sourcePixels = 0;
+ for (let index = 0; index < pixels.length; index += 4) {
+ if (pixels[index] === 76 && pixels[index + 1] === 139 && pixels[index + 2] === 245) {
+ sourcePixels += 1;
+ }
+ }
+ bitmap.close();
+ expect(sourcePixels).toBeGreaterThan(1000);
+ expect(capturedClone?.querySelectorAll('img')).toHaveLength(1);
+ expect(capturedClone?.querySelector('img')?.src).toBe(source);
+ expect(capturedClone?.textContent).toContain('authored-source.png');
+ expect(capturedClone?.textContent).not.toContain('Latest output');
+ expect(capturedClone?.querySelector('button, input')).toBeNull();
+ expect(adapter.commands.editGraph).not.toHaveBeenCalled();
+ } finally {
+ thumbnailSpy.mockRestore();
+ }
+ }
+ );
+
it('keeps running progress in the editor but omits it from the exported graph clone', async () => {
const execution = createExecutionPort();
const adapter = createAdapter(execution.port);
@@ -1084,11 +1289,14 @@ describe('InvocationFlowNode output preview', () => {
expect(unknownShell?.textContent).not.toContain('Unknown node type');
expect(getComputedStyle(unknownShell!).borderColor).toBe(getComputedStyle(knownShell!).borderColor);
expect(unknownTitle?.textContent).toBe(unknownLabel);
- expect(getComputedStyle(unknownTitle!).overflowWrap).toBe('anywhere');
+ expect(getComputedStyle(unknownTitle!).whiteSpace).toBe('nowrap');
expect(unknownTitle?.dataset.workflowExportStaticNodeContent).toBe('true');
const bounds = getWorkflowContentBounds(flowElement, { x: 20, y: 20, width: 600, height: 100 });
- expect(bounds.height).toBeGreaterThan(100);
+ expect(bounds.height).toBeCloseTo(
+ Math.max(knownShell!.getBoundingClientRect().height, unknownShell!.getBoundingClientRect().height)
+ );
+ expect(bounds.height).toBeLessThan(100);
await exportWorkflowAsPng({
bounds,
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
index b84df1963d..15e20acf25 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
@@ -229,17 +229,13 @@ const NodeTitle = ({
if (isWorkflowImageExport) {
return (
- <Text
+ <MiddleTruncate
data-workflow-export-node-title="true"
data-workflow-export-static-node-content="true"
- flex="1"
fontWeight="700"
minW="0"
- overflowWrap="anywhere"
- whiteSpace="pre-wrap"
- >
- {title}
- </Text>
+ text={title}
+ />
);
}
@@ -988,16 +984,17 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
<HStack gap="1.5" minW={isWorkflowImageExport ? '0' : undefined} p="3">
{!isWorkflowImageExport ? <Icon as={TriangleAlertIcon} boxSize="3.5" color="red.solid" /> : null}
<Stack flex={isWorkflowImageExport ? '1' : undefined} gap="0" minW={isWorkflowImageExport ? '0' : undefined}>
- <Text
- data-workflow-export-node-title={isWorkflowImageExport ? 'true' : undefined}
- data-workflow-export-static-node-content={isWorkflowImageExport ? 'true' : undefined}
- fontWeight="700"
- minW={isWorkflowImageExport ? '0' : undefined}
- overflowWrap={isWorkflowImageExport ? 'anywhere' : undefined}
- whiteSpace={isWorkflowImageExport ? 'pre-wrap' : undefined}
- >
- {node.data.label || node.data.type}
- </Text>
+ {isWorkflowImageExport ? (
+ <MiddleTruncate
+ data-workflow-export-node-title="true"
+ data-workflow-export-static-node-content="true"
+ fontWeight="700"
+ minW="0"
+ text={node.data.label || node.data.type}
+ />
+ ) : (
+ <Text fontWeight="700">{node.data.label || node.data.type}</Text>
+ )}
{!isWorkflowImageExport ? (
<Text color="fg.subtle" fontSize="2xs">
Unknown node type "{node.data.type}". It cannot run on this backend.
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/NotesFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NotesFlowNode.tsx
index 6e29f8f874..b4291d6ea9 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/NotesFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NotesFlowNode.tsx
@@ -3,6 +3,7 @@ import type { NodeProps } from '@xyflow/react';
import { Box, Input, Text, Textarea } from '@chakra-ui/react';
import { getWorkflowNodeChromeProps, useIsWorkflowImageExport } from '@features/workflow/ui/nodeChrome';
import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';
+import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { memo, useCallback, type ChangeEvent } from 'react';
import type { NotesFlowNode as NotesFlowNodeType } from './flowAdapters';
@@ -20,9 +21,13 @@ const NotesSnapshotNode = ({ data }: NodeProps<NotesFlowNodeType>) => {
w="16rem"
{...getWorkflowNodeChromeProps({ selected: false })}
>
- <Text fontSize="2xs" fontWeight="700" mb="1.5">
- {node.data.label}
- </Text>
+ <MiddleTruncate
+ data-workflow-export-node-title="true"
+ fontSize="2xs"
+ fontWeight="700"
+ mb="1.5"
+ text={node.data.label}
+ />
{node.data.notes ? (
<Text fontSize="2xs" overflowWrap="anywhere" whiteSpace="pre-wrap">
{node.data.notes}
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
index 3769062c0b..e53c57724f 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
@@ -1,5 +1,6 @@
import type { ModelConfig, ModelTaxonomyType } from '@features/models/react';
import type { FieldInputTemplate } from '@features/workflow/contracts';
+import type { WorkflowLibraryPage, WorkflowRecordDTO } from '@features/workflow/data/api';
import type { LoraFieldCollectionEntry } from '@features/workflow/utility';
import type { SeedInputPatch } from '@platform/ui/SeedInput';
@@ -48,7 +49,9 @@ import {
} from '@features/workflow/data/savedWorkflowFieldUtils';
import {
getWorkflowPagesItems,
+ savedWorkflowDetailQueryKey,
savedWorkflowDetailQueryOptions,
+ savedWorkflowPickerQueryKeyPrefix,
savedWorkflowPickerQueryOptions,
} from '@features/workflow/data/savedWorkflowQueries';
import { isSeedInputField } from '@features/workflow/graph';
@@ -99,7 +102,7 @@ import {
} from '@platform/ui';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { SeedInput } from '@platform/ui/SeedInput';
-import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query';
+import { useInfiniteQuery, useQuery, useQueryClient, type InfiniteData } from '@tanstack/react-query';
import { FilmIcon, ImageIcon, ImagePlusIcon, PlusIcon, RotateCcwIcon, Trash2Icon, XIcon } from 'lucide-react';
import {
lazy,
@@ -111,6 +114,7 @@ import {
useMemo,
useRef,
useState,
+ useSyncExternalStore,
type ChangeEvent,
} from 'react';
import { useTranslation } from 'react-i18next';
@@ -1924,6 +1928,64 @@ const formatSnapshotValue = (value: unknown, template: FieldInputTemplate): stri
return isRecord(value) ? formatSnapshotObject(value) : null;
};
+const SNAPSHOT_VALUE_TEXT_PROPS = {
+ color: 'fg.muted',
+ fontSize: '2xs',
+ lineHeight: 'short',
+ mt: '0.5',
+ overflowWrap: 'anywhere',
+ whiteSpace: 'pre-wrap',
+} as const;
+
+/** Use the freshest cached name without fetching or notifying the child-signature synchronizer. */
+const SavedWorkflowSnapshot = ({ workflowId }: { workflowId: string }) => {
+ const queryClient = useQueryClient();
+ const getName = useCallback(() => {
+ const detailKey = savedWorkflowDetailQueryKey(workflowId);
+ const record = queryClient.getQueryData<WorkflowRecordDTO>(detailKey);
+ let name = record?.name || workflowId;
+ let updatedAt = record?.name ? (queryClient.getQueryState(detailKey)?.dataUpdatedAt ?? 0) : -1;
+ for (const [key, pages] of queryClient.getQueriesData<InfiniteData<WorkflowLibraryPage>>({
+ queryKey: savedWorkflowPickerQueryKeyPrefix,
+ })) {
+ const pickerUpdatedAt = queryClient.getQueryState(key)?.dataUpdatedAt ?? 0;
+ if (pickerUpdatedAt < updatedAt) {
+ continue;
+ }
+ for (const page of pages?.pages ?? []) {
+ const workflow = page.items.find((item) => item.workflow_id === workflowId);
+ if (workflow?.name) {
+ name = workflow.name;
+ updatedAt = pickerUpdatedAt;
+ break;
+ }
+ }
+ }
+ return name;
+ }, [queryClient, workflowId]);
+ const subscribe = useCallback(
+ (onChange: () => void) =>
+ queryClient.getQueryCache().subscribe(({ query }) => {
+ const key = query.queryKey;
+ if (
+ key[0] === 'workflow' &&
+ key[1] === 'call-saved' &&
+ (key[2] === 'picker' || (key[2] === 'detail' && key[3] === workflowId))
+ ) {
+ onChange();
+ }
+ }),
+ [queryClient, workflowId]
+ );
+ const name = useSyncExternalStore(subscribe, getName, getName);
+
+ return (
+ <Text {...SNAPSHOT_VALUE_TEXT_PROPS} data-workflow-export-field-value="true">
+ {name}
+ </Text>
+ );
+};
+
/** Renders authored values without mounting editors or resolving runtime diagnostics. */
export const WorkflowFieldSnapshot = ({
seedMode = 'fixed',
@@ -1941,6 +2003,46 @@ export const WorkflowFieldSnapshot = ({
text = seedMode === 'random' || !text ? modeLabel : `${text} (${modeLabel})`;
}
+ if (template.type.name === 'SavedWorkflowField' && typeof value === 'string' && value) {
+ return <SavedWorkflowSnapshot workflowId={value} />;
+ }
+
+ if (template.type.name === 'ImageField') {
+ const names =
+ template.type.cardinality === 'COLLECTION'
+ ? getImageCollectionNames(value).filter(Boolean)
+ : isRecord(value) && typeof value.image_name === 'string' && value.image_name
+ ? [value.image_name]
+ : [];
+ if (names.length > 0) {
+ return (
+ <Box data-workflow-export-field-value="true" mt="0.5" w="full">
+ {template.type.cardinality === 'COLLECTION' ? (
+ <SimpleGrid borderWidth="1px" columns={3} gap="1" p="1" rounded="sm">
+ {names.map((name) => (
+ <Box key={name} aspectRatio="1" bg="bg.subtle" rounded="xs">
+ <Image
+ alt=""
+ h="full"
+ objectFit="cover"
+ rounded="xs"
+ src={galleryImageUrls.thumbnail(name)}
+ w="full"
+ />
+ </Box>
+ ))}
+ </SimpleGrid>
+ ) : (
+ <Flex align="center" borderWidth="1px" h="32" justify="center" overflow="hidden" rounded="sm" w="full">
+ <Image alt="" maxH="full" maxW="full" objectFit="contain" src={galleryImageUrls.thumbnail(names[0]!)} />
+ </Flex>
+ )}
+ <Text {...SNAPSHOT_VALUE_TEXT_PROPS}>{text}</Text>
+ </Box>
+ );
+ }
+ }
+
if (template.type.name === 'StringField') {
return (
<Box
@@ -1965,15 +2067,7 @@ export const WorkflowFieldSnapshot = ({
}
return text ? (
- <Text
- color="fg.muted"
- data-workflow-export-field-value="true"
- fontSize="2xs"
- lineHeight="short"
- mt="0.5"
- overflowWrap="anywhere"
- whiteSpace="pre-wrap"
- >
+ <Text {...SNAPSHOT_VALUE_TEXT_PROPS} data-workflow-export-field-value="true">
{text}
</Text>
) : null;