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(workflow): keep node controls clickable and fold the output preview
Josh Corbettaf7d2fbfb2cf
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 390bfd56e3..cae82e1744 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1451,6 +1451,8 @@"forReturnOwnership": "Each ForReturn must belong to exactly one For","executionCompleted": "Completed","executionFailed": "Failed",+ "latestOutput": "Latest output",+ "latestOutputImage": "Latest output of this node","forLoopBodyBoundary": "For loop body","imageCollectionCount_one": "{{count}} image","imageCollectionCount_other": "{{count}} images",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.tsxnew file mode 100644index 0000000000..d675b82422--- /dev/null+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.browser.test.tsx@@ -0,0 +1,349 @@+import type { InvocationTemplate, ProjectGraphState, WorkflowInvocationNode } from '@features/workflow/contracts';+import type { WorkflowNodeExecutionState } from '@features/workflow/ui/contracts';+import type { WorkflowUiAdapter } from '@features/workflow/ui/WorkflowUiContext';++/* 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 { WorkflowUiProvider } from '@features/workflow/ui/WorkflowUiContext';+import { setNodePreviewCollapsed } from '@features/workflow/ui/workflowUiStore';+import { createProjectGraph } from '@features/workflow/utility';+import { system } from '@theme/system';+import { ReactFlow } from '@xyflow/react';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { page } from 'vitest/browser';++import { toFlowEdges, toFlowNodes } from './flowAdapters';+import { InvocationFlowNode } from './InvocationFlowNode';++import '@xyflow/react/dist/style.css';++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string) =>+ ({ 'nodes.latestOutput': 'Latest output', 'nodes.latestOutputImage': 'Latest output of this node' })[key] ?? key,+ }),+}));++const NODE_ID = 'preview-node';+/** The preview's fixed height (10rem) in CSS pixels, however the root font is sized. */+const previewHeightPx = () => parseFloat(getComputedStyle(document.documentElement).fontSize) * 10;++const template: InvocationTemplate = {+ category: 'test',+ classification: 'stable',+ description: '',+ inputs: {+ a: {+ default: undefined,+ description: '',+ exclusiveMaximum: null,+ exclusiveMinimum: null,+ fieldKind: 'input',+ input: 'connection',+ maximum: null,+ minimum: null,+ multipleOf: null,+ name: 'a',+ options: null,+ required: false,+ title: 'A',+ type: { batch: false, cardinality: 'SINGLE', name: 'IntegerField' },+ uiChoiceLabels: null,+ uiComponent: null,+ uiHidden: false,+ uiModelBase: null,+ uiModelFormat: null,+ uiModelType: null,+ uiOrder: null,+ },+ },+ nodePack: 'invokeai',+ outputType: 'test',+ outputs: {+ value: {+ description: '',+ name: 'value',+ title: 'Value',+ type: { batch: false, cardinality: 'SINGLE', name: 'IntegerField' },+ },+ },+ tags: [],+ title: 'Preview',+ type: 'preview',+ useCache: true,+ version: '1.0.0',+};++const documentNode: WorkflowInvocationNode = {+ data: {+ inputs: {},+ isIntermediate: true,+ isOpen: true,+ label: '',+ nodePack: 'invokeai',+ notes: '',+ type: 'preview',+ useCache: true,+ version: '1.0.0',+ },+ id: NODE_ID,+ position: { x: 20, y: 20 },+ type: 'invocation',+};++const projectGraph: ProjectGraphState = { ...createProjectGraph('preview-test'), nodes: [documentNode] };+const templates = { preview: template };+const flowNodes = toFlowNodes(projectGraph, [], templates);+const nodeTypes = { invocation: InvocationFlowNode };++const outputImage = (width: number, height: number): string => {+ const canvas = document.createElement('canvas');+ canvas.width = width;+ canvas.height = height;+ const context = canvas.getContext('2d')!;+ context.fillStyle = '#4c8bf5';+ context.fillRect(0, 0, width, height);+ return canvas.toDataURL();+};++const completed = (outputImageUrl: string): WorkflowNodeExecutionState => ({+ error: null,+ latestOutput: null,+ outputImageUrl,+ progress: null,+ progressMessage: null,+ status: 'completed',+});++/** A node-execution port the test can advance between renders. */+const createExecutionPort = () => {+ const listeners = new Set<() => void>();+ let state: WorkflowNodeExecutionState | null = null;++ return {+ port: {+ get: (nodeId: string) => (nodeId === NODE_ID ? state : null),+ subscribe: (_nodeId: string, listener: () => void) => {+ listeners.add(listener);+ return () => listeners.delete(listener);+ },+ },+ set(next: WorkflowNodeExecutionState) {+ state = next;+ listeners.forEach((listener) => listener());+ },+ };+};++const preferencesSnapshot = {+ reduceMotion: true,+ themeId: 'classic' as const,+ workflowEdgeStyle: 'curved' as const,+ workflowEdgesBehindNodes: false,+ workflowShowMinimap: false,+ workflowSnapToGrid: false,+ workflowValidateConnections: true,+};+const projectSnapshot = {+ galleryValues: {},+ id: 'project-1',+ isWorkflowRunning: false,+ projectGraph,+ workflowValues: {},+};++const createAdapter = (nodeExecution: WorkflowUiAdapter['nodeExecution']): WorkflowUiAdapter =>+ ({+ capabilities: { getSnapshot: () => ({ canUseCache: true }), subscribe: () => () => {} },+ commands: { bindLibraryWorkflow: vi.fn(), editGraph: vi.fn(), redo: vi.fn(), replace: vi.fn(), undo: vi.fn() },+ getProjectGraph: () => projectGraph,+ nodeExecution,+ notifications: { error: vi.fn(), info: vi.fn(), success: vi.fn() },+ openAddModels: vi.fn(),+ performance: {+ mark: vi.fn(),+ measure: vi.fn(),+ time: <T,>(_name: string, _source: unknown, callback: () => T) => callback(),+ },+ preferences: { getSnapshot: () => preferencesSnapshot, subscribe: () => () => {} },+ project: { getSnapshot: () => projectSnapshot, subscribe: () => () => {} },+ registerModalHotkeyLayer: vi.fn(() => vi.fn()),+ widgets: { open: vi.fn(), patchValues: vi.fn() },+ }) as unknown as WorkflowUiAdapter;++describe('InvocationFlowNode output preview', () => {+ let host: HTMLDivElement;+ let root: Root;++ beforeEach(() => {+ setNodePreviewCollapsed(NODE_ID, false);+ host = document.createElement('div');+ host.style.cssText = 'width: 480px; height: 520px;';+ document.body.append(host);+ root = createRoot(host);+ });++ afterEach(async () => {+ await act(() => root.unmount());+ host.remove();+ });++ const render = (adapter: WorkflowUiAdapter, zoom = 1) =>+ act(() =>+ root.render(+ <ChakraProvider value={system}>+ <WorkflowUiProvider adapter={adapter}>+ <ReactFlow+ defaultViewport={{ x: 0, y: 0, zoom }}+ edges={[]}+ minZoom={0.1}+ nodes={flowNodes}+ nodeTypes={nodeTypes}+ />+ </WorkflowUiProvider>+ </ChakraProvider>+ )+ );+ const image = () => host.querySelector<HTMLImageElement>('.react-flow__node img');+ const disclosure = () =>+ [...host.querySelectorAll<HTMLButtonElement>('.react-flow__node button[aria-expanded]')].find(+ (button) => button.textContent === 'Latest output'+ )!;+ const nodeHeight = () => host.querySelector<HTMLElement>('.react-flow__node')!.getBoundingClientRect().height;++ it('keeps one preview height across differently shaped outputs and folds it away per node', async () => {+ const execution = createExecutionPort();+ const adapter = createAdapter(execution.port);++ await render(adapter);+ expect(image()).toBeNull();+ expect(disclosure()).toBeUndefined();++ 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)));+ expect(image()!.getBoundingClientRect().height).toBeCloseTo(previewHeightPx(), 0);+ expect(nodeHeight()).toBe(heightWithWideOutput);++ await act(() => disclosure().click());+ 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());+ root = createRoot(host);+ await render(adapter);+ expect(disclosure().getAttribute('aria-expanded')).toBe('false');+ expect(image()).toBeNull();++ await act(() => disclosure().click());+ expect(disclosure().getAttribute('aria-expanded')).toBe('true');+ await vi.waitFor(() => expect(image()!.getBoundingClientRect().height).toBeCloseTo(previewHeightPx(), 0));+ });++ it('stands in a same-height skeleton for the image when the viewport is zoomed out', async () => {+ const execution = createExecutionPort();+ const adapter = createAdapter(execution.port);+ execution.set(completed(outputImage(400, 100)));++ await render(adapter);+ await vi.waitFor(() => expect(image()).not.toBeNull());+ const node = () => host.querySelector<HTMLElement>('.react-flow__node')!;+ const layoutHeight = node().offsetHeight;++ await act(() => root.unmount());+ root = createRoot(host);+ await render(adapter, 0.3);++ await vi.waitFor(() => expect(image()).toBeNull());+ expect(node().offsetHeight).toBe(layoutHeight);+ });+});++describe('InvocationFlowNode edge stacking', () => {+ let host: HTMLDivElement;+ let root: Root;++ beforeEach(() => {+ host = document.createElement('div');+ host.style.cssText = 'width: 400px; height: 500px;';+ document.body.append(host);+ root = createRoot(host);+ });++ afterEach(async () => {+ await act(() => root.unmount());+ host.remove();+ });++ /** Screen-space samples along an edge's hit path that fall inside `rect`, with what the pointer would hit there. */+ const hitsInside = (path: SVGGeometryElement, rect: DOMRect) => {+ const svg = path.ownerSVGElement!;+ const matrix = svg.getScreenCTM()!;+ const length = path.getTotalLength();+ const hits: Element[] = [];++ for (let step = 0; step <= 80; step += 1) {+ const point = path.getPointAtLength((length * step) / 80).matrixTransform(matrix);++ if (point.x > rect.left + 2 && point.x < rect.right - 2 && point.y > rect.top + 2 && point.y < rect.bottom - 2) {+ hits.push(document.elementFromPoint(point.x, point.y)!);+ }+ }++ return hits;+ };++ it('keeps a selected node clickable where its own edge crosses it, while the edge stays above other nodes', async () => {+ // The target sits behind and above the source, so the edge leaves the source's right handle and+ // sweeps back across the source's own body and over an unrelated node on the way. Everything stays+ // inside the test viewport.+ const target: WorkflowInvocationNode = { ...documentNode, id: 'target-node', position: { x: 0, y: 0 } };+ const bystander: WorkflowInvocationNode = { ...documentNode, id: 'bystander-node', position: { x: 20, y: 120 } };+ const graph: ProjectGraphState = {+ ...projectGraph,+ edges: [+ { id: 'e', source: NODE_ID, sourceHandle: 'value', target: target.id, targetHandle: 'a', type: 'default' },+ ],+ nodes: [{ ...documentNode, position: { x: 100, y: 220 } }, target, bystander],+ };+ const nodes = toFlowNodes(graph, [], templates).map((node) => ({ ...node, selected: node.id === NODE_ID }));+ const edges = toFlowEdges(graph, [], 'default', new Set([NODE_ID]), templates);++ await act(() =>+ root.render(+ <ChakraProvider value={system}>+ <WorkflowUiProvider adapter={createAdapter({ get: () => null, subscribe: () => () => {} })}>+ {/* The editor passes `elevateEdgesOnSelect` unless edges are kept behind nodes; xyflow defaults it off. */}+ <ReactFlow edges={edges} elevateEdgesOnSelect nodes={nodes} nodeTypes={nodeTypes} />+ </WorkflowUiProvider>+ </ChakraProvider>+ )+ );++ const path = await vi.waitFor(() => {+ const element = host.querySelector<SVGGeometryElement>('.react-flow__edge-interaction');+ expect(element?.getTotalLength()).toBeGreaterThan(0);+ return element!;+ });+ const selectedNode = host.querySelector<HTMLElement>(`.react-flow__node[data-id="${NODE_ID}"]`)!;+ const otherNode = host.querySelector<HTMLElement>(`.react-flow__node[data-id="${bystander.id}"]`)!;+ const overSelected = hitsInside(path, selectedNode.getBoundingClientRect());+ const overOther = hitsInside(path, otherNode.getBoundingClientRect());++ expect(overSelected.length).toBeGreaterThan(0);+ expect(overSelected.every((hit) => selectedNode.contains(hit))).toBe(true);+ expect(overOther.length).toBeGreaterThan(0);+ expect(overOther.some((hit) => hit.closest('.react-flow__edge') !== null)).toBe(true);+ });+});diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsxindex b029ce6c47..9a486baeb6 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx@@ -2,7 +2,20 @@import type { FieldInputTemplate, FieldOutputTemplate, WorkflowInvocationNode } from '@features/workflow/contracts';import type { WorkflowNodeExecutionState as NodeExecutionState } from '@features/workflow/ui/contracts';-import { Box, Checkbox, Field, Flex, HStack, Icon, IconButton, Image, Input, Stack, Text } from '@chakra-ui/react';+import {+ Box,+ chakra,+ Checkbox,+ Field,+ Flex,+ HStack,+ Icon,+ IconButton,+ Image,+ Input,+ Stack,+ Text,+} 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';@@ -12,12 +25,14 @@ import {getWorkflowNodeHeaderProps,getWorkflowNodeShellProps,WORKFLOW_NODE_DENSITY,+ WORKFLOW_NODE_SURFACE_TOKEN,WorkflowNodeInfoIcon,WorkflowNodeOutcomeIcon,type WorkflowNodeOutcome,} from '@features/workflow/ui/nodeChrome';import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';import { useWorkflowNodeExecutionState } from '@features/workflow/ui/WorkflowUiContext';+import { setNodePreviewCollapsed, workflowUiStore } from '@features/workflow/ui/workflowUiStore';import {cloneWorkflowFieldDefault,formatOutputFieldValue,@@ -29,11 +44,12 @@ import {isExposableField,isWorkflowFieldValueDefault,} from '@features/workflow/utility';+import { useExternalStoreSelector } from '@platform/state/selectors';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 { memo, useState, type ChangeEvent, type KeyboardEvent } 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';@@ -265,6 +281,80 @@ const NodeInfoIcon = ({/>);+/** Fixed so a run's differently shaped outputs do not resize the node and shove its neighbours around. */+const NODE_OUTPUT_PREVIEW_HEIGHT = '10rem';++/**+ * The node's latest output image behind a disclosure. The fold is session-lived+ * (`workflowUiStore`), matching the preview itself, so it is not a graph edit.+ */+const NodeOutputPreview = ({+ imageUrl,+ isSkeleton,+ nodeId,+ roundedBottom,+}: {+ imageUrl: string;+ isSkeleton: boolean;+ nodeId: string;+ roundedBottom: boolean;+}) => {+ const { t } = useTranslation();+ const contentId = useId();+ const collapsed = useExternalStoreSelector(workflowUiStore.subscribe, workflowUiStore.getSnapshot, (snapshot) =>+ snapshot.collapsedPreviewNodeIds.has(nodeId)+ );++ return (+ <Box borderBottomRadius={roundedBottom ? 'lg' : 'none'} borderColor="border.subtle" borderTopWidth="1px">+ <chakra.button+ alignItems="center"+ aria-controls={contentId}+ aria-expanded={!collapsed}+ className="nodrag"+ display="flex"+ focusVisibleRing="inside"+ gap="1"+ px={WORKFLOW_NODE_DENSITY.rowPaddingX}+ py="1"+ textAlign="start"+ type="button"+ w="full"+ onClick={() => setNodePreviewCollapsed(nodeId, !collapsed)}+ >+ <Icon as={collapsed ? ChevronRightIcon : ChevronDownIcon} boxSize="3" color="fg.subtle" />+ <Text+ color="fg.subtle"+ fontSize="2xs"+ fontWeight="600"+ letterSpacing="wide"+ lineHeight="1"+ textTransform="uppercase"+ >+ {t('nodes.latestOutput')}+ </Text>+ </chakra.button>+ {/* The frame behind the image keeps a letterboxed output reading as a picture, not a gap. */}+ <Box id={contentId} hidden={collapsed} pb="1.5" px={WORKFLOW_NODE_DENSITY.rowPaddingX}>+ {collapsed ? null : isSkeleton ? (+ <SkeletonBar h={NODE_OUTPUT_PREVIEW_HEIGHT} w="full" />+ ) : (+ <Image+ alt={t('nodes.latestOutputImage')}+ bg={WORKFLOW_NODE_SURFACE_TOKEN}+ draggable={false}+ h={NODE_OUTPUT_PREVIEW_HEIGHT}+ objectFit="contain"+ rounded="sm"+ src={imageUrl}+ w="full"+ />+ )}+ </Box>+ </Box>+ );+};+const NodeFooter = ({ canUseCache, node }: { canUseCache: boolean; node: WorkflowInvocationNode }) => {const { editGraph } = useProjectGraphCommands();@@ -775,21 +865,12 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode<HiddenHandles inputTemplates={inputTemplates} outputTemplates={outputTemplates} />)}{isOpen && execution?.outputImageUrl ? (- <Box borderBottomRadius={withFooter ? 'none' : 'lg'} borderColor="border.subtle" borderTopWidth="1px" p="1.5">- {isZoomedOut ? (- <SkeletonBar h="6rem" w="full" />- ) : (- <Image- alt="Latest output of this node"- draggable={false}- maxH="10rem"- mx="auto"- objectFit="contain"- rounded="sm"- src={execution.outputImageUrl}- />- )}- </Box>+ <NodeOutputPreview+ imageUrl={execution.outputImageUrl}+ isSkeleton={isZoomedOut}+ nodeId={node.id}+ roundedBottom={!withFooter}+ />) : null}{isOpen && withFooter ? <NodeFooter canUseCache={data.canUseCache} node={node} /> : null}</NodeShell>diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts b/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.tsindex c8dc983b77..c0ac0995af 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.test.ts@@ -337,7 +337,10 @@ describe('flowAdapters identity preservation', () => {expect(highlighted[0]?.animated).toBe(true);expect(highlighted[0]?.className).toBe('workflow-selected-node-edge');- expect(highlighted[0]?.zIndex).toBe(1000);+ // xyflow already lifts these edges with `elevateEdgesOnSelect`; adding a z-index of our own+ // stacked them above the selected node, where their 20px interaction path swallowed clicks+ // on its controls.+ expect(highlighted[0]?.zIndex).toBeUndefined();expect(highlighted[0]?.style).toEqual({ strokeWidth: 2 });expect(toFlowEdges(doc, highlighted, 'default', new Set(['a']))[0]).toBe(highlighted[0]);@@ -346,7 +349,6 @@ describe('flowAdapters identity preservation', () => {expect(cleared[0]).not.toBe(highlighted[0]);expect(cleared[0]?.animated).toBeUndefined();expect(cleared[0]?.className).toBeUndefined();- expect(cleared[0]?.zIndex).toBeUndefined();expect(cleared[0]?.style).toBeUndefined();});@@ -356,7 +358,6 @@ describe('flowAdapters identity preservation', () => {expect(highlighted[0]?.animated).toBeUndefined();expect(highlighted[0]?.className).toBe('workflow-selected-node-edge');- expect(highlighted[0]?.zIndex).toBe(1000);expect(highlighted[0]?.style).toEqual({ strokeWidth: 2 });});});diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.ts b/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.tsindex 290333f057..c4583501db 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.ts+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/flowAdapters.ts@@ -419,7 +419,6 @@ export const toFlowEdges = (const animated = isConnectedToSelectedNode && !reduceMotion ? true : undefined;const className = isConnectedToSelectedNode ? SELECTED_NODE_EDGE_CLASS : undefined;const style = isConnectedToSelectedNode ? SELECTED_NODE_EDGE_STYLE : undefined;- const zIndex = isConnectedToSelectedNode ? 1000 : undefined;if (previous &&@@ -431,8 +430,7 @@ export const toFlowEdges = (previous.animated === animated &&previous.className === className &&isSameEdgeData(previous.data, data) &&- previous.style === style &&- previous.zIndex === zIndex+ previous.style === style) {return previous;}@@ -449,7 +447,6 @@ export const toFlowEdges = (target: edge.target,targetHandle: edge.targetHandle,type: flowType,- zIndex,};});};diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/workflowUiStore.ts b/invokeai/frontend/webv2/src/features/workflow/ui/workflowUiStore.tsindex 01039c5101..e57a5cfd11 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/workflowUiStore.ts+++ b/invokeai/frontend/webv2/src/features/workflow/ui/workflowUiStore.ts@@ -27,6 +27,8 @@ export type AddNodeConnectionFilter =export interface WorkflowUiSnapshot {addNodeConnection: AddNodeConnectionFilter | null;addNodePosition: XYPosition | null;+ /** Nodes whose latest-output preview is folded away. Session-lived, like the previews themselves. */+ collapsedPreviewNodeIds: ReadonlySet<string>;isAddNodeOpen: boolean;isLibraryOpen: boolean;isNewWorkflowConfirmOpen: boolean;@@ -46,6 +48,7 @@ let nextLibraryWorkflowLoadRequestId = 0;const INITIAL_WORKFLOW_UI_SNAPSHOT: WorkflowUiSnapshot = {addNodeConnection: null,addNodePosition: null,+ collapsedPreviewNodeIds: new Set(),importRequestCount: 0,isAddNodeOpen: false,isLibraryOpen: false,@@ -95,6 +98,18 @@ export const clearPendingLibraryWorkflowLoad = (requestId: number): void => {}};+export const setNodePreviewCollapsed = (nodeId: string, collapsed: boolean): void => {+ const collapsedPreviewNodeIds = new Set(workflowUiStore.getSnapshot().collapsedPreviewNodeIds);++ if (collapsed) {+ collapsedPreviewNodeIds.add(nodeId);+ } else {+ collapsedPreviewNodeIds.delete(nodeId);+ }++ workflowUiStore.patchSnapshot({ collapsedPreviewNodeIds });+};+export const requestWorkflowImport = (): void => {workflowUiStore.patchSnapshot({ importRequestCount: workflowUiStore.getSnapshot().importRequestCount + 1 });};