diff --git a/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-2x-linux.png b/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-2x-linux.png index dcf176b11..ec41fd109 100644 Binary files a/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-2x-linux.png and b/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-2x-linux.png differ diff --git a/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-linux.png b/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-linux.png index c9056497f..698d7a1b7 100644 Binary files a/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-linux.png and b/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-node-group-node-chromium-linux.png differ diff --git a/src/extensions/core/groupNode.ts b/src/extensions/core/groupNode.ts index 7fc4ed49f..358362625 100644 --- a/src/extensions/core/groupNode.ts +++ b/src/extensions/core/groupNode.ts @@ -404,15 +404,35 @@ export class GroupNodeConfig { inputName let key = name let prefix = '' + + // Ensure seenInputs is initialized before checking + seenInputs[key] = (seenInputs[key] ?? 0) + 1 + // 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) || seenInputs[name] > 1) { prefix = `${node.title ?? node.type} ` key = name = `${prefix}${inputName}` - if (name in seenInputs) { - name = `${prefix}${seenInputs[name]} ${inputName}` + + // Ensure seenInputs is initialized before checking it + seenInputs[name] = seenInputs[name] ?? 0 + + let finalName + if (seenInputs[name] > 0) { + // If a duplicate is found, append an incremental number + prefix = `${node.title ?? node.type} ` + finalName = `${prefix} ${seenInputs[name] + 1} ${inputName}` + } else { + // Use the original name if it's the first time + prefix = `${node.title ?? node.type} ` + finalName = `${prefix}${inputName}` } + + // Store the incremented count for tracking duplicates + seenInputs[name]++ + + // Ensure the name is added to the definition list correctly + this.nodeDef.input.required[finalName] = config } - seenInputs[key] = (seenInputs[key] ?? 1) + 1 if (inputName === 'seed' || inputName === 'noise_seed') { if (!extra) extra = {} @@ -640,24 +660,32 @@ export class GroupNodeConfig { this.nodeDef.output.push(def.output[outputId]) this.nodeDef.output_is_list.push(def.output_is_list[outputId]) - let label = customConfig?.name + // Try to get a custom name from the configuration if it exists + let label = + customConfig?.name ?? + // If no custom name, check if the definition provides an output name + def.output_name?.[outputId] ?? + // If neither exist, fallback to the raw output type (e.g., "FLOAT", "INT") + def.output[outputId] + + // Check if label is missing and fallback if (!label) { - label = def.output_name?.[outputId] ?? def.output[outputId] - const output = node.outputs.find((o) => o.name === label) - if (output?.label) { - label = output.label - } + const output = node.outputs.find((o) => o.name) + label = output?.label ?? 'UnnamedOutput' } let name = label - if (name in seenOutputs) { - const prefix = `${node.title ?? node.type} ` - name = `${prefix}${label}` - if (name in seenOutputs) { - name = `${prefix}${node.index} ${label}` - } + + // Always prefix with node title or type + const prefix = `${node.title ?? node.type} ` + name = `${prefix}${label}` + + // Apply the same duplicate tracking logic as inputs + if (seenOutputs[name]) { + name = `${prefix} ${seenOutputs[name] + 1} ${label}` } - seenOutputs[name] = 1 + + seenOutputs[name] = (seenOutputs[name] ?? 0) + 1 this.nodeDef.output_name.push(name) }