Comfy-Org / Comfy-Org/ComfyUI_frontend
Circular deps: misc store/service/composable cycles
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Problem
Several smaller circular dependency cycles exist between stores, services, and composables:
| Cycle | Description |
|-------|-------------|
| `nodeDefStore.ts ↔ nodeSearchService.ts` | Store instantiates service, service imports store type |
| `nodeDefStore.ts ↔ subgraphStore.ts` | Store-to-store cycle |
| `domWidget.ts ↔ domWidgetStore.ts` | Script uses store, store imports type from script |
| `queueStore.ts ↔ jobOutputCache.ts` | Store ↔ cache service |
| `maskEditorStore.ts ↔ useCanvasHistory.ts` | Store ↔ composable |
| `useLoad3d.ts ↔ load3dService.ts` | Composable ↔ service |
| `load3dService.ts ↔ useLoad3dViewer.ts` | Service ↔ composable |
| `QuadTree.ts ↔ spatialIndex.ts` | Renderer ↔ type file (type-only cycle) |
| `proxyWidget.ts ↔ proxyWidgetUtils.ts` | Internal subgraph module cycle |
| `widgetInputs.ts ↔ nodeTypeGuards.ts` | Extension ↔ renderer utility |
### Common pattern
Most of these follow the same anti-pattern: Module A imports a class/function from Module B, while Module B imports a type from Module A.
### Suggested fix
- For type-only cycles: use `import type` and extract shared interfaces to leaf-level type files
- For class/function cycles: use dependency injection or extract shared logic to a third module
- For the QuadTree ↔ spatialIndex type cycle: move `Bounds` type into `QuadTree.ts` or a shared geometry types file
### Files involved
- `src/stores/nodeDefStore.ts`, `src/services/nodeSearchService.ts`
- `src/stores/nodeDefStore.ts`, `src/stores/subgraphStore.ts`
- `src/scripts/domWidget.ts`, `src/stores/domWidgetStore.ts`
- `src/stores/queueStore.ts`, `src/services/jobOutputCache.ts`
- `src/stores/maskEditorStore.ts`, `src/composables/maskeditor/useCanvasHistory.ts`
- `src/composables/useLoad3d.ts`, `src/services/load3dService.ts`, `src/composables/useLoad3dViewer.ts`
- `src/renderer/core/spatial/QuadTree.ts`, `src/types/spatialIndex.ts`
- `src/core/graph/subgraph/proxyWidget.ts`, `src/core/graph/subgraph/proxyWidgetUtils.ts`
- `src/extensions/core/widgetInputs.ts`, `src/renderer/utils/nodeTypeGuards.ts`
Parent: #11022
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11099-Circular-deps-misc-store-service-composable-cycles-33e6d73d365081f5bc0bc43b272750ad) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.