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): preserve seed modes in snapshot exports
JPPhoto17e86a2a4073
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 5857841d02..4626fe933a 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@@ -675,6 +675,59 @@ describe('InvocationFlowNode output preview', () => {expect(capturedClone?.querySelector('button')).toBeNull();});+ it.each([+ ['fixed', '42'],+ ['random', 'Random'],+ ['increment', '42 (Increment)'],+ ['decrement', '42 (Decrement)'],+ [undefined, '42'],+ ] as const)('preserves authored seed mode %s in snapshot exports', async (seedMode, expected) => {+ const seedTemplate: InvocationTemplate = {+ ...template,+ inputs: {+ seed: { ...template.inputs.a!, input: 'direct', maximum: 4_294_967_295, name: 'seed', title: 'Seed' },+ },+ };+ const seedNode: WorkflowInvocationNode = {+ ...documentNode,+ data: { ...documentNode.data, inputs: { seed: { label: '', name: 'seed', seedMode, value: 42 } } },+ };+ const ordinaryNode: WorkflowInvocationNode = {+ ...documentNode,+ id: 'ordinary-integer',+ position: { x: 420, y: 20 },+ data: { ...documentNode.data, type: 'ordinary', inputs: { a: { label: '', name: 'a', seedMode, value: 42 } } },+ };+ const graph = { ...projectGraph, nodes: [seedNode, ordinaryNode] };+ const nodes = toFlowNodes(graph, [], {+ preview: seedTemplate,+ ordinary: { ...template, type: 'ordinary', inputs: { a: { ...template.inputs.a!, input: 'direct' } } },+ });+ 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: 720, height: 260 },+ fallbackWorkflowName: 'Untitled Workflow',+ flowElement: host.querySelector<HTMLElement>('.react-flow')!,+ workflowName: 'Seed modes',+ });++ expect(+ capturedClone?.querySelector(`[data-id="${NODE_ID}"] [data-workflow-export-field-value="true"]`)?.textContent+ ).toBe(expected);+ expect(+ capturedClone?.querySelector('[data-id="ordinary-integer"] [data-workflow-export-field-value="true"]')+ ?.textContent+ ).toBe('42');+ expect(capturedClone?.querySelector('input, button, [role="menu"]')).toBeNull();+ });+it('omits legacy generator results while preserving generator settings in snapshot exports', async () => {const generatorTemplate: InvocationTemplate = {...template,diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsxindex 1a649f39a4..b84df1963d 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx@@ -724,7 +724,11 @@ const InputFieldRow = ({</HStack>{showsControl ? (isWorkflowImageExport ? (- <WorkflowFieldSnapshot template={template} value={instance?.value} />+ <WorkflowFieldSnapshot+ seedMode={getWorkflowFieldSeedMode(instance)}+ template={template}+ value={instance?.value}+ />) : (<Box mt="0.5" w="full"><WorkflowFieldInputdiff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsxindex 22e34999d4..c60fac2c5e 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx@@ -1925,8 +1925,21 @@ const formatSnapshotValue = (value: unknown, template: FieldInputTemplate): stri};/** Renders authored values without mounting editors or resolving runtime diagnostics. */-export const WorkflowFieldSnapshot = ({ template, value }: { template: FieldInputTemplate; value: unknown }) => {- const text = formatSnapshotValue(value, template);+export const WorkflowFieldSnapshot = ({+ seedMode = 'fixed',+ template,+ value,+}: {+ seedMode?: SeedMode;+ template: FieldInputTemplate;+ value: unknown;+}) => {+ const { t } = useTranslation();+ let text = formatSnapshotValue(value, template);+ if (isSeedInputField(template) && seedMode !== 'fixed') {+ const modeLabel = t(`common.seedMode.${seedMode}`);+ text = seedMode === 'random' || !text ? modeLabel : `${text} (${modeLabel})`;+ }return text ? (<Text