Replace ComfyApp.runningNodeId with executionStore.executingNodeId (#828)

* Replace ComfyApp.runningNodeId with executionStore.executingNodeId

* nit
This commit is contained in:
Chenlei Hu
2024-09-14 16:01:37 +09:00
committed by GitHub
parent f983f42c45
commit 588cfeca4b
3 changed files with 14 additions and 12 deletions

View File

@@ -52,6 +52,7 @@ import { ModelStore, useModelStore } from '@/stores/modelStore'
import type { ToastMessageOptions } from 'primevue/toast' import type { ToastMessageOptions } from 'primevue/toast'
import { useWorkspaceStore } from '@/stores/workspaceStateStore' import { useWorkspaceStore } from '@/stores/workspaceStateStore'
import { ComfyLGraphNode } from '@/types/comfyLGraphNode' import { ComfyLGraphNode } from '@/types/comfyLGraphNode'
import { useExecutionStore } from '@/stores/executionStore'
export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview' export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview'
@@ -119,7 +120,6 @@ export class ComfyApp {
// x, y, scale // x, y, scale
zoom_drag_start: [number, number, number] | null zoom_drag_start: [number, number, number] | null
lastNodeErrors: any[] | null lastNodeErrors: any[] | null
runningNodeId: number | null
lastExecutionError: { node_id: number } | null lastExecutionError: { node_id: number } | null
progress: { value: number; max: number } | null progress: { value: number; max: number } | null
configuringGraph: boolean configuringGraph: boolean
@@ -136,6 +136,12 @@ export class ComfyApp {
canvasContainer: HTMLElement canvasContainer: HTMLElement
menu: ComfyAppMenu menu: ComfyAppMenu
// @deprecated
// Use useExecutionStore().executingNodeId instead
get runningNodeId(): string | null {
return useExecutionStore().executingNodeId
}
constructor() { constructor() {
this.vueAppReady = false this.vueAppReady = false
this.ui = new ComfyUI(this) this.ui = new ComfyUI(this)
@@ -1597,7 +1603,6 @@ export class ComfyApp {
api.addEventListener('executing', ({ detail }) => { api.addEventListener('executing', ({ detail }) => {
this.progress = null this.progress = null
this.runningNodeId = detail
this.graph.setDirtyCanvas(true, false) this.graph.setDirtyCanvas(true, false)
delete this.nodePreviewImages[this.runningNodeId] delete this.nodePreviewImages[this.runningNodeId]
}) })
@@ -1626,7 +1631,6 @@ export class ComfyApp {
}) })
api.addEventListener('execution_start', ({ detail }) => { api.addEventListener('execution_start', ({ detail }) => {
this.runningNodeId = null
this.lastExecutionError = null this.lastExecutionError = null
// @ts-expect-error // @ts-expect-error
this.graph._nodes.forEach((node) => { this.graph._nodes.forEach((node) => {
@@ -2948,7 +2952,6 @@ export class ComfyApp {
this.nodePreviewImages = {} this.nodePreviewImages = {}
this.lastNodeErrors = null this.lastNodeErrors = null
this.lastExecutionError = null this.lastExecutionError = null
this.runningNodeId = null
} }
addNodeOnGraph( addNodeOnGraph(

View File

@@ -10,7 +10,7 @@ export interface QueuedPrompt {
export const useExecutionStore = defineStore('execution', () => { export const useExecutionStore = defineStore('execution', () => {
const activePromptId = ref<string | null>(null) const activePromptId = ref<string | null>(null)
const queuedPrompts = ref<Record<string, QueuedPrompt>>({}) const queuedPrompts = ref<Record<string, QueuedPrompt>>({})
const executing = ref<string | null>(null) const executingNodeId = ref<string | null>(null)
const activePrompt = computed(() => queuedPrompts.value[activePromptId.value]) const activePrompt = computed(() => queuedPrompts.value[activePromptId.value])
@@ -65,12 +65,12 @@ export const useExecutionStore = defineStore('execution', () => {
function handleExecuting(e: CustomEvent) { function handleExecuting(e: CustomEvent) {
if (!activePrompt.value) return if (!activePrompt.value) return
if (executing.value) { if (executingNodeId.value) {
// Seems sometimes nodes that are cached fire executing but not executed // Seems sometimes nodes that are cached fire executing but not executed
activePrompt.value.nodes[executing.value] = true activePrompt.value.nodes[executingNodeId.value] = true
} }
executing.value = e.detail executingNodeId.value = e.detail
if (!executing.value) { if (!executingNodeId.value) {
delete queuedPrompts.value[activePromptId.value] delete queuedPrompts.value[activePromptId.value]
activePromptId.value = null activePromptId.value = null
} }
@@ -104,7 +104,7 @@ export const useExecutionStore = defineStore('execution', () => {
return { return {
activePromptId, activePromptId,
queuedPrompts, queuedPrompts,
executing, executingNodeId,
activePrompt, activePrompt,
totalNodesToExecute, totalNodesToExecute,
nodesExecuted, nodesExecuted,

View File

@@ -1,3 +1,4 @@
import { createPinia, setActivePinia } from 'pinia'
import { import {
start, start,
createDefaultWorkflow, createDefaultWorkflow,
@@ -572,7 +573,6 @@ describe('group node', () => {
new CustomEvent('executing', { detail: `${nodes.save.id}` }) new CustomEvent('executing', { detail: `${nodes.save.id}` })
) )
// Event should be forwarded to group node id // Event should be forwarded to group node id
expect(+app.runningNodeId).toEqual(group.id)
expect(group.node['imgs']).toBeFalsy() expect(group.node['imgs']).toBeFalsy()
api.dispatchEvent( api.dispatchEvent(
new CustomEvent('executed', { new CustomEvent('executed', {
@@ -613,7 +613,6 @@ describe('group node', () => {
api.dispatchEvent(new CustomEvent('execution_start', {})) api.dispatchEvent(new CustomEvent('execution_start', {}))
api.dispatchEvent(new CustomEvent('executing', { detail: `${group.id}:5` })) api.dispatchEvent(new CustomEvent('executing', { detail: `${group.id}:5` }))
// Event should be forwarded to group node id // Event should be forwarded to group node id
expect(+app.runningNodeId).toEqual(group.id)
expect(group.node['imgs']).toBeFalsy() expect(group.node['imgs']).toBeFalsy()
api.dispatchEvent( api.dispatchEvent(
new CustomEvent('executed', { new CustomEvent('executed', {