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): export pristine workflow snapshots

JPPhotoeb5edb715cbb
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/ConnectorFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/ConnectorFlowNode.tsx
index 9141a72a37..4c261e679b 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/ConnectorFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/ConnectorFlowNode.tsx
@@ -1,6 +1,6 @@
import type { FieldType } from '@features/workflow/contracts';
-import { Box, Flex, Stack, Text } from '@chakra-ui/react';
+import { Box, Flex } from '@chakra-ui/react';
import {
getWorkflowNodeChromeProps,
getWorkflowNodeHandleStyle,
@@ -15,7 +15,6 @@ import { useTranslation } from 'react-i18next';
import type { ConnectorFlowNode as ConnectorFlowNodeType } from './flowAdapters';
import { getHandleTypeTooltip } from './handleTooltip';
-import { useIsWorkflowImageExport } from './InvocationFlowNode';
/** An untyped ("any") connector end: a plain grid-tinted dot rather than a field-typed handle. */
const genericHandleStyle: React.CSSProperties = {
@@ -30,7 +29,6 @@ const getConnectorHandleStyle = (type: FieldType | null, side: 'left' | 'right')
const ConnectorFlowNodeComponent = ({ data, selected }: NodeProps<ConnectorFlowNodeType>) => {
const node = data.documentNode;
- const isWorkflowImageExport = useIsWorkflowImageExport();
const { t } = useTranslation();
const inputTooltip = getHandleTypeTooltip(data.inputFieldType, t('nodes.anyInput'), t);
const outputTooltip = getHandleTypeTooltip(data.outputFieldType, t('nodes.anyOutput'), t);
@@ -64,36 +62,6 @@ const ConnectorFlowNodeComponent = ({ data, selected }: NodeProps<ConnectorFlowN
<Tooltip content={outputTooltip} showArrow>
<Handle id={CONNECTOR_OUTPUT_HANDLE} position={Position.Right} style={outputHandleStyle} type="source" />
</Tooltip>
- {isWorkflowImageExport ? (
- <Stack
- align="center"
- bg="bg"
- borderColor="border.subtle"
- borderWidth="1px"
- data-workflow-export-content="true"
- gap="0.5"
- left="50%"
- maxW="14rem"
- overflowWrap="anywhere"
- position="absolute"
- px="2"
- py="1"
- rounded="sm"
- top="calc(100% + 0.25rem)"
- transform="translateX(-50%)"
- zIndex="2"
- >
- <Text data-workflow-export-connector-tooltip="true" fontSize="2xs">
- {inputTooltip}
- </Text>
- <Text data-workflow-export-connector-tooltip="true" fontSize="2xs" fontWeight="600">
- {connectorTooltip}
- </Text>
- <Text data-workflow-export-connector-tooltip="true" fontSize="2xs">
- {outputTooltip}
- </Text>
- </Stack>
- ) : null}
</Flex>
);
};
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 e453b467fb..df1a81160a 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/CurrentImageFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/CurrentImageFlowNode.tsx
@@ -3,7 +3,11 @@ import type { NodeProps } from '@xyflow/react';
import { Box, Flex, Text } from '@chakra-ui/react';
import { useProgressImage } from '@features/queue/react';
-import { getWorkflowNodeHeaderProps, getWorkflowNodeShellProps } from '@features/workflow/ui/nodeChrome';
+import {
+ getWorkflowNodeHeaderProps,
+ getWorkflowNodeShellProps,
+ useIsWorkflowImageExport,
+} from '@features/workflow/ui/nodeChrome';
import { useWorkflowProjectSelector } from '@features/workflow/ui/WorkflowUiContext';
import { StreamingImageFrame } from '@platform/ui/streaming-image/StreamingImageFrame';
import {
@@ -14,18 +18,15 @@ import { memo } from 'react';
import type { CurrentImageFlowNode as CurrentImageFlowNodeType } from './flowAdapters';
-import { useIsWorkflowImageExport } from './InvocationFlowNode';
-
const getLatestImage = (values: Record<string, unknown>): GeneratedImageContract | null => {
const recentImages = Array.isArray(values.recentImages) ? (values.recentImages as GeneratedImageContract[]) : [];
return recentImages[0] ?? null;
};
-const CurrentImageFlowNodeComponent = ({ data, selected }: NodeProps<CurrentImageFlowNodeType>) => {
+const CurrentImageEditorNode = ({ data, selected }: NodeProps<CurrentImageFlowNodeType>) => {
const galleryValues = useWorkflowProjectSelector((project) => project.galleryValues);
const progressImage = useProgressImage();
- const isWorkflowImageExport = useIsWorkflowImageExport();
const node = data.documentNode;
const latestImage = getLatestImage(galleryValues);
@@ -55,7 +56,7 @@ const CurrentImageFlowNodeComponent = ({ data, selected }: NodeProps<CurrentImag
})}
fit="contain"
h="18rem"
- liveImage={isWorkflowImageExport ? null : progressImageToStreamingSource(progressImage)}
+ liveImage={progressImageToStreamingSource(progressImage)}
w="full"
>
<Flex align="center" color="fg.subtle" fontSize="2xs" h="full" justify="center" px="4" textAlign="center">
@@ -66,4 +67,37 @@ const CurrentImageFlowNodeComponent = ({ data, selected }: NodeProps<CurrentImag
);
};
+const CurrentImageSnapshotNode = ({ data, selected }: NodeProps<CurrentImageFlowNodeType>) => {
+ const node = data.documentNode;
+
+ return (
+ <Box
+ data-is-selected={selected}
+ data-workflow-node-shell="true"
+ w="20rem"
+ {...getWorkflowNodeShellProps({ selected })}
+ >
+ <Flex {...getWorkflowNodeHeaderProps()}>
+ <Text
+ 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>
+ </Flex>
+ </Box>
+ );
+};
+
+const CurrentImageFlowNodeComponent = (props: NodeProps<CurrentImageFlowNodeType>) => {
+ const isWorkflowImageExport = useIsWorkflowImageExport();
+
+ return isWorkflowImageExport ? <CurrentImageSnapshotNode {...props} /> : <CurrentImageEditorNode {...props} />;
+};
+
export const CurrentImageFlowNode = memo(CurrentImageFlowNodeComponent);
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 393dd2d8b3..5857841d02 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
@@ -1,26 +1,40 @@
-import type { InvocationTemplate, ProjectGraphState, WorkflowInvocationNode } from '@features/workflow/contracts';
+import type {
+ InvocationTemplate,
+ ProjectGraphState,
+ WorkflowEdge,
+ WorkflowInvocationNode,
+} from '@features/workflow/contracts';
import type { WorkflowNodeExecutionState } from '@features/workflow/ui/contracts';
import type { WorkflowUiAdapter } from '@features/workflow/ui/WorkflowUiContext';
import type { ProjectGraphAction } from '@features/workflow/utility';
/* 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 { WorkflowImageExportProvider } from '@features/workflow/ui/nodeChrome';
import { WorkflowUiProvider } from '@features/workflow/ui/WorkflowUiContext';
import { setNodePreviewCollapsed } from '@features/workflow/ui/workflowUiStore';
-import { buildCurrentImageNode, createProjectGraph, projectGraphReducer } from '@features/workflow/utility';
+import {
+ buildCurrentImageNode,
+ buildNotesNode,
+ createProjectGraph,
+ projectGraphReducer,
+} from '@features/workflow/utility';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { system } from '@theme/system';
import { applyNodeChanges, ReactFlow, type NodeChange } from '@xyflow/react';
import { createInstance } from 'i18next';
import { act, createRef, startTransition, useCallback, useEffect, useState, useSyncExternalStore } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { page, userEvent } from 'vitest/browser';
+import { userEvent } from 'vitest/browser';
import { ConnectorFlowNode } from './ConnectorFlowNode';
import { CurrentImageFlowNode } from './CurrentImageFlowNode';
import { toFlowEdges, toFlowNodes } from './flowAdapters';
-import { InvocationFlowNode, WorkflowImageExportProvider } from './InvocationFlowNode';
-import { exportWorkflowAsPng, WORKFLOW_EXPORT_TIMEOUT_MS } from './workflowImageExport';
+import { InvocationFlowNode } from './InvocationFlowNode';
+import { LoopBodyBoundaryOverlay } from './LoopBodyBoundaryOverlay';
+import { NotesFlowNode } from './NotesFlowNode';
+import { exportWorkflowAsPng, getWorkflowContentBounds, WORKFLOW_EXPORT_TIMEOUT_MS } from './workflowImageExport';
import { WorkflowImageExportView } from './WorkflowImageExportView';
import '@xyflow/react/dist/style.css';
@@ -33,6 +47,13 @@ const exportMocks = vi.hoisted(() => ({
vi.mock('html-to-image', () => ({ toBlob: exportMocks.toBlob }));
vi.mock('@platform/browser/downloadBlob', () => ({ downloadBlob: vi.fn() }));
vi.mock('@features/queue/react', () => ({ useProgressImage: () => exportMocks.progressImage }));
+vi.mock('@features/generation/queries', () => ({
+ promptTemplatesQueryOptions: () => ({
+ queryFn: () => Promise.resolve([]),
+ queryKey: ['generation', 'promptTemplates', 'list'],
+ staleTime: 30_000,
+ }),
+}));
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
@@ -54,6 +75,7 @@ await i18n.init({
},
});
exportMocks.translate = (key, options) => i18n.t(key, options as never) as unknown as string;
+const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
const NODE_ID = 'preview-node';
/** The preview's fixed height (10rem) in CSS pixels, however the root font is sized. */
@@ -128,7 +150,12 @@ const flowNodes = toFlowNodes(projectGraph, [], templates);
const currentImageNode = buildCurrentImageNode({ x: 20, y: 20 });
const currentImageGraph: ProjectGraphState = { ...createProjectGraph('current-image-test'), nodes: [currentImageNode] };
const currentImageNodes = toFlowNodes(currentImageGraph, []);
-const nodeTypes = { connector: ConnectorFlowNode, current_image: CurrentImageFlowNode, invocation: InvocationFlowNode };
+const nodeTypes = {
+ connector: ConnectorFlowNode,
+ current_image: CurrentImageFlowNode,
+ invocation: InvocationFlowNode,
+ notes: NotesFlowNode,
+};
const callNodeId = 'call-node';
const callNode: WorkflowInvocationNode = {
@@ -256,6 +283,7 @@ describe('InvocationFlowNode output preview', () => {
beforeEach(() => {
setNodePreviewCollapsed(NODE_ID, false);
+ queryClient.clear();
host = document.createElement('div');
host.style.cssText = 'width: 480px; height: 520px;';
document.body.append(host);
@@ -273,17 +301,19 @@ describe('InvocationFlowNode output preview', () => {
act(() =>
root.render(
<ChakraProvider value={system}>
- <WorkflowImageExportProvider isExporting={isExporting}>
- <WorkflowUiProvider adapter={adapter}>
- <ReactFlow
- defaultViewport={{ x: 0, y: 0, zoom }}
- edges={[]}
- minZoom={0.1}
- nodes={nodes}
- nodeTypes={nodeTypes}
- />
- </WorkflowUiProvider>
- </WorkflowImageExportProvider>
+ <QueryClientProvider client={queryClient}>
+ <WorkflowImageExportProvider isExporting={isExporting}>
+ <WorkflowUiProvider adapter={adapter}>
+ <ReactFlow
+ defaultViewport={{ x: 0, y: 0, zoom }}
+ edges={[]}
+ minZoom={0.1}
+ nodes={nodes}
+ nodeTypes={nodeTypes}
+ />
+ </WorkflowUiProvider>
+ </WorkflowImageExportProvider>
+ </QueryClientProvider>
</ChakraProvider>
)
);
@@ -294,7 +324,104 @@ describe('InvocationFlowNode output preview', () => {
)!;
const nodeHeight = () => host.querySelector<HTMLElement>('.react-flow__node')!.getBoundingClientRect().height;
- it('keeps node and field descriptions plus full output values in the exported graph clone', async () => {
+ it('keeps field-description editing available in the workflow editor', async () => {
+ const adapter = createAdapter(createExecutionPort().port);
+ await render(adapter);
+
+ const trigger = host.querySelector<HTMLButtonElement>('button[aria-label="Edit field description"]');
+ expect(trigger).not.toBeNull();
+ await userEvent.click(trigger!);
+ const description = await vi.waitFor(() => {
+ const textarea = document.querySelector<HTMLTextAreaElement>('textarea[aria-label="Field description"]');
+ expect(textarea).not.toBeNull();
+ return textarea!;
+ });
+ await userEvent.fill(description, 'Authored field guidance');
+
+ expect(adapter.commands.editGraph).toHaveBeenCalledWith({
+ description: 'Authored field guidance',
+ fieldName: 'a',
+ nodeId: NODE_ID,
+ type: 'setFieldDescription',
+ });
+ });
+
+ it('renders authored notes as static text in snapshot exports', async () => {
+ const noteBody = Array.from({ length: 60 }, (_, index) => `Snapshot note line ${index + 1}`).join('\n');
+ const authoredNote = {
+ ...buildNotesNode({ x: 20, y: 20 }),
+ data: { label: 'Planning note', notes: noteBody },
+ };
+ const emptyNote = {
+ ...buildNotesNode({ x: 320, y: 20 }),
+ data: { label: 'Empty note', notes: '' },
+ };
+ const graph = { ...projectGraph, nodes: [authoredNote, emptyNote] };
+ const nodes = toFlowNodes(graph, []);
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ let capturedClone: HTMLElement | undefined;
+ let capturedOptions: { height?: number } | undefined;
+ exportMocks.toBlob.mockImplementation((clone: HTMLElement, options: { height?: number }) => {
+ capturedClone = clone;
+ capturedOptions = options;
+ return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
+ });
+
+ await render(adapter, 1, true, nodes);
+ await exportWorkflowAsPng({
+ bounds: { x: 20, y: 20, width: 500, height: 260 },
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,
+ workflowName: 'Notes',
+ });
+
+ expect(capturedClone?.textContent).toContain('Planning note');
+ expect(capturedClone?.textContent).toContain('Snapshot note line 60');
+ expect(capturedClone?.textContent).toContain('Empty note');
+ expect(capturedClone?.textContent).not.toContain('Write a note');
+ expect(capturedClone?.querySelector('input[aria-label="Note title"]')).toBeNull();
+ expect(capturedClone?.querySelector('textarea[aria-label="Note text"]')).toBeNull();
+ expect(capturedOptions?.height).toBeGreaterThan(500);
+ });
+
+ it('omits editor checkboxes from executable image-output nodes in snapshot exports', async () => {
+ const imageTemplate: InvocationTemplate = {
+ ...template,
+ inputs: {},
+ outputs: {
+ image: {
+ description: '',
+ name: 'image',
+ title: 'Image',
+ type: { batch: false, cardinality: 'SINGLE', name: 'ImageField' },
+ },
+ },
+ type: 'txt2img',
+ };
+ const imageNode = { ...documentNode, data: { ...documentNode.data, type: 'txt2img' } };
+ const graph = { ...projectGraph, nodes: [imageNode] };
+ const nodes = toFlowNodes(graph, [], { txt2img: imageTemplate });
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ let capturedClone: HTMLElement | undefined;
+ exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
+ capturedClone = clone;
+ return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
+ });
+
+ await render(adapter, 1, true, nodes);
+ await exportWorkflowAsPng({
+ bounds: { x: 20, y: 20, width: 300, height: 260 },
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,
+ workflowName: 'Image output',
+ });
+
+ expect(capturedClone?.textContent).not.toContain('Use Cache');
+ expect(capturedClone?.textContent).not.toContain('Save to Gallery');
+ expect(capturedClone?.querySelector('input[type="checkbox"]')).toBeNull();
+ });
+
+ it('exports authored field labels without tooltip metadata or execution results', async () => {
const longOutput = 'x'.repeat(60);
const longOutputTitle = 'An output title that is deliberately long enough to wrap instead of truncating';
const exportTemplate: InvocationTemplate = {
@@ -320,6 +447,7 @@ describe('InvocationFlowNode output preview', () => {
},
isOpen: false,
notes: 'Node export note',
+ version: '0.9.0',
},
};
const exportConnector = {
@@ -343,13 +471,12 @@ describe('InvocationFlowNode output preview', () => {
execution.set({
error: null,
latestOutput: { value: longOutput },
- outputImageUrl: null,
+ outputImageUrl: 'data:image/png;base64,cHJldmlldw==',
progress: null,
progressMessage: null,
status: 'completed',
})
);
- await page.screenshot({ path: '../../../../../artifacts/workflow-export-content.png' });
const flowElement = host.querySelector<HTMLElement>('.react-flow')!;
await exportWorkflowAsPng({
@@ -359,28 +486,82 @@ describe('InvocationFlowNode output preview', () => {
workflowName: 'Export content',
});
- expect(capturedClone?.textContent).toContain('Node export description');
- expect(capturedClone?.textContent).toContain('Node export note');
- expect(capturedClone?.textContent).toContain('Field export description');
- expect(capturedClone?.textContent).toContain('Output export description');
- expect(capturedClone?.textContent).toContain('Type: preview');
- expect(capturedClone?.textContent).toContain('Node pack: invokeai');
- expect(capturedClone?.textContent).toContain('Version: 1.0.0');
- expect(capturedClone?.textContent).toContain('Classification: stable');
- expect(capturedClone?.textContent).toContain('Category: Export category');
- expect(capturedClone?.textContent).toContain('Field: a');
- expect(capturedClone?.textContent).toContain('Type: Integer');
- expect(capturedClone?.textContent).toContain('Connection only');
- expect(capturedClone?.textContent).toContain('Output');
- expect(capturedClone?.textContent).toContain('Any input');
- expect(capturedClone?.textContent).toContain('Connector: Any input → Any output');
- expect(capturedClone?.textContent).toContain('Any output');
- expect(capturedClone?.textContent).toContain(longOutput);
+ expect(capturedClone?.textContent).not.toContain('Node export description');
+ expect(capturedClone?.textContent).not.toContain('Node export note');
+ expect(capturedClone?.textContent).not.toContain('Field export description');
+ expect(capturedClone?.textContent).not.toContain('Output export description');
+ expect(capturedClone?.textContent).not.toContain('Type: preview');
+ expect(capturedClone?.textContent).not.toContain('Node pack: invokeai');
+ expect(capturedClone?.textContent).not.toContain('Version: 1.0.0');
+ expect(capturedClone?.textContent).not.toContain('Classification: stable');
+ expect(capturedClone?.textContent).not.toContain('Category: Export category');
+ expect(capturedClone?.textContent).not.toContain('Field: a');
+ expect(capturedClone?.textContent).not.toContain('Type: Integer');
+ expect(capturedClone?.textContent).not.toContain('Connection only');
+ expect(capturedClone?.textContent).not.toContain('Any input');
+ expect(capturedClone?.textContent).not.toContain('Connector: Any input → Any output');
+ expect(capturedClone?.textContent).not.toContain('Any output');
+ expect(capturedClone?.textContent).not.toContain(longOutput);
+ expect(capturedClone?.querySelector('.react-flow__node img')).toBeNull();
+ expect(capturedClone?.querySelector('[data-node-input-field-title="true"]')?.textContent).toContain('A');
const outputTitle = capturedClone?.querySelector<HTMLElement>('[data-workflow-export-output-title="true"]');
expect(outputTitle?.textContent).toBe(longOutputTitle);
expect(outputTitle && getComputedStyle(outputTitle).whiteSpace).not.toBe('nowrap');
- expect(capturedClone?.querySelectorAll('[data-workflow-export-connector-tooltip="true"]')).toHaveLength(5);
- expect(capturedClone?.querySelectorAll('[data-workflow-export-content="true"]').length).toBeGreaterThanOrEqual(4);
+ expect(capturedClone?.querySelectorAll('[data-workflow-export-connector-tooltip="true"]')).toHaveLength(0);
+ expect(capturedClone?.querySelectorAll('[data-workflow-export-content="true"]')).toHaveLength(0);
+ expect(capturedClone?.querySelector('[data-node-info-icon="true"]')).toBeNull();
+ expect(capturedClone?.querySelector('svg[aria-label]')).toBeNull();
+ expect(capturedClone?.querySelector('button[aria-label="Collapse node"]')).toBeNull();
+ });
+
+ it('wraps and measures long authored node labels in the static export', async () => {
+ const invocationLabel = 'Authored invocation label '.repeat(24);
+ const currentImageLabel = `Authored current image ${'unbroken-label-'.repeat(24)}`;
+ const invocationNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: { ...documentNode.data, label: invocationLabel },
+ id: 'long-label-node',
+ };
+ const imageNode = {
+ ...buildCurrentImageNode({ x: 420, y: 20 }),
+ data: { label: currentImageLabel },
+ id: 'long-current-image-node',
+ };
+ const graph = { ...projectGraph, nodes: [invocationNode, imageNode] };
+ const nodes = toFlowNodes(graph, [], { preview: template });
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ let capturedClone: HTMLElement | undefined;
+ exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
+ capturedClone = clone;
+ return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
+ });
+
+ await render(adapter, 1, true, nodes);
+ const flowElement = host.querySelector<HTMLElement>('.react-flow')!;
+ const invocationTitle = host.querySelector<HTMLElement>(
+ '.react-flow__node[data-id="long-label-node"] [data-workflow-export-node-title="true"]'
+ );
+ const imageTitle = host.querySelector<HTMLElement>(
+ '.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(imageTitle?.textContent).toBe(currentImageLabel);
+ expect(getComputedStyle(imageTitle!).overflowWrap).toBe('anywhere');
+ expect(invocationTitle?.dataset.workflowExportStaticNodeContent).toBe('true');
+ expect(imageTitle?.dataset.workflowExportStaticNodeContent).toBe('true');
+
+ const bounds = getWorkflowContentBounds(flowElement, { x: 20, y: 20, width: 720, height: 100 });
+ expect(bounds.height).toBeGreaterThan(100);
+ await exportWorkflowAsPng({
+ bounds,
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement,
+ workflowName: 'Long labels',
+ });
+
+ expect(capturedClone?.textContent).toContain(invocationLabel);
+ expect(capturedClone?.textContent).toContain(currentImageLabel);
});
it('keeps running progress in the editor but omits it from the exported graph clone', async () => {
@@ -418,7 +599,211 @@ describe('InvocationFlowNode output preview', () => {
expect(capturedClone?.querySelector('[data-node-progress-strip="true"]')).toBeNull();
});
- it('uses the saved current image in exports while the editor shows the live generation frame', async () => {
+ it('omits field validation diagnostics from the static export', async () => {
+ const requiredTemplate: InvocationTemplate = {
+ ...template,
+ inputs: { a: { ...template.inputs.a!, input: 'direct', required: true } },
+ };
+ const incompleteNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: { ...documentNode.data, inputs: { a: { label: 'A', name: 'a', value: undefined } } },
+ };
+ const nodes = toFlowNodes({ ...projectGraph, nodes: [incompleteNode] }, [], { preview: requiredTemplate });
+ const adapter = createAdapter(createExecutionPort().port);
+ let capturedClone: HTMLElement | undefined;
+ exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
+ capturedClone = clone;
+ return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
+ });
+
+ await render(adapter, 1, true, nodes);
+ await exportWorkflowAsPng({
+ bounds: { x: 20, y: 20, width: 300, height: 260 },
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,
+ workflowName: 'Incomplete workflow',
+ });
+
+ expect(capturedClone?.querySelector('[data-part="error-text"]')).toBeNull();
+ expect(capturedClone?.querySelector('[aria-invalid="true"]')).toBeNull();
+ expect(capturedClone?.textContent).not.toContain('Required value.');
+ });
+
+ it('renders stale record field values without picker diagnostics or controls in snapshot exports', async () => {
+ const styleTemplate: InvocationTemplate = {
+ ...template,
+ inputs: {
+ a: {
+ ...template.inputs.a!,
+ input: 'direct',
+ title: 'Style Preset',
+ type: { batch: false, cardinality: 'SINGLE', name: 'StylePresetField' },
+ },
+ },
+ };
+ const styleNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: {
+ ...documentNode.data,
+ inputs: { a: { label: 'Style Preset', name: 'a', value: { style_preset_id: 'missing-preset' } } },
+ isOpen: true,
+ },
+ };
+ const graph = { ...projectGraph, nodes: [styleNode] };
+ const nodes = toFlowNodes(graph, [], { preview: styleTemplate });
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ queryClient.setQueryData(['generation', 'promptTemplates', 'list'], []);
+ let capturedClone: HTMLElement | undefined;
+ exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
+ capturedClone = clone;
+ return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
+ });
+
+ await render(adapter, 1, false, nodes);
+ await vi.waitFor(() => expect(host.textContent).toContain(i18n.t('nodes.stylePresetMissing')));
+ await render(adapter, 1, true, nodes);
+ await exportWorkflowAsPng({
+ bounds: { x: 20, y: 20, width: 300, height: 260 },
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,
+ workflowName: 'Stale style preset',
+ });
+
+ expect(capturedClone?.textContent).toContain('missing-preset');
+ expect(capturedClone?.textContent).not.toContain(i18n.t('nodes.stylePresetMissing'));
+ expect(capturedClone?.querySelector('input')).toBeNull();
+ expect(capturedClone?.querySelector('button')).toBeNull();
+ });
+
+ it('omits legacy generator results while preserving generator settings in snapshot exports', async () => {
+ const generatorTemplate: InvocationTemplate = {
+ ...template,
+ inputs: {
+ a: {
+ ...template.inputs.a!,
+ input: 'direct',
+ title: 'Values',
+ type: { batch: false, cardinality: 'SINGLE', name: 'FloatGeneratorField' },
+ },
+ },
+ };
+ const generatorValue = {
+ type: 'float_generator_arithmetic_sequence',
+ start: 0,
+ step: 0.2,
+ count: 3,
+ values: [0.2, 0.4, 0.6],
+ };
+ const generatorNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: {
+ ...documentNode.data,
+ inputs: { a: { label: 'Values', name: 'a', value: generatorValue } },
+ isOpen: true,
+ },
+ };
+ const graph = { ...projectGraph, nodes: [generatorNode] };
+ const nodes = toFlowNodes(graph, [], { preview: generatorTemplate });
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ let capturedClone: HTMLElement | undefined;
+ exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
+ capturedClone = clone;
+ return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
+ });
+
+ await render(adapter, 1, true, nodes);
+ await exportWorkflowAsPng({
+ bounds: { x: 20, y: 20, width: 300, height: 260 },
+ fallbackWorkflowName: 'Untitled Workflow',
+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,
+ workflowName: 'Generator workflow',
+ });
+
+ const fieldValue = capturedClone?.querySelector<HTMLElement>('[data-workflow-export-field-value="true"]');
+ expect(fieldValue?.textContent).toBe(
+ '{"type":"float_generator_arithmetic_sequence","start":0,"step":0.2,"count":3}'
+ );
+ expect(capturedClone?.textContent).not.toContain('0.2, 0.4, 0.6');
+ expect(capturedClone?.querySelector('input')).toBeNull();
+ expect(capturedClone?.querySelector('button')).toBeNull();
+ });
+
+ it('removes loop validation status from static boundary labels', async () => {
+ const forNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: { ...documentNode.data, type: 'for', label: 'For' },
+ id: 'for-node',
+ };
+ const bodyNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: { ...documentNode.data, type: 'number', label: 'Body' },
+ id: 'body-node',
+ position: { x: 300, y: 20 },
+ };
+ const returnNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: { ...documentNode.data, type: 'for_return', label: 'Return' },
+ id: 'return-node',
+ position: { x: 600, y: 20 },
+ };
+ const edges: WorkflowEdge[] = [
+ {
+ id: 'iteration-edge',
+ source: forNode.id,
+ sourceHandle: 'item',
+ target: bodyNode.id,
+ targetHandle: 'value',
+ type: 'default',
+ },
+ {
+ id: 'return-edge',
+ source: bodyNode.id,
+ sourceHandle: 'value',
+ target: returnNode.id,
+ targetHandle: 'output',
+ type: 'default',
+ },
+ ];
+ const graph = { ...projectGraph, edges, nodes: [forNode, bodyNode, returnNode] };
+ const nodes = toFlowNodes(graph, [], {});
+ const adapter = createAdapter(createExecutionPort().port);
+ const renderBoundary = (isExporting: boolean) =>
+ act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <WorkflowImageExportProvider isExporting={isExporting}>
+ <WorkflowUiProvider adapter={adapter}>
+ <ReactFlow edges={[]} nodes={nodes} nodeTypes={nodeTypes}>
+ <LoopBodyBoundaryOverlay edges={edges} nodes={graph.nodes} />
+ </ReactFlow>
+ </WorkflowUiProvider>
+ </WorkflowImageExportProvider>
+ </ChakraProvider>
+ )
+ );
+
+ await renderBoundary(false);
+ const editorBoundary = await vi.waitFor(() => {
+ const boundary = host.querySelector<HTMLElement>('[data-loop-body-boundary="for-node"]');
+ expect(boundary).not.toBeNull();
+ return boundary!;
+ });
+ expect(editorBoundary.getAttribute('data-loop-body-status')).toBe('missing_linkage');
+ expect(editorBoundary.getAttribute('aria-label')).toContain(
+ i18n.t('nodes.forLoopBodyBoundaryStatus.missing_linkage')
+ );
+
+ await renderBoundary(true);
+ const snapshotBoundary = await vi.waitFor(() => {
+ const boundary = host.querySelector<HTMLElement>('[data-loop-body-boundary="for-node"]');
+ expect(boundary).not.toBeNull();
+ return boundary!;
+ });
+ expect(snapshotBoundary.getAttribute('aria-label')).toBe(i18n.t('nodes.forLoopBodyBoundary'));
+ expect(snapshotBoundary.hasAttribute('data-loop-body-status')).toBe(false);
+ });
+
+ it('omits gallery images from static exports while the editor shows the live generation frame', async () => {
const liveImageUrl = 'data:image/png;base64,bGl2ZQ==';
const savedImageUrl = 'data:image/png;base64,c2F2ZWQ=';
let capturedClone: HTMLElement | undefined;
@@ -454,109 +839,145 @@ describe('InvocationFlowNode output preview', () => {
});
const exportedImage = capturedClone?.querySelector<HTMLImageElement>('.react-flow__node img');
- expect(exportedImage?.src).toBe(savedImageUrl);
- expect(exportedImage?.src).not.toBe(liveImageUrl);
+ expect(exportedImage).toBeNull();
+ expect(capturedClone?.textContent).not.toContain('No image yet');
+ expect(capturedClone?.textContent).not.toContain('generating');
});
- it('localizes exported field and connector metadata using the selected language catalog', async () => {
- await i18n.changeLanguage('fr');
- const batchType = { ...template.inputs.a!.type, batch: true };
- const localizedTemplate: InvocationTemplate = {
- ...template,
- inputs: { a: { ...template.inputs.a!, required: true, type: batchType } },
- outputs: { value: { ...template.outputs.value!, type: batchType } },
- };
- const localizedNode: WorkflowInvocationNode = {
- ...documentNode,
- data: { ...documentNode.data, inputs: { a: { label: 'A', name: 'a', value: null } } },
- };
- const connector = {
- data: { label: '' },
- id: 'localized-connector',
- position: { x: 380, y: 300 },
- type: 'connector' as const,
- };
- const batchConnector = {
- data: { label: '' },
- id: 'localized-batch-connector',
- position: { x: 500, y: 300 },
- type: 'connector' as const,
- };
- const graph = { ...projectGraph, nodes: [localizedNode, connector, batchConnector] };
- const nodes = toFlowNodes(graph, [], { preview: localizedTemplate });
- const localizedConnector = nodes.find(
- (node) => node.type === 'connector' && node.data.documentNode.id === 'localized-batch-connector'
- );
- if (localizedConnector?.type === 'connector') {
- localizedConnector.data.inputFieldType = batchType;
- localizedConnector.data.outputFieldType = batchType;
- }
- const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+ it('omits failure status and backend diagnostics from the static export', async () => {
+ const execution = createExecutionPort(callNodeId);
+ execution.set({
+ error: 'Child node failed',
+ latestOutput: null,
+ outputImageUrl: null,
+ progress: null,
+ progressMessage: null,
+ status: 'failed',
+ });
+ const adapter = createAdapter(execution.port);
let capturedClone: HTMLElement | undefined;
exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
capturedClone = clone;
return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
});
- await render(adapter, 1, true, nodes);
+ await render(adapter, 1, true, callFlowNodes);
const flowElement = host.querySelector<HTMLElement>('.react-flow')!;
await exportWorkflowAsPng({
bounds: { x: 20, y: 20, width: 300, height: 260 },
fallbackWorkflowName: 'Untitled Workflow',
flowElement,
- workflowName: 'Workflow localisé',
+ workflowName: 'Failed workflow',
});
- const exportedText = capturedClone?.textContent ?? '';
- expect(exportedText).toContain('Champ : a');
- expect(exportedText).toContain('Type : Integer');
- expect(exportedText).toContain('Obligatoire');
- expect(exportedText).toContain('Connexion uniquement');
- expect(exportedText).toContain('Integer en lot');
- expect(exportedText).not.toContain(' batch');
- expect(exportedText).toContain('N’importe quelle entrée');
- expect(exportedText).toContain('Connecteur : N’importe quelle entrée → N’importe quelle sortie');
- expect(exportedText).toContain('N’importe quelle sortie');
+ expect(capturedClone?.querySelector('[data-node-status-indicator="true"]')).toBeNull();
+ expect(capturedClone?.textContent).not.toContain('Failed');
+ expect(capturedClone?.textContent).not.toContain('Child node failed');
+ expect(capturedClone?.textContent).not.toContain('Child workflow error');
});
- it('marks a failed node in the export without including its backend diagnostic', async () => {
- const execution = createExecutionPort(callNodeId);
- execution.set({
- error: 'Child node failed',
- latestOutput: null,
- outputImageUrl: null,
- progress: null,
- progressMessage: null,
- status: 'failed',
- });
- const adapter = createAdapter(execution.port);
+ it('omits missing-template diagnostics from the static export', async () => {
+ const unknownLabel = `Preserved unknown node ${'x'.repeat(240)}`;
+ const unknownNode: WorkflowInvocationNode = {
+ ...documentNode,
+ data: { ...documentNode.data, label: unknownLabel, type: 'removed_invocation' },
+ id: 'unknown-node',
+ position: { x: 420, y: 20 },
+ };
+ const graph = { ...projectGraph, nodes: [documentNode, unknownNode] };
+ const nodes = toFlowNodes(graph, [], { preview: template });
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
let capturedClone: HTMLElement | undefined;
exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
capturedClone = clone;
return Promise.resolve(new Blob(['png'], { type: 'image/png' }));
});
- await render(adapter, 1, true, callFlowNodes);
- await page.screenshot({ path: '../../../../../artifacts/workflow-export-failed-label.png' });
+ await render(adapter, 1, true, nodes);
const flowElement = host.querySelector<HTMLElement>('.react-flow')!;
+ const knownShell = host.querySelector<HTMLElement>(
+ '.react-flow__node[data-id="preview-node"] [data-workflow-node-shell="true"]'
+ );
+ const unknownShell = host.querySelector<HTMLElement>(
+ '.react-flow__node[data-id="unknown-node"] [data-workflow-node-shell="true"]'
+ );
+ const unknownTitle = unknownShell?.querySelector<HTMLElement>('p');
+ expect(unknownShell?.textContent).toContain(unknownLabel);
+ 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(unknownTitle?.dataset.workflowExportStaticNodeContent).toBe('true');
+
+ const bounds = getWorkflowContentBounds(flowElement, { x: 20, y: 20, width: 600, height: 100 });
+ expect(bounds.height).toBeGreaterThan(100);
+
await exportWorkflowAsPng({
- bounds: { x: 20, y: 20, width: 300, height: 260 },
+ bounds,
fallbackWorkflowName: 'Untitled Workflow',
flowElement,
- workflowName: 'Failed workflow',
+ workflowName: 'Unknown node',
});
- expect(capturedClone?.querySelector('[data-node-status-indicator="true"]')?.getAttribute('style')).toContain(
- 'display: none'
+ expect(capturedClone?.textContent).toContain(unknownLabel);
+ expect(capturedClone?.textContent).not.toContain('Unknown node type');
+ });
+
+ it('removes editor selection styling from nodes and edges in the static export', async () => {
+ const targetNode = { ...documentNode, id: 'target-node', position: { x: 420, y: 20 } };
+ const graph: ProjectGraphState = {
+ ...projectGraph,
+ edges: [
+ {
+ id: 'edge',
+ source: NODE_ID,
+ sourceHandle: 'value',
+ target: targetNode.id,
+ targetHandle: 'a',
+ type: 'default',
+ },
+ ],
+ nodes: [documentNode, targetNode],
+ };
+ const nodes = toFlowNodes(graph, [], { preview: template }).map((node) => ({
+ ...node,
+ selected: node.id === NODE_ID,
+ }));
+ const edges = toFlowEdges(graph, [], 'default', new Set([NODE_ID]), { preview: template });
+ const exportRef = createRef<HTMLDivElement>();
+ const adapter = createAdapter(createExecutionPort().port, projectSnapshotFor(graph));
+
+ await act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <WorkflowUiProvider adapter={adapter}>
+ <WorkflowImageExportView containerRef={exportRef} edges={edges} nodes={nodes} nodeTypes={nodeTypes} />
+ </WorkflowUiProvider>
+ </ChakraProvider>
+ )
);
- expect(capturedClone?.textContent).toContain('Failed');
- expect(capturedClone?.textContent).not.toContain('Child node failed');
- expect(capturedClone?.textContent).not.toContain('Child workflow error');
+
+ const selectedShell = exportRef.current?.querySelector<HTMLElement>(
+ '.react-flow__node[data-id="preview-node"] [data-workflow-node-shell="true"]'
+ );
+ const plainShell = exportRef.current?.querySelector<HTMLElement>(
+ '.react-flow__node[data-id="target-node"] [data-workflow-node-shell="true"]'
+ );
+ expect(selectedShell).not.toBeNull();
+ expect(plainShell).not.toBeNull();
+ expect(getComputedStyle(selectedShell!).boxShadow).toBe(getComputedStyle(plainShell!).boxShadow);
+ expect(exportRef.current?.querySelector('.react-flow__edge.workflow-selected-node-edge')).toBeNull();
+ expect(exportRef.current?.querySelector('.react-flow__edge.animated')).toBeNull();
});
it('keeps the visible collapsed node unchanged while an expanded offscreen snapshot is rasterizing', async () => {
const node = { ...documentNode, data: { ...documentNode.data, isOpen: false, notes: 'Snapshot metadata' } };
- const directNode = { ...documentNode, id: 'direct-node', position: { x: 20, y: 100 } };
+ const directNode = {
+ ...documentNode,
+ data: { ...documentNode.data, inputs: { a: { label: 'A', name: 'a', value: 42 } } },
+ id: 'direct-node',
+ position: { x: 20, y: 100 },
+ };
const graph = { ...projectGraph, nodes: [node, directNode] };
const directTemplate = { ...template, inputs: { a: { ...template.inputs.a!, input: 'direct' as const } } };
const nodes = toFlowNodes(graph, [], { preview: directTemplate });
@@ -600,15 +1021,16 @@ describe('InvocationFlowNode output preview', () => {
const visibleInput = visible.querySelector<HTMLInputElement>('input');
const offscreenInput = exportRef.current!.querySelector<HTMLInputElement>('input');
expect(visibleInput).not.toBeNull();
- expect(offscreenInput).not.toBeNull();
- expect(visibleInput?.id).not.toBe(offscreenInput?.id);
- expect(capturedClone?.textContent).toContain('Snapshot metadata');
- await page.screenshot({ path: '../../../../../artifacts/workflow-export-pending.png' });
+ expect(offscreenInput).toBeNull();
+ expect(capturedClone?.textContent).not.toContain('Snapshot metadata');
+ expect(capturedClone?.textContent).toContain('42');
+ expect(capturedClone?.querySelector('input')).toBeNull();
+ expect(capturedClone?.querySelector('button[aria-label="Collapse node"]')).toBeNull();
finish(new Blob(['png'], { type: 'image/png' }));
await capture;
});
- it.each(['running', 'failed'] as const)('omits retained results from a %s retry snapshot', async (status) => {
+ it.each(['completed', 'running', 'failed'] as const)('omits execution results from a %s snapshot', async (status) => {
const execution = createExecutionPort();
const completed = {
error: null,
@@ -621,7 +1043,7 @@ describe('InvocationFlowNode output preview', () => {
execution.set(completed);
const adapter = createAdapter(execution.port);
await render(adapter, 1, true);
- expect(host.textContent).toContain('previous result');
+ expect(host.textContent).not.toContain('previous result');
await act(() => execution.set({ ...completed, status }));
let capturedClone: HTMLElement | undefined;
exportMocks.toBlob.mockImplementation((clone: HTMLElement) => {
@@ -636,9 +1058,7 @@ describe('InvocationFlowNode output preview', () => {
});
expect(capturedClone?.textContent).not.toContain('previous result');
expect(capturedClone?.querySelector('img')).toBeNull();
- if (status === 'failed') {
- expect(capturedClone?.textContent).toContain('Failed');
- }
+ expect(capturedClone?.textContent).not.toContain('Failed');
});
it('blocks a third capture after two timeouts and recovers when one rasterization settles', async () => {
@@ -709,7 +1129,6 @@ describe('InvocationFlowNode output preview', () => {
await act(() => execution.set(completed(outputImage(400, 100))));
await vi.waitFor(() => expect(image()!.getBoundingClientRect().height).toBeCloseTo(previewHeightPx(), 0));
const heightWithWideOutput = nodeHeight();
- await page.screenshot({ path: '../../../../../artifacts/workflow-node-preview/expanded.png' });
await act(() => execution.set(completed(outputImage(100, 400))));
await vi.waitFor(() => expect(image()!.src).toBe(outputImage(100, 400)));
@@ -720,7 +1139,6 @@ describe('InvocationFlowNode output preview', () => {
expect(disclosure().getAttribute('aria-expanded')).toBe('false');
expect(image()).toBeNull();
expect(nodeHeight()).toBeLessThan(heightWithWideOutput - 100);
- await page.screenshot({ path: '../../../../../artifacts/workflow-node-preview/collapsed.png' });
// The fold outlives the node's mount: a remount (offscreen virtualization, a project switch back) keeps it.
await act(() => root.unmount());
@@ -752,14 +1170,14 @@ describe('InvocationFlowNode output preview', () => {
expect(node().offsetHeight).toBe(layoutHeight);
});
- it('renders full node content for image export when the viewport is zoomed out', async () => {
+ it('omits completed output previews from image exports when zoomed out', async () => {
const execution = createExecutionPort();
const adapter = createAdapter(execution.port);
execution.set(completed(outputImage(400, 100)));
await render(adapter, 0.3, true);
- await vi.waitFor(() => expect(image()).not.toBeNull());
+ expect(image()).toBeNull();
});
it('renders full fields for compact nodes during image export', async () => {
@@ -777,7 +1195,8 @@ describe('InvocationFlowNode output preview', () => {
await render(adapter, 1, true, compactNodes);
expect(host.querySelector('[data-node-input-field-title="true"]')?.textContent).toContain('A');
- expect(host.querySelector<HTMLInputElement>('.react-flow__node input')?.value).toBe('42');
+ expect(host.querySelector('.react-flow__node input')).toBeNull();
+ expect(host.querySelector('[data-workflow-export-field-value="true"]')?.textContent).toBe('42');
});
});
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 4b8a1a899d..1a649f39a4 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
@@ -18,7 +18,7 @@ import {
} from '@chakra-ui/react';
import { getWorkflowFieldSeedMode, isSeedInputField } from '@features/workflow/graph';
import { FieldDescriptionPopover } from '@features/workflow/ui/fields/FieldDescriptionPopover';
-import { WorkflowFieldInput } from '@features/workflow/ui/fields/WorkflowFieldInput';
+import { WorkflowFieldInput, WorkflowFieldSnapshot } from '@features/workflow/ui/fields/WorkflowFieldInput';
import {
getWorkflowNodeBodyProps,
getWorkflowNodeHandleStyle,
@@ -28,6 +28,7 @@ import {
WORKFLOW_NODE_SURFACE_TOKEN,
WorkflowNodeInfoIcon,
WorkflowNodeOutcomeIcon,
+ useIsWorkflowImageExport,
type WorkflowNodeOutcome,
} from '@features/workflow/ui/nodeChrome';
import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';
@@ -54,16 +55,7 @@ import { Tooltip } from '@platform/ui';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { Handle, Position, useStore, type NodeProps } from '@xyflow/react';
import { ChevronDownIcon, ChevronRightIcon, PinIcon, PinOffIcon, RotateCcwIcon, TriangleAlertIcon } from 'lucide-react';
-import {
- createContext,
- memo,
- useContext,
- useId,
- useState,
- type ChangeEvent,
- type KeyboardEvent,
- type ReactNode,
-} from 'react';
+import { memo, useId, useState, type ChangeEvent, type KeyboardEvent } from 'react';
import { useTranslation } from 'react-i18next';
import type { InvocationFlowNode as InvocationFlowNodeType, InvocationNodeTemplateView } from './flowAdapters';
@@ -76,18 +68,6 @@ const ROW_PADDING_X = 12;
/** Below this viewport zoom, field content renders as skeleton bars (ComfyUI-style) for performance/readability. */
const CONTENT_VISIBILITY_ZOOM = 0.4;
-const WorkflowImageExportContext = createContext(false);
-
-export const WorkflowImageExportProvider = ({
- children,
- isExporting,
-}: {
- children: ReactNode;
- isExporting: boolean;
-}) => <WorkflowImageExportContext value={isExporting}>{children}</WorkflowImageExportContext>;
-
-export const useIsWorkflowImageExport = () => useContext(WorkflowImageExportContext);
-
/** True while the viewport is zoomed out far enough that field content is unreadable noise. */
const useIsZoomedOut = (): boolean => {
const isWorkflowImageExport = useIsWorkflowImageExport();
@@ -235,10 +215,34 @@ const NodeProgressStrip = ({ execution }: { execution: NodeExecutionState | null
);
};
-const NodeTitle = ({ node, title }: { node: WorkflowInvocationNode; title: string }) => {
+const NodeTitle = ({
+ isWorkflowImageExport,
+ node,
+ title,
+}: {
+ isWorkflowImageExport: boolean;
+ node: WorkflowInvocationNode;
+ title: string;
+}) => {
const { editGraph } = useProjectGraphCommands();
const [draftLabel, setDraftLabel] = useState<string | null>(null);
+ if (isWorkflowImageExport) {
+ return (
+ <Text
+ 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>
+ );
+ }
+
if (draftLabel !== null) {
return (
<Input
@@ -391,11 +395,9 @@ const NodeUpdateIcon = ({
};
const NodeInfoTooltipContent = ({
- isFailed = false,
node,
template,
}: {
- isFailed?: boolean;
node: WorkflowInvocationNode;
template: InvocationNodeTemplateView['template'];
}) => {
@@ -413,7 +415,6 @@ const NodeInfoTooltipContent = ({
{updateStatusText ? <Text color="fg.warning">{updateStatusText}</Text> : null}
<Text color="fg.subtle">{t('nodes.nodeClassification', { classification: template.classification })}</Text>
<Text color="fg.subtle">{t('nodes.nodeCategory', { category: template.category })}</Text>
- {isFailed ? <Text color="fg.error">{t('nodes.executionFailed')}</Text> : null}
{template.description ? <Text fontStyle="italic">{template.description}</Text> : null}
{node.data.notes ? <Text>{node.data.notes}</Text> : null}
</Stack>
@@ -594,8 +595,26 @@ const InputFieldRow = ({
value: instance?.value,
});
const isInvalid = invalidReason !== null;
+ const showInvalid = isInvalid && !isWorkflowImageExport;
const handleTooltip = getHandleTypeTooltip(template.type, t('nodes.any'), t);
- const canReset = showsControl && !isWorkflowFieldValueDefault(template, instance?.value);
+ const canReset = !isWorkflowImageExport && showsControl && !isWorkflowFieldValueDefault(template, instance?.value);
+ const fieldTitle = (
+ <Text
+ color={showInvalid ? 'fg.error' : isConnected ? 'fg.muted' : 'fg'}
+ data-node-input-field-title="true"
+ fontSize="2xs"
+ lineHeight="shorter"
+ minW="0"
+ truncate
+ >
+ {label}
+ {template.required ? (
+ <Text as="span" color="fg.error">
+ {' *'}
+ </Text>
+ ) : null}
+ </Text>
+ );
if (isSkeleton) {
return (
@@ -619,8 +638,13 @@ const InputFieldRow = ({
}
return (
- <Box px={WORKFLOW_NODE_DENSITY.rowPaddingX} py={WORKFLOW_NODE_DENSITY.rowPaddingY} w="full">
- <Field.Root gap="0" invalid={isInvalid} minW="0" w="full">
+ <Box
+ data-workflow-export-field-content={isWorkflowImageExport ? 'true' : undefined}
+ px={WORKFLOW_NODE_DENSITY.rowPaddingX}
+ py={WORKFLOW_NODE_DENSITY.rowPaddingY}
+ w="full"
+ >
+ <Field.Root gap="0" invalid={isInvalid && !isWorkflowImageExport} minW="0" w="full">
{/* The handle lives inside the label row so it stays centered on the
label even when the value control below grows the row. */}
<HStack gap="1.5" h="5" justify="space-between" minW="0" position="relative" w="full">
@@ -634,34 +658,24 @@ const InputFieldRow = ({
/>
</Tooltip>
) : null}
- <Tooltip
- positioning={{ placement: 'top-start' }}
- content={
- <InputFieldTooltip
- description={description}
- isConnected={isConnected}
- isExposed={isExposed}
- label={label}
- template={template}
- />
- }
- >
- <Text
- color={isInvalid ? 'fg.error' : isConnected ? 'fg.muted' : 'fg'}
- data-node-input-field-title="true"
- fontSize="2xs"
- lineHeight="shorter"
- minW="0"
- truncate
+ {isWorkflowImageExport ? (
+ fieldTitle
+ ) : (
+ <Tooltip
+ positioning={{ placement: 'top-start' }}
+ content={
+ <InputFieldTooltip
+ description={description}
+ isConnected={isConnected}
+ isExposed={isExposed}
+ label={label}
+ template={template}
+ />
+ }
>
- {label}
- {template.required ? (
- <Text as="span" color="fg.error">
- {' *'}
- </Text>
- ) : null}
- </Text>
- </Tooltip>
+ {fieldTitle}
+ </Tooltip>
+ )}
<HStack flexShrink={0} gap="0" ml="auto">
{canReset ? (
<Tooltip content="Reset to default value">
@@ -685,13 +699,15 @@ const InputFieldRow = ({
</IconButton>
</Tooltip>
) : null}
- <FieldDescriptionPopover
- description={instance?.description}
- fieldName={template.name}
- nodeId={node.id}
- templateDescription={template.description}
- />
- {isExposableField(template) ? (
+ {!isWorkflowImageExport ? (
+ <FieldDescriptionPopover
+ description={instance?.description}
+ fieldName={template.name}
+ nodeId={node.id}
+ templateDescription={template.description}
+ />
+ ) : null}
+ {!isWorkflowImageExport && isExposableField(template) ? (
<IconButton
aria-label={isExposed ? `Remove ${label} from Linear UI` : `Expose ${label} in Linear UI`}
className="nodrag"
@@ -706,43 +722,33 @@ const InputFieldRow = ({
) : null}
</HStack>
</HStack>
- {isWorkflowImageExport ? (
- <Stack data-workflow-export-content="true" gap="0.5" mt="0.5" overflowWrap="anywhere" w="full">
- <InputFieldTooltip
- description={description}
- isConnected={isConnected}
- isExposed={isExposed}
- label={label}
- template={template}
- />
- {template.input !== 'direct' ? (
- <Text data-workflow-export-connector-tooltip="true" fontSize="2xs">
- {handleTooltip}
- </Text>
- ) : null}
- </Stack>
- ) : null}
{showsControl ? (
- <Box mt="0.5" w="full">
- <WorkflowFieldInput
- id={`${isWorkflowImageExport ? 'export-' : ''}${node.id}-${template.name}-value`}
- invalid={isInvalid}
- nodeId={node.id}
- seedMode={getWorkflowFieldSeedMode(instance)}
- template={template}
- value={instance?.value}
- onChange={(value) =>
- editGraph({ fieldName: template.name, nodeId: node.id, type: 'setFieldValue', value })
- }
- onSeedModeChange={(seedMode) =>
- editGraph({ fieldName: template.name, nodeId: node.id, seedMode, type: 'setFieldSeedMode' })
- }
- />
- </Box>
- ) : isConnected && isSeedInputField(template) ? (
+ isWorkflowImageExport ? (
+ <WorkflowFieldSnapshot template={template} value={instance?.value} />
+ ) : (
+ <Box mt="0.5" w="full">
+ <WorkflowFieldInput
+ id={`${node.id}-${template.name}-value`}
+ invalid={isInvalid}
+ nodeId={node.id}
+ seedMode={getWorkflowFieldSeedMode(instance)}
+ template={template}
+ value={instance?.value}
+ onChange={(value) =>
+ editGraph({ fieldName: template.name, nodeId: node.id, type: 'setFieldValue', value })
+ }
+ onSeedModeChange={(seedMode) =>
+ editGraph({ fieldName: template.name, nodeId: node.id, seedMode, type: 'setFieldSeedMode' })
+ }
+ />
+ </Box>
+ )
+ ) : !isWorkflowImageExport && isConnected && isSeedInputField(template) ? (
<ProvidedByConnectionNote />
) : null}
- {invalidReason ? <Field.ErrorText fontSize="2xs">{invalidReason}</Field.ErrorText> : null}
+ {invalidReason && !isWorkflowImageExport ? (
+ <Field.ErrorText fontSize="2xs">{invalidReason}</Field.ErrorText>
+ ) : null}
</Field.Root>
</Box>
);
@@ -760,7 +766,8 @@ const OutputFieldRow = ({
const isWorkflowImageExport = useIsWorkflowImageExport();
const { t } = useTranslation();
const handleTooltip = getHandleTypeTooltip(template.type, t('nodes.any'), t);
- const value = latestResult === undefined ? null : formatOutputFieldValue(latestResult, template.name);
+ const value =
+ !isWorkflowImageExport && latestResult !== undefined ? formatOutputFieldValue(latestResult, template.name) : null;
return (
<Box px={WORKFLOW_NODE_DENSITY.rowPaddingX} py={WORKFLOW_NODE_DENSITY.rowPaddingY}>
@@ -787,7 +794,6 @@ const OutputFieldRow = ({
<Box flexShrink={0} maxW="full" textAlign="end">
<Text
color="fg.muted"
- data-workflow-export-content="true"
data-workflow-export-output-title="true"
fontSize="2xs"
lineHeight="shorter"
@@ -832,19 +838,6 @@ const OutputFieldRow = ({
</HStack>
)}
</Flex>
- {isWorkflowImageExport ? (
- <Stack data-workflow-export-content="true" gap="0.5" maxW="full" px={WORKFLOW_NODE_DENSITY.rowPaddingX}>
- <Text data-workflow-export-connector-tooltip="true" fontSize="2xs" overflowWrap="anywhere">
- {handleTooltip}
- </Text>
- <OutputFieldTooltip includeTitle={false} template={template} />
- {value ? (
- <Text color="fg.subtle" fontSize="2xs" maxW="full" overflowWrap="anywhere" whiteSpace="pre-wrap">
- {value.full}
- </Text>
- ) : null}
- </Stack>
- ) : null}
</Box>
);
};
@@ -987,14 +980,25 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
if (!templateView) {
return (
- <NodeShell isMissing selected={selected ?? false}>
- <HStack gap="1.5" p="3">
- <Icon as={TriangleAlertIcon} boxSize="3.5" color="red.solid" />
- <Stack gap="0">
- <Text fontWeight="700">{node.data.label || node.data.type}</Text>
- <Text color="fg.subtle" fontSize="2xs">
- Unknown node type "{node.data.type}". It cannot run on this backend.
+ <NodeShell isMissing={!isWorkflowImageExport} selected={selected ?? false}>
+ <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 ? (
+ <Text color="fg.subtle" fontSize="2xs">
+ Unknown node type "{node.data.type}". It cannot run on this backend.
+ </Text>
+ ) : null}
</Stack>
</HStack>
</NodeShell>
@@ -1013,48 +1017,53 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
const isRunning = execution?.status === 'running';
const isMissingRequiredInput = hasMissingRequiredInputs(node, inputTemplates, connectedFieldNames);
const isCompact = data.isCompact && !selected && !isWorkflowImageExport;
- const withFooter = !isZoomedOut && templateView.isExecutable && templateView.hasImageOutput;
- const resultExecution = isWorkflowImageExport && execution?.status !== 'completed' ? null : execution;
+ const withFooter = !isWorkflowImageExport && !isZoomedOut && templateView.isExecutable && templateView.hasImageOutput;
+ const resultExecution = isWorkflowImageExport ? null : execution;
const withOutputPreview = Boolean(resultExecution?.outputImageUrl);
const latestResult = resultExecution?.latestOutput;
return (
<NodeShell
- hasMissingRequiredInput={isMissingRequiredInput}
- isOutdated={isOutdated}
- isRunning={isRunning}
- outcome={getExecutionOutcome(execution)}
+ hasMissingRequiredInput={!isWorkflowImageExport && isMissingRequiredInput}
+ isOutdated={!isWorkflowImageExport && isOutdated}
+ isRunning={!isWorkflowImageExport && isRunning}
+ outcome={isWorkflowImageExport ? null : getExecutionOutcome(execution)}
selected={selected ?? false}
>
{/* The collapse chevron carries its own hit padding, so the header pulls its start padding in. */}
- <Flex {...getWorkflowNodeHeaderProps({ roundedBottom: !isOpen })} gap="1" ps="1">
- <IconButton
- aria-label={isOpen ? 'Collapse node' : 'Expand node'}
- className="nodrag"
- size="2xs"
- variant="ghost"
- onClick={() => editGraph({ isOpen: !isOpen, nodeId: node.id, type: 'setNodeIsOpen' })}
- >
- <Icon as={isOpen ? ChevronDownIcon : ChevronRightIcon} boxSize="3.5" />
- </IconButton>
+ <Flex
+ {...getWorkflowNodeHeaderProps({ roundedBottom: !isOpen })}
+ gap="1"
+ ps={isWorkflowImageExport ? WORKFLOW_NODE_DENSITY.headerPaddingStart : '1'}
+ >
+ {!isWorkflowImageExport ? (
+ <IconButton
+ aria-label={isOpen ? 'Collapse node' : 'Expand node'}
+ className="nodrag"
+ size="2xs"
+ variant="ghost"
+ onClick={() => editGraph({ isOpen: !isOpen, nodeId: node.id, type: 'setNodeIsOpen' })}
+ >
+ <Icon as={isOpen ? ChevronDownIcon : ChevronRightIcon} boxSize="3.5" />
+ </IconButton>
+ ) : null}
{isZoomedOut ? (
<MiddleTruncate fontSize="sm" fontWeight="700" minW="0" text={node.data.label || template.title} />
) : (
<>
- <NodeTitle node={node} title={node.data.label || template.title} />
+ <NodeTitle
+ isWorkflowImageExport={isWorkflowImageExport}
+ node={node}
+ title={node.data.label || template.title}
+ />
<BatchGroupSuffix node={node} />
<Box flex="1" />
- <NodeOutcomeIcon execution={execution} node={node} />
- {isOutdated ? <NodeUpdateIcon node={node} template={template} /> : null}
- <NodeInfoIcon node={node} template={template} />
+ {!isWorkflowImageExport ? <NodeOutcomeIcon execution={execution} node={node} /> : null}
+ {!isWorkflowImageExport && isOutdated ? <NodeUpdateIcon node={node} template={template} /> : null}
+ {!isWorkflowImageExport ? <NodeInfoIcon node={node} template={template} /> : null}
</>
)}
</Flex>
- {isWorkflowImageExport ? (
- <Box data-workflow-export-content="true" maxW="full" px={WORKFLOW_NODE_DENSITY.rowPaddingX} py="1">
- <NodeInfoTooltipContent isFailed={execution?.status === 'failed'} node={node} template={template} />
- </Box>
- ) : null}
<NodeProgressStrip execution={execution} />
{isOpen && isCompact ? (
<>
@@ -1085,11 +1094,11 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
template={inputTemplate}
/>
))}
- {shouldShowCallSavedWorkflowLoadingHint(node) ? (
+ {!isWorkflowImageExport && shouldShowCallSavedWorkflowLoadingHint(node) ? (
<Text color="fg.subtle" fontSize="2xs" px={WORKFLOW_NODE_DENSITY.rowPaddingX} py="1">
{t('nodes.savedWorkflowDetailLoading')}
</Text>
- ) : shouldShowCallSavedWorkflowNoExposedFieldsHint(node) ? (
+ ) : !isWorkflowImageExport && shouldShowCallSavedWorkflowNoExposedFieldsHint(node) ? (
<Text color="fg.subtle" fontSize="2xs" px={WORKFLOW_NODE_DENSITY.rowPaddingX} py="1">
{t('nodes.savedWorkflowNoExposedFields')}
</Text>
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/LoopBodyBoundaryOverlay.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/LoopBodyBoundaryOverlay.tsx
index f68cf0474a..6f69dce6c6 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/LoopBodyBoundaryOverlay.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/LoopBodyBoundaryOverlay.tsx
@@ -1,6 +1,7 @@
import type { WorkflowEdge, WorkflowNode } from '@features/workflow/contracts';
import { Box, Text } from '@chakra-ui/react';
+import { useIsWorkflowImageExport } from '@features/workflow/ui/nodeChrome';
import { getForLoopBodyBoundaries, type LoopBodyBoundaryStatus } from '@features/workflow/utility';
import { type ReactFlowState, useStore, ViewportPortal } from '@xyflow/react';
import { memo, useCallback, useMemo } from 'react';
@@ -63,6 +64,7 @@ const areSameRects = (a: (BoundaryRect | null)[], b: (BoundaryRect | null)[]): b
});
export const LoopBodyBoundaryOverlay = ({ nodes, edges }: { nodes: WorkflowNode[]; edges: WorkflowEdge[] }) => {
+ const isWorkflowImageExport = useIsWorkflowImageExport();
const { t } = useTranslation();
const boundaries = useMemo(() => getForLoopBodyBoundaries(nodes, edges), [edges, nodes]);
const selectBounds = useCallback(
@@ -80,10 +82,14 @@ export const LoopBodyBoundaryOverlay = ({ nodes, edges }: { nodes: WorkflowNode[
return null;
}
- const colors = getStatusColor(boundary.status);
+ const colors = isWorkflowImageExport
+ ? { border: 'border.emphasized', text: 'fg.subtle' }
+ : getStatusColor(boundary.status);
const bodyLabel = t('nodes.forLoopBodyBoundary');
const statusLabel =
- boundary.status === 'complete' ? '' : t(`nodes.forLoopBodyBoundaryStatus.${boundary.status}`);
+ isWorkflowImageExport || boundary.status === 'complete'
+ ? ''
+ : t(`nodes.forLoopBodyBoundaryStatus.${boundary.status}`);
const label = statusLabel ? `${bodyLabel} - ${statusLabel}` : bodyLabel;
return (
@@ -94,7 +100,7 @@ export const LoopBodyBoundaryOverlay = ({ nodes, edges }: { nodes: WorkflowNode[
borderColor={colors.border}
borderRadius="base"
data-loop-body-boundary={boundary.forNodeId ?? boundary.returnNodeId}
- data-loop-body-status={boundary.status}
+ data-loop-body-status={isWorkflowImageExport ? undefined : boundary.status}
h={bounds.height + BOUNDARY_PADDING * 2}
pointerEvents="none"
position="absolute"
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 6a2db52c73..6e29f8f874 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/NotesFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NotesFlowNode.tsx
@@ -1,13 +1,38 @@
import type { NodeProps } from '@xyflow/react';
-import { Box, Input, Textarea } from '@chakra-ui/react';
-import { getWorkflowNodeChromeProps } from '@features/workflow/ui/nodeChrome';
+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 { memo, useCallback, type ChangeEvent } from 'react';
import type { NotesFlowNode as NotesFlowNodeType } from './flowAdapters';
-const NotesFlowNodeComponent = ({ data, selected }: NodeProps<NotesFlowNodeType>) => {
+const NotesSnapshotNode = ({ data }: NodeProps<NotesFlowNodeType>) => {
+ const node = data.documentNode;
+
+ return (
+ <Box
+ bg="bg.subtle"
+ data-workflow-export-static-node-content="true"
+ data-workflow-node-shell="true"
+ p="2"
+ rounded="lg"
+ w="16rem"
+ {...getWorkflowNodeChromeProps({ selected: false })}
+ >
+ <Text fontSize="2xs" fontWeight="700" mb="1.5">
+ {node.data.label}
+ </Text>
+ {node.data.notes ? (
+ <Text fontSize="2xs" overflowWrap="anywhere" whiteSpace="pre-wrap">
+ {node.data.notes}
+ </Text>
+ ) : null}
+ </Box>
+ );
+};
+
+const NotesEditorNode = ({ data, selected }: NodeProps<NotesFlowNodeType>) => {
const { editGraph } = useProjectGraphCommands();
const node = data.documentNode;
const onLabelChange = useCallback(
@@ -56,4 +81,10 @@ const NotesFlowNodeComponent = ({ data, selected }: NodeProps<NotesFlowNodeType>
);
};
+const NotesFlowNodeComponent = (props: NodeProps<NotesFlowNodeType>) => {
+ const isWorkflowImageExport = useIsWorkflowImageExport();
+
+ return isWorkflowImageExport ? <NotesSnapshotNode {...props} /> : <NotesEditorNode {...props} />;
+};
+
export const NotesFlowNode = memo(NotesFlowNodeComponent);
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowImageExportView.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowImageExportView.tsx
index d721107ab6..b777df0f2d 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowImageExportView.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowImageExportView.tsx
@@ -1,17 +1,31 @@
import { Box } from '@chakra-ui/react';
+import { WorkflowImageExportProvider } from '@features/workflow/ui/nodeChrome';
import { Background, BackgroundVariant, ReactFlow, ReactFlowProvider, type ReactFlowProps } from '@xyflow/react';
-import { useId, type RefObject } from 'react';
+import { useId, useMemo, type RefObject } from 'react';
import type { WorkflowFlowEdge, WorkflowFlowNode } from './flowAdapters';
-import { WorkflowImageExportProvider } from './InvocationFlowNode';
-
/** A separate flow store keeps export measurements and expanded nodes out of the editor. */
export const WorkflowImageExportView = ({
containerRef,
...props
}: ReactFlowProps<WorkflowFlowNode, WorkflowFlowEdge> & { containerRef: RefObject<HTMLDivElement | null> }) => {
const gridId = useId();
+ const nodes = useMemo(
+ () => props.nodes?.map((node) => (node.selected ? { ...node, selected: false } : node)),
+ [props.nodes]
+ );
+ const edges = useMemo(
+ () =>
+ props.edges?.map((edge) => ({
+ ...edge,
+ animated: undefined,
+ className: undefined,
+ selected: false,
+ style: undefined,
+ })),
+ [props.edges]
+ );
return (
<Box ref={containerRef} aria-hidden inert h="full" left="-100000px" position="absolute" top="0" w="full">
@@ -20,7 +34,9 @@ export const WorkflowImageExportView = ({
<ReactFlow
{...props}
id={`workflow-export-${gridId}`}
+ edges={edges}
elementsSelectable={false}
+ nodes={nodes}
nodesConnectable={false}
nodesDraggable={false}
>
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.edgeCases.test.ts b/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.edgeCases.test.ts
index 9f95fda6ce..3a9dc291cb 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.edgeCases.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.edgeCases.test.ts
@@ -201,8 +201,8 @@ describe('workflow image export edge cases', () => {
).toMatchObject({ x: 0, y: 0, width: 690, height: 100 });
});
- it('includes inline export descriptions in content bounds', () => {
- const description = {
+ it('includes overflowing output titles in content bounds', () => {
+ const outputTitle = {
getBoundingClientRect: () => ({ left: 650, top: 250, width: 100, height: 50 }),
scrollWidth: 100,
scrollHeight: 50,
@@ -212,7 +212,7 @@ describe('workflow image export edge cases', () => {
getBoundingClientRect: () => ({ left: 100, top: 200 }),
querySelector: (selector: string) => (selector === '.react-flow__viewport' ? viewport : null),
querySelectorAll: (selector: string) =>
- selector === '[data-workflow-export-content="true"]' ? [description] : [],
+ selector === '[data-workflow-export-output-title="true"]' ? [outputTitle] : [],
};
expect(
@@ -226,8 +226,64 @@ describe('workflow image export edge cases', () => {
).toMatchObject({ x: 0, y: 0, width: 650, height: 100 });
});
- it('measures export content in logical coordinates when the workflow is zoomed out', () => {
- const description = {
+ it('includes full static field rows when measuring expanded snapshot content', () => {
+ const fieldContent = {
+ getBoundingClientRect: () => ({ left: 350, top: 120, width: 200, height: 420 }),
+ scrollWidth: 200,
+ scrollHeight: 420,
+ };
+ const viewport = { getBoundingClientRect: () => ({ left: 100, top: 100, width: 1000, height: 1000 }) };
+ const flowElement = {
+ getBoundingClientRect: () => ({ left: 100, top: 100 }),
+ querySelector: (selector: string) => (selector === '.react-flow__viewport' ? viewport : null),
+ querySelectorAll: (selector: string) =>
+ selector === '[data-workflow-export-field-content="true"]' ? [fieldContent] : [],
+ };
+
+ vi.stubGlobal('getComputedStyle', () => ({ direction: 'ltr', transform: 'none' }));
+ try {
+ expect(
+ getWorkflowContentBounds(
+ flowElement as unknown as HTMLElement,
+ { x: 0, y: 0, width: 300, height: 200 },
+ { includeInputFieldLabels: false }
+ )
+ ).toMatchObject({ x: 0, y: 0, width: 450, height: 440 });
+ } finally {
+ vi.unstubAllGlobals();
+ }
+ });
+
+ it('includes expanded static node content in snapshot bounds', () => {
+ const staticNodeContent = {
+ getBoundingClientRect: () => ({ left: 350, top: 120, width: 200, height: 420 }),
+ scrollWidth: 200,
+ scrollHeight: 420,
+ };
+ const viewport = { getBoundingClientRect: () => ({ left: 100, top: 100, width: 1000, height: 1000 }) };
+ const flowElement = {
+ getBoundingClientRect: () => ({ left: 100, top: 100 }),
+ querySelector: (selector: string) => (selector === '.react-flow__viewport' ? viewport : null),
+ querySelectorAll: (selector: string) =>
+ selector === '[data-workflow-export-static-node-content="true"]' ? [staticNodeContent] : [],
+ };
+
+ vi.stubGlobal('getComputedStyle', () => ({ direction: 'ltr', transform: 'none' }));
+ try {
+ expect(
+ getWorkflowContentBounds(
+ flowElement as unknown as HTMLElement,
+ { x: 0, y: 0, width: 300, height: 200 },
+ { includeInputFieldLabels: false }
+ )
+ ).toMatchObject({ x: 0, y: 0, width: 450, height: 440 });
+ } finally {
+ vi.unstubAllGlobals();
+ }
+ });
+
+ it('measures output titles in logical coordinates when the workflow is zoomed out', () => {
+ const outputTitle = {
getBoundingClientRect: () => ({ left: 50, top: 50, width: 100, height: 25 }),
scrollWidth: 200,
scrollHeight: 50,
@@ -237,7 +293,7 @@ describe('workflow image export edge cases', () => {
getBoundingClientRect: () => ({ left: 0, top: 0 }),
querySelector: (selector: string) => (selector === '.react-flow__viewport' ? viewport : null),
querySelectorAll: (selector: string) =>
- selector === '[data-workflow-export-content="true"]' ? [description] : [],
+ selector === '[data-workflow-export-output-title="true"]' ? [outputTitle] : [],
};
vi.stubGlobal('getComputedStyle', (element: unknown) => ({
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.ts b/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.ts
index fb7030c187..0f98a6f349 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/workflowImageExport.ts
@@ -188,7 +188,9 @@ export const getWorkflowContentBounds = (
...(includeInputFieldLabels
? flowElement.querySelectorAll<HTMLElement>('[data-node-input-field-title="true"]')
: []),
- ...flowElement.querySelectorAll<HTMLElement>('[data-workflow-export-content="true"]'),
+ ...flowElement.querySelectorAll<HTMLElement>('[data-workflow-export-field-content="true"]'),
+ ...flowElement.querySelectorAll<HTMLElement>('[data-workflow-export-static-node-content="true"]'),
+ ...flowElement.querySelectorAll<HTMLElement>('[data-workflow-export-output-title="true"]'),
]);
contentElements.forEach((element) => {
const elementRect = element.getBoundingClientRect();
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 f0eb3748b1..22e34999d4 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
@@ -1854,3 +1854,91 @@ export const WorkflowFieldInput = (props: WorkflowFieldInputProps) => {
return CONNECTION_ONLY_FALLBACK;
}
};
+
+const isRecord = (value: unknown): value is Record<string, unknown> =>
+ typeof value === 'object' && value !== null && !Array.isArray(value);
+
+const stringifySnapshotValue = (value: unknown): string | null => {
+ try {
+ return JSON.stringify(value) ?? null;
+ } catch {
+ return null;
+ }
+};
+
+const formatSnapshotObject = (value: Record<string, unknown>): string | null => {
+ const lora = value.lora;
+ if (isRecord(lora) && typeof lora.name === 'string') {
+ return typeof value.weight === 'number' ? `${lora.name} (${value.weight})` : lora.name;
+ }
+
+ for (const key of [
+ 'name',
+ 'image_name',
+ 'video_name',
+ 'latents_name',
+ 'tensor_name',
+ 'key',
+ 'style_preset_id',
+ 'system_prompt_id',
+ 'workflow_id',
+ 'board_id',
+ 'id',
+ ]) {
+ const entry = value[key];
+ if (typeof entry === 'string' || typeof entry === 'number' || typeof entry === 'boolean') {
+ return String(entry);
+ }
+ }
+
+ if (['r', 'g', 'b', 'a'].every((channel) => typeof value[channel] === 'number')) {
+ return `rgba(${value.r}, ${value.g}, ${value.b}, ${value.a})`;
+ }
+
+ return stringifySnapshotValue(value);
+};
+
+const formatSnapshotValue = (value: unknown, template: FieldInputTemplate): string | null => {
+ if (isWorkflowGeneratorFieldTypeName(template.type.name) && isRecord(value)) {
+ const { values: _resolvedValues, ...settings } = value;
+ return stringifySnapshotValue(settings);
+ }
+
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
+ if (template.type.name === 'EnumField') {
+ return template.uiChoiceLabels?.[String(value)] ?? String(value);
+ }
+
+ return value === '' ? null : String(value);
+ }
+
+ if (Array.isArray(value)) {
+ return (
+ value
+ .map((entry) => (isRecord(entry) ? formatSnapshotObject(entry) : String(entry)))
+ .filter(Boolean)
+ .join(', ') || '[]'
+ );
+ }
+
+ return isRecord(value) ? formatSnapshotObject(value) : null;
+};
+
+/** Renders authored values without mounting editors or resolving runtime diagnostics. */
+export const WorkflowFieldSnapshot = ({ template, value }: { template: FieldInputTemplate; value: unknown }) => {
+ const text = formatSnapshotValue(value, template);
+
+ 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}
+ </Text>
+ ) : null;
+};
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx
index b8fe917b9d..9bb6a96071 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx
@@ -6,6 +6,19 @@ import { Box, Icon } from '@chakra-ui/react';
import { getFieldTypeColor, isModelFieldType } from '@features/workflow/utility';
import { Tooltip } from '@platform/ui';
import { CircleAlertIcon, CircleCheckIcon, InfoIcon } from 'lucide-react';
+import { createContext, useContext } from 'react';
+
+const WorkflowImageExportContext = createContext(false);
+
+export const WorkflowImageExportProvider = ({
+ children,
+ isExporting,
+}: {
+ children: ReactNode;
+ isExporting: boolean;
+}) => <WorkflowImageExportContext value={isExporting}>{children}</WorkflowImageExportContext>;
+
+export const useIsWorkflowImageExport = () => useContext(WorkflowImageExportContext);
/** Share node styling across editor, static previews, and form builder to prevent visual drift. */