From 6550fc372fc119d7094e9c314c4e33c1578e00d8 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Sat, 11 Oct 2025 18:53:58 -0700 Subject: [PATCH] fix(execution): reset progress state after runs to unfreeze tab title/favicon (main) (#6026) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry picked over from #6025, should've been made to target main to begin with ## Summary Fixes the browser tab progress and favicon remaining at ~14% after workflow completion on `main` by resetting execution state when a run ends (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-6026-fix-execution-reset-progress-state-after-runs-to-unfreeze-tab-title-favicon-main-28a6d73d365081f188ebc2e69d936dd9) by [Unito](https://www.unito.io) --- src/stores/executionStore.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index af482cc8a0..51e1826402 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -239,6 +239,7 @@ export const useExecutionStore = defineStore('execution', () => { api.addEventListener('execution_start', handleExecutionStart) api.addEventListener('execution_cached', handleExecutionCached) api.addEventListener('execution_interrupted', handleExecutionInterrupted) + api.addEventListener('execution_success', handleExecutionSuccess) api.addEventListener('executed', handleExecuted) api.addEventListener('executing', handleExecuting) api.addEventListener('progress', handleProgress) @@ -253,6 +254,7 @@ export const useExecutionStore = defineStore('execution', () => { api.removeEventListener('execution_start', handleExecutionStart) api.removeEventListener('execution_cached', handleExecutionCached) api.removeEventListener('execution_interrupted', handleExecutionInterrupted) + api.removeEventListener('execution_success', handleExecutionSuccess) api.removeEventListener('executed', handleExecuted) api.removeEventListener('executing', handleExecuting) api.removeEventListener('progress', handleProgress) @@ -277,7 +279,7 @@ export const useExecutionStore = defineStore('execution', () => { } function handleExecutionInterrupted() { - nodeProgressStates.value = {} + resetExecutionState() } function handleExecuted(e: CustomEvent) { @@ -285,6 +287,10 @@ export const useExecutionStore = defineStore('execution', () => { activePrompt.value.nodes[e.detail.node] = true } + function handleExecutionSuccess() { + resetExecutionState() + } + function handleExecuting(e: CustomEvent): void { // Clear the current node progress when a new node starts executing _executingNodeProgress.value = null @@ -346,6 +352,19 @@ export const useExecutionStore = defineStore('execution', () => { function handleExecutionError(e: CustomEvent) { 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) {