LCOV - code coverage report
Current view: top level - src/services - autoQueueService.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 19 19
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { partnerRunGateBlocksAutoQueue } from '@/platform/billing/composables/usePartnerNodesRunGate'
       2              : import { api } from '@/scripts/api'
       3              : import { app } from '@/scripts/app'
       4              : import {
       5              :   isInstantRunningMode,
       6              :   useQueueSettingsStore
       7              : } from '@/stores/queueSettingsStore'
       8              : import { useQueuePendingTaskCountStore } from '@/stores/queueStore'
       9              : 
      10         2355 : export function setupAutoQueueHandler() {
      11         2355 :   const queueCountStore = useQueuePendingTaskCountStore()
      12         2355 :   const queueSettingsStore = useQueueSettingsStore()
      13              : 
      14         2355 :   let graphHasChanged = false
      15         2355 :   let internalCount = 0 // Use an internal counter here so it is instantly updated when re-queuing
      16         2355 :   api.addEventListener('autoQueueGraphChanged', () => {
      17              :     // Skip the whole submission while gated: never enqueue a prompt the gate
      18              :     // would drop, and never treat queuePrompt's false as gate rejection — it
      19              :     // also means the item was queued behind an active processor.
      20            8 :     if (partnerRunGateBlocksAutoQueue()) return
      21            7 :     if (queueSettingsStore.mode === 'change') {
      22            7 :       if (internalCount) {
      23            5 :         graphHasChanged = true
      24              :       } else {
      25            2 :         graphHasChanged = false
      26              :         // Queue the prompt in the background
      27            2 :         void app.queuePrompt(0, queueSettingsStore.batchCount, {
      28              :           intent: { trigger_source: 'auto_queue' }
      29              :         })
      30            2 :         internalCount++
      31              :       }
      32              :     }
      33              :   })
      34              : 
      35         2355 :   queueCountStore.$subscribe(
      36              :     async () => {
      37          163 :       internalCount = queueCountStore.count
      38          163 :       if (
      39              :         !internalCount &&
      40              :         !app.lastExecutionError &&
      41              :         !partnerRunGateBlocksAutoQueue()
      42              :       ) {
      43              :         if (
      44           66 :           isInstantRunningMode(queueSettingsStore.mode) ||
      45              :           (queueSettingsStore.mode === 'change' && graphHasChanged)
      46              :         ) {
      47            1 :           graphHasChanged = false
      48            1 :           await app.queuePrompt(0, queueSettingsStore.batchCount, {
      49              :             intent: { trigger_source: 'auto_queue' }
      50              :           })
      51              :         }
      52              :       }
      53              :     },
      54              :     { detached: true }
      55              :   )
      56              : }
        

Generated by: LCOV version 2.0-1