Files
ComfyUI_frontend/src/services/autoQueueService.ts
Benjamin Lu 541ad387b9 fix: show stop state for active instant run button (#8917)
Switch the Run (Instant) actionbar button into a stop-state while
instant auto-queue is actively running, so users can explicitly stop
that mode from the same control.

Figma context:
https://www.figma.com/design/LVilZgHGk5RwWOkVN6yCEK/Queue-Progress-Modal?node-id=3381-6181&m=dev

## Screenshots (if applicable)



https://github.com/user-attachments/assets/a4aca6ab-eb0c-41a2-9f05-3af7ecf2bedd
2026-02-20 01:59:15 -08:00

44 lines
1.3 KiB
TypeScript

import { api } from '@/scripts/api'
import { app } from '@/scripts/app'
import {
isInstantRunningMode,
useQueuePendingTaskCountStore,
useQueueSettingsStore
} from '@/stores/queueStore'
export function setupAutoQueueHandler() {
const queueCountStore = useQueuePendingTaskCountStore()
const queueSettingsStore = useQueueSettingsStore()
let graphHasChanged = false
let internalCount = 0 // Use an internal counter here so it is instantly updated when re-queuing
api.addEventListener('graphChanged', () => {
if (queueSettingsStore.mode === 'change') {
if (internalCount) {
graphHasChanged = true
} else {
graphHasChanged = false
// Queue the prompt in the background
void app.queuePrompt(0, queueSettingsStore.batchCount)
internalCount++
}
}
})
queueCountStore.$subscribe(
async () => {
internalCount = queueCountStore.count
if (!internalCount && !app.lastExecutionError) {
if (
isInstantRunningMode(queueSettingsStore.mode) ||
(queueSettingsStore.mode === 'change' && graphHasChanged)
) {
graphHasChanged = false
await app.queuePrompt(0, queueSettingsStore.batchCount)
}
}
},
{ detached: true }
)
}