LCOV - code coverage report
Current view: top level - src/renderer/extensions/firstRunTour/gettingStarted - GettingStartedScreen.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 0.0 % 43 0
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2            0 :   <Teleport to="body">
       3              :     <FocusScope as-child :trapped="!dialogOpen" loop>
       4              :       <div
       5              :         ref="screenRef"
       6              :         class="fixed inset-0 z-onboarding flex overflow-y-auto bg-background focus:outline-none"
       7              :         role="dialog"
       8              :         :aria-modal="!dialogOpen"
       9              :         :aria-label="t('gettingStarted.title')"
      10              :         tabindex="-1"
      11              :         @keydown.escape.capture.prevent="dismissGettingStarted()"
      12              :       >
      13              :         <div class="m-auto flex w-full flex-col items-center gap-8 px-8 py-16">
      14              :           <div class="flex flex-col items-center gap-3 text-center">
      15              :             <h1 class="m-0 text-4xl/11 font-medium">
      16              :               {{ t('gettingStarted.title') }}
      17              :             </h1>
      18              :             <p class="m-0 text-base/5 text-muted-foreground">
      19              :               {{ t('gettingStarted.subtitle') }}
      20              :             </p>
      21              :           </div>
      22              : 
      23              :           <TabList
      24              :             v-model="activeTab"
      25              :             class="w-auto gap-1 rounded-full border border-border/50 p-0.5"
      26              :             :aria-label="t('gettingStarted.tabsLabel')"
      27              :           >
      28            0 :             <Tab
      29              :               v-for="tab in tabs"
      30              :               :key="tab.value"
      31              :               :value="tab.value"
      32              :               class="gap-2.5 rounded-full px-3 text-xs font-medium text-foreground hover:opacity-100 data-[state=active]:bg-muted data-[state=inactive]:opacity-70"
      33              :             >
      34              :               <i :class="cn(tab.icon, 'size-3.5')" aria-hidden="true" />
      35              :               {{ t(tab.labelKey) }}
      36              :             </Tab>
      37              :           </TabList>
      38              : 
      39              :           <div class="w-full max-w-5xl">
      40            0 :             <TabPanel
      41              :               v-for="tab in tabs"
      42              :               :key="tab.value"
      43              :               :value="tab.value"
      44              :               :model-value="activeTab"
      45              :             >
      46              :               <div
      47              :                 v-if="tab.value === 'templates'"
      48              :                 class="grid grid-cols-2 gap-5 sm:grid-cols-3 lg:grid-cols-4"
      49              :               >
      50              :                 <template v-if="templatesStore.isLoaded">
      51            0 :                   <GettingStartedTemplateCard
      52              :                     v-for="template in cards"
      53              :                     :key="template.name"
      54              :                     :template
      55              :                     :loading="loadingTemplateId === template.name"
      56              :                     :failed="failedTemplateId === template.name"
      57              :                     class="min-w-0"
      58              :                     @select="onSelectTemplate"
      59              :                   />
      60              :                 </template>
      61              :                 <div
      62              :                   v-else-if="catalogFailed"
      63              :                   class="col-span-full flex flex-col items-center gap-4 py-16"
      64              :                 >
      65              :                   <p class="m-0 text-center text-sm text-muted-foreground">
      66              :                     {{ t('gettingStarted.loadFailed') }}
      67              :                   </p>
      68              :                   <Button
      69              :                     variant="secondary"
      70              :                     data-testid="getting-started-retry-catalog"
      71              :                     @click="loadCatalog"
      72              :                   >
      73              :                     {{ t('gettingStarted.retry') }}
      74              :                   </Button>
      75              :                 </div>
      76              :                 <template v-else>
      77            0 :                   <GettingStartedCard
      78              :                     v-for="id in CURATED_TEMPLATE_IDS"
      79              :                     :key="id"
      80              :                     skeleton
      81              :                     :testid="`getting-started-card-skeleton-${id}`"
      82              :                     class="min-w-0"
      83              :                   />
      84              :                 </template>
      85              :               </div>
      86              : 
      87              :               <div
      88              :                 v-else
      89              :                 class="grid grid-cols-2 gap-5 sm:grid-cols-3 lg:grid-cols-4"
      90              :               >
      91            0 :                 <GettingStartedCard
      92              :                   v-for="(tutorial, index) in tutorialCards"
      93              :                   :key="tutorial.id"
      94              :                   :image-src="
      95              :                     tutorialThumbnail(tutorial.thumbnailTemplate, index)
      96              :                   "
      97              :                   :title="t(tutorial.titleKey)"
      98              :                   :badge-icon="TUTORIAL_BADGE_ICON"
      99              :                   :testid="`getting-started-tutorial-${tutorial.id}`"
     100              :                   class="min-w-0"
     101              :                   @select="openTutorial(tutorial.url)"
     102              :                 />
     103              :               </div>
     104              :             </TabPanel>
     105              :           </div>
     106              : 
     107              :           <Button
     108              :             variant="muted-textonly"
     109              :             data-testid="getting-started-blank"
     110              :             @click="dismissGettingStarted()"
     111              :           >
     112              :             {{ t('gettingStarted.startBlank') }}
     113              :           </Button>
     114              :         </div>
     115              :       </div>
     116              :     </FocusScope>
     117              :   </Teleport>
     118              : </template>
     119              : 
     120              : <script setup lang="ts">
     121              : import { take, uniqBy } from 'es-toolkit'
     122              : import { FocusScope } from 'reka-ui'
     123              : import { computed, nextTick, onMounted, ref, useTemplateRef } from 'vue'
     124              : import { useI18n } from 'vue-i18n'
     125              : 
     126              : import { cn } from '@comfyorg/tailwind-utils'
     127              : 
     128              : import Tab from '@comfyorg/design-system/tab/Tab'
     129              : import TabList from '@comfyorg/design-system/tab/TabList'
     130              : import TabPanel from '@comfyorg/design-system/tab/TabPanel'
     131              : import Button from '@comfyorg/design-system/button/Button'
     132              : import { useTemplateWorkflows } from '@/platform/workflow/templates/composables/useTemplateWorkflows'
     133              : import { useWorkflowTemplatesStore } from '@/platform/workflow/templates/repositories/workflowTemplatesStore'
     134              : import { useDialogStore } from '@/stores/dialogStore'
     135              : 
     136              : import GettingStartedCard from './GettingStartedCard.vue'
     137              : import GettingStartedTemplateCard from './GettingStartedTemplateCard.vue'
     138              : import { useFirstRunEntry } from './firstRunEntry'
     139              : import type { TutorialCard } from './tutorialCards'
     140              : import {
     141              :   CURATED_TEMPLATE_IDS,
     142              :   FALLBACK_TEMPLATE_IDS,
     143              :   TUTORIAL_BADGE_ICON,
     144              :   tutorialCards
     145              : } from './tutorialCards'
     146              : 
     147              : type TabValue = 'templates' | 'tutorials'
     148              : 
     149            0 : const tabs = [
     150              :   {
     151              :     value: 'templates' as const,
     152              :     labelKey: 'gettingStarted.tabs.templates',
     153              :     icon: 'icon-[lucide--layout-template]'
     154              :   },
     155              :   {
     156              :     value: 'tutorials' as const,
     157              :     labelKey: 'gettingStarted.tabs.tutorials',
     158              :     icon: 'icon-[lucide--tv-minimal-play]'
     159              :   }
     160              : ]
     161              : 
     162            0 : const { t } = useI18n()
     163              : 
     164            0 : const { dismissGettingStarted, dismissIntoFirstRunTour } = useFirstRunEntry()
     165            0 : const templatesStore = useWorkflowTemplatesStore()
     166            0 : const dialogStore = useDialogStore()
     167              : 
     168            0 : const dialogOpen = computed(() => dialogStore.dialogStack.length > 0)
     169            0 : const { loadWorkflowTemplate, getTemplateThumbnailUrl, loadingTemplateId } =
     170              :   useTemplateWorkflows()
     171              : 
     172            0 : const activeTab = ref<TabValue>('templates')
     173            0 : const failedTemplateId = ref<string | null>(null)
     174            0 : const catalogFailed = ref(false)
     175              : 
     176            0 : const screenRef = useTemplateRef<HTMLElement>('screenRef')
     177              : 
     178            0 : function resolveTemplates(ids: readonly string[]) {
     179            0 :   return ids
     180              :     .map((id) => templatesStore.getTemplateByName(id))
     181              :     .filter((template) => template !== undefined)
     182              : }
     183              : 
     184              : /** Backfills past the pinned ids so a template-package skew cannot empty the grid. */
     185            0 : const cards = computed(() =>
     186              :   take(
     187              :     uniqBy(
     188              :       [
     189              :         ...resolveTemplates(CURATED_TEMPLATE_IDS),
     190              :         ...resolveTemplates(FALLBACK_TEMPLATE_IDS),
     191              :         ...templatesStore.enhancedTemplates
     192              :       ],
     193              :       (template) => template.name
     194              :     ),
     195              :     CURATED_TEMPLATE_IDS.length
     196              :   )
     197              : )
     198              : 
     199            0 : async function loadCatalog() {
     200            0 :   catalogFailed.value = false
     201            0 :   await templatesStore.loadWorkflowTemplates()
     202            0 :   catalogFailed.value = !templatesStore.isLoaded
     203              : }
     204              : 
     205              : // Nothing else loads the catalog on this path, so load it (and take focus) on open.
     206            0 : onMounted(() => {
     207            0 :   if (!templatesStore.isLoaded) void loadCatalog()
     208            0 :   void nextTick(() => {
     209            0 :     if (!dialogOpen.value) screenRef.value?.focus()
     210              :   })
     211              : })
     212              : 
     213            0 : function tutorialThumbnail(
     214              :   id: TutorialCard['thumbnailTemplate'],
     215              :   index: number
     216              : ) {
     217            0 :   const fallbacks = cards.value
     218            0 :   const template =
     219              :     templatesStore.getTemplateByName(id) ??
     220              :     (fallbacks.length ? fallbacks[index % fallbacks.length] : undefined)
     221            0 :   return template ? getTemplateThumbnailUrl(template, 'default') : ''
     222              : }
     223              : 
     224            0 : function openTutorial(url: string) {
     225            0 :   window.open(url, '_blank', 'noopener,noreferrer')
     226              : }
     227              : 
     228            0 : async function onSelectTemplate(id: string) {
     229            0 :   if (loadingTemplateId.value) return
     230            0 :   failedTemplateId.value = null
     231              : 
     232              :   const result = await loadWorkflowTemplate(id, 'default')
     233            0 :   if (result === 'loaded') {
     234            0 :     try {
     235            0 :       await dismissIntoFirstRunTour(id)
     236              :     } catch (error) {
     237            0 :       console.error('first-run tour failed to start', error)
     238              :     }
     239            0 :     return
     240              :   }
     241              : 
     242            0 :   failedTemplateId.value = id
     243              : }
     244              : </script>
        

Generated by: LCOV version 2.0-1