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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(workflows): include hover metadata in snapshot exports
JPPhoto6b56196b4819
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/ConnectorFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/ConnectorFlowNode.tsxindex acf66929a6..6f082e2763 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 } from '@chakra-ui/react';+import { Box, Flex, Stack, Text } from '@chakra-ui/react';import {getWorkflowNodeChromeProps,getWorkflowNodeHandleStyle,@@ -14,6 +14,7 @@ import { memo, useMemo } from 'react';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 = {@@ -35,6 +36,10 @@ const getConnectorTitle = (inputType: FieldType | null, outputType: FieldType |const ConnectorFlowNodeComponent = ({ data, selected }: NodeProps<ConnectorFlowNodeType>) => {const node = data.documentNode;+ const isWorkflowImageExport = useIsWorkflowImageExport();+ const inputTooltip = getHandleTypeTooltip(data.inputFieldType, 'Any input');+ const connectorTooltip = getConnectorTitle(data.inputFieldType, data.outputFieldType);+ const outputTooltip = getHandleTypeTooltip(data.outputFieldType, 'Any output');const inputHandleStyle = useMemo(() => ({ ...getConnectorHandleStyle(data.inputFieldType, 'left'), left: -WORKFLOW_NODE_HANDLE_SIZE / 2 }),[data.inputFieldType]@@ -46,10 +51,10 @@ const ConnectorFlowNodeComponent = ({ data, selected }: NodeProps<ConnectorFlowNreturn (<Flex align="center" data-connector-node-id={node.id} justify="center" position="relative">- <Tooltip content={getHandleTypeTooltip(data.inputFieldType, 'Any input')} showArrow>+ <Tooltip content={inputTooltip} showArrow><Handle id={CONNECTOR_INPUT_HANDLE} position={Position.Left} style={inputHandleStyle} type="target" /></Tooltip>- <Tooltip content={getConnectorTitle(data.inputFieldType, data.outputFieldType)} showArrow>+ <Tooltip content={connectorTooltip} showArrow><Boxbg="bg"data-connector-node-body="true"@@ -61,9 +66,39 @@ const ConnectorFlowNodeComponent = ({ data, selected }: NodeProps<ConnectorFlowN{...getWorkflowNodeChromeProps({ selected })}/></Tooltip>- <Tooltip content={getHandleTypeTooltip(data.outputFieldType, 'Any output')} showArrow>+ <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/InvocationFlowNode.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.browser.test.tsxindex 3e68a12239..0d40515006 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@@ -15,9 +15,10 @@ import { createRoot, type Root } from 'react-dom/client';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { page, userEvent } from 'vitest/browser';+import { ConnectorFlowNode } from './ConnectorFlowNode';import { toFlowEdges, toFlowNodes } from './flowAdapters';import { InvocationFlowNode, WorkflowImageExportProvider } from './InvocationFlowNode';-import { exportWorkflowAsPng } from './workflowImageExport';+import { exportWorkflowAsPng, WORKFLOW_EXPORT_TIMEOUT_MS } from './workflowImageExport';import '@xyflow/react/dist/style.css';@@ -29,13 +30,31 @@ vi.mock('@platform/browser/downloadBlob', () => ({ downloadBlob: vi.fn() }));vi.mock('react-i18next', () => ({useTranslation: () => ({- t: (key: string, options?: { error?: string }) =>+ t: (+ key: string,+ options?: {+ category?: string;+ classification?: string;+ error?: string;+ name?: string;+ type?: string;+ version?: string;+ }+ ) =>({'nodes.childWorkflowError': `Child workflow error: ${options?.error ?? ''}`,'nodes.executionFailed': 'Failed','nodes.executionCompleted': 'Completed',+ 'nodes.fieldName': `Field: ${options?.name ?? ''}`,+ 'nodes.fieldType': `Type: ${options?.type ?? ''}`,'nodes.latestOutput': 'Latest output','nodes.latestOutputImage': 'Latest output of this node',+ 'nodes.nodeCategory': `Category: ${options?.category ?? ''}`,+ 'nodes.nodeClassification': `Classification: ${options?.classification ?? ''}`,+ 'nodes.nodePackLabel': `Node pack: ${options?.name ?? ''}`,+ 'nodes.nodeType': `Node type: ${options?.type ?? ''}`,+ 'nodes.nodeVersion': `Node version: ${options?.version ?? ''}`,+ 'nodes.output': 'Output',})[key] ?? key,}),}));@@ -110,7 +129,7 @@ const documentNode: WorkflowInvocationNode = {const projectGraph: ProjectGraphState = { ...createProjectGraph('preview-test'), nodes: [documentNode] };const templates = { preview: template };const flowNodes = toFlowNodes(projectGraph, [], templates);-const nodeTypes = { invocation: InvocationFlowNode };+const nodeTypes = { connector: ConnectorFlowNode, invocation: InvocationFlowNode };const callNodeId = 'call-node';const callNode: WorkflowInvocationNode = {@@ -275,11 +294,20 @@ describe('InvocationFlowNode output preview', () => {it('keeps node and field descriptions plus full output values in the exported graph clone', async () => {const longOutput = 'x'.repeat(60);+ const longOutputTitle = 'An output title that is deliberately long enough to wrap instead of truncating';const exportTemplate: InvocationTemplate = {...template,+ category: 'Export category',+ classification: 'stable',description: 'Node export description',inputs: { a: { ...template.inputs.a!, description: 'Template field description' } },- outputs: { value: { ...template.outputs.value!, description: 'Output export description' } },+ outputs: {+ value: {+ ...template.outputs.value!,+ description: 'Output export description',+ title: longOutputTitle,+ },+ },};const exportNode: WorkflowInvocationNode = {...documentNode,@@ -292,7 +320,13 @@ describe('InvocationFlowNode output preview', () => {notes: 'Node export note',},};- const exportGraph = { ...projectGraph, nodes: [exportNode] };+ const exportConnector = {+ data: { label: '' },+ id: 'export-connector',+ position: { x: 380, y: 300 },+ type: 'connector' as const,+ };+ const exportGraph = { ...projectGraph, nodes: [exportNode, exportConnector] };const exportNodes = toFlowNodes(exportGraph, [], { preview: exportTemplate });const execution = createExecutionPort();const adapter = createAdapter(execution.port);@@ -327,10 +361,118 @@ describe('InvocationFlowNode output preview', () => {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('Node type: preview');+ expect(capturedClone?.textContent).toContain('Node pack: invokeai');+ expect(capturedClone?.textContent).toContain('Node 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);+ 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);});+ it('keeps running progress in the editor but omits it from the exported graph clone', async () => {+ const execution = createExecutionPort();+ 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);+ await act(() =>+ execution.set({+ error: null,+ latestOutput: null,+ outputImageUrl: null,+ progress: 0.5,+ progressMessage: null,+ status: 'running',+ })+ );+ expect(host.querySelector('[data-node-progress-strip="true"]')).not.toBeNull();++ await render(adapter, 1, true);++ const flowElement = host.querySelector<HTMLElement>('.react-flow')!;+ await exportWorkflowAsPng({+ bounds: { x: 20, y: 20, width: 300, height: 260 },+ fallbackWorkflowName: 'Untitled Workflow',+ flowElement,+ workflowName: 'Running workflow',+ });++ expect(capturedClone?.querySelector('[data-node-progress-strip="true"]')).toBeNull();+ });++ it('blocks a third capture after two timeouts and recovers when one rasterization settles', async () => {+ vi.useFakeTimers();+ exportMocks.toBlob.mockClear();+ const finishRasterizations: Array<(blob: Blob | null) => void> = [];+ let signalBothStarted: () => void = () => {};+ const bothStarted = new Promise<void>((resolve) => {+ signalBothStarted = resolve;+ });+ exportMocks.toBlob.mockImplementation(+ () =>+ new Promise<Blob | null>((resolve) => {+ finishRasterizations.push(resolve);+ if (finishRasterizations.length === 2) {+ signalBothStarted();+ }+ })+ );+ const execution = createExecutionPort();+ const adapter = createAdapter(execution.port);+ const exportOptions = {+ bounds: { x: 20, y: 20, width: 300, height: 260 },+ fallbackWorkflowName: 'Untitled Workflow',+ flowElement: undefined as unknown as HTMLElement,+ workflowName: 'Stalled workflow',+ };++ try {+ await render(adapter, 1, true);+ exportOptions.flowElement = host.querySelector<HTMLElement>('.react-flow')!;+ const firstExport = exportWorkflowAsPng(exportOptions);+ const secondExport = exportWorkflowAsPng(exportOptions);+ const firstTimedOut = expect(firstExport).rejects.toThrow('timed out');+ const secondTimedOut = expect(secondExport).rejects.toThrow('timed out');++ await bothStarted;+ expect(exportMocks.toBlob).toHaveBeenCalledTimes(2);+ await vi.advanceTimersByTimeAsync(WORKFLOW_EXPORT_TIMEOUT_MS);+ await Promise.all([firstTimedOut, secondTimedOut]);++ await expect(exportWorkflowAsPng(exportOptions)).rejects.toThrow('still running');+ expect(exportMocks.toBlob).toHaveBeenCalledTimes(2);++ finishRasterizations[0]!(null);+ await vi.advanceTimersByTimeAsync(0);+ exportMocks.toBlob.mockResolvedValueOnce(new Blob(['png'], { type: 'image/png' }));+ await exportWorkflowAsPng(exportOptions);+ expect(exportMocks.toBlob).toHaveBeenCalledTimes(3);++ finishRasterizations[1]!(null);+ await vi.advanceTimersByTimeAsync(0);+ } finally {+ finishRasterizations.forEach((finish) => finish(null));+ await vi.advanceTimersByTimeAsync(0);+ vi.useRealTimers();+ }+ });+it('keeps one preview height across differently shaped outputs and folds it away per node', async () => {const execution = createExecutionPort();const adapter = createAdapter(execution.port);diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsxindex 67a86e49d5..9f66204f4e 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx@@ -210,12 +210,14 @@ const NodeOutcomeIcon = ({/** Thin progress strip under the header while the node's invocation executes. */const NodeProgressStrip = ({ execution }: { execution: NodeExecutionState | null }) => {- if (execution?.status !== 'running') {+ const isWorkflowImageExport = useIsWorkflowImageExport();++ if (isWorkflowImageExport || execution?.status !== 'running') {return null;}return (- <Box bg="bg.muted" h="2px" overflow="hidden" position="relative" w="full">+ <Box bg="bg.muted" data-node-progress-strip="true" h="2px" overflow="hidden" position="relative" w="full"><Boxbg="brand.solid"h="full"@@ -309,12 +311,18 @@ const InputFieldTooltip = ({</Stack>);-const OutputFieldTooltip = ({ template }: { template: FieldOutputTemplate }) => {+const OutputFieldTooltip = ({+ includeTitle = true,+ template,+}: {+ includeTitle?: boolean;+ template: FieldOutputTemplate;+}) => {const { t } = useTranslation();return (<Stack gap="0.5" maxW="18rem">- <Text fontWeight="700">{template.title}</Text>+ {includeTitle ? <Text fontWeight="700">{template.title}</Text> : null}<Text color="fg.subtle">{t('nodes.fieldName', { name: template.name })}</Text><Text color="fg.subtle">{t('nodes.fieldType', { type: getFieldTypeLabel(template.type) })}</Text><Text color="fg.subtle">{t('nodes.output')}</Text>@@ -703,17 +711,21 @@ const InputFieldRow = ({) : null}</HStack></HStack>- {isWorkflowImageExport && description ? (- <Text- color="fg.subtle"- data-workflow-export-content="true"- fontSize="2xs"- mt="0.5"- overflowWrap="anywhere"- whiteSpace="pre-wrap"- >- {description}- </Text>+ {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">@@ -756,7 +768,13 @@ const OutputFieldRow = ({return (<Box px={WORKFLOW_NODE_DENSITY.rowPaddingX} py={WORKFLOW_NODE_DENSITY.rowPaddingY}>- <Flex align="center" h="5" justify="flex-end" position="relative">+ <Flex+ align="center"+ h={isWorkflowImageExport ? 'auto' : '5'}+ justify="flex-end"+ minH={isWorkflowImageExport ? '5' : undefined}+ position="relative"+ ><Tooltip content={handleTooltip} positioning={{ placement: 'left-start' }} showArrow><Handleid={template.name}@@ -771,17 +789,19 @@ const OutputFieldRow = ({</Flex>) : isWorkflowImageExport ? (<Box flexShrink={0} maxW="full" textAlign="end">- <Tooltip content={<OutputFieldTooltip template={template} />} positioning={{ placement: 'top-end' }}>- <MiddleTruncate- as="span"- color="fg.muted"- fontSize="2xs"- justifyContent="flex-end"- lineHeight="shorter"- maxW="full"- text={template.title}- />- </Tooltip>+ <Text+ color="fg.muted"+ data-workflow-export-content="true"+ data-workflow-export-output-title="true"+ fontSize="2xs"+ lineHeight="shorter"+ maxW="full"+ overflowWrap="anywhere"+ textAlign="end"+ whiteSpace="normal"+ >+ {template.title}+ </Text></Box>) : (<HStack gap="1.5" justify="flex-end" minW="0" w="full">@@ -816,29 +836,18 @@ const OutputFieldRow = ({</HStack>)}</Flex>- {isWorkflowImageExport && value ? (- <Text- color="fg.subtle"- data-workflow-export-content="true"- fontSize="2xs"- maxW="full"- overflowWrap="anywhere"- whiteSpace="pre-wrap"- >- {value.full}- </Text>- ) : null}- {isWorkflowImageExport && template.description ? (- <Text- color="fg.subtle"- data-workflow-export-content="true"- fontSize="2xs"- maxW="full"- overflowWrap="anywhere"- whiteSpace="pre-wrap"- >- {template.description}- </Text>+ {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>);@@ -1044,26 +1053,10 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode</>)}</Flex>- {isWorkflowImageExport && (template.description || node.data.notes) ? (- <Stack gap="1" px={WORKFLOW_NODE_DENSITY.rowPaddingX} py="1">- {template.description ? (- <Text- color="fg.subtle"- data-workflow-export-content="true"- fontSize="2xs"- fontStyle="italic"- overflowWrap="anywhere"- whiteSpace="pre-wrap"- >- {template.description}- </Text>- ) : null}- {node.data.notes ? (- <Text data-workflow-export-content="true" fontSize="2xs" overflowWrap="anywhere" whiteSpace="pre-wrap">- {node.data.notes}- </Text>- ) : null}- </Stack>+ {isWorkflowImageExport ? (+ <Box data-workflow-export-content="true" maxW="full" px={WORKFLOW_NODE_DENSITY.rowPaddingX} py="1">+ <NodeInfoTooltipContent node={node} template={template} />+ </Box>) : null}<NodeProgressStrip execution={execution} />{isOpen && isCompact ? (