Comfy-Org / Comfy-Org/ComfyUI_frontend
[Bug]: Linked subgraph instances behave as independent copies instead of sharing state
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
[Bug]: Linked subgraph instances behave as independent copies instead of sharing state
## Prerequisites
- [x] I am running the latest version of ComfyUI
- [x] I have searched existing issues to make sure this isn't a duplicate
- [x] I have tested with all custom nodes disabled
## What happened?
When creating a linked copy of a subgraph across workflows, the instances do not properly share state and instead behave as completely independent subgraphs. This defeats the purpose of linked instances where changes to one instance should be reflected in all linked copies.
This issue was partially addressed by removing subgraphs from the Add Node context menu in PR #4820, but the underlying linking mechanism remains broken and needs to be fixed before linked instances are re-introduced in v2.
## Steps to Reproduce
Since PR #4820 removed subgraphs from the context menu, this issue cannot currently be reproduced in the UI. However, the underlying issue still exists in the codebase:
1. Previously, when subgraphs were available in Add Node menu:
- Create a subgraph with some internal nodes
- Add the subgraph from Right Click -> Add Node menu
- Add another instance of the same subgraph
- Modify one instance
- The other instance would not reflect the changes (bug)
2. Expected behavior:
- Linked subgraph instances should share the same underlying subgraph definition
- Changes to the subgraph structure should be reflected in all instances
- Only the instance-specific properties (position, size, parameter values) should be independent
## How is this affecting you?
Feature doesn't work as expected
## ComfyUI Frontend Version
1.26.0
## Browser
Chrome/Chromium
## Additional Context
This issue is related to the subgraph architecture where SubgraphNode instances should reference a shared Subgraph definition. The problem appears to be that when creating instances from the Add Node menu, new independent Subgraph objects were created instead of referencing the existing one.
Related context:
- PR #4820 removed subgraphs from Add Node menu as a temporary fix
- Issue #4522 mentions similar behavior where cloning creates full copies
- The fix is needed before re-introducing linked instances in v2 launch
Technical details:
- `Subgraph` class represents the definition/template
- `SubgraphNode` class represents an instance
- Multiple `SubgraphNode` instances should be able to share one `Subgraph` definition
- The linking mechanism needs to properly maintain these references
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-4853-Bug-Linked-subgraph-instances-behave-as-independent-copies-instead-of-sharing-state-24a6d73d3650817c94acec71d37b24b7) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.