diff --git a/src/lib/litegraph/src/subgraph/SubgraphNode.ts b/src/lib/litegraph/src/subgraph/SubgraphNode.ts index 3b9efa1b4fc..25f2c984e99 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphNode.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphNode.ts @@ -294,6 +294,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { return isWidgetValue(value) ? value : undefined }, set value(next) { + if (next === null) return store.setValue(id, next) }, // Canvas edits operate on a transient concrete widget (toConcreteWidget), @@ -301,6 +302,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { // its own local state and then calls this callback, which is the only // bridge back to the store. callback(next) { + if (next === null) return store.setValue(id, next) } } @@ -498,7 +500,8 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { const value = quarantineValuesByInputName.get(input.name) ?? widgetValues?.[valueIndex] - if (value !== undefined) { + // `null` means "no host override" — keep the interior widget's value. + if (value !== undefined && value !== null) { useWidgetValueStore().setValue(input.widgetId, value) } valueIndex += 1 diff --git a/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts b/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts index 6585d1d0ee6..3d04325c8ce 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts @@ -1130,6 +1130,33 @@ describe('SubgraphWidgetPromotion', () => { 'second host value' ]) }) + + it('falls through to the interior widget value when a legacy host entry is null', () => { + const subgraph = createTestSubgraph() + buildSources(subgraph, NUMBER_PAIR) + + const host = createTestSubgraphNode(subgraph, { id: 101 }) + const serialized = host.serialize() + + const widgetStore = useWidgetValueStore() + widgetStore.clearGraph(host.rootGraph.id) + const reloaded = createTestSubgraphNode(subgraph, { id: 101 }) + reloaded.configure({ + ...serialized, + widgets_values: fromAny([null, null]) + }) + + expect( + widgetStore.getWidget( + widgetId(reloaded.rootGraph.id, reloaded.id, 'first') + )?.value + ).toBe(1) + expect( + widgetStore.getWidget( + widgetId(reloaded.rootGraph.id, reloaded.id, 'second') + )?.value + ).toBe(2) + }) }) describe('proxyWidgets is no longer re-emitted', () => {