refactor(GraphCanvas): Phase 3 - code organization fixes

- Consolidate two Vue node lifecycle reset watchers into one
- Remove duplicate useVueFeatureFlags() call
- Cache store references at top level instead of calling inside callbacks

Amp-Thread-ID: https://ampcode.com/threads/T-019bf963-9130-77df-bacc-7d4b1c5cae31
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Alexander Brown
2026-01-26 00:22:50 -08:00
parent bbec515a7b
commit 3a2dbe68a3

View File

@@ -225,13 +225,11 @@ const handleVueNodeLifecycleReset = async () => {
}
}
watch(() => canvasStore.currentGraph, handleVueNodeLifecycleReset)
watch(
() => canvasStore.isInSubgraph,
async (newValue, oldValue) => {
if (oldValue && !newValue) {
useWorkflowStore().updateActiveGraph()
() => [canvasStore.currentGraph, canvasStore.isInSubgraph] as const,
async ([_graph, isInSubgraph], [_prevGraph, wasInSubgraph]) => {
if (wasInSubgraph && !isInSubgraph) {
workflowStore.updateActiveGraph()
}
await handleVueNodeLifecycleReset()
}
@@ -334,7 +332,6 @@ watch(
[executionStore.nodeLocationProgressStates, canvasStore.canvas] as const,
([nodeLocationProgressStates, canvas]) => {
if (!canvas?.graph) return
const workflowStore = useWorkflowStore()
for (const node of canvas.graph.nodes) {
const nodeLocatorId = workflowStore.nodeIdToNodeLocatorId(node.id)
const progressState = nodeLocationProgressStates[nodeLocatorId]
@@ -401,6 +398,7 @@ useEventListener(
const comfyAppReady = ref(false)
const workflowPersistence = useWorkflowPersistence()
const commandStore = useCommandStore()
const { flags } = useFeatureFlags()
// Set up invite loader during setup phase so useRoute/useRouter work correctly
const inviteUrlLoader = isCloud ? useInviteUrlLoader() : null
@@ -433,7 +431,7 @@ watch(
'Somehow the Locale setting was changed while the settings or i18n had a setup error'
)
}
await useCommandStore().execute('Comfy.RefreshNodeDefinitions')
await commandStore.execute('Comfy.RefreshNodeDefinitions')
if (runId !== localeWatcherRunId) return
await useWorkflowService().reloadCurrentWorkflow()
}