Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src_web/comfyui/base_any_input_connected_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export class BaseAnyInputConnectedNode extends RgthreeBaseVirtualNode {
// so if it's pasted/templatized the data is correct. Otherwise, clear the inputs and so the new
// node is ready to go, fresh.
if (!rgthree.canvasCurrentlyCopyingToClipboardWithMultipleNodes) {
while (cloned.inputs.length > 1) {
cloned.removeInput(cloned.inputs.length - 1);
}
// Trim the slot array directly rather than calling `removeInput()`. The clone shares the
// original's id, and newer frontends resolve slot links from the graph's link store by node
// id, so `removeInput()` on a graph-attached clone disconnects the ORIGINAL node's links
// (and on a graph-less clone, older frontends threw). The clone's inputs carry no links.
cloned.inputs.splice(1);
if (cloned.inputs[0]) {
cloned.inputs[0].label = "";
}
Expand Down
12 changes: 6 additions & 6 deletions src_web/comfyui/base_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ export abstract class RgthreeBaseNode extends LGraphNode {
if (cloned?.properties && !!window.structuredClone) {
cloned.properties = structuredClone(cloned.properties);
}
// [🤮] https://github.com/Comfy-Org/ComfyUI_frontend/issues/5037
// ComfyUI started throwing errors when some of our nodes wanted to remove inputs when cloning
// (like our dynamic inputs) because the disconnect method that's automatically called assumes
// there should be a graph. For now, I _think_ we can simply assign the current graph to avoid
// the error, which would then be overwritten when placed...
cloned.graph = this.graph;
// NOTE: We used to assign `cloned.graph = this.graph` here to work around
// https://github.com/Comfy-Org/ComfyUI_frontend/issues/5037 (removing inputs on a graph-less
// clone threw). That is no longer needed since subclasses now trim their clone's slot arrays
// directly, and it became harmful: the clone keeps the original's id, and newer frontends
// resolve slot links from the graph's link store by node id, so a graph-attached clone both
// serializes the original's links and disconnects them when its slots are removed.
return cloned;
}

Expand Down
11 changes: 5 additions & 6 deletions src_web/comfyui/dynamic_context_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,14 @@ export class DynamicContextNodeBase extends BaseContextNode {
}
override clone() {
const cloned = super.clone()! as DynamicContextNodeBase;
while (cloned.inputs.length > 1) {
cloned.removeInput(cloned.inputs.length - 1);
}
// Trim slot arrays directly rather than calling `removeInput()`/`removeOutput()`. The clone
// shares the original's id, and newer frontends resolve slot links from the graph's link store
// by node id, so those calls on a graph-attached clone disconnect the ORIGINAL node's links.
cloned.inputs.splice(1);
while (cloned.widgets.length > 1) {
cloned.removeWidget(cloned.widgets.length - 1);
}
while (cloned.outputs.length > 1) {
cloned.removeOutput(cloned.outputs.length - 1);
}
cloned.outputs.splice(1);
return cloned;
}

Expand Down
4 changes: 1 addition & 3 deletions web/comfyui/base_any_input_connected_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export class BaseAnyInputConnectedNode extends RgthreeBaseVirtualNode {
clone() {
const cloned = super.clone();
if (!rgthree.canvasCurrentlyCopyingToClipboardWithMultipleNodes) {
while (cloned.inputs.length > 1) {
cloned.removeInput(cloned.inputs.length - 1);
}
cloned.inputs.splice(1);
if (cloned.inputs[0]) {
cloned.inputs[0].label = "";
}
Expand Down
1 change: 0 additions & 1 deletion web/comfyui/base_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class RgthreeBaseNode extends LGraphNode {
if ((cloned === null || cloned === void 0 ? void 0 : cloned.properties) && !!window.structuredClone) {
cloned.properties = structuredClone(cloned.properties);
}
cloned.graph = this.graph;
return cloned;
}
onModeChange(from, to) {
Expand Down
8 changes: 2 additions & 6 deletions web/comfyui/dynamic_context_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,11 @@ export class DynamicContextNodeBase extends BaseContextNode {
}
clone() {
const cloned = super.clone();
while (cloned.inputs.length > 1) {
cloned.removeInput(cloned.inputs.length - 1);
}
cloned.inputs.splice(1);
while (cloned.widgets.length > 1) {
cloned.removeWidget(cloned.widgets.length - 1);
}
while (cloned.outputs.length > 1) {
cloned.removeOutput(cloned.outputs.length - 1);
}
cloned.outputs.splice(1);
return cloned;
}
onNodeCreated() {
Expand Down