Line data Source code
1 : import { computed } from 'vue'
2 :
3 : import type { JobId } from '@comfyorg/api-client/executionTypes'
4 : import { useExecutionStore } from '@/stores/executionStore'
5 : import { useQueueStore } from '@/stores/queueStore'
6 :
7 2009 : export function useInterruptibleJob() {
8 2009 : const executionStore = useExecutionStore()
9 2009 : const queueStore = useQueueStore()
10 :
11 2009 : const interruptibleJobId = computed<JobId | null>(() => {
12 4362 : if (executionStore.activeJobId) return executionStore.activeJobId
13 4259 : if (queueStore.runningTasks.length !== 1) return null
14 33 : const jobId = queueStore.runningTasks[0].jobId
15 4362 : return typeof jobId === 'string' && jobId.length > 0 ? jobId : null
16 : })
17 :
18 : const canInterrupt = computed(() => interruptibleJobId.value !== null)
19 :
20 2009 : return { interruptibleJobId, canInterrupt }
21 : }
|