LCOV - code coverage report
Current view: top level - src/components/queue - QueueNotificationBanner.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 88.1 % 42 37
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2          306 :   <div class="inline-flex overflow-hidden rounded-lg bg-secondary">
       3              :     <div class="flex items-center gap-2 p-1 pr-3">
       4              :       <div
       5              :         :class="
       6              :           cn(
       7              :             'relative shrink-0 items-center rounded-[4px]',
       8              :             showsCompletionPreview && showThumbnails
       9              :               ? 'flex h-8 overflow-visible p-0'
      10              :               : showsCompletionPreview
      11              :                 ? 'flex size-8 justify-center overflow-hidden p-0'
      12              :                 : 'flex size-8 justify-center p-1'
      13              :           )
      14              :         "
      15              :       >
      16              :         <template v-if="showThumbnails">
      17              :           <div class="flex h-8 shrink-0 items-center">
      18            0 :             <div
      19              :               v-for="(thumbnailUrl, index) in thumbnailUrls"
      20              :               :key="`completion-preview-${index}`"
      21              :               :class="
      22              :                 cn(
      23              :                   'relative size-8 shrink-0 overflow-hidden rounded-[4px]',
      24              :                   index > 0 && '-ml-3 ring-2 ring-secondary'
      25              :                 )
      26              :               "
      27              :             >
      28              :               <img
      29              :                 :src="thumbnailUrl"
      30              :                 :alt="t('sideToolbar.queueProgressOverlay.preview')"
      31              :                 class="size-full object-cover"
      32              :               />
      33              :             </div>
      34              :           </div>
      35              :         </template>
      36              :         <div
      37              :           v-else-if="showCompletionGradientFallback"
      38              :           class="size-full bg-linear-to-br from-coral-500 via-coral-500 to-azure-600"
      39              :         />
      40              :         <i
      41              :           v-else
      42              :           :class="cn(iconClass, iconColorClass)"
      43              :           aria-hidden="true"
      44              :           data-testid="notification-icon"
      45              :         />
      46              :       </div>
      47              :       <div class="flex h-full items-center">
      48              :         <span
      49              :           class="overflow-hidden text-center text-[12px] leading-normal font-normal text-ellipsis"
      50              :         >
      51              :           {{ bannerText }}
      52              :         </span>
      53              :       </div>
      54              :     </div>
      55              :   </div>
      56              : </template>
      57              : 
      58              : <script setup lang="ts">
      59              : import { computed } from 'vue'
      60              : import { useI18n } from 'vue-i18n'
      61              : 
      62              : import type { QueueNotificationBanner } from '@/composables/queue/useQueueNotificationBanners'
      63              : import { cn } from '@comfyorg/tailwind-utils'
      64              : 
      65              : const { notification } = defineProps<{
      66              :   notification: QueueNotificationBanner
      67              : }>()
      68              : 
      69          172 : const { t, n } = useI18n()
      70              : 
      71          172 : const thumbnailUrls = computed(() => {
      72            1 :   if (notification.type !== 'completed') {
      73            0 :     return []
      74              :   }
      75            1 :   return notification.thumbnailUrls?.slice(0, 2) ?? []
      76              : })
      77              : 
      78          172 : const showThumbnails = computed(() => {
      79          306 :   if (notification.type !== 'completed') {
      80          305 :     return false
      81              :   }
      82            1 :   return thumbnailUrls.value.length > 0
      83              : })
      84              : 
      85          172 : const showCompletionGradientFallback = computed(
      86              :   () => notification.type === 'completed' && !showThumbnails.value
      87              : )
      88              : 
      89          172 : const showsCompletionPreview = computed(
      90              :   () => showThumbnails.value || showCompletionGradientFallback.value
      91              : )
      92              : 
      93          172 : const bannerText = computed(() => {
      94          306 :   const count = notification.count
      95          306 :   if (notification.type === 'queuedPending') {
      96          167 :     return t('queue.jobQueueing')
      97              :   }
      98          142 :   if (notification.type === 'queued') {
      99          137 :     if (count === 1) {
     100          135 :       return t('queue.jobAddedToQueue')
     101              :     }
     102            2 :     return t(
     103              :       'sideToolbar.queueProgressOverlay.jobsAddedToQueue',
     104              :       { count: n(count) },
     105              :       count
     106              :     )
     107              :   }
     108            2 :   if (notification.type === 'failed') {
     109            1 :     if (count === 1) {
     110            1 :       return t('sideToolbar.queueProgressOverlay.jobFailed')
     111              :     }
     112            0 :     return t(
     113              :       'sideToolbar.queueProgressOverlay.jobsFailed',
     114              :       { count: n(count) },
     115              :       count
     116              :     )
     117              :   }
     118            1 :   if (count === 1) {
     119            1 :     return t('sideToolbar.queueProgressOverlay.jobCompleted')
     120              :   }
     121            0 :   return t(
     122              :     'sideToolbar.queueProgressOverlay.jobsCompleted',
     123              :     { count: n(count) },
     124              :     count
     125              :   )
     126              : })
     127              : 
     128          172 : const iconClass = computed(() => {
     129          305 :   if (notification.type === 'queuedPending') {
     130          167 :     return 'icon-[lucide--loader-circle]'
     131              :   }
     132          141 :   if (notification.type === 'queued') {
     133          137 :     return 'icon-[lucide--check]'
     134              :   }
     135            1 :   if (notification.type === 'failed') {
     136            1 :     return 'icon-[lucide--circle-alert]'
     137              :   }
     138            0 :   return 'icon-[lucide--image]'
     139              : })
     140              : 
     141          172 : const iconColorClass = computed(() => {
     142          305 :   if (notification.type === 'queuedPending') {
     143          167 :     return 'animate-spin text-muted-foreground'
     144              :   }
     145          304 :   if (notification.type === 'failed') {
     146            1 :     return 'text-destructive'
     147              :   }
     148          137 :   return 'text-muted-foreground'
     149              : })
     150              : </script>
        

Generated by: LCOV version 2.0-1