Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/stores/executionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -277,14 +279,18 @@ export const useExecutionStore = defineStore('execution', () => {
}

function handleExecutionInterrupted() {
nodeProgressStates.value = {}
resetExecutionState()
}

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

function handleExecutionSuccess() {
resetExecutionState()
}

function handleExecuting(e: CustomEvent<NodeId | null>): void {
// Clear the current node progress when a new node starts executing
_executingNodeProgress.value = null
Expand Down Expand Up @@ -346,6 +352,19 @@ export const useExecutionStore = defineStore('execution', () => {

function handleExecutionError(e: CustomEvent<ExecutionErrorWsMessage>) {
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) {
Expand Down
Loading