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

            Line data    Source code
       1              : import { computed } from 'vue'
       2              : import { useI18n } from 'vue-i18n'
       3              : 
       4              : import { useExecutionStore } from '@/stores/executionStore'
       5              : import { clampPercentInt, formatPercent0 } from '@/utils/numberUtil'
       6              : 
       7         2355 : const withDefault = <T>(value: T | null | undefined, fallback: T): T =>
       8              :   value ?? fallback
       9              : 
      10              : /**
      11              :  * Queue progress composable exposing total/current node progress values and styles.
      12              :  */
      13         4143 : export function useQueueProgress() {
      14         4143 :   const { locale } = useI18n()
      15         4143 :   const executionStore = useExecutionStore()
      16              : 
      17         4143 :   const totalPercent = computed(() =>
      18              :     clampPercentInt(
      19              :       Math.round(withDefault(executionStore.executionProgress, 0) * 100)
      20              :     )
      21              :   )
      22              : 
      23         4143 :   const totalPercentFormatted = computed(() =>
      24              :     formatPercent0(locale.value, totalPercent.value)
      25              :   )
      26              : 
      27         4143 :   const currentNodePercent = computed(() =>
      28              :     clampPercentInt(
      29              :       Math.round((executionStore.executingNodeProgress ?? 0) * 100)
      30              :     )
      31              :   )
      32              : 
      33              :   const currentNodePercentFormatted = computed(() =>
      34              :     formatPercent0(locale.value, currentNodePercent.value)
      35              :   )
      36              : 
      37              :   const totalProgressStyle = computed(() => ({
      38              :     transform: `scaleX(${totalPercent.value / 100})`,
      39              :     background: 'var(--primary)'
      40              :   }))
      41              : 
      42              :   const currentNodeProgressStyle = computed(() => ({
      43              :     transform: `scaleX(${currentNodePercent.value / 100})`,
      44              :     background: 'color-mix(in srgb, var(--primary) 30%, transparent)'
      45              :   }))
      46              : 
      47         4143 :   return {
      48              :     totalPercent,
      49              :     totalPercentFormatted,
      50              :     currentNodePercent,
      51              :     currentNodePercentFormatted,
      52              :     totalProgressStyle,
      53              :     currentNodeProgressStyle
      54              :   }
      55              : }
        

Generated by: LCOV version 2.0-1