mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-06-05 20:54:56 +00:00
fix: clear stale active job after reconnect
This commit is contained in:
@@ -491,6 +491,45 @@ describe('useExecutionStore - clearTrackedJob', () => {
|
||||
expect(store.initializingJobIds).toEqual(new Set(['job-2']))
|
||||
expect(store._executingNodeProgress).toBeNull()
|
||||
})
|
||||
|
||||
it('clears a stale active job when a different prompt completes', () => {
|
||||
const terminalJobState = {
|
||||
value: 3,
|
||||
max: 10,
|
||||
state: 'running' as const,
|
||||
node_id: 'node-2',
|
||||
prompt_id: 'job-2'
|
||||
}
|
||||
|
||||
store.activeJobId = 'job-1'
|
||||
store.queuedJobs = {
|
||||
'job-1': { nodes: {} },
|
||||
'job-2': { nodes: {} }
|
||||
}
|
||||
store.nodeProgressStates = {
|
||||
'node-2': terminalJobState
|
||||
}
|
||||
store.nodeProgressStatesByJob = {
|
||||
'job-1': {},
|
||||
'job-2': { 'node-2': terminalJobState }
|
||||
}
|
||||
store.initializingJobIds = new Set(['job-1', 'job-2'])
|
||||
store.bindExecutionEvents()
|
||||
|
||||
const handler = apiEventHandlers.get('execution_success')
|
||||
if (!handler) throw new Error('execution_success handler not bound')
|
||||
handler(
|
||||
new CustomEvent('execution_success', {
|
||||
detail: { prompt_id: 'job-2' }
|
||||
})
|
||||
)
|
||||
|
||||
expect(store.activeJobId).toBeNull()
|
||||
expect(store.queuedJobs).toEqual({})
|
||||
expect(store.nodeProgressStates).toEqual({})
|
||||
expect(store.nodeProgressStatesByJob).toEqual({})
|
||||
expect(store.initializingJobIds).toEqual(new Set())
|
||||
})
|
||||
})
|
||||
|
||||
describe('useExecutionErrorStore - Node Error Lookups', () => {
|
||||
|
||||
@@ -544,10 +544,22 @@ export const useExecutionStore = defineStore('execution', () => {
|
||||
return
|
||||
}
|
||||
|
||||
removeTrackedJobState(jobId, {
|
||||
const normalizedJobId = String(jobId)
|
||||
const staleActiveJobId =
|
||||
activeJobId.value && activeJobId.value !== normalizedJobId
|
||||
? activeJobId.value
|
||||
: null
|
||||
|
||||
removeTrackedJobState(normalizedJobId, {
|
||||
clearAllNodeProgressStates: true,
|
||||
clearPromptError: true
|
||||
})
|
||||
|
||||
if (staleActiveJobId) {
|
||||
removeTrackedJobState(staleActiveJobId, {
|
||||
clearPromptError: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -585,7 +585,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
const activeJobId = executionStore.activeJobId
|
||||
const missedTerminalExecution =
|
||||
activeJobId !== null &&
|
||||
!activeJobIds.has(String(activeJobId)) &&
|
||||
!activeJobIds.has(activeJobId) &&
|
||||
nextHistoryTasks.some((task) => task.jobId === activeJobId)
|
||||
|
||||
if (missedTerminalExecution) {
|
||||
|
||||
Reference in New Issue
Block a user