Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/lib/litegraph/src/subgraph/SubgraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,15 @@ 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),
// so the value setter above is never invoked; BaseWidget.setValue writes
// 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)
}
}
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions src/lib/litegraph/src/subgraph/SubgraphWidgetPromotion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading