Make sure new input slots are serializable

This commit is contained in:
space-nuko
2023-05-21 19:43:32 -05:00
parent 4d93312731
commit 970946b514
2 changed files with 8 additions and 2 deletions

View File

@@ -296,6 +296,7 @@ function convertPrimitiveNode(vanillaWorkflow: ComfyVanillaWorkflow, node: Seria
link[5] = widgetInputType // link data type
if (foundInput != null) {
foundInput.type = widgetInputType;
(foundInput as IComfyInputSlot).serialize = true; // IMPORTANT!!!
}
// Change the title of the widget to the name of the first input connected to
@@ -305,7 +306,10 @@ function convertPrimitiveNode(vanillaWorkflow: ComfyVanillaWorkflow, node: Seria
}
}
}
// Remove links on the old node so they won't be double-removed when it's pruned
// Remove links on the old node so they won't be double-removed when
// it's pruned (removeSerializedNode will remove any links still
// connected to other inputs, but we want to keep the ones we rewrote)
mainOutput.links = []
}
else {
@@ -423,7 +427,7 @@ export default function convertVanillaWorkflow(vanillaWorkflow: ComfyVanillaWork
config: inputOpts,
defaultWidgetNode: null,
widgetNodeType,
serialize: true,
serialize: true, // IMPORTANT!
properties: {}
}

View File

@@ -8,6 +8,7 @@ import layoutStates, { defaultWorkflowAttributes, type IDragItem, type WidgetLay
import ComfyApp from '$lib/components/ComfyApp';
import { LiteGraph } from '@litegraph-ts/core';
import type { ComfyNodeDef } from '$lib/ComfyNodeDef';
import type IComfyInputSlot from '$lib/IComfyInputSlot';
const objectInfo: Record<string, ComfyNodeDef> = await import("./data/objectInfo.json")
const json1: ComfyVanillaWorkflow = await import("./data/convertedWidget.json")
@@ -103,6 +104,7 @@ export default class convertVanillaWorkflowTests extends UnitTest {
const targetNode = widget.node.getOutputNodes(0)[0]
expect(targetNode.inputs[links[0].target_slot].type).toEqual("number")
expect((targetNode.inputs[links[0].target_slot] as IComfyInputSlot).serialize).toEqual(true)
expect(links[0].type).toEqual("number");
}