Fix corrupt workflow permanently corrupts session (#3484)

This commit is contained in:
filtered
2025-04-18 00:18:14 +10:00
committed by Chenlei Hu
parent 29e63baca6
commit 0d921e72b9

View File

@@ -47,7 +47,7 @@ export class PrimitiveNode extends LGraphNode {
applyToGraph(extraLinks: LLink[] = []) { applyToGraph(extraLinks: LLink[] = []) {
if (!this.outputs[0].links?.length) return if (!this.outputs[0].links?.length) return
let links = [ const links = [
...this.outputs[0].links.map((l) => app.graph.links[l]), ...this.outputs[0].links.map((l) => app.graph.links[l]),
...extraLinks ...extraLinks
] ]
@@ -58,30 +58,35 @@ export class PrimitiveNode extends LGraphNode {
// For each output link copy our value over the original widget value // For each output link copy our value over the original widget value
for (const linkInfo of links) { for (const linkInfo of links) {
// @ts-expect-error fixme ts strict error const node = this.graph?.getNodeById(linkInfo.target_id)
const node = this.graph.getNodeById(linkInfo.target_id) const input = node?.inputs[linkInfo.target_slot]
// @ts-expect-error fixme ts strict error if (!input) {
const input = node.inputs[linkInfo.target_slot] console.warn('Unable to resolve node or input for link', linkInfo)
let widget: IWidget | undefined continue
const widgetName = (input.widget as { name: string }).name
if (widgetName) {
// @ts-expect-error fixme ts strict error
widget = node.widgets.find((w) => w.name === widgetName)
} }
if (widget) { const widgetName = input.widget?.name
widget.value = v if (!widgetName) {
if (widget.callback) { console.warn('Invalid widget or widget name', input.widget)
widget.callback( continue
widget.value,
app.canvas,
// @ts-expect-error fixme ts strict error
node,
app.canvas.graph_mouse,
{} as CanvasMouseEvent
)
}
} }
const widget = node.widgets?.find((w) => w.name === widgetName)
if (!widget) {
console.warn(
`Unable to find widget "${widgetName}" on node [${node.id}]`
)
continue
}
widget.value = v
widget.callback?.(
widget.value,
app.canvas,
node,
app.canvas.graph_mouse,
{} as CanvasMouseEvent
)
} }
} }