|
| 1 | +# 1. Merge LiteGraph.js into ComfyUI Frontend |
| 2 | + |
| 3 | +Date: 2025-08-05 |
| 4 | + |
| 5 | +## Status |
| 6 | + |
| 7 | +Accepted |
| 8 | + |
| 9 | +## Context |
| 10 | + |
| 11 | +ComfyUI's frontend architecture currently depends on a forked version of litegraph.js maintained as a separate package (@comfyorg/litegraph). This separation has created several architectural and operational challenges: |
| 12 | + |
| 13 | +**Architectural Issues:** |
| 14 | +- The current split creates a distributed monolith where both packages handle rendering, user interactions, and data models without clear separation of responsibilities |
| 15 | +- Both frontend and litegraph manipulate the same data structures, forcing tight coupling across the frontend's data model, views, and business logic |
| 16 | +- The lack of clear boundaries prevents implementation of modern architectural patterns like MVC or event-sourcing |
| 17 | + |
| 18 | +**Operational Issues:** |
| 19 | +- ComfyUI is the only known user of the @comfyorg/litegraph fork |
| 20 | +- Managing separate repositories significantly slows developer velocity due to coordination overhead |
| 21 | +- Version mismatches between frontend and litegraph cause recurring issues |
| 22 | +- No upstream contributions to consider (original litegraph.js is no longer maintained) |
| 23 | + |
| 24 | +**Future Requirements:** |
| 25 | +The following planned features are blocked by the current architecture: |
| 26 | +- Multiplayer collaboration requiring CRDT-based state management |
| 27 | +- Cloud-based backend support |
| 28 | +- Alternative rendering backends |
| 29 | +- Improved undo/redo system |
| 30 | +- Clear API versioning and compatibility layers |
| 31 | + |
| 32 | +## Decision |
| 33 | + |
| 34 | +We will merge litegraph.js directly into the ComfyUI frontend repository using git subtree to preserve the complete commit history. |
| 35 | + |
| 36 | +The merge will: |
| 37 | +1. Move litegraph source to `src/lib/litegraph/` |
| 38 | +2. Update all import paths from `@comfyorg/litegraph` to `@/lib/litegraph` |
| 39 | +3. Remove the npm dependency on `@comfyorg/litegraph` |
| 40 | +4. Preserve the full git history using subtree merge |
| 41 | + |
| 42 | +This integration is the first step toward restructuring the application along clear Model-View-Controller boundaries, with state mutations going through a single CRDT-mediated access point. |
| 43 | + |
| 44 | +## Consequences |
| 45 | + |
| 46 | +### Positive |
| 47 | + |
| 48 | +- **Enables architectural refactoring**: Direct integration allows restructuring along proper MVC boundaries |
| 49 | +- **Unblocks new features**: Multiplayer, cloud features, and improved undo/redo can now be implemented |
| 50 | +- **Faster development**: Eliminates overhead of coordinating changes across two tightly-coupled packages |
| 51 | +- **Better developer experience**: No more version mismatch issues or cross-repository debugging |
| 52 | +- **Simplified maintenance**: One less repository to maintain, release, and version |
| 53 | + |
| 54 | +### Negative |
| 55 | + |
| 56 | +- **Larger repository**: The frontend repository will increase in size |
| 57 | +- **Loss of versioning**: No more semantic versioning for litegraph changes |
| 58 | +- **Maintenance responsibility**: Must maintain litegraph code directly |
| 59 | +- **Historical references**: Past commit messages may reference issues from the original litegraph repository |
| 60 | + |
| 61 | +## Notes |
| 62 | + |
| 63 | +- Git subtree was chosen over submodules to provide a cleaner developer experience |
| 64 | +- The original litegraph repository will be archived after the merge |
| 65 | +- Future litegraph improvements will be made directly in the frontend repository |
0 commit comments