Comfy-Org / Comfy-Org/ComfyUI_frontend
Circular deps: workflowStore ↔ changeTracker/thumbnail cluster
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 704
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
## Problem
`workflowStore.ts` has bidirectional imports with two modules:
```
workflowStore.ts → changeTracker.ts → executionStore.ts → ... → workflowStore.ts
workflowStore.ts → useWorkflowThumbnail.ts → (imports ComfyWorkflow type from workflowStore)
```
### Root cause
- `workflowStore` imports `ChangeTracker` class, while `changeTracker.ts` imports types from `workflowStore`
- `workflowStore` uses `useWorkflowThumbnail()` composable, which imports the `ComfyWorkflow` type back from the store
### Impact
- Long transitive cycle through executionStore and widget composables (up to 17 edges in some paths)
- The workflowStore ↔ changeTracker cycle is one of the most deeply connected in the codebase
### Suggested fix
- Extract `ComfyWorkflow` type to a separate types file (e.g. `workflowTypes.ts`) so `changeTracker` and `useWorkflowThumbnail` can import the type without importing the store
- Consider making `ChangeTracker` accept its dependencies via constructor injection
### Files involved
- `src/platform/workflow/management/stores/workflowStore.ts`
- `src/scripts/changeTracker.ts`
- `src/renderer/core/thumbnail/useWorkflowThumbnail.ts`
- `src/renderer/core/thumbnail/graphThumbnailRenderer.ts`
- `src/stores/executionStore.ts`
Parent: #11022
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11098-Circular-deps-workflowStore-changeTracker-thumbnail-cluster-33e6d73d3650814cb7ddc0076974e0cd) by [Unito](https://www.unito.io)
Contributor guide
Research direction
Start by tracing the imports among workflowStore.ts, changeTracker.ts, useWorkflowThumbnail.ts, graphThumbnailRenderer.ts, and executionStore.ts, using the issue's dependency paths as the initial map. Evaluate the proposed workflowTypes.ts extraction and constructor injection, then confirm that the listed circular dependency paths are removed without breaking the affected imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100