Fix converted widgets not reconnecting

This commit is contained in:
pythongosssss 2023-11-04 12:35:51 +00:00
parent 49b97dc5d8
commit c7eea7cb8e
2 changed files with 26 additions and 7 deletions

View File

@ -580,4 +580,30 @@ describe("group node", () => {
expect(call).toContain("NotVAEDecode");
expect(call).toContain("workflow/testerror");
});
test("maintains widget inputs on conversion back to nodes", async () => {
const { ez, graph, app } = await start();
let pos = ez.CLIPTextEncode({ text: "positive" });
pos.node.title = "Positive";
let neg = ez.CLIPTextEncode({ text: "negative" });
neg.node.title = "Negative";
pos.widgets.text.convertToInput();
neg.widgets.text.convertToInput();
let primitive = ez.PrimitiveNode();
primitive.outputs[0].connectTo(pos.inputs.text);
primitive.outputs[0].connectTo(neg.inputs.text);
const group = await convertToGroup(app, graph, "test", [pos, neg, primitive]);
expect(group.widgets["Positive text"].value).toBe("positive");
expect(group.widgets["Negative text"].value).toBe("positive");
const newNodes = group.menu["Convert to nodes"].call();
pos = graph.find(newNodes.find((n) => n.title === "Positive"));
neg = graph.find(newNodes.find((n) => n.title === "Negative"));
primitive = graph.find(newNodes.find((n) => n.type === "PrimitiveNode"));
expect(pos.inputs).toHaveLength(2);
expect(neg.inputs).toHaveLength(2);
expect(primitive.outputs[0].connections).toHaveLength(2);
});
});

View File

@ -154,13 +154,6 @@ function buildNodeDef(config, nodeName, defs, source = "workflow") {
seenInputs[name] = 1;
}
const nodeInput = node.inputs?.findIndex((input) => input.name === inputName);
// For now internal widget inputs are not supported
if (nodeInput > -1 && node.inputs[nodeInput]?.widget) {
node.inputs.splice(nodeInput, 1);
}
if (widgetType) {
// Store mapping to get a group widget name from an inner id + name
if (!slots.widgets[nodeId]) slots.widgets[nodeId] = {};