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.

feat(webv2): update outdated workflow nodes to their template versions

Josh Corbett34cbd98b6b06
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 0d4571d169..23c17eff53 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -1519,6 +1519,23 @@
"noMatchingSystemPrompts": "No matching system prompts",
"recordListLoading": "Loading…",
"recordListFailed": "The list could not be loaded.",
+ "updateNode": "Update node",
+ "updateAllNodes_one": "Update {{count}} outdated node",
+ "updateAllNodes_other": "Update {{count}} outdated nodes",
+ "updateNodeTo": "Update to {{version}}",
+ "nodeUpdateAvailable": "Version {{from}} → {{to}}: update available",
+ "nodeNewerThanBackend": "Version {{from}} is newer than this Invoke installation supports ({{to}}); update Invoke",
+ "nodeVersionIncompatible": "Version {{from}} cannot be updated to {{to}}; delete and re-add the node",
+ "unableToUpdateNodes_one": "{{count}} node could not be updated to its current version.",
+ "unableToUpdateNodes_other": "{{count}} nodes could not be updated to their current versions.",
+ "updateDroppedEdges_one": "Removed {{count}} connection to an input its updated node no longer has.",
+ "updateDroppedEdges_other": "Removed {{count}} connections to inputs their updated nodes no longer have.",
+ "updateDroppedFormFields_one": "Removed {{count}} form field for an input its updated node no longer has.",
+ "updateDroppedFormFields_other": "Removed {{count}} form fields for inputs their updated nodes no longer have.",
+ "contextPaste": "Paste",
+ "contextCollapse": "Collapse",
+ "contextExpand": "Expand",
+ "contextAddConnector": "Add connector",
"collectionItemCount_one": "{{count}} item",
"collectionItemCount_other": "{{count}} items",
"forLoopBodyBoundaryStatus": {
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts
index b386bfab6c..40e6645e9e 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/document.test.ts
@@ -1,15 +1,19 @@
import { describe, expect, it } from 'vitest';
-import type { InvocationTemplate, ProjectGraphState, WorkflowEdge } from './types';
+import type { InvocationTemplate, ProjectGraphState, WorkflowEdge, WorkflowInvocationNode } from './types';
+import { CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX } from './callSavedWorkflow';
import {
buildInvocationNode,
createProjectGraph,
getFormChildren,
+ getNodeUpdateStatus,
getProjectGraphUndoEntry,
+ getUpdatableNodeIds,
isFieldExposed,
normalizeProjectGraph,
projectGraphReducer,
+ updateWorkflowNodes,
} from './document';
const template: InvocationTemplate = {
@@ -445,3 +449,265 @@ describe('getProjectGraphUndoEntry', () => {
expect(getProjectGraphUndoEntry({ isOpen: false, nodeId: 'n', type: 'setNodeIsOpen' })).toBeNull();
});
});
+
+describe('node updates', () => {
+ const input = (
+ name: string,
+ overrides: Partial<InvocationTemplate['inputs'][string]> = {}
+ ): InvocationTemplate['inputs'][string] => ({
+ ...(template.inputs.a as InvocationTemplate['inputs'][string]),
+ name,
+ title: name.toUpperCase(),
+ ...overrides,
+ });
+ const templateV110: InvocationTemplate = {
+ ...template,
+ inputs: { a: input('a'), b: input('b', { default: 5 }) },
+ version: '1.1.0',
+ };
+ const oldNode = (): WorkflowInvocationNode => ({
+ ...buildInvocationNode(template, { x: 4, y: 8 }),
+ data: {
+ ...buildInvocationNode(template, { x: 4, y: 8 }).data,
+ inputs: {
+ a: { label: 'Custom A', name: 'a', value: 3 },
+ z: { label: '', name: 'z', value: 'obsolete' },
+ },
+ label: 'My add',
+ notes: 'keep me',
+ useCache: false,
+ },
+ id: 'add-1',
+ });
+
+ it('reports whether a node can move to its template version', () => {
+ const node = oldNode();
+
+ expect(getNodeUpdateStatus(node, template)).toBe('current');
+ expect(getNodeUpdateStatus(node, templateV110)).toBe('updatable');
+ expect(getNodeUpdateStatus(node, { ...template, version: '2.0.0' })).toBe('incompatible');
+ expect(getNodeUpdateStatus(node, { ...template, version: 'next' })).toBe('incompatible');
+ expect(getNodeUpdateStatus(node, { ...template, type: 'subtract' })).toBe('incompatible');
+ expect(getNodeUpdateStatus({ ...node, data: { ...node.data, version: '1.2.0' } }, templateV110)).toBe('newer');
+ // Custom node packs ship prerelease tags and short versions; they still compare by their numbers.
+ expect(getNodeUpdateStatus({ ...node, data: { ...node.data, version: 'v1.0.0-beta.2' } }, templateV110)).toBe(
+ 'updatable'
+ );
+ expect(getNodeUpdateStatus({ ...node, data: { ...node.data, version: '1.1' } }, templateV110)).toBe('current');
+ });
+
+ it('lists the nodes an update would move, leaving newer and incompatible ones out', () => {
+ const doc = {
+ ...createProjectGraph('update-test'),
+ nodes: [
+ oldNode(),
+ { ...oldNode(), data: { ...oldNode().data, version: '1.5.0' }, id: 'newer' },
+ { ...oldNode(), data: { ...oldNode().data, version: '0.9.0' }, id: 'major' },
+ { ...oldNode(), data: { ...oldNode().data, version: '1.1.0' }, id: 'current' },
+ { ...oldNode(), data: { ...oldNode().data, type: 'unknown' }, id: 'no-template' },
+ ],
+ };
+
+ expect(getUpdatableNodeIds(doc, { add: templateV110 })).toEqual(['add-1']);
+ });
+
+ it('merges fresh defaults under the stored node, drops inputs the template lost, and cleans their edges and form elements', () => {
+ const node = oldNode();
+ let doc: ProjectGraphState = {
+ ...createProjectGraph('update-test'),
+ edges: [
+ { id: 'e-a', source: 'src', sourceHandle: 'value', target: 'add-1', targetHandle: 'a', type: 'default' },
+ { id: 'e-z', source: 'src', sourceHandle: 'value', target: 'add-1', targetHandle: 'z', type: 'default' },
+ ],
+ nodes: [buildInvocationNode({ ...template, type: 'src' }, { x: 0, y: 0 }), node],
+ };
+
+ doc = { ...doc, nodes: doc.nodes.map((n) => (n.id === doc.nodes[0]?.id ? { ...n, id: 'src' } : n)) };
+ doc = projectGraphReducer(doc, { fieldIdentifier: { fieldName: 'a', nodeId: 'add-1' }, type: 'exposeField' });
+ doc = projectGraphReducer(doc, { fieldIdentifier: { fieldName: 'z', nodeId: 'add-1' }, type: 'exposeField' });
+
+ const update = updateWorkflowNodes(doc, { add: templateV110 });
+ const updated = update.document.nodes.find((n) => n.id === 'add-1');
+
+ expect(update.updatedNodeIds).toEqual(['add-1']);
+ expect(update.skippedNodeIds).toEqual([]);
+ expect(update.droppedEdgeIds).toEqual(['e-z']);
+ expect(update.droppedFormElementIds).toHaveLength(1);
+ expect(updated?.type === 'invocation' && updated.data).toMatchObject({
+ inputs: {
+ a: { label: 'Custom A', name: 'a', value: 3 },
+ b: { label: '', name: 'b', value: 5 },
+ },
+ label: 'My add',
+ notes: 'keep me',
+ useCache: false,
+ version: '1.1.0',
+ });
+ expect(updated?.type === 'invocation' ? Object.keys(updated.data.inputs) : []).toEqual(['a', 'b']);
+ expect(updated?.position).toEqual({ x: 4, y: 8 });
+ expect(update.document.edges.map((edge) => edge.id)).toEqual(['e-a']);
+ expect(isFieldExposed(update.document.form, { fieldName: 'a', nodeId: 'add-1' })).toBe(true);
+ expect(isFieldExposed(update.document.form, { fieldName: 'z', nodeId: 'add-1' })).toBe(false);
+ });
+
+ it('fills a cleared value from the template but keeps dynamic and extra-input node inputs', () => {
+ const cleared: WorkflowInvocationNode = {
+ ...oldNode(),
+ data: {
+ ...oldNode().data,
+ dynamicInputTemplates: { dyn: input('dyn') },
+ inputs: {
+ a: { label: '', name: 'a', value: undefined },
+ dyn: { label: '', name: 'dyn', value: 'dynamic' },
+ [`${CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX}x`]: {
+ label: '',
+ name: `${CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX}x`,
+ value: 1,
+ },
+ },
+ },
+ };
+ const doc = { ...createProjectGraph('update-test'), nodes: [cleared] };
+ const updated = updateWorkflowNodes(doc, { add: templateV110 }).document.nodes[0];
+
+ expect(updated?.type === 'invocation' ? updated.data.inputs : {}).toMatchObject({
+ a: { value: 1 },
+ b: { value: 5 },
+ dyn: { value: 'dynamic' },
+ [`${CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX}x`]: { value: 1 },
+ });
+
+ const metadata: WorkflowInvocationNode = {
+ ...oldNode(),
+ data: {
+ ...oldNode().data,
+ inputs: { extra: { label: '', name: 'extra', value: 'kept' } },
+ type: 'core_metadata',
+ },
+ };
+ const metadataUpdate = updateWorkflowNodes(
+ { ...createProjectGraph('update-test'), nodes: [metadata] },
+ { core_metadata: { ...templateV110, type: 'core_metadata' } }
+ ).document.nodes[0];
+
+ expect(metadataUpdate?.type === 'invocation' ? metadataUpdate.data.inputs.extra?.value : null).toBe('kept');
+ });
+
+ it('skips nodes newer than or a major away from their template and returns the same document when nothing changes', () => {
+ const newer: WorkflowInvocationNode = { ...oldNode(), data: { ...oldNode().data, version: '1.5.0' }, id: 'newer' };
+ const major: WorkflowInvocationNode = { ...oldNode(), data: { ...oldNode().data, version: '0.9.0' }, id: 'major' };
+ const current: WorkflowInvocationNode = {
+ ...oldNode(),
+ data: { ...oldNode().data, version: '1.1.0' },
+ id: 'current',
+ };
+ const doc = { ...createProjectGraph('update-test'), nodes: [newer, major, current] };
+ const update = updateWorkflowNodes(doc, { add: templateV110 });
+
+ expect(update.document).toBe(doc);
+ expect(update.updatedNodeIds).toEqual([]);
+ expect(update.skippedNodeIds).toEqual(['newer', 'major']);
+ expect(updateWorkflowNodes(doc, {}).document).toBe(doc);
+ });
+
+ it('moves an old image_collection list from collection to images unless collection is connected', () => {
+ const imageList = { batch: false, cardinality: 'COLLECTION' as const, name: 'ImageField' };
+ const collectionTemplate: InvocationTemplate = {
+ ...template,
+ inputs: {
+ collection: input('collection', { default: undefined, input: 'connection', type: imageList }),
+ images: input('images', { default: [], type: imageList }),
+ },
+ type: 'image_collection',
+ version: '1.0.2',
+ };
+ const images = [{ image_name: 'a.png' }];
+ const node = (id: string): WorkflowInvocationNode => ({
+ ...oldNode(),
+ data: {
+ ...oldNode().data,
+ inputs: { collection: { label: '', name: 'collection', value: images } },
+ type: 'image_collection',
+ version: '1.0.1',
+ },
+ id,
+ });
+ let doc: ProjectGraphState = {
+ ...createProjectGraph('update-test'),
+ edges: [
+ { id: 'e', source: 'src', sourceHandle: 'x', target: 'wired', targetHandle: 'collection', type: 'default' },
+ ],
+ nodes: [node('free'), node('wired')],
+ };
+
+ doc = projectGraphReducer(doc, {
+ fieldIdentifier: { fieldName: 'collection', nodeId: 'free' },
+ type: 'exposeField',
+ });
+
+ const update = updateWorkflowNodes(doc, { image_collection: collectionTemplate });
+ const free = update.document.nodes.find((n) => n.id === 'free');
+ const wired = update.document.nodes.find((n) => n.id === 'wired');
+
+ expect(free?.type === 'invocation' ? free.data.inputs : {}).toMatchObject({
+ collection: { value: undefined },
+ images: { value: images },
+ });
+ expect(wired?.type === 'invocation' ? wired.data.inputs : {}).toMatchObject({
+ collection: { value: images },
+ images: { value: [] },
+ });
+ // The exposed form element follows the value to its new input.
+ expect(isFieldExposed(update.document.form, { fieldName: 'images', nodeId: 'free' })).toBe(true);
+ expect(isFieldExposed(update.document.form, { fieldName: 'collection', nodeId: 'free' })).toBe(false);
+ });
+
+ it('turns a stored minimax_h3_denoise frame count into the matching choice or the default', () => {
+ const framesTemplate: InvocationTemplate = {
+ ...template,
+ inputs: {
+ num_frames: input('num_frames', {
+ default: '124',
+ options: ['90', '124'],
+ type: { batch: false, cardinality: 'SINGLE', name: 'EnumField' },
+ }),
+ },
+ type: 'minimax_h3_denoise',
+ version: '1.4.0',
+ };
+ const node = (id: string, frames: number): WorkflowInvocationNode => ({
+ ...oldNode(),
+ data: {
+ ...oldNode().data,
+ inputs: { num_frames: { label: '', name: 'num_frames', value: frames } },
+ type: 'minimax_h3_denoise',
+ version: '1.2.0',
+ },
+ id,
+ });
+ const update = updateWorkflowNodes(
+ { ...createProjectGraph('update-test'), nodes: [node('on-grid', 90), node('off-grid', 100)] },
+ { minimax_h3_denoise: framesTemplate }
+ );
+ const value = (id: string) => {
+ const n = update.document.nodes.find((candidate) => candidate.id === id);
+
+ return n?.type === 'invocation' ? n.data.inputs.num_frames?.value : null;
+ };
+
+ expect(value('on-grid')).toBe('90');
+ expect(value('off-grid')).toBe('124');
+ });
+
+ it('applies through the reducer and is idempotent once every node is current', () => {
+ const doc = { ...createProjectGraph('update-test'), nodes: [oldNode()] };
+ const next = projectGraphReducer(doc, {
+ nodeIds: ['add-1'],
+ templates: { add: templateV110 },
+ type: 'updateNodes',
+ });
+
+ expect(next.nodes[0]?.type === 'invocation' ? next.nodes[0].data.version : null).toBe('1.1.0');
+ expect(projectGraphReducer(next, { templates: { add: templateV110 }, type: 'updateNodes' })).toBe(next);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/document.ts b/invokeai/frontend/webv2/src/features/workflow/core/document.ts
index a21e62e0dc..a3331fff06 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/document.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/document.ts
@@ -4,6 +4,7 @@ import type {
ContainerFormElement,
FieldIdentifier,
InvocationTemplate,
+ InvocationTemplates,
NodeFieldFormElement,
ProjectGraphState,
WorkflowCurrentImageNode,
@@ -21,6 +22,7 @@ import type {
} from './types';
import {
+ CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX,
clearSavedWorkflowDynamicFields,
setCallSavedWorkflowStatus,
syncCallSavedWorkflowFields,
@@ -284,6 +286,278 @@ const removeNodeFieldElements = (form: WorkflowForm, removedNodeIds: Set<string>
.filter((element) => element.type === 'node-field' && removedNodeIds.has(element.data.fieldIdentifier.nodeId))
.reduce((nextForm, element) => removeFormElement(nextForm, element.id), form);
+// #region Node updates
+
+export type WorkflowNodeUpdateStatus = 'current' | 'updatable' | 'incompatible' | 'newer';
+
+type Version = [number, number, number];
+
+/** `1.2.3`, with an optional `v`, a missing patch, or a prerelease tag (custom node packs use them). */
+const parseVersion = (version: string): Version | null => {
+ const match = /^v?(\d+)\.(\d+)(?:\.(\d+))?(?:[-+][\w.-]+)?$/.exec(version.trim());
+
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3] ?? 0)] : null;
+};
+
+const compareVersions = (a: Version, b: Version): number => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
+
+/**
+ * Whether a stored node can take its template's version. Only a same-major template merges safely: a template
+ * bumps its major when a value-preserving merge would leave the node invalid (the legacy rule).
+ */
+export const getNodeUpdateStatus = (
+ node: WorkflowInvocationNode,
+ template: InvocationTemplate
+): WorkflowNodeUpdateStatus => {
+ if (node.data.type !== template.type) {
+ return 'incompatible';
+ }
+
+ if (node.data.version === template.version) {
+ return 'current';
+ }
+
+ const nodeVersion = parseVersion(node.data.version);
+ const templateVersion = parseVersion(template.version);
+
+ if (!nodeVersion || !templateVersion || nodeVersion[0] !== templateVersion[0]) {
+ return 'incompatible';
+ }
+
+ const order = compareVersions(nodeVersion, templateVersion);
+
+ return order === 0 ? 'current' : order > 0 ? 'newer' : 'updatable';
+};
+
+/** Node types whose undeclared inputs the backend accepts (`extra='allow'`), so an update must carry them over. */
+const EXTRA_INPUT_NODE_TYPES = new Set(['core_metadata']);
+
+interface InvocationNodeUpdate {
+ node: WorkflowInvocationNode;
+ droppedInputNames: string[];
+ /** Inputs whose exposed form elements now belong to another input (`collection` → `images`). */
+ renamedInputs: Record<string, string>;
+}
+
+/**
+ * Fresh template defaults underneath the node's own values: existing labels, values, and node settings win, new
+ * inputs start at their defaults, inputs the template no longer declares are dropped (dynamic and extra inputs
+ * aside). The id is kept so edges survive.
+ */
+const updateInvocationNodeToTemplate = (
+ node: WorkflowInvocationNode,
+ template: InvocationTemplate,
+ connectedInputNames: ReadonlySet<string>
+): InvocationNodeUpdate => {
+ const fresh = buildInvocationNode(template, node.position);
+ const inputs: Record<string, WorkflowFieldInstance> = {};
+ const renamedInputs: Record<string, string> = {};
+ const droppedInputNames: string[] = [];
+
+ for (const [name, freshInstance] of Object.entries(fresh.data.inputs)) {
+ const existing = node.data.inputs[name];
+
+ inputs[name] = existing
+ ? { ...freshInstance, ...existing, value: existing.value === undefined ? freshInstance.value : existing.value }
+ : freshInstance;
+ }
+
+ for (const [name, instance] of Object.entries(node.data.inputs)) {
+ if (name in inputs) {
+ continue;
+ }
+
+ if (
+ EXTRA_INPUT_NODE_TYPES.has(node.data.type) ||
+ node.data.dynamicInputTemplates?.[name] !== undefined ||
+ name.startsWith(CALL_SAVED_WORKFLOW_DYNAMIC_FIELD_PREFIX)
+ ) {
+ inputs[name] = instance;
+ } else {
+ droppedInputNames.push(name);
+ }
+ }
+
+ const sourceVersion = parseVersion(node.data.version);
+
+ // `image_collection` 1.0.2 moved its direct list from `collection` to `images`; a connected `collection` keeps
+ // feeding the node and is left alone.
+ if (node.data.type === 'image_collection' && sourceVersion && compareVersions(sourceVersion, [1, 0, 2]) < 0) {
+ const collection = node.data.inputs.collection;
+ const images = inputs.images;
+
+ if (images) {
+ renamedInputs.collection = 'images';
+
+ if (
+ collection &&
+ Array.isArray(collection.value) &&
+ !(Array.isArray(images.value) && images.value.length > 0) &&
+ !connectedInputNames.has('collection')
+ ) {
+ inputs.images = { ...images, value: collection.value };
+
+ if (inputs.collection) {
+ inputs.collection = { ...inputs.collection, value: fresh.data.inputs.collection?.value };
+ }
+ }
+ }
+ }
+
+ // `minimax_h3_denoise` 1.3.0 turned the free frame count into a choice list; a count still on the grid becomes
+ // that choice, anything else falls back to the default.
+ if (node.data.type === 'minimax_h3_denoise' && sourceVersion && compareVersions(sourceVersion, [1, 3, 0]) < 0) {
+ const frames = inputs.num_frames;
+ const frameTemplate = template.inputs.num_frames;
+
+ if (frames && frameTemplate?.options && typeof frames.value === 'number') {
+ const choice = String(frames.value);
+
+ inputs.num_frames = {
+ ...frames,
+ value: frameTemplate.options.includes(choice) ? choice : frameTemplate.default,
+ };
+ }
+ }
+
+ return {
+ droppedInputNames,
+ node: { ...node, data: { ...node.data, inputs, version: template.version } },
+ renamedInputs,
+ };
+};
+
+export interface WorkflowNodesUpdate {
+ document: ProjectGraphState;
+ updatedNodeIds: string[];
+ /** Nodes whose template is newer by a major or older than the node; they need deleting and re-adding. */
+ skippedNodeIds: string[];
+ /** Edges and form elements that pointed at inputs the updated templates no longer declare. */
+ droppedEdgeIds: string[];
+ droppedFormElementIds: string[];
+}
+
+/** Nodes an `updateNodes` action would move; drives the update-all count and the per-node menu item. */
+export const getUpdatableNodeIds = (document: Pick<ProjectGraphState, 'nodes'>, templates: InvocationTemplates) =>
+ document.nodes.flatMap((node) => {
+ const template = isInvocationNode(node) ? templates[node.data.type] : undefined;
+
+ return isInvocationNode(node) && template && getNodeUpdateStatus(node, template) === 'updatable' ? [node.id] : [];
+ });
+
+/**
+ * Moves the given nodes (every invocation node by default) to their templates' versions, dropping edges and form
+ * elements that pointed at inputs the templates no longer declare. Returns the same document when nothing changed.
+ */
+export const updateWorkflowNodes = (
+ document: ProjectGraphState,
+ templates: InvocationTemplates,
+ nodeIds?: readonly string[]
+): WorkflowNodesUpdate => {
+ const wanted = nodeIds ? new Set(nodeIds) : null;
+ const updatedNodeIds: string[] = [];
+ const skippedNodeIds: string[] = [];
+ const droppedByNode = new Map<string, Set<string>>();
+ const renamedByNode = new Map<string, Record<string, string>>();
+ // One pass over the edges; a per-node scan is quadratic on the large graphs the load path opens.
+ const connectedInputsByNode = new Map<string, Set<string>>();
+
+ for (const edge of document.edges) {
+ if (edge.targetHandle) {
+ const handles = connectedInputsByNode.get(edge.target) ?? new Set<string>();
+
+ handles.add(edge.targetHandle);
+ connectedInputsByNode.set(edge.target, handles);
+ }
+ }
+
+ const nodes = document.nodes.map((node) => {
+ if (!isInvocationNode(node) || (wanted && !wanted.has(node.id))) {
+ return node;
+ }
+
+ const template = templates[node.data.type];
+
+ if (!template) {
+ return node;
+ }
+
+ const status = getNodeUpdateStatus(node, template);
+
+ if (status === 'current') {
+ return node;
+ }
+
+ if (status !== 'updatable') {
+ skippedNodeIds.push(node.id);
+ return node;
+ }
+
+ const update = updateInvocationNodeToTemplate(node, template, connectedInputsByNode.get(node.id) ?? new Set());
+
+ updatedNodeIds.push(node.id);
+
+ if (update.droppedInputNames.length > 0) {
+ droppedByNode.set(node.id, new Set(update.droppedInputNames));
+ }
+
+ if (Object.keys(update.renamedInputs).length > 0) {
+ renamedByNode.set(node.id, update.renamedInputs);
+ }
+
+ return update.node;
+ });
+
+ if (updatedNodeIds.length === 0) {
+ return { document, droppedEdgeIds: [], droppedFormElementIds: [], skippedNodeIds, updatedNodeIds };
+ }
+
+ const droppedEdgeIds = document.edges
+ .filter((edge) => edge.targetHandle && droppedByNode.get(edge.target)?.has(edge.targetHandle))
+ .map((edge) => edge.id);
+ const droppedEdgeIdSet = new Set(droppedEdgeIds);
+ const edges = document.edges.filter((edge) => !droppedEdgeIdSet.has(edge.id));
+ const droppedFormElementIds: string[] = [];
+ let form = document.form;
+
+ for (const element of Object.values(document.form.elements)) {
+ if (element.type !== 'node-field') {
+ continue;
+ }
+
+ const { fieldName, nodeId } = element.data.fieldIdentifier;
+ const renamedTo = renamedByNode.get(nodeId)?.[fieldName];
+
+ if (renamedTo) {
+ // The renamed input may already be exposed; one element per field keeps the form lookups unambiguous.
+ if (findNodeFieldElement(form, { fieldName: renamedTo, nodeId })) {
+ form = removeFormElement(form, element.id);
+ } else {
+ form = {
+ ...form,
+ elements: {
+ ...form.elements,
+ [element.id]: { ...element, data: { ...element.data, fieldIdentifier: { fieldName: renamedTo, nodeId } } },
+ },
+ };
+ }
+ } else if (droppedByNode.get(nodeId)?.has(fieldName)) {
+ form = removeFormElement(form, element.id);
+ droppedFormElementIds.push(element.id);
+ }
+ }
+
+ return {
+ document: { ...document, edges, form, nodes },
+ droppedEdgeIds,
+ droppedFormElementIds,
+ skippedNodeIds,
+ updatedNodeIds,
+ };
+};
+
+// #endregion
+
export type ProjectGraphAction =
| { type: 'addNode'; node: WorkflowNode }
| { type: 'addNodeAndEdge'; node: WorkflowNode; edge: WorkflowEdge | WorkflowEdge[] }
@@ -296,6 +570,8 @@ export type ProjectGraphAction =
| { type: 'setNodeIsIntermediate'; nodeId: string; isIntermediate: boolean }
| { type: 'setNodeUseCache'; nodeId: string; useCache: boolean }
| { type: 'setFieldValue'; nodeId: string; fieldName: string; value: unknown }
+ /** Moves nodes to their templates' versions; the reducer has no template access, so the action carries them. */
+ | { type: 'updateNodes'; templates: InvocationTemplates; nodeIds?: readonly string[] }
| {
type: 'syncCallSavedWorkflowFields';
nodeId: string;
@@ -358,6 +634,7 @@ const undoLabels: Partial<Record<ProjectGraphAction['type'], string>> = {
setNodeNotes: 'Edit workflow node notes',
setNodeUseCache: 'Change workflow node caching',
unexposeField: 'Remove workflow field from form',
+ updateNodes: 'Update workflow nodes',
};
export interface ProjectGraphUndoEntry {
@@ -552,6 +829,9 @@ const applyProjectGraphAction = (document: ProjectGraphState, action: ProjectGra
case 'setNodePosition': {
return updateNode(document, action.nodeId, (node) => ({ ...node, position: { ...action.position } }));
}
+ case 'updateNodes': {
+ return updateWorkflowNodes(document, action.templates, action.nodeIds).document;
+ }
case 'setNodeLabel': {
// Narrowed per branch so TS keeps the node type / data correlation through the spread.
return updateNode(document, action.nodeId, (node) => {
diff --git a/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts b/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts
index 53ecac8c10..d15caef250 100644
--- a/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/data/templates.test.ts
@@ -1,6 +1,21 @@
-import { describe, expect, it } from 'vitest';
+import type { ProjectGraphState } from '@features/workflow/core/types';
-import { parseFieldType, parseOpenApiToTemplates } from './templates';
+import { buildInvocationNode, createProjectGraph } from '@features/workflow/core/document';
+import { describe, expect, it, vi } from 'vitest';
+
+import {
+ parseFieldType,
+ parseOpenApiToTemplates,
+ refreshInvocationTemplates,
+ updateLoadedWorkflowNodes,
+} from './templates';
+
+const httpMock = vi.hoisted(() => ({ apiFetchJson: vi.fn() }));
+
+vi.mock('@platform/transport/http', async (importOriginal) => ({
+ ...(await importOriginal<Record<string, unknown>>()),
+ apiFetchJson: httpMock.apiFetchJson,
+}));
const openApiFixture = {
components: {
@@ -507,3 +522,43 @@ describe('integer Literal enum templates', () => {
expect(parsed.nullable_max_seq_len_invocation?.inputs.t5_max_seq_len?.default).toBe(256);
});
});
+
+describe('updateLoadedWorkflowNodes', () => {
+ const translate = (key: string, options: { count: number }) => `${key}:${options.count}`;
+ const outdatedDocument = (): ProjectGraphState => {
+ const templates = parseOpenApiToTemplates(openApiFixture);
+ const node = buildInvocationNode(templates.add!, { x: 0, y: 0 });
+
+ return {
+ ...createProjectGraph('load-test'),
+ edges: [
+ { id: 'stale', source: 'x', sourceHandle: 'value', target: node.id, targetHandle: 'gone', type: 'default' },
+ ],
+ nodes: [
+ {
+ ...node,
+ data: {
+ ...node.data,
+ inputs: { ...node.data.inputs, gone: { label: '', name: 'gone', value: 1 } },
+ version: '1.0.0',
+ },
+ },
+ ],
+ };
+ };
+
+ it('leaves a document alone until templates have loaded, then migrates it and words what was dropped', async () => {
+ const document = outdatedDocument();
+
+ expect(updateLoadedWorkflowNodes(document, translate)).toEqual({ document, warnings: [] });
+
+ httpMock.apiFetchJson.mockResolvedValueOnce(openApiFixture);
+ await refreshInvocationTemplates();
+
+ const { document: updated, warnings } = updateLoadedWorkflowNodes(document, translate);
+
+ expect(updated.nodes[0]?.type === 'invocation' ? updated.nodes[0].data.version : null).toBe('1.0.1');
+ expect(updated.edges).toEqual([]);
+ expect(warnings).toEqual(['nodes.updateDroppedEdges:1']);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/workflow/data/templates.ts b/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
index f431b00bd0..d8658aa326 100644
--- a/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/data/templates.ts
@@ -5,8 +5,10 @@ import type {
InvocationTemplate,
InvocationTemplates,
InvocationTemplatesSnapshot,
+ ProjectGraphState,
} from '@features/workflow/core/types';
+import { updateWorkflowNodes } from '@features/workflow/core/document';
import { isEditableCollectionFieldType } from '@features/workflow/core/fields';
import { createLogger } from '@platform/logging/logger';
import {
@@ -489,5 +491,36 @@ export const useInvocationTemplatesSelector = store.useSelector;
/** Imperative read for the workbench reducer and route validation. */
export const getInvocationTemplatesSnapshot = (): InvocationTemplatesSnapshot => store.getSnapshot();
+/**
+ * Moves a freshly parsed document's nodes to the loaded templates before it enters the project, so an outdated
+ * workflow opens current, and words what the update could not keep. A document loaded before templates arrive is
+ * left as is; the editor's update actions cover it later.
+ */
+export const updateLoadedWorkflowNodes = (
+ document: ProjectGraphState,
+ translate: (key: string, options: { count: number }) => string
+): { document: ProjectGraphState; warnings: string[] } => {
+ const snapshot = store.getSnapshot();
+
+ if (snapshot.status !== 'loaded') {
+ return { document, warnings: [] };
+ }
+
+ const update = updateWorkflowNodes(document, snapshot.templates);
+ const warnings = [
+ ...(update.skippedNodeIds.length > 0
+ ? [translate('nodes.unableToUpdateNodes', { count: update.skippedNodeIds.length })]
+ : []),
+ ...(update.droppedEdgeIds.length > 0
+ ? [translate('nodes.updateDroppedEdges', { count: update.droppedEdgeIds.length })]
+ : []),
+ ...(update.droppedFormElementIds.length > 0
+ ? [translate('nodes.updateDroppedFormFields', { count: update.droppedFormElementIds.length })]
+ : []),
+ ];
+
+ return { document: update.document, warnings };
+};
+
/** For readers that combine this store with another one; a single-store reader uses the selector. */
export const subscribeInvocationTemplates = store.subscribe;
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/PendingLibraryWorkflowLoader.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/PendingLibraryWorkflowLoader.tsx
index ed1cf6bb82..fba20eeaf5 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/PendingLibraryWorkflowLoader.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/PendingLibraryWorkflowLoader.tsx
@@ -1,4 +1,5 @@
import { getLibraryWorkflow, touchLibraryWorkflowOpenedAt } from '@features/workflow/data/api';
+import { updateLoadedWorkflowNodes } from '@features/workflow/data/templates';
import { requestWorkflowFitView } from '@features/workflow/ui/editor/flowInstanceStore';
import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';
import { useWorkflowNotifications } from '@features/workflow/ui/WorkflowUiContext';
@@ -45,10 +46,13 @@ export const PendingWorkflowLoader = () => {
}
assertAccountScopeCurrent(owner);
- const { document: parsed, warnings } = parseWorkflowJson(raw);
+ const { document: parsed, warnings: parseWarnings } = parseWorkflowJson(raw);
+ const { document: updated, warnings: updateWarnings } = updateLoadedWorkflowNodes(parsed, t);
+ const warnings = [...parseWarnings, ...updateWarnings];
+
// An embedded document may still carry the id of the library record it was
// saved from; loading it must not start autosaving over that record.
- const document = source.kind === 'library' ? parsed : { ...parsed, libraryWorkflowId: undefined };
+ const document = source.kind === 'library' ? updated : { ...updated, libraryWorkflowId: undefined };
replace(document, label);
requestWorkflowFitView(document.nodes);
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx
index f633ffa641..cc63581b73 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx
@@ -1,6 +1,7 @@
import type { InvocationTemplate, XYPosition } from '@features/workflow/contracts';
import { Box, HStack, Icon, Menu, Text } from '@chakra-ui/react';
+import { updateLoadedWorkflowNodes } from '@features/workflow/data/templates';
import { invalidateWorkflowLibraryCache, updateLibraryWorkflow } from '@features/workflow/queries';
import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';
import {
@@ -497,7 +498,9 @@ export const WorkflowDialogHost = () => {
file
.text()
.then((text) => {
- const { document, warnings } = parseWorkflowJson(JSON.parse(text));
+ const { document: parsed, warnings: parseWarnings } = parseWorkflowJson(JSON.parse(text));
+ const { document, warnings: updateWarnings } = updateLoadedWorkflowNodes(parsed, t);
+ const warnings = [...parseWarnings, ...updateWarnings];
replace(document, `Imported "${file.name}"`);
@@ -512,7 +515,7 @@ export const WorkflowDialogHost = () => {
);
});
},
- [notify, replace]
+ [notify, replace, t]
);
const handleImportFile = useCallback(
(event: ChangeEvent<HTMLInputElement>) => {
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.browser.test.tsx
index fcc7784491..b4369a1432 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.browser.test.tsx
@@ -74,6 +74,38 @@ describe('editor toolbar', () => {
expect(new Set(buttonBoxes())).toEqual(new Set(['28x28']));
});
+ it('offers to update outdated nodes only while there are some, without breaking the toolbar grid', async () => {
+ await render(1);
+ expect(host!.querySelector('button[aria-label="nodes.updateAllNodes"]')).toBeNull();
+
+ const onUpdateNodes = vi.fn();
+
+ await settle(() => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <EditorToolbar
+ nodeOpacity={1}
+ tool="pan"
+ updatableNodeCount={2}
+ onNodeOpacityChange={vi.fn()}
+ onToolChange={vi.fn()}
+ onUpdateNodes={onUpdateNodes}
+ />
+ </ChakraProvider>
+ );
+ });
+
+ const update = host!.querySelector<HTMLButtonElement>('button[aria-label="nodes.updateAllNodes"]')!;
+
+ expect(update).not.toBeNull();
+ expect(new Set(buttonBoxes())).toEqual(new Set(['28x28']));
+ update.focus();
+ await settle(() => update.click());
+ expect(onUpdateNodes).toHaveBeenCalledOnce();
+ // The button leaves with the last outdated node; focus is already on its neighbour.
+ expect(document.activeElement?.getAttribute('aria-label')).toBe('Fit view');
+ });
+
it('states node opacity the way the tool buttons state themselves', async () => {
await render(0.5);
const opacity = host!.querySelector<HTMLButtonElement>('button[aria-label="Node opacity"]')!;
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.tsx
index 8cd24f8f76..fe552c5849 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/EditorToolbar.tsx
@@ -8,11 +8,13 @@ import {
EraserIcon,
HandIcon,
LassoIcon,
+ CircleArrowUpIcon,
MaximizeIcon,
ZoomInIcon,
ZoomOutIcon,
} from 'lucide-react';
-import { useCallback, useId, useMemo } from 'react';
+import { useCallback, useId, useMemo, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
/**
* Pane drag follows the selected pan/box/lasso tool; eraser clicks delete. Shift selects while panning, and middle
@@ -40,14 +42,20 @@ const EDITOR_TOOLBAR_TOP = 'var(--wb-center-chrome-inset, var(--chakra-spacing-2
export const EditorToolbar = ({
nodeOpacity,
tool,
+ updatableNodeCount = 0,
onNodeOpacityChange,
onToolChange,
+ onUpdateNodes,
}: {
nodeOpacity: number;
tool: EditorTool;
+ /** Nodes with a newer same-major template; the update button shows only while there are some. */
+ updatableNodeCount?: number;
onNodeOpacityChange: (opacity: number) => void;
onToolChange: (tool: EditorTool) => void;
+ onUpdateNodes?: () => void;
}) => {
+ const { t } = useTranslation();
const { fitView, zoomIn, zoomOut } = useReactFlow();
const reduceMotion = useWorkflowPreferencesSelector((preferences) => preferences.reduceMotion);
const opacityTriggerId = useId();
@@ -57,6 +65,12 @@ export const EditorToolbar = ({
const onZoomInClick = useCallback(() => void zoomIn(), [zoomIn]);
const onZoomOutClick = useCallback(() => void zoomOut(), [zoomOut]);
const onFitViewClick = useCallback(() => void fitView({ duration: fitViewDuration }), [fitView, fitViewDuration]);
+ const fitViewRef = useRef<HTMLButtonElement>(null);
+ // The update button leaves with the last outdated node; keyboard focus steps to its stable neighbour first.
+ const onUpdateNodesClick = useCallback(() => {
+ fitViewRef.current?.focus();
+ onUpdateNodes?.();
+ }, [onUpdateNodes]);
const onSliderValueChange = useCallback(
(event: { value: number[] }) => onNodeOpacityChange((event.value[0] ?? 100) / 100),
[onNodeOpacityChange]
@@ -78,7 +92,18 @@ export const EditorToolbar = ({
<ToolbarSeparator />
<ToolbarButton icon={ZoomInIcon} label="Zoom in" onClick={onZoomInClick} />
<ToolbarButton icon={ZoomOutIcon} label="Zoom out" onClick={onZoomOutClick} />
- <ToolbarButton icon={MaximizeIcon} label="Fit view" onClick={onFitViewClick} />
+ <ToolbarButton ref={fitViewRef} icon={MaximizeIcon} label="Fit view" onClick={onFitViewClick} />
+ {updatableNodeCount > 0 ? (
+ <>
+ <ToolbarSeparator />
+ <ToolbarButton
+ color="fg.warning"
+ icon={CircleArrowUpIcon}
+ label={t('nodes.updateAllNodes', { count: updatableNodeCount })}
+ onClick={onUpdateNodesClick}
+ />
+ </>
+ ) : null}
<ToolbarSeparator />
<Popover.Root ids={opacityIds} positioning={POPOVER_POSITIONING}>
<Tooltip content="Node opacity" ids={opacityIds} positioning={TOOLTIP_POSITIONING}>
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 a8a45347f0..a7ef61ed1f 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
@@ -689,3 +689,46 @@ describe('InvocationFlowNode field entry', () => {
expect(rowError(steps)).toBeNull();
});
});
+
+describe('InvocationFlowNode template version', () => {
+ let host: HTMLDivElement;
+ let root: Root;
+
+ beforeEach(() => {
+ 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 = (nodes: ReturnType<typeof toFlowNodes>) =>
+ act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <WorkflowUiProvider adapter={createAdapter(createExecutionPort().port)}>
+ <ReactFlow edges={[]} nodes={nodes} nodeTypes={nodeTypes} />
+ </WorkflowUiProvider>
+ </ChakraProvider>
+ )
+ );
+ const updateIcon = () => host.querySelector('.react-flow__node [role="img"][aria-label^="nodes.node"]');
+ const borderColor = () => getComputedStyle(host.querySelector<HTMLElement>('.react-flow__node > div')!).borderColor;
+
+ it('marks a node whose template moved on with a warning border and an update tooltip, and leaves a current one alone', async () => {
+ await render(flowNodes);
+ expect(updateIcon()).toBeNull();
+ const currentBorder = borderColor();
+
+ await render(toFlowNodes(projectGraph, [], { preview: { ...template, version: '1.1.0' } }));
+ expect(updateIcon()?.getAttribute('aria-label')).toBe('nodes.nodeUpdateAvailable');
+ expect(borderColor()).not.toBe(currentBorder);
+
+ await render(toFlowNodes(projectGraph, [], { preview: { ...template, version: '2.0.0' } }));
+ expect(updateIcon()?.getAttribute('aria-label')).toBe('nodes.nodeVersionIncompatible');
+ });
+});
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 86c745c6a2..d82656164f 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/InvocationFlowNode.tsx
@@ -39,6 +39,7 @@ import {
formatOutputFieldValue,
getEffectiveWorkflowFieldDescription,
getFieldTypeLabel,
+ getNodeUpdateStatus,
getOutputFieldNamesByScope,
getOutputFieldRows,
getWorkflowFieldInvalidReason,
@@ -122,6 +123,7 @@ const NodeShell = ({
hasMissingRequiredInput,
children,
isMissing,
+ isOutdated,
isRunning,
outcome,
selected,
@@ -129,6 +131,7 @@ const NodeShell = ({
hasMissingRequiredInput?: boolean;
children: React.ReactNode;
isMissing?: boolean;
+ isOutdated?: boolean;
isRunning?: boolean;
outcome?: WorkflowNodeOutcome | null;
selected: boolean;
@@ -136,7 +139,16 @@ const NodeShell = ({
const isInvalid = isMissing || hasMissingRequiredInput;
return (
- <Box w={NODE_WIDTH} {...getWorkflowNodeShellProps({ invalid: isInvalid, outcome, running: isRunning, selected })}>
+ <Box
+ w={NODE_WIDTH}
+ {...getWorkflowNodeShellProps({
+ invalid: isInvalid,
+ outcome,
+ outdated: isOutdated,
+ running: isRunning,
+ selected,
+ })}
+ >
{children}
</Box>
);
@@ -281,6 +293,48 @@ const OutputFieldTooltip = ({ template }: { template: FieldOutputTemplate }) =>
);
};
+/** One line naming the node's version against its template's, for the tooltip and the inspector. */
+const getUpdateStatusText = (
+ t: ReturnType<typeof useTranslation>['t'],
+ node: WorkflowInvocationNode,
+ template: InvocationNodeTemplateView['template']
+): string | null => {
+ const status = getNodeUpdateStatus(node, template);
+ const versions = { from: node.data.version, to: template.version };
+
+ return status === 'current'
+ ? null
+ : status === 'updatable'
+ ? t('nodes.nodeUpdateAvailable', versions)
+ : status === 'newer'
+ ? t('nodes.nodeNewerThanBackend', versions)
+ : t('nodes.nodeVersionIncompatible', versions);
+};
+
+const UPDATE_TOOLTIP_POSITIONING = { placement: 'top-end' } as const;
+
+/** Header mark for a node whose version is not its template's; the tooltip says what can be done about it. */
+const NodeUpdateIcon = ({
+ node,
+ template,
+}: {
+ node: WorkflowInvocationNode;
+ template: InvocationNodeTemplateView['template'];
+}) => {
+ const { t } = useTranslation();
+ const label = getUpdateStatusText(t, node, template);
+
+ if (label === null) {
+ return null;
+ }
+
+ return (
+ <Tooltip content={label} positioning={UPDATE_TOOLTIP_POSITIONING} showArrow>
+ <Icon aria-label={label} as={TriangleAlertIcon} boxSize="3.5" color="fg.warning" flexShrink={0} role="img" />
+ </Tooltip>
+ );
+};
+
const NodeInfoTooltipContent = ({
node,
template,
@@ -291,6 +345,7 @@ const NodeInfoTooltipContent = ({
const { t } = useTranslation();
const title = node.data.label ? `${node.data.label} (${template.title})` : template.title;
const nodePack = node.data.nodePack || template.nodePack;
+ const updateStatusText = getUpdateStatusText(t, node, template);
return (
<Stack gap="1" maxW="20rem">
@@ -298,6 +353,7 @@ const NodeInfoTooltipContent = ({
<Text color="fg.subtle">{t('nodes.nodeType', { type: template.type })}</Text>
<Text color="fg.subtle">{t('nodes.nodePackLabel', { name: nodePack })}</Text>
<Text color="fg.subtle">{t('nodes.nodeVersion', { version: node.data.version })}</Text>
+ {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>
{template.description ? <Text fontStyle="italic">{template.description}</Text> : null}
@@ -771,10 +827,12 @@ const CompactInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNodeT
const inputTemplates = templateView?.inputTemplates ?? [];
const outputTemplates = templateView?.outputTemplates ?? [];
const title = node.data.label || templateView?.template.title || node.data.type;
+ const isOutdated = templateView ? getNodeUpdateStatus(node, templateView.template) !== 'current' : false;
return (
<NodeShell
isMissing={!templateView}
+ isOutdated={isOutdated}
isRunning={execution?.status === 'running'}
outcome={getExecutionOutcome(execution)}
selected={selected ?? false}
@@ -783,6 +841,7 @@ const CompactInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNodeT
<MiddleTruncate fontSize="sm" fontWeight="700" minW="0" text={title} />
<Box flex="1" />
<NodeOutcomeIcon execution={execution} node={node} />
+ {templateView && isOutdated ? <NodeUpdateIcon node={node} template={templateView.template} /> : null}
</Flex>
{templateView ? (
<CompactNodeBody inputCount={inputTemplates.length} outputCount={outputTemplates.length} />
@@ -826,6 +885,7 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
}
const template = templateView.template;
+ const isOutdated = getNodeUpdateStatus(node, template) !== 'current';
const connectedFieldNames = new Set(data.connectedTargetHandles);
const exposedFieldNames = new Set(data.exposedFieldNames);
const inputTemplates = templateView.inputTemplates;
@@ -843,6 +903,7 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
return (
<NodeShell
hasMissingRequiredInput={isMissingRequiredInput}
+ isOutdated={isOutdated}
isRunning={isRunning}
outcome={getExecutionOutcome(execution)}
selected={selected ?? false}
@@ -865,6 +926,7 @@ const ExpandedInvocationNode = ({ data, selected }: NodeProps<InvocationFlowNode
<NodeTitle node={node} title={node.data.label || template.title} />
<Box flex="1" />
<NodeOutcomeIcon execution={execution} node={node} />
+ {isOutdated ? <NodeUpdateIcon node={node} template={template} /> : null}
<NodeInfoIcon node={node} template={template} />
</>
)}
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.browser.test.tsx
new file mode 100644
index 0000000000..347df6a24e
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.browser.test.tsx
@@ -0,0 +1,65 @@
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { NodeContextMenu, type NodeContextMenuState } from './NodeContextMenu';
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+describe('NodeContextMenu', () => {
+ let host: HTMLDivElement;
+ let root: Root;
+
+ beforeEach(() => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ });
+
+ afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+ });
+
+ const menuStates: Record<'no' | 'yes', NodeContextMenuState> = {
+ no: { canUpdate: false, isNodeOpen: true, kind: 'node', nodeId: 'n1', x: 20, y: 20 },
+ yes: { canUpdate: true, isNodeOpen: true, kind: 'node', nodeId: 'n1', x: 20, y: 20 },
+ };
+ const render = (canUpdate: boolean, onUpdate: () => void) => {
+ const menuState = menuStates[canUpdate ? 'yes' : 'no'];
+
+ return act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <NodeContextMenu
+ canPaste={false}
+ menuState={menuState}
+ onAddConnector={vi.fn()}
+ onClose={vi.fn()}
+ onCopy={vi.fn()}
+ onDelete={vi.fn()}
+ onDuplicate={vi.fn()}
+ onPaste={vi.fn()}
+ onToggleOpen={vi.fn()}
+ onUpdate={onUpdate}
+ />
+ </ChakraProvider>
+ )
+ );
+ };
+ const updateItem = () => document.querySelector<HTMLElement>('[role="menuitem"][data-value="update"]');
+
+ it('offers "Update node" only for a node whose template can be applied in place', async () => {
+ const onUpdate = vi.fn();
+
+ await render(false, onUpdate);
+ expect(updateItem()).toBeNull();
+
+ await render(true, onUpdate);
+ expect(updateItem()?.textContent).toContain('nodes.updateNode');
+ await act(() => updateItem()!.click());
+ expect(onUpdate).toHaveBeenCalledOnce();
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.tsx
index f5096734fb..a28da6d087 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/NodeContextMenu.tsx
@@ -5,6 +5,7 @@ import { MenuContent } from '@platform/ui/Menu';
import {
ChevronsDownUpIcon,
ChevronsUpDownIcon,
+ CircleArrowUpIcon,
ClipboardPasteIcon,
CopyIcon,
CopyPlusIcon,
@@ -12,12 +13,15 @@ import {
Trash2Icon,
} from 'lucide-react';
import { useCallback, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
export interface NodeContextMenuState {
kind: 'node';
nodeId?: string;
/** The node's `isOpen`; null for node types without a collapse toggle (notes). */
isNodeOpen: boolean | null;
+ /** The node's template is a newer same-major version, so it can be updated in place. */
+ canUpdate: boolean;
x: number;
y: number;
}
@@ -41,6 +45,7 @@ export const NodeContextMenu = ({
onDuplicate,
onPaste,
onToggleOpen,
+ onUpdate,
}: {
canPaste: boolean;
menuState: WorkflowContextMenuState | null;
@@ -51,7 +56,9 @@ export const NodeContextMenu = ({
onDuplicate: () => void;
onPaste: () => void;
onToggleOpen: () => void;
+ onUpdate: () => void;
}) => {
+ const { t } = useTranslation();
const positioning = useMemo(
() => ({
getAnchorRect: () => (menuState ? { height: 1, width: 1, x: menuState.x, y: menuState.y } : null),
@@ -79,28 +86,36 @@ export const NodeContextMenu = ({
<>
<Menu.Item value="copy" onClick={onCopy}>
<Icon as={CopyIcon} boxSize="3.5" />
- <Menu.ItemText>Copy</Menu.ItemText>
+ <Menu.ItemText>{t('common.copy')}</Menu.ItemText>
<Menu.ItemCommand>Ctrl C</Menu.ItemCommand>
</Menu.Item>
<Menu.Item disabled={!canPaste} value="paste" _disabled={DISABLED_PROPS} onClick={onPaste}>
<Icon as={ClipboardPasteIcon} boxSize="3.5" />
- <Menu.ItemText>Paste</Menu.ItemText>
+ <Menu.ItemText>{t('nodes.contextPaste')}</Menu.ItemText>
<Menu.ItemCommand>Ctrl V</Menu.ItemCommand>
</Menu.Item>
<Menu.Item value="duplicate" onClick={onDuplicate}>
<Icon as={CopyPlusIcon} boxSize="3.5" />
- <Menu.ItemText>Duplicate</Menu.ItemText>
+ <Menu.ItemText>{t('common.duplicate')}</Menu.ItemText>
</Menu.Item>
{menuState.isNodeOpen !== null ? (
<Menu.Item value="toggle-open" onClick={onToggleOpen}>
<Icon as={menuState.isNodeOpen ? ChevronsDownUpIcon : ChevronsUpDownIcon} boxSize="3.5" />
- <Menu.ItemText>{menuState.isNodeOpen ? 'Collapse' : 'Expand'}</Menu.ItemText>
+ <Menu.ItemText>
+ {menuState.isNodeOpen ? t('nodes.contextCollapse') : t('nodes.contextExpand')}
+ </Menu.ItemText>
+ </Menu.Item>
+ ) : null}
+ {menuState.canUpdate ? (
+ <Menu.Item value="update" onClick={onUpdate}>
+ <Icon as={CircleArrowUpIcon} boxSize="3.5" />
+ <Menu.ItemText>{t('nodes.updateNode')}</Menu.ItemText>
</Menu.Item>
) : null}
<Menu.Separator borderColor="border.subtle" />
<Menu.Item data-danger="" value="delete" onClick={onDelete}>
<Icon as={Trash2Icon} boxSize="3.5" />
- <Menu.ItemText>Delete</Menu.ItemText>
+ <Menu.ItemText>{t('common.delete')}</Menu.ItemText>
<Menu.ItemCommand>Del</Menu.ItemCommand>
</Menu.Item>
</>
@@ -121,12 +136,13 @@ const PaneAddConnectorMenuItem = ({
onAddConnector: (position: XYPosition) => void;
position: XYPosition;
}) => {
+ const { t } = useTranslation();
const onClick = useCallback(() => onAddConnector(position), [onAddConnector, position]);
return (
<Menu.Item value="add-connector" onClick={onClick}>
<Icon as={PlusIcon} boxSize="3.5" />
- <Menu.ItemText>Add connector</Menu.ItemText>
+ <Menu.ItemText>{t('nodes.contextAddConnector')}</Menu.ItemText>
</Menu.Item>
);
};
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx
index a27b3ffe67..7256687b22 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx
@@ -18,6 +18,8 @@ import {
buildConnectorNode,
createWorkflowGraphIndex,
createWorkflowId,
+ getNodeUpdateStatus,
+ getUpdatableNodeIds,
getWorkflowSourceFieldType,
getWorkflowTargetFieldType,
LOOP_LINKAGE_FIELD,
@@ -888,6 +890,10 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
event.preventDefault();
setContextMenu({
kind: 'node',
+ canUpdate:
+ node.type === 'invocation' &&
+ node.data.template !== null &&
+ getNodeUpdateStatus(node.data.documentNode, node.data.template.template) === 'updatable',
isNodeOpen: node.type === 'invocation' ? node.data.documentNode.data.isOpen : null,
nodeId: node.id,
x: event.clientX,
@@ -909,6 +915,7 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
) {
setContextMenu({
kind: 'node',
+ canUpdate: false,
isNodeOpen: null,
x: event.clientX,
y: event.clientY,
@@ -937,6 +944,7 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
event.stopPropagation();
setContextMenu({
kind: 'node',
+ canUpdate: false,
isNodeOpen: null,
x: event.clientX,
y: event.clientY,
@@ -1099,6 +1107,19 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
setContextMenu(null);
}, [contextMenu, editGraph]);
+ const onContextMenuUpdate = useCallback(() => {
+ if (contextMenu?.kind === 'node' && contextMenu.nodeId) {
+ editGraph({ nodeIds: [contextMenu.nodeId], templates, type: 'updateNodes' });
+ }
+
+ setContextMenu(null);
+ }, [contextMenu, editGraph, templates]);
+ const updatableNodeCount = useMemo(
+ () => getUpdatableNodeIds(projectGraph, templates).length,
+ [projectGraph, templates]
+ );
+ // No id list: the reducer already skips every node that cannot move.
+ const onUpdateNodes = useCallback(() => editGraph({ templates, type: 'updateNodes' }), [editGraph, templates]);
if (isPreparing) {
return <WorkflowEditorPreparingState edgeCount={projectGraph.edges.length} nodeCount={projectGraph.nodes.length} />;
@@ -1166,8 +1187,10 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
<EditorToolbar
nodeOpacity={nodeOpacity}
tool={tool}
+ updatableNodeCount={updatableNodeCount}
onNodeOpacityChange={setNodeOpacity}
onToolChange={setTool}
+ onUpdateNodes={onUpdateNodes}
/>
{workflowShowMinimap && (!isLargeGraph || isMinimapReady) ? <FlowMiniMap /> : null}
</ReactFlow>
@@ -1190,6 +1213,7 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
onDuplicate={onContextMenuDuplicate}
onPaste={onContextMenuPaste}
onToggleOpen={onContextMenuToggleOpen}
+ onUpdate={onContextMenuUpdate}
/>
</Box>
);
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/library/useLoadLibraryWorkflow.ts b/invokeai/frontend/webv2/src/features/workflow/ui/library/useLoadLibraryWorkflow.ts
index a586fde553..f5809064ff 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/library/useLoadLibraryWorkflow.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/library/useLoadLibraryWorkflow.ts
@@ -1,5 +1,6 @@
import type { WorkflowLibraryListItem } from '@features/workflow/queries';
+import { updateLoadedWorkflowNodes } from '@features/workflow/data/templates';
import { getLibraryWorkflowCached, touchLibraryWorkflowOpenedAt } from '@features/workflow/queries';
import { requestWorkflowFitView } from '@features/workflow/ui/editor/flowInstanceStore';
import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';
@@ -48,7 +49,9 @@ export const useLoadLibraryWorkflow = (onLoaded: () => void): LoadLibraryWorkflo
const raw = await getLibraryWorkflowCached(item.workflow_id, owner.signal);
assertAccountScopeCurrent(owner);
- const { document, warnings } = parseWorkflowJson(raw);
+ const { document: parsed, warnings: parseWarnings } = parseWorkflowJson(raw);
+ const { document, warnings: updateWarnings } = updateLoadedWorkflowNodes(parsed, t);
+ const warnings = [...parseWarnings, ...updateWarnings];
assertAccountScopeCurrent(owner);
setLoadPhase('applying');
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.browser.test.tsx
index bb20b9bbbf..80a8c93ff5 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.browser.test.tsx
@@ -43,10 +43,15 @@ const template: InvocationTemplate = {
version: '1.0.0',
};
+// A holder rather than the template itself: a test swaps in a new object, which memoized tabs notice.
+const templatesState = vi.hoisted(() => ({ templates: {} as Record<string, unknown> }));
+
+templatesState.templates = { resize: template };
+
vi.mock('@features/workflow/react', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useInvocationTemplatesSelector: (selector: (snapshot: unknown) => unknown) =>
- selector({ error: null, status: 'loaded', templates: { resize: template } }),
+ selector({ error: null, status: 'loaded', templates: templatesState.templates }),
}));
vi.mock('react-i18next', () => ({
@@ -194,3 +199,66 @@ describe('NodeInspector outputs tab', () => {
expect(host.querySelector('img')).toBeNull();
});
});
+
+// Module scope: an adapter built inside the describe reads as a per-render object to the JSX prop lint.
+const detailsSnapshot = { ...projectSnapshot, workflowValues: { inspectorTab: 'details' } };
+const baseAdapter = createAdapter(createExecutionPort().port);
+const detailsAdapter = {
+ ...baseAdapter,
+ project: { ...baseAdapter.project, getSnapshot: () => detailsSnapshot },
+} as WorkflowUiAdapter;
+
+describe('NodeInspector details tab node updates', () => {
+ let host: HTMLDivElement;
+ let root: Root;
+
+ beforeEach(() => {
+ workflowSelectionStore.patchSnapshot({ hoveredNodeId: null, selectedNodeIds: [node.id], selectionRequest: null });
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ });
+
+ afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+ templatesState.templates = { resize: template };
+ });
+
+ const renderDetails = () =>
+ act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <WorkflowUiProvider adapter={detailsAdapter}>
+ <NodeInspector projectGraph={projectGraph} />
+ </WorkflowUiProvider>
+ </ChakraProvider>
+ )
+ );
+ const updateButton = () =>
+ Array.from(host.querySelectorAll('button')).find((button) => button.textContent === 'nodes.updateNodeTo');
+
+ it('offers an in-place update for a newer same-major template and explains an incompatible one', async () => {
+ await renderDetails();
+ expect(updateButton()).toBeUndefined();
+
+ const newer = { ...template, version: '1.2.0' };
+
+ templatesState.templates = { resize: newer };
+ await renderDetails();
+
+ updateButton()!.focus();
+ await act(() => updateButton()!.click());
+ expect(document.activeElement?.getAttribute('role')).toBe('tab');
+ expect(detailsAdapter.commands.editGraph).toHaveBeenCalledWith({
+ nodeIds: [node.id],
+ templates: { resize: newer },
+ type: 'updateNodes',
+ });
+
+ templatesState.templates = { resize: { ...template, version: '2.0.0' } };
+ await renderDetails();
+ expect(updateButton()).toBeUndefined();
+ expect(host.textContent).toContain('nodes.nodeVersionIncompatible');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.tsx
index a290af91c4..92c0a81d09 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/linear/NodeInspector.tsx
@@ -6,7 +6,7 @@ import type {
} from '@features/workflow/contracts';
import type { ChangeEvent } from 'react';
-import { Flex, HStack, Image, Stack, Text, Textarea } from '@chakra-ui/react';
+import { Box, Flex, HStack, Image, Stack, Text, Textarea } from '@chakra-ui/react';
import { useInvocationTemplatesSelector } from '@features/workflow/react';
import { workflowSelectionStore } from '@features/workflow/ui/editor/selectionStore';
import { useProjectGraphCommands } from '@features/workflow/ui/useProjectGraphCommands';
@@ -15,8 +15,8 @@ import {
useWorkflowNodeExecutionState,
useWorkflowProjectSelector,
} from '@features/workflow/ui/WorkflowUiContext';
-import { formatOutputFieldValue } from '@features/workflow/utility';
-import { JsonPreview, Scrollable, Tabs } from '@platform/ui';
+import { formatOutputFieldValue, getNodeUpdateStatus } from '@features/workflow/utility';
+import { Button, JsonPreview, Scrollable, Tabs } from '@platform/ui';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
@@ -40,6 +40,48 @@ const DetailRow = ({ label, value }: { label: string; value: string }) => (
const JsonBlock = ({ label, value }: { label: string; value: unknown }) => <JsonPreview label={label} value={value} />;
+/** The version row's action: update in place when the template allows it, otherwise say why not. */
+const NodeUpdateRow = ({ node, template }: { node: WorkflowInvocationNode; template: InvocationTemplate }) => {
+ const { t } = useTranslation();
+ const { editGraph } = useProjectGraphCommands();
+ const status = getNodeUpdateStatus(node, template);
+ // The button leaves once the node is current; keyboard focus steps to the inspector's active tab first.
+ const onUpdate = useCallback(
+ (event: React.MouseEvent<HTMLButtonElement>) => {
+ event.currentTarget
+ .closest('[data-node-inspector]')
+ ?.querySelector<HTMLElement>('[role="tab"][aria-selected="true"]')
+ ?.focus();
+ editGraph({ nodeIds: [node.id], templates: { [template.type]: template }, type: 'updateNodes' });
+ },
+ [editGraph, node.id, template]
+ );
+
+ if (status === 'current') {
+ return null;
+ }
+
+ const versions = { from: node.data.version, to: template.version };
+
+ return (
+ <HStack align="start" gap="2">
+ {/* Aligned with the detail values: an empty label cell the width of the label column. */}
+ <Box flexShrink={0} minW="16" />
+ {status === 'updatable' ? (
+ <Button size="2xs" variant="outline" onClick={onUpdate}>
+ {t('nodes.updateNodeTo', { version: template.version })}
+ </Button>
+ ) : (
+ <Text color="fg.warning" fontSize="2xs">
+ {status === 'newer'
+ ? t('nodes.nodeNewerThanBackend', versions)
+ : t('nodes.nodeVersionIncompatible', versions)}
+ </Text>
+ )}
+ </HStack>
+ );
+};
+
const DetailsTab = ({ node, template }: { node: WorkflowInvocationNode; template: InvocationTemplate | undefined }) => {
const { t } = useTranslation();
const { editGraph } = useProjectGraphCommands();
@@ -54,6 +96,7 @@ const DetailsTab = ({ node, template }: { node: WorkflowInvocationNode; template
<DetailRow label={t('widgets.workflow.title')} value={node.data.label || template?.title || node.data.type} />
<DetailRow label={t('widgets.workflow.type')} value={node.data.type} />
<DetailRow label={t('widgets.workflow.version')} value={node.data.version} />
+ {template ? <NodeUpdateRow node={node} template={template} /> : null}
{template ? <DetailRow label={t('widgets.workflow.class')} value={template.classification} /> : null}
{template ? <DetailRow label={t('widgets.workflow.pack')} value={template.nodePack} /> : null}
{template?.description ? <DetailRow label={t('widgets.workflow.about')} value={template.description} /> : null}
@@ -195,7 +238,7 @@ export const NodeInspector = ({ projectGraph }: { projectGraph: ProjectGraphStat
);
return (
- <Flex direction="column" h="full" minH="0">
+ <Flex data-node-inspector="" direction="column" h="full" minH="0">
<HStack flexShrink={0} justify="space-between" px="2" h={10} borderBottomWidth={1}>
<Text color="fg.muted" fontSize="2xs" fontWeight="600" textTransform="uppercase">
{t('widgets.workflow.nodeInspector')}
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx
index db6d610df5..ad50e5ec61 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/nodeChrome.tsx
@@ -32,24 +32,30 @@ export type WorkflowNodeOutcome = 'completed' | 'failed';
export interface WorkflowNodeChromeState {
invalid?: boolean;
+ /** The node's version differs from its template's; it still runs, so the tint is a warning, not an error. */
+ outdated?: boolean;
outcome?: WorkflowNodeOutcome | null;
running?: boolean;
selected: boolean;
}
-const getNodeBorderColor = ({ invalid, outcome, running }: WorkflowNodeChromeState): string => {
+const getNodeBorderColor = ({ invalid, outcome, outdated, running }: WorkflowNodeChromeState): string => {
if (invalid) {
return 'red.solid';
}
if (running) {
return 'brand.solid';
}
- if (outcome === 'completed') {
- return 'fg.success';
- }
+ // A failed run outranks a stale version: the nodes that cannot be updated are the ones most likely to fail.
if (outcome === 'failed') {
return 'border.error';
}
+ if (outdated) {
+ return 'border.warning';
+ }
+ if (outcome === 'completed') {
+ return 'fg.success';
+ }
return 'border.emphasized';
};
diff --git a/invokeai/frontend/webv2/src/workbench/autoRoutePolicy.ts b/invokeai/frontend/webv2/src/workbench/autoRoutePolicy.ts
index ae8f66428e..5d76d97cb3 100644
--- a/invokeai/frontend/webv2/src/workbench/autoRoutePolicy.ts
+++ b/invokeai/frontend/webv2/src/workbench/autoRoutePolicy.ts
@@ -101,6 +101,7 @@ const GRAPH_EDIT_CONFIDENCE = {
retryCallSavedWorkflow: false,
syncCallSavedWorkflowFields: false,
unexposeField: false,
+ updateNodes: false,
} satisfies Record<ProjectGraphAction['type'], boolean>;
export const isHighConfidenceGraphEdit = (action: ProjectGraphAction): boolean => GRAPH_EDIT_CONFIDENCE[action.type];