From ca312fd1eab540cc4ddc0e3d244d38b3858574f0 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 15 Sep 2025 02:22:37 -0700 Subject: [PATCH] [refactor] Improve workflow domain organization (#5584) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [refactor] move workflow domain to its own folder * [refactor] Fix workflow platform architecture organization - Move workflow rendering functionality to renderer/thumbnail domain - Rename ui folder to management for better semantic clarity - Update all import paths to reflect proper domain boundaries - Fix test imports to use new structure Architecture improvements: - rendering → renderer/thumbnail (belongs with other rendering logic) - ui → management (better name for state management and UI integration) This ensures proper separation of concerns and domain boundaries. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude * [fix] Resolve circular dependency between nodeDefStore and subgraphStore * [fix] Update browser test imports to use new workflow platform paths --------- Co-authored-by: Claude --- browser_tests/fixtures/ComfyPage.ts | 2 +- .../fixtures/utils/litegraphUtils.ts | 2 +- browser_tests/helpers/templates.ts | 2 +- scripts/generate-json-schema.ts | 2 +- .../breadcrumb/SubgraphBreadcrumb.vue | 2 +- .../breadcrumb/SubgraphBreadcrumbItem.vue | 7 +- .../dialog/UnloadWindowConfirmDialog.vue | 2 +- .../dialog/footer/ManagerProgressFooter.vue | 2 +- src/components/graph/GraphCanvas.vue | 8 +- .../ColorPickerButton.spec.ts | 2 +- .../selectionToolbox/ColorPickerButton.vue | 2 +- .../searchbox/NodeSearchBoxPopover.vue | 2 +- .../sidebar/tabs/QueueSidebarTab.vue | 2 +- .../sidebar/tabs/WorkflowsSidebarTab.vue | 8 +- .../sidebar/tabs/queue/ResultGallery.spec.ts | 2 +- .../sidebar/tabs/queue/TaskItem.vue | 2 +- .../tabs/workflows/WorkflowTreeLeaf.vue | 5 +- .../templates/TemplateWorkflowCard.spec.ts | 80 +++++++++++-------- .../templates/TemplateWorkflowCard.vue | 4 +- .../templates/TemplateWorkflowList.vue | 4 +- .../templates/TemplateWorkflowView.spec.ts | 2 +- .../templates/TemplateWorkflowView.vue | 2 +- .../templates/TemplateWorkflowsContent.vue | 4 +- .../templates/TemplateWorkflowsSideNav.vue | 2 +- .../toast/RerouteMigrationToast.vue | 4 +- .../topbar/WorkflowOverflowMenu.vue | 4 +- src/components/topbar/WorkflowTab.vue | 8 +- src/components/topbar/WorkflowTabs.vue | 9 ++- src/composables/graph/useCanvasRefresh.ts | 2 +- src/composables/graph/useGroupMenuOptions.ts | 2 +- .../graph/useSelectedNodeActions.ts | 2 +- .../graph/useSelectionOperations.ts | 2 +- .../graph/useSubgraphOperations.ts | 2 +- src/composables/nodePack/useWorkflowPacks.ts | 2 +- src/composables/useBrowserTabTitle.ts | 2 +- src/composables/useCanvasDrop.ts | 4 +- src/composables/useCoreCommands.ts | 7 +- src/composables/usePaste.ts | 2 +- src/composables/useTemplateFiltering.ts | 2 +- src/extensions/core/electronAdapter.ts | 2 +- src/extensions/core/groupNode.ts | 2 +- .../core}/services/workflowService.ts | 12 +-- .../workflow/core/types/formats.ts} | 0 .../composables}/useWorkflowsSidebarTab.ts | 2 +- .../management}/stores/workflowStore.ts | 9 +-- .../composables/useWorkflowAutoSave.ts | 4 +- .../composables/useWorkflowPersistence.ts | 4 +- .../composables/useTemplateWorkflows.ts | 10 +-- .../repositories}/workflowTemplatesStore.ts | 4 +- .../workflow/templates/types/template.ts} | 0 .../composables/useWorkflowValidation.ts | 4 +- .../validation/schemas/workflowSchema.ts} | 0 .../minimap/composables/useMinimap.ts | 2 +- .../minimap/composables/useMinimapGraph.ts | 2 +- .../vueNodes/composables/useNodeZIndex.ts | 2 +- .../thumbnail/graphThumbnailRenderer.ts | 2 +- .../{composables => }/useWorkflowThumbnail.ts | 2 +- src/schemas/apiSchema.ts | 5 +- src/scripts/api.ts | 12 +-- src/scripts/app.ts | 18 ++--- src/scripts/changeTracker.ts | 7 +- src/scripts/defaultGraph.ts | 2 +- src/scripts/metadata/ebml.ts | 2 +- src/scripts/metadata/gltf.ts | 2 +- src/scripts/metadata/isobmff.ts | 2 +- src/scripts/ui.ts | 2 +- src/services/litegraphService.ts | 4 +- src/services/load3dService.ts | 2 +- src/services/subgraphService.ts | 2 +- src/stores/executionStore.ts | 16 ++-- src/stores/imagePreviewStore.ts | 2 +- src/stores/nodeDefStore.ts | 2 +- src/stores/queueStore.ts | 5 +- src/stores/subgraphNavigationStore.ts | 3 +- src/stores/subgraphStore.ts | 18 ++--- src/stores/workspace/sidebarTabStore.ts | 2 +- src/stores/workspaceStore.ts | 2 +- src/types/comfy.ts | 2 +- src/types/litegraph-augmentation.d.ts | 3 +- src/types/metadataTypes.ts | 2 +- src/types/nodeIdentification.ts | 2 +- src/utils/errorReportUtil.ts | 2 +- src/utils/executionUtil.ts | 2 +- src/utils/migration/migrateReroute.ts | 2 +- src/utils/modelMetadataUtil.ts | 2 +- tests-ui/store-testing.md | 2 +- tests-ui/tests/comfyWorkflow.test.ts | 2 +- .../footer/ManagerProgressFooter.test.ts | 2 +- .../tests/composables/BrowserTabTitle.spec.ts | 2 +- .../tests/composables/useCoreCommands.test.ts | 4 +- tests-ui/tests/composables/useMinimap.test.ts | 2 +- .../composables/useTemplateWorkflows.test.ts | 13 +-- .../composables/useWorkflowAutoSave.test.ts | 8 +- .../composables/useWorkflowThumbnail.spec.ts | 7 +- tests-ui/tests/store/executionStore.test.ts | 4 +- .../store/subgraphNavigationStore.test.ts | 4 +- .../subgraphNavigationStore.viewport.test.ts | 4 +- tests-ui/tests/store/workflowStore.test.ts | 8 +- .../tests/types/nodeIdentification.test.ts | 2 +- .../utils/migration/migrateReroute.test.ts | 2 +- tests-ui/unit-testing.md | 2 +- 101 files changed, 251 insertions(+), 213 deletions(-) rename src/{ => platform/workflow/core}/services/workflowService.ts (97%) rename src/{constants/supportedWorkflowFormats.ts => platform/workflow/core/types/formats.ts} (100%) rename src/{composables/sidebarTabs => platform/workflow/management/composables}/useWorkflowsSidebarTab.ts (91%) rename src/{ => platform/workflow/management}/stores/workflowStore.ts (98%) rename src/{ => platform/workflow/persistence}/composables/useWorkflowAutoSave.ts (93%) rename src/{ => platform/workflow/persistence}/composables/useWorkflowPersistence.ts (96%) rename src/{ => platform/workflow/templates}/composables/useTemplateWorkflows.ts (96%) rename src/{stores => platform/workflow/templates/repositories}/workflowTemplatesStore.ts (99%) rename src/{types/workflowTemplateTypes.ts => platform/workflow/templates/types/template.ts} (100%) rename src/{ => platform/workflow/validation}/composables/useWorkflowValidation.ts (92%) rename src/{schemas/comfyWorkflowSchema.ts => platform/workflow/validation/schemas/workflowSchema.ts} (100%) rename src/renderer/thumbnail/{composables => }/useWorkflowThumbnail.ts (96%) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 008233091..c9a8820f5 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -5,7 +5,7 @@ import dotenv from 'dotenv' import * as fs from 'fs' import type { LGraphNode } from '../../src/lib/litegraph/src/litegraph' -import type { NodeId } from '../../src/schemas/comfyWorkflowSchema' +import type { NodeId } from '../../src/platform/workflow/validation/schemas/workflowSchema' import type { KeyCombo } from '../../src/schemas/keyBindingSchema' import type { useWorkspaceStore } from '../../src/stores/workspaceStore' import { NodeBadgeMode } from '../../src/types/nodeSource' diff --git a/browser_tests/fixtures/utils/litegraphUtils.ts b/browser_tests/fixtures/utils/litegraphUtils.ts index c9bf88a91..4becc999c 100644 --- a/browser_tests/fixtures/utils/litegraphUtils.ts +++ b/browser_tests/fixtures/utils/litegraphUtils.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test' -import type { NodeId } from '../../../src/schemas/comfyWorkflowSchema' +import type { NodeId } from '../../../src/platform/workflow/validation/schemas/workflowSchema' import { ManageGroupNode } from '../../helpers/manageGroupNode' import type { ComfyPage } from '../ComfyPage' import type { Position, Size } from '../types' diff --git a/browser_tests/helpers/templates.ts b/browser_tests/helpers/templates.ts index d659e125a..0d2c9f31e 100644 --- a/browser_tests/helpers/templates.ts +++ b/browser_tests/helpers/templates.ts @@ -4,7 +4,7 @@ import path from 'path' import { TemplateInfo, WorkflowTemplates -} from '../../src/types/workflowTemplateTypes' +} from '../../src/platform/workflow/templates/types/template' export class ComfyTemplates { readonly content: Locator diff --git a/scripts/generate-json-schema.ts b/scripts/generate-json-schema.ts index 76aa41b2e..1a2056626 100644 --- a/scripts/generate-json-schema.ts +++ b/scripts/generate-json-schema.ts @@ -5,7 +5,7 @@ import { zodToJsonSchema } from 'zod-to-json-schema' import { zComfyWorkflow, zComfyWorkflow1 -} from '../src/schemas/comfyWorkflowSchema' +} from '../src/platform/workflow/validation/schemas/workflowSchema' import { zComfyNodeDef as zComfyNodeDefV2 } from '../src/schemas/nodeDef/nodeDefSchemaV2' import { zComfyNodeDef as zComfyNodeDefV1 } from '../src/schemas/nodeDefSchema' diff --git a/src/components/breadcrumb/SubgraphBreadcrumb.vue b/src/components/breadcrumb/SubgraphBreadcrumb.vue index 6e9c59af9..fb218ab1e 100644 --- a/src/components/breadcrumb/SubgraphBreadcrumb.vue +++ b/src/components/breadcrumb/SubgraphBreadcrumb.vue @@ -38,10 +38,10 @@ import { computed, onUpdated, ref, watch } from 'vue' import SubgraphBreadcrumbItem from '@/components/breadcrumb/SubgraphBreadcrumbItem.vue' import { useOverflowObserver } from '@/composables/element/useOverflowObserver' +import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' import { useSubgraphStore } from '@/stores/subgraphStore' -import { useWorkflowStore } from '@/stores/workflowStore' import { forEachSubgraphNode } from '@/utils/graphTraversalUtil' const MIN_WIDTH = 28 diff --git a/src/components/breadcrumb/SubgraphBreadcrumbItem.vue b/src/components/breadcrumb/SubgraphBreadcrumbItem.vue index eb688dff6..5f5671a4d 100644 --- a/src/components/breadcrumb/SubgraphBreadcrumbItem.vue +++ b/src/components/breadcrumb/SubgraphBreadcrumbItem.vue @@ -53,11 +53,14 @@ import Tag from 'primevue/tag' import { computed, nextTick, ref } from 'vue' import { useI18n } from 'vue-i18n' +import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' +import { + ComfyWorkflow, + useWorkflowStore +} from '@/platform/workflow/management/stores/workflowStore' import { useDialogService } from '@/services/dialogService' -import { useWorkflowService } from '@/services/workflowService' import { useCommandStore } from '@/stores/commandStore' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' -import { ComfyWorkflow, useWorkflowStore } from '@/stores/workflowStore' import { appendJsonExt } from '@/utils/formatUtil' interface Props { diff --git a/src/components/dialog/UnloadWindowConfirmDialog.vue b/src/components/dialog/UnloadWindowConfirmDialog.vue index 2a26c276d..9a9c30bd3 100644 --- a/src/components/dialog/UnloadWindowConfirmDialog.vue +++ b/src/components/dialog/UnloadWindowConfirmDialog.vue @@ -12,8 +12,8 @@