From b034e2c3265aca36e128a80838deae74f07ae4dc Mon Sep 17 00:00:00 2001 From: Jacob Segal Date: Thu, 3 Jul 2025 14:03:11 -0700 Subject: [PATCH] Address PR feedback --- src/components/graph/GraphCanvas.vue | 10 ++------ src/composables/useBrowserTabTitle.ts | 33 +++++++++++++-------------- src/extensions/core/groupNode.ts | 6 ++--- src/scripts/domWidget.ts | 2 +- src/services/litegraphService.ts | 7 ++---- src/stores/executionStore.ts | 24 +------------------ 6 files changed, 25 insertions(+), 57 deletions(-) diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 61e99f771..9f0de2612 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -209,15 +209,9 @@ watch( // Only show progress for running nodes if (progressState.state === 'running') { if (node.progress === undefined || node.progress === 0.0) { - console.log( - `${Date.now()} Setting progress for node ${node.id} to ${progressState.value / progressState.max}=${progressState.value}/${progressState.max} due to ${nodeId}` - ) node.progress = progressState.value / progressState.max } else { // Update progress if it was already set - console.log( - `${Date.now()} Setting progress for node ${node.id} to Math.min(${node.progress}, ${progressState.value / progressState.max}=${progressState.value}/${progressState.max}) due to ${nodeId}` - ) node.progress = Math.min( node.progress, progressState.value / progressState.max @@ -227,8 +221,8 @@ watch( } } - // TODO - Do we need to force canvas redraw here? - // comfyApp.graph.setDirtyCanvas(true, true) + // Force canvas redraw to ensure progress updates are visible + comfyApp.graph.setDirtyCanvas(true, false) }, { deep: true } ) diff --git a/src/composables/useBrowserTabTitle.ts b/src/composables/useBrowserTabTitle.ts index 6f0b85a82..2056b21ce 100644 --- a/src/composables/useBrowserTabTitle.ts +++ b/src/composables/useBrowserTabTitle.ts @@ -46,25 +46,24 @@ export const useBrowserTabTitle = () => { ([_, state]) => state.state === 'running' ) - if (runningNodes.length > 0) { - // If multiple nodes are running - if (runningNodes.length > 1) { - return `${executionText.value}[${runningNodes.length} ${t('g.nodesRunning', 'nodes running')}]` - } - // If only one node is running - else { - const [nodeId, state] = runningNodes[0] - const progress = Math.round((state.value / state.max) * 100) - const nodeType = - executionStore.activePrompt?.workflow?.changeTracker?.activeState?.nodes.find( - (n) => String(n.id) === nodeId - )?.type || 'Node' - - return `${executionText.value}[${progress}%] ${nodeType}` - } + if (runningNodes.length === 0) { + return '' } - return '' + // If multiple nodes are running + if (runningNodes.length > 1) { + return `${executionText.value}[${runningNodes.length} ${t('g.nodesRunning', 'nodes running')}]` + } + + // If only one node is running + const [nodeId, state] = runningNodes[0] + const progress = Math.round((state.value / state.max) * 100) + const nodeType = + executionStore.activePrompt?.workflow?.changeTracker?.activeState?.nodes.find( + (n) => String(n.id) === nodeId + )?.type || 'Node' + + return `${executionText.value}[${progress}%] ${nodeType}` }) const workflowTitle = computed( diff --git a/src/extensions/core/groupNode.ts b/src/extensions/core/groupNode.ts index 4e6ce514c..2e56e091d 100644 --- a/src/extensions/core/groupNode.ts +++ b/src/extensions/core/groupNode.ts @@ -1225,10 +1225,10 @@ export class GroupNodeHandler { node.onDrawForeground = function (ctx) { // @ts-expect-error fixme ts strict error onDrawForeground?.apply?.(this, arguments) - const executionStore = useExecutionStore() + const progressState = useExecutionStore().nodeProgressStates[this.id] if ( - executionStore.nodeProgressStates[this.id] && - executionStore.nodeProgressStates[this.id].state === 'running' && + progressState && + progressState.state === 'running' && this.runningInternalNodeId !== null ) { // @ts-expect-error fixme ts strict error diff --git a/src/scripts/domWidget.ts b/src/scripts/domWidget.ts index ae237752d..36ad0445f 100644 --- a/src/scripts/domWidget.ts +++ b/src/scripts/domWidget.ts @@ -237,7 +237,7 @@ export class ComponentWidgetImpl< component: Component inputSpec: InputSpec props?: P - componentProps?: Record + componentProps?: Partial

options: DOMWidgetOptions }) { super({ diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 04addfde1..c2715a593 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -363,12 +363,9 @@ export const useLitegraphService = () => { */ #setupStrokeStyles() { this.strokeStyles['running'] = function (this: LGraphNode) { - const nodeProgressStates = useExecutionStore().nodeProgressStates const nodeId = String(this.id) - if ( - nodeProgressStates[nodeId] && - nodeProgressStates[nodeId].state === 'running' - ) { + const state = useExecutionStore().nodeProgressStates[nodeId]?.state + if (state === 'running') { return { color: '#0f0' } } } diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index c2a5cc595..bec879d33 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -23,6 +23,7 @@ import type { NodeId } from '@/schemas/comfyWorkflowSchema' import { api } from '@/scripts/api' +import { app } from '@/scripts/app' import { useCanvasStore } from './graphStore' import { ComfyWorkflow, useWorkflowStore } from './workflowStore' @@ -110,29 +111,6 @@ export const useExecutionStore = defineStore('execution', () => { return getSubgraphsFromInstanceIds(subgraph, subgraphNodeIds, subgraphs) } - const executionIdToCurrentId = (id: string) => { - const subgraph = workflowStore.activeSubgraph - - // Short-circuit: ID belongs to the parent workflow / no active subgraph - if (!id.includes(':')) { - return !subgraph ? id : undefined - } else if (!subgraph) { - return - } - - // Parse the hierarchical ID (e.g., "123:456:789") - const subgraphNodeIds = id.split(':') - - // If the last subgraph is the active subgraph, return the node ID - const subgraphs = getSubgraphsFromInstanceIds( - subgraph.rootGraph, - subgraphNodeIds - ) - if (subgraphs.at(-1) === subgraph) { - return subgraphNodeIds.at(-1) - } - } - // This is the progress of the currently executing node (for backward compatibility) const _executingNodeProgress = ref(null) const executingNodeProgress = computed(() =>