Skip to content

Fix copy/clone disconnecting links on the original node - #799

Merged
rgthree merged 1 commit into
rgthree:mainfrom
unclehooru:fix-clone-disconnects-original
Oct 28, 2026
Merged

rgthree merged 1 commit into
rgthree:mainfrom
unclehooru:fix-clone-disconnects-original

Conversation

@unclehooru

Copy link
Copy Markdown
Contributor

Problem

On ComfyUI frontend 1.53.1 and later, copying or cloning a Fast Bypasser / Fast Muter / Mute / Bypass Repeater / Mute / Bypass Relay / Random Unmuter (any BaseAnyInputConnectedNode) disconnects input slots 1+ of the original node. Only the first input survives.

Repro (frontend 1.57.4):

  1. Connect two Load Image outputs into a Fast Bypasser (two inputs + the empty trailing slot).
  2. Select only the Fast Bypasser and press Ctrl+C, or right-click → Clone.
  3. The original Fast Bypasser's second input is disconnected.

Which operations trigger it:

Operation Single node Multiple selected
Ctrl+C / Copy disconnects OK (the canvasCurrentlyCopyingToClipboardWithMultipleNodes path skips trimming)
Right-click → Clone, Alt+drag clone disconnects disconnects

Duplicate and "Save Selected as Template" go through the same copyToClipboard() path as Ctrl+C, so they should behave the same (not tested separately).

It does not happen on frontend 1.52.7.

Before / After

Ctrl+C, right-click → Clone, and Alt+drag clone on frontend 1.57.4:

link_disconnect_behavior.mp4

Verification workflow: link_disconnect_example.json

Root cause

Since the ECS migration (Comfy-Org/ComfyUI_frontend#14246, first released in 1.53.1), removeInput() / disconnectOutput() / serialize() no longer read input.link. Instead they resolve links from the graph's link store by (graph, node id, slot). A graph-attached clone with the original's id therefore resolves, and removes, the original node's links. Before 1.53.1 the lookup went through input.link, which clone() nulls out, so the workaround was harmless.

Side effects of the same root cause:

  • DynamicContextNodeBase.clone() (unreleased) also calls removeOutput(), so it cuts the original's outputs 1+ as well, even on multi-node copy.
  • A graph-attached clone serializes the original's link ids into the clipboard data, unlike a stock clone.

Fix

  • BaseAnyInputConnectedNode.clone() and DynamicContextNodeBase.clone() trim the clone's slot arrays directly (splice(1)). A clone's slots carry no links, so nothing needs disconnecting. This works on every frontend version and needs no graph.
  • RgthreeBaseNode.clone() no longer attaches the graph to the clone. These two overrides were the only reason for the #5037 workaround, so clones now behave like stock clones.

src_web and the corresponding web output are both updated.

Testing

Manual UI checks (frontend 1.57.4):

  • Single Ctrl+C / Ctrl+V of Fast Bypasser, Fast Muter, Repeater, Relay, Random Unmuter keeps the original's inputs
  • Right-click Clone and Alt+drag clone (single and multiple) keep the original's inputs
  • Pasted / cloned nodes start with a single empty input
  • Multi-node copy + Ctrl+Shift+V still restores connections

Manual UI checks (frontend 1.52.7, via --front-end-version):

  • Without this patch: copy/clone does not disconnect the original
  • With this patch: copy/clone behaves the same, no regression on older frontends

🤖 Generated with Claude Code

On ComfyUI frontend 1.53.1+ (after the ECS migration), slot links are
resolved from the graph's link store by (graph, node id, slot) instead
of `input.link`. A cloned node keeps the original's id, and
RgthreeBaseNode.clone() attached the original graph to the clone as a
workaround for ComfyUI_frontend#5037. As a result:

- BaseAnyInputConnectedNode.clone() trimming extra inputs with
  removeInput() disconnected input slots 1+ of the ORIGINAL node
  (Fast Bypasser/Muter, Mute/Bypass Repeater/Relay, Random Unmuter,
  Node Collector, Fast Actions Button) on single-node copy, clone,
  duplicate, alt+drag clone and "Save Selected as Template".
- DynamicContextNodeBase.clone() also cut the original's outputs 1+.
- The graph-attached clone serialized the original's link ids.

Trim the clone's slot arrays directly (they carry no links) and stop
attaching the graph to clones, so clones behave like stock clones.

Co-Authored-By: Claude Code <noreply@anthropic.com>

@rgthree rgthree left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks straightforward. Thanks!

@rgthree
rgthree merged commit 218d634 into rgthree:main Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants