LCOV - code coverage report
Current view: top level - src/components/actionbar - PartnerNodesEducationCard.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 82.1 % 28 23
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2         2355 :   <Teleport to="body">
       3              :     <Transition
       4              :       enter-active-class="motion-safe:transition-opacity duration-300 ease-out"
       5              :       enter-from-class="opacity-0"
       6              :       enter-to-class="opacity-100"
       7              :       leave-active-class="motion-safe:transition-opacity duration-200 ease-in"
       8              :       leave-from-class="opacity-100"
       9              :       leave-to-class="opacity-0"
      10              :     >
      11              :       <div
      12              :         v-if="isVisible"
      13              :         class="pointer-events-none fixed right-0 bottom-0 z-education"
      14              :       >
      15              :         <div
      16              :           role="dialog"
      17              :           aria-modal="false"
      18              :           :aria-labelledby="pitchId"
      19              :           data-testid="partner-nodes-education-card"
      20              :           class="pointer-events-auto flex w-100 flex-col gap-2 overflow-hidden rounded-2xl border border-white/5 bg-background"
      21              :         >
      22              :           <div class="isolate flex h-60 flex-col">
      23              :             <VideoCompareSlider
      24              :               ref="slider"
      25              :               :base-src="PARTNER_MODEL_VIDEO"
      26              :               :overlay-src="OPEN_SOURCE_MODEL_VIDEO"
      27              :               :base-muted="audibleSide !== 'partner'"
      28              :               :overlay-muted="audibleSide !== 'open'"
      29              :               :label="t('partnerNodesEducation.sliderLabel')"
      30              :               class="z-2 -mb-5 flex-1 rounded-t-xl"
      31              :             >
      32            4 :               <Button
      33              :                 v-for="control in audioControls"
      34              :                 :key="control.side"
      35              :                 variant="textonly"
      36              :                 size="icon"
      37              :                 :class="
      38              :                   cn(
      39              :                     'absolute bottom-2 size-7 rounded-full bg-black/40 text-white backdrop-blur-sm hover:bg-black/60 hover:text-white',
      40              :                     control.position
      41              :                   )
      42              :                 "
      43              :                 :aria-label="control.label"
      44              :                 @click="toggleAudio(control.side)"
      45              :               >
      46              :                 <i :class="control.icon" />
      47              :               </Button>
      48              : 
      49              :               <Button
      50              :                 variant="textonly"
      51              :                 size="icon"
      52              :                 class="absolute top-1.5 right-1.5 size-7 rounded-full bg-charcoal-600/50 text-white opacity-50 transition-opacity hover:bg-charcoal-600/50 hover:opacity-100"
      53              :                 data-testid="partner-nodes-education-dismiss"
      54              :                 :aria-label="t('g.close')"
      55              :                 @click="educationStore.dismissCard"
      56              :               >
      57              :                 <i class="icon-[lucide--x]" />
      58              :               </Button>
      59              :             </VideoCompareSlider>
      60              : 
      61              :             <div class="z-1 flex h-14 items-start">
      62              :               <div
      63              :                 class="flex h-14 flex-1 items-center justify-center gap-1.5 bg-secondary px-3 pt-7 pb-1.5 text-white opacity-60 backdrop-blur-md"
      64              :               >
      65              :                 <i class="icon-[lucide--boxes]" />
      66              :                 <span class="text-xs font-semibold">
      67              :                   {{ t('partnerNodesEducation.openTab') }}
      68              :                 </span>
      69              :               </div>
      70              :               <div
      71              :                 class="flex h-14 flex-1 items-center justify-center gap-1.5 bg-accent px-3 pt-7 pb-1.5 backdrop-blur-md"
      72              :               >
      73              :                 <i class="icon-[tabler--crown-filled] text-brand-yellow" />
      74              :                 <span class="text-xs font-semibold text-white">
      75              :                   {{ t('partnerNodesEducation.partnerTab') }}
      76              :                 </span>
      77              :                 <Tooltip open-on-click>
      78              :                   <TooltipTrigger as-child>
      79              :                     <button
      80              :                       type="button"
      81              :                       :aria-label="t('partnerNodesEducation.tooltip')"
      82              :                       class="flex items-center text-white/60 hover:text-white"
      83              :                     >
      84              :                       <i class="icon-[lucide--info] size-3" />
      85              :                     </button>
      86              :                   </TooltipTrigger>
      87              :                   <TooltipContent :side-offset="8" class="max-w-56">{{
      88              :                     t('partnerNodesEducation.tooltip')
      89              :                   }}</TooltipContent>
      90              :                 </Tooltip>
      91              :               </div>
      92              :             </div>
      93              :           </div>
      94              : 
      95              :           <div class="flex flex-col gap-3 px-6 pt-4 pb-6">
      96              :             <div class="flex flex-col text-sm/snug">
      97              :               <span :id="pitchId" class="font-semibold text-white">
      98              :                 {{ t('partnerNodesEducation.pitch') }}
      99              :               </span>
     100              :               <span class="text-muted-foreground">
     101              :                 {{ t('partnerNodesEducation.reassurance') }}
     102              :               </span>
     103              :             </div>
     104              : 
     105              :             <div class="flex pr-4.5 text-xs font-medium text-muted-foreground">
     106              :               <span class="flex-1" />
     107              :               <span class="w-15 text-center">
     108              :                 {{ t('partnerNodesEducation.openHeader') }}
     109              :               </span>
     110              :               <span class="w-15 text-center">
     111              :                 {{ t('partnerNodesEducation.partnerHeader') }}
     112              :               </span>
     113              :             </div>
     114              : 
     115              :             <div class="flex flex-col gap-2">
     116            8 :               <div
     117              :                 v-for="row in comparisonRows"
     118              :                 :key="row.key"
     119              :                 class="flex items-center pr-4.5"
     120              :               >
     121              :                 <span class="flex-1 text-sm/snug text-muted-foreground">
     122              :                   {{ t(`partnerNodesEducation.benefits.${row.key}`) }}
     123              :                 </span>
     124           16 :                 <span
     125              :                   v-for="column in [
     126              :                     {
     127              :                       label: t('partnerNodesEducation.openHeader'),
     128              :                       status: row.open
     129              :                     },
     130              :                     {
     131              :                       label: t('partnerNodesEducation.partnerHeader'),
     132              :                       status: row.partner
     133              :                     }
     134              :                   ]"
     135              :                   :key="column.label"
     136              :                   class="flex w-15 justify-center"
     137              :                 >
     138              :                   <i
     139              :                     :class="comparisonStatusClasses[column.status]"
     140              :                     aria-hidden="true"
     141              :                   />
     142              :                   <span class="sr-only">
     143              :                     {{ column.label }}:
     144              :                     {{
     145              :                       column.status === 'included'
     146              :                         ? t('partnerNodesEducation.included')
     147              :                         : t('partnerNodesEducation.notIncluded')
     148              :                     }}
     149              :                   </span>
     150              :                 </span>
     151              :               </div>
     152              :             </div>
     153              : 
     154              :             <Button
     155              :               v-if="gate === 'sign-in'"
     156              :               variant="secondary"
     157              :               size="lg"
     158              :               class="mt-1 h-9 w-full bg-credit/15 text-credit hover:bg-credit/25 focus-visible:ring-credit"
     159              :               data-testid="partner-nodes-education-sign-in"
     160              :               @click="openSignIn"
     161              :             >
     162              :               {{ t('actionbar.partnerRunGate.signInToRun') }}
     163              :             </Button>
     164              :           </div>
     165              :         </div>
     166              :       </div>
     167              :     </Transition>
     168              :   </Teleport>
     169              : </template>
     170              : 
     171              : <script setup lang="ts">
     172              : import { storeToRefs } from 'pinia'
     173              : import { computed, ref, useId, useTemplateRef, watch } from 'vue'
     174              : import { useI18n } from 'vue-i18n'
     175              : 
     176              : import VideoCompareSlider from '@comfyorg/design-system/common/VideoCompareSlider'
     177              : import Button from '@comfyorg/design-system/button/Button'
     178              : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
     179              : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
     180              : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
     181              : import { usePartnerNodesRunGate } from '@/platform/billing/composables/usePartnerNodesRunGate'
     182              : import { usePartnerNodesInGraph } from '@/composables/node/usePartnerNodesInGraph'
     183              : import { useAuthDialogs } from '@/composables/auth/useAuthDialogs'
     184              : import { usePartnerNodesEducationStore } from '@/platform/workflow/templates/stores/partnerNodesEducationStore'
     185              : import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
     186              : import { cn } from '@comfyorg/tailwind-utils'
     187              : 
     188              : interface ComparisonRow {
     189              :   key: string
     190              :   open: 'included' | 'notIncluded'
     191              :   partner: 'included' | 'notIncluded'
     192              : }
     193              : 
     194         2355 : const OPEN_SOURCE_MODEL_VIDEO =
     195              :   'https://media.comfy.org/website/partner-nodes/ltx-open-1280.webm'
     196         2355 : const PARTNER_MODEL_VIDEO =
     197              :   'https://media.comfy.org/website/partner-nodes/ltx-partner-1280.webm'
     198              : 
     199         2355 : const comparisonRows: ComparisonRow[] = [
     200              :   { key: 'noDownload', open: 'notIncluded', partner: 'included' },
     201              :   { key: 'noVram', open: 'notIncluded', partner: 'included' },
     202              :   { key: 'offline', open: 'included', partner: 'notIncluded' },
     203              :   { key: 'free', open: 'included', partner: 'notIncluded' }
     204              : ]
     205              : 
     206         2355 : const comparisonStatusClasses = {
     207              :   included: 'icon-[lucide--check] text-brand-yellow',
     208              :   notIncluded: 'icon-[lucide--minus] text-muted-foreground'
     209              : }
     210              : 
     211         2355 : const { t } = useI18n()
     212         2355 : const pitchId = useId()
     213              : 
     214         2355 : const slider = useTemplateRef<InstanceType<typeof VideoCompareSlider>>('slider')
     215         2355 : const audibleSide = ref<'open' | 'partner' | null>(null)
     216              : 
     217         2355 : const audioControls = computed(() =>
     218              :   [
     219              :     {
     220              :       side: 'open' as const,
     221              :       position: 'left-2',
     222              :       muteLabel: t('partnerNodesEducation.muteOpen'),
     223              :       unmuteLabel: t('partnerNodesEducation.unmuteOpen')
     224              :     },
     225              :     {
     226              :       side: 'partner' as const,
     227              :       position: 'right-2',
     228              :       muteLabel: t('partnerNodesEducation.mutePartner'),
     229              :       unmuteLabel: t('partnerNodesEducation.unmutePartner')
     230              :     }
     231              :   ].map((control) => ({
     232              :     ...control,
     233              :     label:
     234              :       audibleSide.value === control.side
     235              :         ? control.muteLabel
     236              :         : control.unmuteLabel,
     237              :     icon:
     238              :       audibleSide.value === control.side
     239              :         ? 'icon-[lucide--volume-2]'
     240              :         : 'icon-[lucide--volume-x]'
     241              :   }))
     242              : )
     243              : 
     244            0 : function toggleAudio(side: 'open' | 'partner') {
     245            0 :   audibleSide.value = audibleSide.value === side ? null : side
     246            0 :   slider.value?.syncPlayback()
     247              : }
     248              : 
     249         2355 : const educationStore = usePartnerNodesEducationStore()
     250         2355 : const { isCardRequested, requestedForWorkflowKey } = storeToRefs(educationStore)
     251         2355 : const { hasPartnerNodes } = usePartnerNodesInGraph()
     252         2355 : const { gate, partnerNodes } = usePartnerNodesRunGate()
     253         2355 : const { activeWorkflow } = storeToRefs(useWorkflowStore())
     254         2355 : const { showApiNodesSignInDialog } = useAuthDialogs()
     255              : 
     256            0 : function openSignIn() {
     257            0 :   void showApiNodesSignInDialog(
     258              :     partnerNodes.value.map((node) => node.displayName)
     259              :   )
     260              : }
     261              : 
     262         2355 : const isForRequestedWorkflow = computed(
     263              :   () => activeWorkflow.value?.key === requestedForWorkflowKey.value
     264              : )
     265              : 
     266         2355 : const isVisible = computed(
     267              :   () =>
     268              :     isCardRequested.value &&
     269              :     hasPartnerNodes.value &&
     270              :     isForRequestedWorkflow.value
     271              : )
     272              : 
     273              : // Retire the one-off request as soon as its workflow is no longer active, so it
     274              : // neither shows on the wrong workflow nor resurfaces on returning to its own.
     275         2355 : watch(
     276              :   () => isCardRequested.value && !isForRequestedWorkflow.value,
     277              :   (stale) => {
     278            2 :     if (stale) educationStore.retireCard()
     279              :   }
     280              : )
     281              : </script>
        

Generated by: LCOV version 2.0-1