mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-04-19 19:03:51 +00:00
Fix name counter preventing more than 3 of the same node
Fix linked widget offset when populating values
This commit is contained in:
parent
e45d920ae3
commit
6453dc1ca2
@ -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`])
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -331,16 +331,17 @@ export class GroupNodeConfig {
|
|||||||
|
|
||||||
getInputConfig(node, inputName, seenInputs, config, extra) {
|
getInputConfig(node, inputName, seenInputs, config, extra) {
|
||||||
let name = node.inputs?.find((inp) => inp.name === inputName)?.label ?? inputName;
|
let name = node.inputs?.find((inp) => inp.name === inputName)?.label ?? inputName;
|
||||||
|
let key = name;
|
||||||
let prefix = "";
|
let prefix = "";
|
||||||
// Special handling for primitive to include the title if it is set rather than just "value"
|
// 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) {
|
if ((node.type === "PrimitiveNode" && node.title) || name in seenInputs) {
|
||||||
prefix = `${node.title ?? node.type} `;
|
prefix = `${node.title ?? node.type} `;
|
||||||
name = `${prefix}${inputName}`;
|
key = name = `${prefix}${inputName}`;
|
||||||
if (name in seenInputs) {
|
if (name in seenInputs) {
|
||||||
name = `${prefix}${seenInputs[name]} ${inputName}`;
|
name = `${prefix}${seenInputs[name]} ${inputName}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seenInputs[name] = (seenInputs[name] ?? 1) + 1;
|
seenInputs[key] = (seenInputs[key] ?? 1) + 1;
|
||||||
|
|
||||||
if (inputName === "seed" || inputName === "noise_seed") {
|
if (inputName === "seed" || inputName === "noise_seed") {
|
||||||
if (!extra) extra = {};
|
if (!extra) extra = {};
|
||||||
@ -1010,10 +1011,10 @@ export class GroupNodeHandler {
|
|||||||
const newName = map[oldName];
|
const newName = map[oldName];
|
||||||
const widgetIndex = this.node.widgets.findIndex((w) => w.name === newName);
|
const widgetIndex = this.node.widgets.findIndex((w) => w.name === newName);
|
||||||
const mainWidget = this.node.widgets[widgetIndex];
|
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
|
// 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);
|
const innerWidget = this.innerNodes[nodeId].widgets?.find((w) => w.name === oldName);
|
||||||
linkedShift += innerWidget.linkedWidgets?.length ?? 0;
|
linkedShift += innerWidget?.linkedWidgets?.length ?? 0;
|
||||||
}
|
}
|
||||||
if (widgetIndex === -1) {
|
if (widgetIndex === -1) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user