Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Fix name counter preventing more than 3 of the same node Fix linked widget offset when populating values

pythongosssss6453dc1ca2d9
diff --git a/tests-ui/tests/groupNode.test.js b/tests-ui/tests/groupNode.test.js
index 625890a09..e6ebedd91 100644
--- a/tests-ui/tests/groupNode.test.js
+++ b/tests-ui/tests/groupNode.test.js
@@ -970,4 +970,36 @@ describe("group node", () => {
});
});
});
+ test("converted inputs with linked widgets map values correctly on creation", async () => {
+ const { ez, graph, app } = await start();
+ const k1 = ez.KSampler();
+ const k2 = ez.KSampler();
+ k1.widgets.seed.convertToInput();
+ k2.widgets.seed.convertToInput();
+
+ const rr = ez.Reroute();
+ rr.outputs[0].connectTo(k1.inputs.seed);
+ rr.outputs[0].connectTo(k2.inputs.seed);
+
+ const group = await convertToGroup(app, graph, "test", [k1, k2, rr]);
+ expect(group.widgets.steps.value).toBe(20);
+ expect(group.widgets.cfg.value).toBe(8);
+ expect(group.widgets.scheduler.value).toBe("normal");
+ expect(group.widgets["KSampler steps"].value).toBe(20);
+ expect(group.widgets["KSampler cfg"].value).toBe(8);
+ expect(group.widgets["KSampler scheduler"].value).toBe("normal");
+ });
+ test("allow multiple of the same node type to be added", async () => {
+ const { ez, graph, app } = await start();
+ const nodes = [...Array(10)].map(() => ez.ImageScaleBy());
+ const group = await convertToGroup(app, graph, "test", nodes);
+ expect(group.inputs.length).toBe(10);
+ expect(group.outputs.length).toBe(10);
+ expect(group.widgets.length).toBe(20);
+ expect(group.widgets.map((w) => w.widget.name)).toStrictEqual(
+ [...Array(10)]
+ .map((_, i) => `${i > 0 ? "ImageScaleBy " : ""}${i > 1 ? i + " " : ""}`)
+ .flatMap((p) => [`${p}upscale_method`, `${p}scale_by`])
+ );
+ });
});
diff --git a/web/extensions/core/groupNode.js b/web/extensions/core/groupNode.js
index dc962ac24..4cf1f7621 100644
--- a/web/extensions/core/groupNode.js
+++ b/web/extensions/core/groupNode.js
@@ -331,16 +331,17 @@ export class GroupNodeConfig {
getInputConfig(node, inputName, seenInputs, config, extra) {
let name = node.inputs?.find((inp) => inp.name === inputName)?.label ?? inputName;
+ let key = name;
let prefix = "";
// Special handling for primitive to include the title if it is set rather than just "value"
if ((node.type === "PrimitiveNode" && node.title) || name in seenInputs) {
prefix = `${node.title ?? node.type} `;
- name = `${prefix}${inputName}`;
+ key = name = `${prefix}${inputName}`;
if (name in seenInputs) {
name = `${prefix}${seenInputs[name]} ${inputName}`;
}
}
- seenInputs[name] = (seenInputs[name] ?? 1) + 1;
+ seenInputs[key] = (seenInputs[key] ?? 1) + 1;
if (inputName === "seed" || inputName === "noise_seed") {
if (!extra) extra = {};
@@ -1010,10 +1011,10 @@ export class GroupNodeHandler {
const newName = map[oldName];
const widgetIndex = this.node.widgets.findIndex((w) => w.name === newName);
const mainWidget = this.node.widgets[widgetIndex];
- if (this.populatePrimitive(node, nodeId, oldName, i, linkedShift)) {
+ if (this.populatePrimitive(node, nodeId, oldName, i, linkedShift) || widgetIndex === -1) {
// Find the inner widget and shift by the number of linked widgets as they will have been removed too
const innerWidget = this.innerNodes[nodeId].widgets?.find((w) => w.name === oldName);
- linkedShift += innerWidget.linkedWidgets?.length ?? 0;
+ linkedShift += innerWidget?.linkedWidgets?.length ?? 0;
}
if (widgetIndex === -1) {
continue;