mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
fix(execution): reset progress state after runs to unfreeze tab title/favicon (#6025)
## Summary Fixes browser tab progress and favicon remaining at ~14% after workflow completion on `rh-test` by resetting execution state on success, error, or interruption. ## Changes - Add `execution_success` listener in the execution store - Centralize terminal-state cleanup in `resetExecutionState()` - Clear `nodeProgressStates`, queued prompt entry, `_executingNodeProgress`, and set `activePromptId` to `null` - Ensures `isIdle` becomes `true` post-run so tab title and favicon no longer freeze mid-progress Resolves #6024 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6025-fix-execution-reset-progress-state-after-runs-to-unfreeze-tab-title-favicon-2896d73d365081fc8849f3814f524d41) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -239,6 +239,7 @@ export const useExecutionStore = defineStore('execution', () => {
|
|||||||
api.addEventListener('execution_start', handleExecutionStart)
|
api.addEventListener('execution_start', handleExecutionStart)
|
||||||
api.addEventListener('execution_cached', handleExecutionCached)
|
api.addEventListener('execution_cached', handleExecutionCached)
|
||||||
api.addEventListener('execution_interrupted', handleExecutionInterrupted)
|
api.addEventListener('execution_interrupted', handleExecutionInterrupted)
|
||||||
|
api.addEventListener('execution_success', handleExecutionSuccess)
|
||||||
api.addEventListener('executed', handleExecuted)
|
api.addEventListener('executed', handleExecuted)
|
||||||
api.addEventListener('executing', handleExecuting)
|
api.addEventListener('executing', handleExecuting)
|
||||||
api.addEventListener('progress', handleProgress)
|
api.addEventListener('progress', handleProgress)
|
||||||
@@ -253,6 +254,7 @@ export const useExecutionStore = defineStore('execution', () => {
|
|||||||
api.removeEventListener('execution_start', handleExecutionStart)
|
api.removeEventListener('execution_start', handleExecutionStart)
|
||||||
api.removeEventListener('execution_cached', handleExecutionCached)
|
api.removeEventListener('execution_cached', handleExecutionCached)
|
||||||
api.removeEventListener('execution_interrupted', handleExecutionInterrupted)
|
api.removeEventListener('execution_interrupted', handleExecutionInterrupted)
|
||||||
|
api.removeEventListener('execution_success', handleExecutionSuccess)
|
||||||
api.removeEventListener('executed', handleExecuted)
|
api.removeEventListener('executed', handleExecuted)
|
||||||
api.removeEventListener('executing', handleExecuting)
|
api.removeEventListener('executing', handleExecuting)
|
||||||
api.removeEventListener('progress', handleProgress)
|
api.removeEventListener('progress', handleProgress)
|
||||||
@@ -277,7 +279,7 @@ export const useExecutionStore = defineStore('execution', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleExecutionInterrupted() {
|
function handleExecutionInterrupted() {
|
||||||
nodeProgressStates.value = {}
|
resetExecutionState()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExecuted(e: CustomEvent<ExecutedWsMessage>) {
|
function handleExecuted(e: CustomEvent<ExecutedWsMessage>) {
|
||||||
@@ -285,6 +287,10 @@ export const useExecutionStore = defineStore('execution', () => {
|
|||||||
activePrompt.value.nodes[e.detail.node] = true
|
activePrompt.value.nodes[e.detail.node] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleExecutionSuccess() {
|
||||||
|
resetExecutionState()
|
||||||
|
}
|
||||||
|
|
||||||
function handleExecuting(e: CustomEvent<NodeId | null>): void {
|
function handleExecuting(e: CustomEvent<NodeId | null>): void {
|
||||||
// Clear the current node progress when a new node starts executing
|
// Clear the current node progress when a new node starts executing
|
||||||
_executingNodeProgress.value = null
|
_executingNodeProgress.value = null
|
||||||
@@ -346,6 +352,19 @@ export const useExecutionStore = defineStore('execution', () => {
|
|||||||
|
|
||||||
function handleExecutionError(e: CustomEvent<ExecutionErrorWsMessage>) {
|
function handleExecutionError(e: CustomEvent<ExecutionErrorWsMessage>) {
|
||||||
lastExecutionError.value = e.detail
|
lastExecutionError.value = e.detail
|
||||||
|
resetExecutionState()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset execution-related state after a run completes or is stopped.
|
||||||
|
*/
|
||||||
|
function resetExecutionState() {
|
||||||
|
nodeProgressStates.value = {}
|
||||||
|
if (activePromptId.value) {
|
||||||
|
delete queuedPrompts.value[activePromptId.value]
|
||||||
|
}
|
||||||
|
activePromptId.value = null
|
||||||
|
_executingNodeProgress.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNodeIdIfExecuting(nodeId: string | number) {
|
function getNodeIdIfExecuting(nodeId: string | number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user