LCOV - code coverage report
Current view: top level - src/components/actionbar - BatchCountEdit.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 66.7 % 39 26
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <template>
       2         2001 :   <Tooltip>
       3              :     <TooltipTrigger as-child>
       4              :       <div class="batch-count h-full" :aria-label="t('menu.batchCount')">
       5              :         <div class="flex h-full w-14 overflow-hidden rounded-l-lg bg-secondary">
       6              :           <input
       7              :             ref="batchCountInputRef"
       8              :             v-model="batchCountInput"
       9              :             type="text"
      10              :             inputmode="numeric"
      11              :             :aria-label="t('menu.batchCount')"
      12              :             :class="inputClass"
      13              :             @focus="onInputFocus"
      14              :             @input="onInput"
      15              :             @blur="onInputBlur"
      16              :             @keydown.enter.prevent="onInputEnter"
      17              :           />
      18              :           <div class="flex h-full w-6 flex-col">
      19              :             <Button
      20              :               variant="secondary"
      21              :               size="unset"
      22              :               :aria-label="t('g.increment')"
      23              :               :class="cn(stepButtonClass, incrementButtonClass)"
      24              :               :disabled="isIncrementDisabled"
      25              :               @click="incrementBatchCount"
      26              :             >
      27              :               <TinyChevronIcon rotate-up />
      28              :             </Button>
      29              :             <Button
      30              :               variant="secondary"
      31              :               size="unset"
      32              :               :aria-label="t('g.decrement')"
      33              :               :class="cn(stepButtonClass, decrementButtonClass)"
      34              :               :disabled="isDecrementDisabled"
      35              :               @click="decrementBatchCount"
      36              :             >
      37              :               <TinyChevronIcon />
      38              :             </Button>
      39              :           </div>
      40              :         </div>
      41              :       </div>
      42              :     </TooltipTrigger>
      43              :     <TooltipContent side="bottom">{{ t('menu.batchCount') }}</TooltipContent>
      44              :   </Tooltip>
      45              : </template>
      46              : 
      47              : <script lang="ts" setup>
      48              : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
      49              : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
      50              : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
      51              : 
      52              : import { storeToRefs } from 'pinia'
      53              : import { computed, ref, watch } from 'vue'
      54              : import { useI18n } from 'vue-i18n'
      55              : 
      56              : import Button from '@comfyorg/design-system/button/Button'
      57              : import { useSettingStore } from '@/platform/settings/settingStore'
      58              : import { useQueueSettingsStore } from '@/stores/queueSettingsStore'
      59              : import { cn } from '@comfyorg/tailwind-utils'
      60              : 
      61              : import TinyChevronIcon from '@comfyorg/design-system/icon/TinyChevronIcon'
      62              : 
      63         2001 : const { t } = useI18n()
      64              : 
      65         2001 : const queueSettingsStore = useQueueSettingsStore()
      66         2001 : const { batchCount } = storeToRefs(queueSettingsStore)
      67              : 
      68         2001 : const settingStore = useSettingStore()
      69         1966 : const minQueueCount = 1
      70         2001 : const maxQueueCount = computed(() =>
      71              :   settingStore.get('Comfy.QueueButton.BatchCountLimit')
      72              : )
      73              : 
      74         2001 : const batchCountInputRef = ref<HTMLInputElement | null>(null)
      75         2001 : const batchCountInput = ref(String(batchCount.value))
      76         2001 : const isEditing = ref(false)
      77              : 
      78         2001 : const isIncrementDisabled = computed(
      79              :   () => batchCount.value >= maxQueueCount.value
      80              : )
      81         2001 : const isDecrementDisabled = computed(() => batchCount.value <= minQueueCount)
      82         1966 : const inputClass =
      83              :   'h-full min-w-0 flex-1 border-none bg-secondary pl-1 pr-0 text-center text-sm font-normal tabular-nums text-foreground outline-none'
      84         1966 : const stepButtonClass =
      85              :   'h-1/2 w-full rounded-none p-0 text-muted-foreground disabled:cursor-not-allowed'
      86         1966 : const incrementButtonClass = 'rounded-tr-none border-b border-border/50'
      87         1966 : const decrementButtonClass = 'rounded-br-none'
      88              : 
      89         2001 : watch(batchCount, (nextBatchCount) => {
      90            0 :   if (!isEditing.value) {
      91            0 :     batchCountInput.value = String(nextBatchCount)
      92              :   }
      93              : })
      94              : 
      95         2001 : const clampBatchCount = (nextBatchCount: number): number =>
      96              :   Math.min(Math.max(nextBatchCount, minQueueCount), maxQueueCount.value)
      97              : 
      98         2001 : const setBatchCount = (nextBatchCount: number) => {
      99            0 :   batchCount.value = clampBatchCount(nextBatchCount)
     100            0 :   batchCountInput.value = String(batchCount.value)
     101              : }
     102              : 
     103         2001 : const incrementBatchCount = () => {
     104            0 :   setBatchCount(batchCount.value * 2)
     105              : }
     106              : 
     107         2001 : const decrementBatchCount = () => {
     108            0 :   setBatchCount(Math.floor(batchCount.value / 2))
     109              : }
     110              : 
     111         2001 : const onInputFocus = () => {
     112            0 :   isEditing.value = true
     113              : }
     114              : 
     115         2001 : const onInput = (event: Event) => {
     116            0 :   const input = event.target as HTMLInputElement
     117            0 :   batchCountInput.value = input.value.replace(/[^0-9]/g, '')
     118              : }
     119              : 
     120         2001 : const onInputBlur = () => {
     121            0 :   isEditing.value = false
     122            0 :   const parsedInput = Number.parseInt(batchCountInput.value, 10)
     123            0 :   setBatchCount(Number.isNaN(parsedInput) ? minQueueCount : parsedInput)
     124              : }
     125              : 
     126         2001 : const onInputEnter = () => {
     127            0 :   batchCountInputRef.value?.blur()
     128              : }
     129              : </script>
        

Generated by: LCOV version 2.0-1