Comfy-Org / Comfy-Org/ComfyUI_frontend

[RFC] Migrate domain-specific utils from `src/utils/` to their domains

Open
#11,064 0 comments 0 reactions 0 assignees View on GitHub
developer experience refactor
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Problem

`src/utils/` contains 45 non-test utility files in a flat directory. Many are domain-specific and should live alongside their domain modules, making the domain self-contained and reducing cross-directory bouncing.

### Domain-specific utils identified

| Domain | Files | Total lines |
|--------|-------|-------------|
| Execution | `executionUtil.ts` (159L), `executionErrorUtil.ts` (127L) | 286 |
| Queue | `queueUtil.ts` (38L), `queueDisplay.ts` (160L) | 198 |
| Graph/LiteGraph | `litegraphUtil.ts` (355L), `graphTraversalUtil.ts` (709L), `linkFixer.ts` | 1,064+ |
| Node Definitions | `nodeDefUtil.ts` (140L), `nodeFilterUtil.ts` (21L), `nodeTitleUtil.ts` (28L) | 189 |
| Widgets | `widgetUtil.ts` (126L), `widgetPropFilter.ts` (72L) | 198 |
| Group Nodes | `executableGroupNodeDto.ts` (76L), `executableGroupNodeChildDTO.ts` (68L) | 144 |

Generic utils (`mathUtil`, `colorUtil`, `tailwindUtil`, `formatUtil`, `treeUtil`, etc.) should stay in `src/utils/`.

## Proposed Deepening

Move domain-specific utils into their domain directories:

- `executionUtil.ts`, `executionErrorUtil.ts` → `platform/execution/` (once created per Issue #11017)
- `queueUtil.ts`, `queueDisplay.ts` → `platform/queue/` (or alongside `queueStore`)
- `litegraphUtil.ts`, `graphTraversalUtil.ts`, `linkFixer.ts` → `lib/litegraph/` or `renderer/`
- `nodeDefUtil.ts`, `nodeFilterUtil.ts`, `nodeTitleUtil.ts` → `platform/nodeCatalog/` (per Issue #11020)
- `widgetUtil.ts`, `widgetPropFilter.ts` → `renderer/` (widget rendering concern)
- `executableGroupNodeDto.ts`, `executableGroupNodeChildDTO.ts` → near group node logic

## Migration Plan

1. This is a follow-on to store migration (Issue #11017) and node catalog consolidation (Issue #11020)
2. Move one domain cluster per PR
3. Update imports, verify with `pnpm typecheck`

## Testing Strategy

- All existing tests pass unchanged (only import paths change)
- `pnpm typecheck` and `pnpm lint` pass after each move

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11064-RFC-Migrate-domain-specific-utils-from-src-utils-to-their-domains-33e6d73d365081e2abf0c741582e9dd9) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.