diff --git a/web/extensions/core/groupNode.js b/web/extensions/core/groupNode.js index 3f3084508..dc10974e2 100644 --- a/web/extensions/core/groupNode.js +++ b/web/extensions/core/groupNode.js @@ -312,14 +312,17 @@ const ext = { new ConvertToGroupAction().addOption(options, options.length); return options; }; - + api.addEventListener("executing", ({ detail }) => { if (detail) { const node = app.graph.getNodeById(detail); if (!node) { const split = detail.split(":"); if (split.length === 2) { - api.dispatchEvent(new CustomEvent("executing", { detail: split[0] })); + const outerNode = app.graph.getNodeById(+split[0]); + if (outerNode?.constructor.nodeData?.[IS_GROUP_NODE]) { + api.dispatchEvent(new CustomEvent("executing", { detail: split[0] })); + } } } } @@ -330,7 +333,11 @@ const ext = { if (!node) { const split = detail.node.split(":"); if (split.length === 2) { - api.dispatchEvent(new CustomEvent("executed", { detail: { ...detail, node: split[0] } })); + const outerNode = app.graph.getNodeById(+split[0]); + if(outerNode?.constructor.nodeData?.[IS_GROUP_NODE]) { + api.dispatchEvent(new CustomEvent("executed", { detail: { ...detail, node: split[0], merge: !outerNode.resetExecution } })); + outerNode.resetExecution = false; + } } } }); @@ -353,6 +360,12 @@ const ext = { const config = def[GROUP_DATA]; const slots = def[GROUP_SLOTS]; + const onExecutionStart = node.onExecutionStart; + node.onExecutionStart = function() { + node.resetExecution = true; + return onExecutionStart?.apply(this, arguments); + } + const onNodeCreated = node.onNodeCreated; node.onNodeCreated = function () { for (let innerNodeId = 0; innerNodeId < config.nodes.length; innerNodeId++) { diff --git a/web/scripts/app.js b/web/scripts/app.js index fd9a39318..a3181a7c9 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -1135,7 +1135,19 @@ export class ComfyApp { }); api.addEventListener("executed", ({ detail }) => { - this.nodeOutputs[detail.node] = detail.output; + const output = this.nodeOutputs[detail.node]; + if (detail.merge && output) { + for (const k in detail.output ?? {}) { + const v = output[k]; + if (v instanceof Array) { + output[k] = v.concat(detail.output[k]); + } else { + output[k] = detail.output[k]; + } + } + } else { + this.nodeOutputs[detail.node] = detail.output; + } const node = this.graph.getNodeById(detail.node); if (node) { if (node.onExecuted)