Comfy-Org / Comfy-Org/ComfyUI_frontend
[RFC] Extract `useCoreCommands` — decompose 1,356-line command registry
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 702
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
## Problem
`src/composables/useCoreCommands.ts` is 1,356 lines with 67 imports touching every layer of the application (stores, platform, renderer, scripts, workbench, composables). It registers all core commands in a single function that returns a flat array.
This is a shallow module — it's essentially a giant switch statement mapping command IDs to handler functions. Adding a new command means modifying this file and importing yet another dependency, growing the coupling surface.
## Proposed Deepening
Split commands into domain-specific command groups that self-register:
- `useWorkflowCommands` — open, save, export, new, template commands
- `useGraphCommands` — undo/redo, copy/paste, arrange, select, group operations
- `useExecutionCommands` — queue, interrupt, batch execution
- `useViewCommands` — zoom, reset view, toggle panels, theme
- `useSubgraphCommands` — enter/exit subgraph, convert to subgraph
- `useAccountCommands` — sign in/out, credits, subscription
Each group registers its own commands. `useCoreCommands` becomes a thin aggregator.
## Interface Design
```typescript
// Each domain exports its commands
export function useWorkflowCommands(): ComfyCommand[] { ... }
export function useGraphCommands(): ComfyCommand[] { ... }
// Aggregator
export function useCoreCommands(): ComfyCommand[] {
return [
...useWorkflowCommands(),
...useGraphCommands(),
...useExecutionCommands(),
...useViewCommands(),
...useSubgraphCommands(),
...useAccountCommands(),
]
}
```
## Migration Plan
1. Extract one command group at a time, starting with the most self-contained (e.g., `useViewCommands`)
2. Each extraction is a single PR
3. `useCoreCommands` shrinks incrementally
## Testing Strategy
- Existing `useCoreCommands.test.ts` continues to pass
- Each new command group gets its own test file
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11060-RFC-Extract-useCoreCommands-decompose-1-356-line-command-registry-33e6d73d3650817dbfcedb21386548f6) by [Unito](https://www.unito.io)
Contributor guide
Research direction
Start by reading src/composables/useCoreCommands.ts and the existing useCoreCommands.test.ts to understand the current command registry and its dependencies. Use the proposed workflow, graph, execution, view, subgraph, and account groupings as the extraction boundary. Done means useCoreCommands is a thin aggregator, each group registers its commands, and the existing and new group tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100