Skip to content

Commit 1d06b4d

Browse files
fix(execution): reset progress state after runs to unfreeze tab title/favicon (main) (#6026)
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)
1 parent 14c07fd commit 1d06b4d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/stores/executionStore.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export const useExecutionStore = defineStore('execution', () => {
239239
api.addEventListener('execution_start', handleExecutionStart)
240240
api.addEventListener('execution_cached', handleExecutionCached)
241241
api.addEventListener('execution_interrupted', handleExecutionInterrupted)
242+
api.addEventListener('execution_success', handleExecutionSuccess)
242243
api.addEventListener('executed', handleExecuted)
243244
api.addEventListener('executing', handleExecuting)
244245
api.addEventListener('progress', handleProgress)
@@ -253,6 +254,7 @@ export const useExecutionStore = defineStore('execution', () => {
253254
api.removeEventListener('execution_start', handleExecutionStart)
254255
api.removeEventListener('execution_cached', handleExecutionCached)
255256
api.removeEventListener('execution_interrupted', handleExecutionInterrupted)
257+
api.removeEventListener('execution_success', handleExecutionSuccess)
256258
api.removeEventListener('executed', handleExecuted)
257259
api.removeEventListener('executing', handleExecuting)
258260
api.removeEventListener('progress', handleProgress)
@@ -277,14 +279,18 @@ export const useExecutionStore = defineStore('execution', () => {
277279
}
278280

279281
function handleExecutionInterrupted() {
280-
nodeProgressStates.value = {}
282+
resetExecutionState()
281283
}
282284

283285
function handleExecuted(e: CustomEvent<ExecutedWsMessage>) {
284286
if (!activePrompt.value) return
285287
activePrompt.value.nodes[e.detail.node] = true
286288
}
287289

290+
function handleExecutionSuccess() {
291+
resetExecutionState()
292+
}
293+
288294
function handleExecuting(e: CustomEvent<NodeId | null>): void {
289295
// Clear the current node progress when a new node starts executing
290296
_executingNodeProgress.value = null
@@ -346,6 +352,19 @@ export const useExecutionStore = defineStore('execution', () => {
346352

347353
function handleExecutionError(e: CustomEvent<ExecutionErrorWsMessage>) {
348354
lastExecutionError.value = e.detail
355+
resetExecutionState()
356+
}
357+
358+
/**
359+
* Reset execution-related state after a run completes or is stopped.
360+
*/
361+
function resetExecutionState() {
362+
nodeProgressStates.value = {}
363+
if (activePromptId.value) {
364+
delete queuedPrompts.value[activePromptId.value]
365+
}
366+
activePromptId.value = null
367+
_executingNodeProgress.value = null
349368
}
350369

351370
function getNodeIdIfExecuting(nodeId: string | number) {

0 commit comments

Comments
 (0)