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

            Line data    Source code
       1              : <template>
       2         2355 :   <template v-if="onScreen">
       3              :     <div
       4              :       v-if="isPositioned && ringStyle"
       5              :       aria-hidden="true"
       6              :       data-testid="first-run-nudge-ring"
       7              :       class="pointer-events-none fixed rounded-lg outline-2 -outline-offset-2 outline-white"
       8              :       :style="ringStyle"
       9              :     />
      10              :     <div
      11              :       ref="cardRef"
      12              :       role="region"
      13              :       :aria-labelledby="titleId"
      14              :       data-testid="first-run-nudge"
      15              :       :class="
      16              :         cn(
      17              :           'fixed w-80 animate-in animation-duration-500 fade-in-0',
      18              :           !isPositioned && 'invisible'
      19              :         )
      20              :       "
      21              :       :style="floatingStyles"
      22              :     >
      23              :       <i
      24              :         data-testid="first-run-nudge-cursor"
      25              :         :class="
      26              :           cn(
      27              :             'absolute icon-[lucide--mouse-pointer-2] text-foreground drop-shadow-md',
      28              :             cursorEdgeClass(placement)
      29              :           )
      30              :         "
      31              :         aria-hidden="true"
      32              :       />
      33              :       <div
      34              :         class="flex flex-col overflow-hidden rounded-xl border border-border/50 bg-background shadow-lg"
      35              :       >
      36              :         <div class="relative h-50 w-full bg-secondary">
      37              :           <img :src="NUDGE_IMAGE" alt="" class="size-full object-cover" />
      38              :           <Button
      39              :             class="absolute top-2 right-2 opacity-50 hover:opacity-100"
      40              :             variant="secondary"
      41              :             size="icon"
      42              :             :aria-label="t('g.close')"
      43              :             @click="dismissNudge"
      44              :           >
      45              :             <i class="icon-[lucide--x]" aria-hidden="true" />
      46              :           </Button>
      47              :         </div>
      48              : 
      49              :         <div class="flex flex-col gap-2 border-t px-4 pt-6 pb-4">
      50              :           <p :id="titleId" class="m-0 text-sm/5 font-bold text-foreground">
      51              :             {{ t(`${copyKey}.title`) }}
      52              :           </p>
      53              :           <p class="m-0 text-sm text-muted-foreground">
      54              :             {{ t(`${copyKey}.body`) }}
      55              :           </p>
      56              :         </div>
      57              : 
      58              :         <div class="flex items-center justify-end gap-4 px-4 pb-4">
      59              :           <Button
      60              :             variant="link"
      61              :             size="unset"
      62              :             class="h-6 font-normal"
      63              :             @click="dismissNudge"
      64              :           >
      65              :             {{ t('onboardingCoachmarks.firstRun.nudge.dismiss') }}
      66              :           </Button>
      67              :           <Button
      68              :             variant="inverted"
      69              :             size="lg"
      70              :             class="font-normal"
      71              :             data-testid="first-run-nudge-explore"
      72              :             @click="onExplore"
      73              :           >
      74              :             {{ t('onboardingCoachmarks.firstRun.nudge.explore') }}
      75              :           </Button>
      76              :         </div>
      77              :       </div>
      78              :     </div>
      79              :   </template>
      80              : </template>
      81              : 
      82              : <script setup lang="ts">
      83              : import { cn } from '@comfyorg/tailwind-utils'
      84              : import {
      85              :   breakpointsTailwind,
      86              :   useBreakpoints,
      87              :   onClickOutside,
      88              :   useEventListener,
      89              :   useTimeoutFn
      90              : } from '@vueuse/core'
      91              : import { computed, ref, useId, watch } from 'vue'
      92              : import { useI18n } from 'vue-i18n'
      93              : 
      94              : import Button from '@comfyorg/design-system/button/Button'
      95              : import { useWorkflowTemplateSelectorDialog } from '@/platform/workflow/templates/composables/useWorkflowTemplateSelectorDialog'
      96              : import { cursorEdgeClass } from '@/platform/onboarding/coachmarkLayout'
      97              : import { useOnboardingTourStore } from '@/platform/onboarding/onboardingTourStore'
      98              : import { FIRST_RUN_COACH_IDS } from '@/platform/onboarding/onboardingTours'
      99              : import type { SpotlightStep } from '@/platform/onboarding/onboardingTours'
     100              : import { useCoachmarkTarget } from '@/platform/onboarding/useCoachmarkTarget'
     101              : import { useSettingStore } from '@/platform/settings/settingStore'
     102              : import { useTelemetry } from '@comfyorg/telemetry'
     103              : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
     104              : import { useDialogStore } from '@/stores/dialogStore'
     105              : import { useSidebarTabStore } from '@/stores/workspace/sidebarTabStore'
     106              : 
     107              : import { useFirstRunTourController } from '@/renderer/extensions/firstRunTour/tour/useFirstRunTourController'
     108              : 
     109         2355 : const NUDGE_IMAGE = '/assets/images/og-image.png'
     110              : 
     111              : /** Delayed, so the finished workflow is seen before this fades in over it. */
     112         2355 : const APPEAR_DELAY_MS = 1500
     113              : 
     114         2355 : const { t } = useI18n()
     115         2355 : const { nudgeArmed, tourWasCompleted, dismissNudge } =
     116              :   useFirstRunTourController()
     117         2355 : const dialogStore = useDialogStore()
     118         2355 : const settingStore = useSettingStore()
     119         2355 : const sidebarTabStore = useSidebarTabStore()
     120         2355 : const canvasStore = useCanvasStore()
     121         2355 : const onboardingTourStore = useOnboardingTourStore()
     122         2355 : const desktopLayout = useBreakpoints(breakpointsTailwind).greaterOrEqual('md')
     123         2355 : const telemetry = useTelemetry()
     124         2355 : const titleId = useId()
     125              : 
     126         2355 : const nudgeStep = computed<SpotlightStep>(() => ({
     127              :   kind: 'spotlight',
     128              :   name: 'nudge',
     129              :   coachId: nudgeArmed.value ? FIRST_RUN_COACH_IDS.templatesButton : undefined,
     130              :   placement:
     131              :     settingStore.get('Comfy.Sidebar.Location') === 'right'
     132              :       ? 'leftCenter'
     133              :       : 'rightCenter',
     134              :   cursor: true
     135              : }))
     136              : 
     137         2355 : const cardRef = ref<HTMLElement | null>(null)
     138         2355 : const {
     139              :   anchor,
     140              :   hasTarget,
     141              :   targetRect,
     142              :   floatingStyles,
     143              :   isPositioned,
     144              :   placement
     145              : } = useCoachmarkTarget(nudgeStep, cardRef)
     146         2355 : const ringStyle = computed(() => {
     147            0 :   const rect = targetRect.value
     148            0 :   if (!rect) return null
     149            0 :   return {
     150              :     left: `${rect.left}px`,
     151              :     top: `${rect.top}px`,
     152              :     width: `${rect.width}px`,
     153              :     height: `${rect.height}px`
     154              :   }
     155              : })
     156              : 
     157              : // Only a tour walked to the end made a first result to congratulate; every
     158              : // other ending still gets a nudge, pointing at the templates instead.
     159         2355 : const copyKey = computed(
     160              :   () =>
     161              :     `onboardingCoachmarks.firstRun.nudge.${tourWasCompleted.value ? 'ran' : 'noTour'}`
     162              : )
     163              : 
     164         2355 : const onScreen = ref(false)
     165         2355 : let reported = false
     166         2355 : const { start: scheduleAppearance, stop: cancelAppearance } = useTimeoutFn(
     167              :   () => {
     168            0 :     if (anchor.value instanceof HTMLElement)
     169            0 :       anchor.value.scrollIntoView({ block: 'nearest' })
     170            0 :     onScreen.value = true
     171            0 :     if (reported) return
     172            0 :     reported = true
     173            0 :     telemetry?.trackOnboardingTour('nudge_shown', {
     174              :       tour: 'firstRun',
     175              :       tour_completed: tourWasCompleted.value
     176              :     })
     177              :   },
     178              :   APPEAR_DELAY_MS,
     179              :   { immediate: false }
     180              : )
     181              : 
     182         2355 : onClickOutside(cardRef, dismissNudge)
     183              : 
     184         2355 : useEventListener(document, 'keydown', (event: KeyboardEvent) => {
     185         1310 :   if (onScreen.value && event.key === 'Escape') dismissNudge()
     186              : })
     187              : 
     188              : /** The nudge sits below the modal stack, so it waits for a clear screen. */
     189         2355 : watch(
     190              :   () =>
     191              :     desktopLayout.value &&
     192              :     dialogStore.dialogStack.length === 0 &&
     193              :     hasTarget.value &&
     194              :     !onboardingTourStore.activeTour &&
     195              :     !canvasStore.isPickingNodes &&
     196              :     !sidebarTabStore.activeSidebarTab,
     197              :   (screenIsClear) => {
     198         2355 :     cancelAppearance()
     199         2355 :     if (!screenIsClear) {
     200         2355 :       onScreen.value = false
     201         2355 :       return
     202              :     }
     203            0 :     scheduleAppearance()
     204              :   },
     205              :   { immediate: true }
     206              : )
     207              : 
     208            0 : function onExplore() {
     209            0 :   useWorkflowTemplateSelectorDialog().show('first_run_nudge')
     210            0 :   telemetry?.trackOnboardingTour('explore_templates_clicked', {
     211              :     tour: 'firstRun',
     212              :     tour_completed: tourWasCompleted.value
     213              :   })
     214            0 :   dismissNudge()
     215              : }
     216              : </script>
        

Generated by: LCOV version 2.0-1