Commit Graph

69 Commits

Author SHA1 Message Date
AustinMroz
fdd8564c07 Deep copy subgraphs to clipboard, update nested ids on paste (#5003)
* Deep copy to clipboard, update nested ids on paste

The copyToClipboard function wasn't walking subgraphs and leaving nested
subgraphs unserialized. This has now been fixed.

This requires that equivalent support be added to _pasteFromClipboard to
update the ids of nested subgraphs which are pasted.

* Add extra advisory comments
2025-08-15 14:03:29 -07:00
Christian Byrne
45cc6ca2b4 Fix widget disconnection issue in subgraphs #4922 (#5015)
* [bugfix] Fix widget disconnection issue in subgraphs

When disconnecting a node from a SubgraphInput, the target input's link
reference was not being cleared in LLink.disconnect(). This caused
widgets to remain greyed out because they still thought they were
connected (slot.link was not null).

The fix ensures that when a link is disconnected, the target node's
input slot is properly cleaned up by setting input.link = null.

Fixes #4922

🤖 Generated with [Claude Code](https://claude.ai/code)

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

* [test] Add tests for LLink disconnect fix for widget issue

Add comprehensive tests for the LLink.disconnect() method to verify
that target input link references are properly cleared when disconnecting.
This prevents widgets from remaining greyed out after disconnection.

Tests cover:
- Basic disconnect functionality with link reference cleanup
- Edge cases with invalid target nodes
- Preventing interference between different connections

Related to #4922

🤖 Generated with [Claude Code](https://claude.ai/code)

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-15 13:12:47 -07:00
Christian Byrne
1e41c6dc45 fix: Handle missing subgraph inputs gracefully during workflow import (#4985)
When loading workflows, SubgraphNode would throw an error if an input
exists in the serialized data that doesn't exist in the current subgraph
definition. This can happen when:
- Subgraph definitions change after workflows are saved
- Workflows are shared between users with different subgraph versions
- Dynamic inputs were added that don't exist in the base definition

This change converts the hard error to a warning and continues processing,
allowing workflows to load even with mismatched subgraph configurations.

Fixes #4905
2025-08-14 14:32:01 -07:00
Christian Byrne
5224c63bce [fix] Prevent incompatible connections to SubgraphInputNode occupied slots (#4984)
## Summary

This PR fixes #4681 by building upon the foundation laid in PR #1182
(litegraph.js). It prevents incompatible type connections when dragging
from a normal node's output to a SubgraphInputNode's occupied slot.

Before:


https://github.com/user-attachments/assets/03def938-dccc-4b2c-b65b-745abf02a13b

After:


https://github.com/user-attachments/assets/7a0a2ed4-9ecd-4147-be56-d643d448d4cb

## Background

PR #1182 implemented:
- `isValidTarget()` method in SubgraphInput/SubgraphOutput classes for
validation
- Visual feedback during drag (40% opacity for invalid targets)
- Validation at the slot level

However, there was a missing piece: while the visual feedback correctly
showed invalid targets, the actual connection would still be made when
dropped.

## Changes

This PR extends PR #1182 by adding the missing connection prevention:

1. **Added `canConnectToSubgraphInput()` method** to render link
classes:
   - `MovingOutputLink`
   - `ToOutputRenderLink`
   - `FloatingRenderLink`
- All methods use the existing `SubgraphInput.isValidTarget()` from PR
#1182

2. **Added validation in `LinkConnector.dropOnIoNode()`**:
   - Checks `canConnectToSubgraphInput()` before allowing the connection
   - Logs a warning when rejecting invalid connections
   - Follows the same pattern as regular node connections

3. **Added `isSubgraphInputValidDrop()` method**:
   - Provides validation for hover states
   - Ensures consistent validation across the UI
2025-08-14 12:51:43 -07:00
Christian Byrne
db1b81b7ff fix: Add guards for _listenerController.abort() calls in SubgraphNode (#4968)
This fix adds guards before calling `_listenerController.abort()` to
prevent runtime errors when loading workflows. The guards check that
`_listenerController` exists and has an `abort` function before calling
it, matching the pattern used in Comfy-Org/litegraph.js#1134.

Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/4907

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-4968-fix-Add-guards-for-_listenerController-abort-calls-in-SubgraphNode-24e6d73d3650813ebeeed69ee676faeb)
by [Unito](https://www.unito.io)
2025-08-13 14:42:34 -07:00
AustinMroz
6566acb406 Bundled subgraph fixes (#4964)
### Group support for subgraph unpacking
The unpacking code would silently delete groups (the cosmetic colored
rectangles). They are now correctly transferred.
### Fix subgraph node position on conversion to subgraph
Converting to subgraph will no longer cause nodes to inch upwards

![subgraph-conversion-positioning](https://github.com/user-attachments/assets/e120c3f9-5602-4dba-9075-c1eadb534f9a)
### Make unpacking use same positioning calcs as conversion
Non trivial, but unpacking is now a proper inverse for conversion.

![subgraph-conversion-inverse](https://github.com/user-attachments/assets/4fcaffca-1c97-4d71-93f7-1af569b1c941)
### Clean up old output links when unpacking
Unpacked nodes were left with dangling outputs. This would cause
cascading issues later, such as when consecutively unpacking nested
subgraphs.
### Minor refactoring for code clarity

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-4964-Bundled-subgraph-fixes-24e6d73d365081d3a043ef1531d9d38a)
by [Unito](https://www.unito.io)
2025-08-13 13:04:44 -07:00
AustinMroz
db71365768 Implement subgraph unpacking (#4840) 2025-08-12 13:45:29 -07:00
Christian Byrne
c42c9315f4 [refactor] Replace lodash with es-toolkit (#4935) 2025-08-12 12:22:09 -07:00
filtered
9c31d708a2 Add automatic trackpad / mouse sensing (#4913) 2025-08-12 10:15:32 -07:00
Christian Byrne
2138ceea80 [fix] ensure consistent link release behavior for subgraph IO nodes (#4931) 2025-08-11 19:28:15 -07:00
Christian Byrne
7972550f6b [fix] Fix link deletion from middle button when connected to reroute nodes deletes wrong link (#4928)
Co-authored-by: github-actions <github-actions@github.com>
2025-08-11 19:26:37 -07:00
Chenlei Hu
c7baf3c340 [feat] Add knip for unused code detection (#4890) 2025-08-11 19:23:08 -07:00
Christian Byrne
90f54414ab fix: Multiple links from reroute create single slot on SubgraphOutputNode (#4915)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-11 13:12:31 -07:00
Christian Byrne
505c242ff4 [refactor] Replace stringOrEmpty with lodash toString (#4917)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-11 11:48:59 -07:00
Christian Byrne
fbc6edde25 [feat] Add red styling to Remove Slot context menu option (#4918)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-11 11:48:02 -07:00
AustinMroz
2c215a6251 Fix subgraph reroute serialization (#4911) 2025-08-11 11:46:32 -07:00
Christian Byrne
a1a8d48544 [feat] Replace removeFromArray with lodash pull (#4906)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-11 09:13:02 -07:00
Christian Byrne
ffc812a8f5 [refactor] Remove unused omitBy function (#4886)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-09 19:12:48 -07:00
Christian Byrne
b745f533ba [feat] Replace manual clamp function with lodash (#4874)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-09 15:34:18 -07:00
Christian Byrne
8f289c8e67 Fix Alt-Click-Drag-Copy of Subgraph Nodes (#4879) 2025-08-09 15:33:59 -07:00
filtered
ff5943f770 Reorder subgraph context menu items (#4870)
Co-authored-by: github-actions <github-actions@github.com>
2025-08-09 14:20:26 -07:00
filtered
5f5f44b310 Fix execution breaks on multi/any-type slots (#4864) 2025-08-09 11:17:10 -07:00
filtered
b42878a9da Remove unused Litegraph context menu options (#4867)
Co-authored-by: github-actions <github-actions@github.com>
2025-08-09 11:14:54 -07:00
Christian Byrne
5cc269eff1 Fix Alt+click create reroute (2/2) (#4863)
Co-authored-by: github-actions <github-actions@github.com>
2025-08-09 11:13:37 -07:00
Vivek Chavan
16d7436883 Fix: Alt+click reroute creation on high-DPI displays (#4831) 2025-08-09 08:59:19 -07:00
AustinMroz
db452c1e63 Fix disconnection from subgraph inputs (#4800) 2025-08-09 03:45:52 -04:00
Chenlei Hu
10d80165c4 [bugfix] Fix subgraph I/O slot rename dialog showing stale label content (#4852)
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-08 23:40:26 -07:00
Chenlei Hu
7bbbf59722 feat: Enable double-click on subgraph slot labels for renaming (#4833) 2025-08-08 18:11:21 -07:00
Chenlei Hu
95ab88693c feat: Add smooth slide-up animation to SelectionToolbox (#4832) 2025-08-07 21:34:10 -07:00
AustinMroz
8899b425a8 Rename subgraph widgets when slot is renamed (#4821) 2025-08-07 15:18:18 -07:00
AustinMroz
385c56d93d Fix widget display on subgraph nodes (#4798) 2025-08-06 23:38:07 -07:00
Benjamin Lu
b33f820b3b explicit this binding 2025-08-05 18:37:19 -04:00
Benjamin Lu
85a5d1ed56 Fix inconsistent subgraphNode usage
Prior to this commit, subgraphNode inconsistently refers to either the
parent graph, or to indicate the current node is a subgraph.

This corrects the usage of subgraphNode to consistently refer to the
subgraph instance as defined in the constructor.

This solves a bug where graph serialization fails due to an incorrectly
reported infinite loop.

Port of https://github.com/Comfy-Org/litegraph.js/pull/1193
2025-08-05 18:29:05 -04:00
Benjamin Lu
01e4260d4c Fix duplicated inputs on loading nested subgraphs
Subgraphs are loaded in order of creation. Under most circumstances,
this means newer subgraphs are loaded first. With nested subgraphs, this
means a subgraph node has it's inputs connected before it's inside is
loaded. When the inner subgraph is loaded, input-added events are
triggered even though inputs already exist on the subgraph node.

This is resolved by adding a check for if an input of the corresponding
name already exists when adding an input.

Port of https://github.com/Comfy-Org/litegraph.js/pull/1192
2025-08-05 18:28:07 -04:00
Benjamin Lu
0ce5aeb2bd eslint disable next litegraph tests 2025-08-05 18:14:47 -04:00
Benjamin Lu
a289f44263 Expect ts errors and remove litegraph test from ts exclude 2025-08-05 18:04:07 -04:00
Benjamin Lu
500c9c6631 Expect ESLint/vue-tsc errors for litegraph src 2025-08-05 17:15:41 -04:00
Benjamin Lu
c53f197de2 npm run format 2025-08-05 09:57:28 -04:00
Benjamin Lu
50feb27339 Delete litegraph .prettierrc file 2025-08-05 09:43:07 -04:00
Benjamin Lu
9e3b845884 Apply patch from a65b8ec8c139a733a857e5ab85b6b1e9ac9ecdd1 2025-08-05 06:49:38 -04:00
Benjamin Lu
a041cc8e0e Literally put subgraph into LGraph 2025-08-05 06:33:02 -04:00
Benjamin Lu
b64a46a386 Revert "Bad circular dep fix: Lazily import and lose some types (needs long term solution)"
This reverts commit b10d06166a.
2025-08-05 01:04:09 -04:00
Benjamin Lu
b10d06166a Bad circular dep fix: Lazily import and lose some types (needs long term solution) 2025-08-04 16:16:14 -04:00
Benjamin Lu
797616c455 Fix some pathings 2025-08-04 14:52:42 -04:00
Benjamin Lu
7f849e9a44 Update remaining @comfyorg/litegraph references 2025-08-04 10:16:24 -04:00
Benjamin Lu
e7f698a08a [chore] Remove package.json and package-lock.json from litegraph
Litegraph is no longer a standalone npm package.
Dependencies are managed by frontend's package.json

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 05:09:25 -04:00
Benjamin Lu
ba3cc19e53 [chore] Remove vite.config.mts from litegraph
No longer needed as litegraph is built as part of frontend, not as standalone library

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 05:08:46 -04:00
Benjamin Lu
a91d8a1836 [chore] Remove disabled/backup config files from litegraph
Removed eslint.config.js.disabled and tsconfig.json.bak
Frontend's configs handle litegraph code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 05:07:54 -04:00
Benjamin Lu
ba09d67e03 [chore] Remove redundant lint-staged config from litegraph
Frontend's root lint-staged config already handles all file types

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 05:07:09 -04:00
Benjamin Lu
eb76222cd0 [chore] Remove redundant .gitignore from litegraph
Root .gitignore already covers all necessary patterns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 05:01:43 -04:00