LCOV - code coverage report
Current view: top level - src/components - TopMenuSection.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 80.2 % 91 73
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2              :   <div
       3         5296 :     v-if="!workspaceStore.focusMode"
       4              :     class="ml-(--comfy-canvas-gutter) flex flex-col gap-1 pt-(--comfy-canvas-gutter)"
       5              :     @mouseenter="isTopMenuHovered = true"
       6              :     @mouseleave="isTopMenuHovered = false"
       7              :   >
       8              :     <div class="flex gap-x-0.5">
       9              :       <div
      10              :         :inert="isActionBarsHidden"
      11              :         :aria-hidden="isActionBarsHidden"
      12              :         :class="
      13              :           cn(
      14              :             'max-h-16 min-w-0 flex-1 transition-all duration-300 ease-in-out',
      15              :             isActionBarsHidden &&
      16              :               'max-h-0 -translate-x-8 overflow-hidden opacity-0'
      17              :           )
      18              :         "
      19              :       >
      20              :         <SubgraphBreadcrumb />
      21              :       </div>
      22              : 
      23              :       <div class="ml-(--comfy-canvas-gutter) flex flex-col items-end gap-1">
      24              :         <div
      25              :           data-testid="top-menu-actionbars"
      26              :           :inert="isActionBarsHidden"
      27              :           :aria-hidden="isActionBarsHidden"
      28              :           :class="
      29              :             cn(
      30              :               'flex max-h-24 items-start gap-2 transition-all duration-300 ease-in-out',
      31              :               isActionBarsHidden &&
      32              :                 'max-h-0 translate-x-8 overflow-hidden opacity-0'
      33              :             )
      34              :           "
      35              :         >
      36              :           <div
      37              :             ref="actionbarCardRef"
      38              :             data-testid="action-bar-card"
      39              :             :class="
      40              :               cn(
      41              :                 'pointer-events-auto relative z-1 flex flex-col',
      42              :                 isActionbarContainerEmpty
      43              :                   ? 'has-[.border-dashed]:floating-panel'
      44              :                   : 'floating-panel'
      45              :               )
      46              :             "
      47              :           >
      48              :             <div
      49              :               :class="
      50              :                 cn(
      51              :                   'actionbar-container relative flex items-center gap-2',
      52              :                   isActionbarContainerEmpty &&
      53              :                     'w-0 min-w-0 has-[.border-dashed]:w-auto has-[.border-dashed]:min-w-auto'
      54              :                 )
      55              :               "
      56              :             >
      57              :               <ActionBarButtons />
      58              :               <div
      59              :                 ref="legacyCommandsContainerRef"
      60              :                 data-testid="legacy-topbar-container"
      61              :                 class="[&:not(:has(*>*:not(:empty)))]:hidden"
      62              :               ></div>
      63              : 
      64              :               <ComfyActionbar
      65              :                 :docked-progress-container="actionbarCardRef"
      66              :                 :queue-overlay-expanded="isQueueOverlayExpanded"
      67              :                 @update:progress-target="updateProgressTarget"
      68              :               />
      69              :               <CurrentUserButton
      70              :                 v-if="
      71              :                   isLoggedIn &&
      72              :                   !isIntegratedTabBar &&
      73              :                   !flags.billingNewUxEnabled
      74              :                 "
      75              :                 class="shrink-0"
      76              :               />
      77              :               <LoginButton v-else-if="!isLoggedIn && !isIntegratedTabBar" />
      78              :               <Button
      79              :                 v-if="managerState.shouldShowExtensionsButton.value"
      80              :                 :tooltip="t('menu.manageExtensions')"
      81              :                 tooltip-side="bottom"
      82              :                 variant="secondary"
      83              :                 size="icon"
      84              :                 :aria-label="t('menu.manageExtensions')"
      85              :                 @click="openCustomNodeManager"
      86              :               >
      87              :                 <i class="icon-[comfy--extensions-blocks]" />
      88              :                 <span
      89              :                   v-if="shouldShowRedDot"
      90              :                   class="absolute top-0.5 right-1 size-2 rounded-full bg-destructive"
      91              :                 />
      92              :               </Button>
      93              :               <CloudButton v-if="isCloudButtonShown" />
      94              :               <Button
      95              :                 v-else-if="isDeployButtonShown"
      96              :                 :tooltip="t('deployToComfyApi.buttonLabel')"
      97              :                 tooltip-side="bottom"
      98              :                 variant="secondary"
      99              :                 size="icon"
     100              :                 :aria-label="t('deployToComfyApi.buttonLabel')"
     101              :                 data-testid="run-bar-deploy"
     102              :                 @click="openDeployInstallationDialog"
     103              :               >
     104              :                 <i class="icon-[lucide--rocket]" />
     105              :               </Button>
     106              :               <Button
     107              :                 v-if="isCloud"
     108              :                 :tooltip="t('actionbar.shareTooltip')"
     109              :                 tooltip-side="bottom"
     110              :                 variant="secondary"
     111              :                 size="icon"
     112              :                 :aria-label="t('actionbar.shareTooltip')"
     113              :                 @click="() => openShareDialog().catch(toastErrorHandler)"
     114              :                 @pointerenter="prefetchShareDialog"
     115              :               >
     116              :                 <i class="icon-[comfy--send]" />
     117              :               </Button>
     118              :               <div v-if="!isPropertiesPanelOpen" class="relative">
     119              :                 <Button
     120              :                   :tooltip="t('rightSidePanel.togglePanel')"
     121              :                   tooltip-side="bottom"
     122              :                   :class="
     123              :                     cn(
     124              :                       showErrorIndicatorOnPanelButton &&
     125              :                         'outline-1 outline-destructive'
     126              :                     )
     127              :                   "
     128              :                   variant="secondary"
     129              :                   size="icon"
     130              :                   :aria-label="t('rightSidePanel.togglePanel')"
     131              :                   @click="openPropertiesPanel"
     132              :                 >
     133              :                   <i class="icon-[lucide--panel-right]" />
     134              :                 </Button>
     135              :                 <Badge
     136              :                   v-if="showErrorIndicatorOnPanelButton"
     137              :                   variant="dot"
     138              :                   severity="danger"
     139              :                   class="absolute -top-1 -right-1"
     140              :                 />
     141              :               </div>
     142              :             </div>
     143              :             <FreeTierQuota v-if="!isActionbarFloating" />
     144              :             <!-- Complement of ComfyActionbar's `!isDocked` mount (same storage
     145              :                  key), so at most one caption renders in any menu state. -->
     146              :             <PartnerNodesRunCaption v-if="isActionbarDocked" />
     147              :           </div>
     148              :         </div>
     149              :         <ErrorOverlay
     150              :           v-if="!isActionBarsHidden"
     151              :           @view-errors="viewErrorsInGraph"
     152              :         />
     153              :         <QueueProgressOverlay
     154              :           v-if="isQueueProgressOverlayEnabled"
     155              :           v-model:expanded="isQueueOverlayExpanded"
     156              :           :menu-hovered="isTopMenuHovered"
     157              :         />
     158              :       </div>
     159              :     </div>
     160              : 
     161              :     <div class="flex flex-col items-end gap-1">
     162              :       <Teleport
     163              :         v-if="inlineProgressSummaryTarget"
     164              :         :to="inlineProgressSummaryTarget"
     165              :       >
     166              :         <div
     167              :           class="pointer-events-none absolute inset-x-0 top-full mt-1 flex justify-end pr-1"
     168              :         >
     169              :           <QueueInlineProgressSummary
     170              :             :hidden="shouldHideInlineProgressSummary"
     171              :           />
     172              :         </div>
     173              :       </Teleport>
     174              :       <QueueInlineProgressSummary
     175              :         v-else-if="shouldShowInlineProgressSummary && !isActionbarFloating"
     176              :         class="pr-1"
     177              :         :hidden="shouldHideInlineProgressSummary"
     178              :       />
     179              :       <QueueNotificationBannerHost
     180              :         v-if="isActionbarEnabled"
     181              :         :class="cn('pr-1', isActionBarsHidden && 'hidden')"
     182              :       />
     183              :     </div>
     184              :   </div>
     185              : </template>
     186              : 
     187              : <script setup lang="ts">
     188              : import { useLocalStorage, useMutationObserver } from '@vueuse/core'
     189              : import { storeToRefs } from 'pinia'
     190              : import { computed, onBeforeUnmount, onMounted, provide, ref } from 'vue'
     191              : import { useI18n } from 'vue-i18n'
     192              : 
     193              : import ComfyActionbar from '@/components/actionbar/ComfyActionbar.vue'
     194              : import PartnerNodesRunCaption from '@/components/actionbar/PartnerNodesRunCaption.vue'
     195              : import SubgraphBreadcrumb from '@/components/breadcrumb/SubgraphBreadcrumb.vue'
     196              : import QueueInlineProgressSummary from '@/components/queue/QueueInlineProgressSummary.vue'
     197              : import QueueNotificationBannerHost from '@/components/queue/QueueNotificationBannerHost.vue'
     198              : import QueueProgressOverlay from '@/components/queue/QueueProgressOverlay.vue'
     199              : import ErrorOverlay from '@/platform/workflowErrors/overlay/ErrorOverlay.vue'
     200              : import { useViewErrorsInGraph } from '@/composables/useViewErrorsInGraph'
     201              : import { AskAgentPortKey } from '@/platform/workflowErrors/askAgentPort'
     202              : import { useAskAgentAboutIssues } from '@/workbench/extensions/agent/composables/agent/useAskAgentAboutIssues'
     203              : import ActionBarButtons from '@/components/topbar/ActionBarButtons.vue'
     204              : import CurrentUserButton from '@/components/topbar/CurrentUserButton.vue'
     205              : import LoginButton from '@/components/topbar/LoginButton.vue'
     206              : import Badge from '@comfyorg/design-system/badge/Badge'
     207              : import Button from '@comfyorg/design-system/button/Button'
     208              : import { useCurrentUser } from '@/composables/auth/useCurrentUser'
     209              : import { useQueueFeatureFlags } from '@/composables/queue/useQueueFeatureFlags'
     210              : import { useErrorHandling } from '@/composables/useErrorHandling'
     211              : import { useFeatureFlags } from '@/composables/useFeatureFlags'
     212              : import FreeTierQuota from '@/platform/billing/subscription/components/FreeTierQuota.vue'
     213              : import { useSettingStore } from '@/platform/settings/settingStore'
     214              : import { useTelemetry } from '@comfyorg/telemetry'
     215              : import { DEPLOYMENT_LISTING_EXTENSIONS_WAIT_MS } from '@/platform/workspace/api/deploymentListingTimeouts'
     216              : import { waitForDeploymentListing } from '@/platform/workspace/composables/waitForDeploymentPick'
     217              : import { openDeployCustomNodesDialog } from '@/platform/workspace/openCustomDeploymentDialog'
     218              : import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore'
     219              : import { app } from '@/scripts/app'
     220              : import { useExecutionErrorStore } from '@/stores/executionErrorStore'
     221              : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
     222              : import { useActionBarButtonStore } from '@/stores/actionBarButtonStore'
     223              : import { useQueueUIStore } from '@/stores/queueStore'
     224              : import { usePropertiesPanelStore } from '@/renderer/extensions/propertiesPanel/propertiesPanelStore'
     225              : import { useWorkspaceStore } from '@/stores/workspaceStore'
     226              : import { isCloud } from '@/platform/distribution/types'
     227              : import CloudButton from '@/components/CloudButton.vue'
     228              : import { canHandOffToCloud } from '@/platform/openOnCloud/localHandoffProtocol'
     229              : import { openDeployToComfyApiDialog } from '@/platform/workflow/deploy/composables/lazyDeployToComfyApiDialog'
     230              : import {
     231              :   openShareDialog,
     232              :   prefetchShareDialog
     233              : } from '@/platform/workflow/sharing/composables/lazyShareDialog'
     234              : import { useConflictAcknowledgment } from '@/platform/customNodes/manager/composables/useConflictAcknowledgment'
     235              : import { useManagerDialog } from '@/platform/customNodes/manager/composables/dialogs/useManagerDialog'
     236              : import { useManagerState } from '@/platform/customNodes/manager/composables/useManagerState'
     237              : import { useManagerSurveyDialog } from '@/platform/customNodes/manager/composables/dialogs/useManagerSurveyDialog'
     238              : import { ManagerTab } from '@/platform/customNodes/manager/types/comfyManagerTypes'
     239              : import { cn } from '@comfyorg/tailwind-utils'
     240              : 
     241         2009 : const settingStore = useSettingStore()
     242         2009 : const workspaceStore = useWorkspaceStore()
     243         2009 : const propertiesPanelStore = usePropertiesPanelStore()
     244         2009 : const canvasStore = useCanvasStore()
     245         2009 : const isActionBarsHidden = computed(() => canvasStore.isPickingNodes)
     246         2009 : const managerState = useManagerState()
     247         2009 : const managerSurveyDialog = useManagerSurveyDialog()
     248         2009 : const deploymentPickStore = useDeploymentPickStore()
     249         2009 : const { isLoggedIn } = useCurrentUser()
     250         2009 : const { t } = useI18n()
     251         2009 : const { toastErrorHandler } = useErrorHandling()
     252         2009 : const { flags } = useFeatureFlags()
     253         2009 : const isCloudButtonShown = computed(
     254              :   () => !isCloud && flags.openOnCloudEnabled && canHandOffToCloud()
     255              : )
     256         2009 : const isDeployButtonShown = computed(() => flags.deployToCloud)
     257            0 : function openDeployInstallationDialog() {
     258            0 :   useTelemetry()?.trackUiButtonClicked({
     259              :     button_id: 'run_bar_deploy_clicked',
     260              :     element_group: 'top_menu'
     261              :   })
     262            0 :   openDeployToComfyApiDialog({ deploysInstallation: true }).catch(
     263              :     toastErrorHandler
     264              :   )
     265              : }
     266         2009 : const executionErrorStore = useExecutionErrorStore()
     267         2009 : const actionBarButtonStore = useActionBarButtonStore()
     268         2009 : const queueUIStore = useQueueUIStore()
     269         2009 : const { isOverlayExpanded: isQueueOverlayExpanded } = storeToRefs(queueUIStore)
     270         2009 : const { shouldShowRedDot: shouldShowConflictRedDot } =
     271              :   useConflictAcknowledgment()
     272         2009 : const isTopMenuHovered = ref(false)
     273         2009 : const actionbarCardRef = ref<HTMLElement>()
     274         2009 : const isActionbarDocked = useLocalStorage('Comfy.MenuPosition.Docked', true)
     275         2009 : const actionbarPosition = computed(() => settingStore.get('Comfy.UseNewMenu'))
     276         2009 : const isActionbarEnabled = computed(
     277              :   () => actionbarPosition.value !== 'Disabled'
     278              : )
     279         2009 : const isActionbarFloating = computed(
     280              :   () => isActionbarEnabled.value && !isActionbarDocked.value
     281              : )
     282         2009 : const hasDockedButtons = computed(() => {
     283            1 :   if (actionBarButtonStore.buttons.length > 0) return true
     284            1 :   if (hasLegacyContent.value) return true
     285            1 :   if (!isIntegratedTabBar.value) return true
     286            1 :   if (managerState.shouldShowExtensionsButton.value) return true
     287            1 :   if (isCloudButtonShown.value || isDeployButtonShown.value) return true
     288              :   if (isCloud) return true
     289            1 :   if (!isPropertiesPanelOpen.value) return true
     290            0 :   return false
     291              : })
     292         2009 : const isActionbarContainerEmpty = computed(
     293              :   () => isActionbarFloating.value && !hasDockedButtons.value
     294              : )
     295         2009 : const isIntegratedTabBar = computed(
     296              :   () => settingStore.get('Comfy.UI.TabBarLayout') !== 'Legacy'
     297              : )
     298         2009 : const { isQueuePanelV2Enabled, isRunProgressBarEnabled } =
     299              :   useQueueFeatureFlags()
     300         2009 : const isQueueProgressOverlayEnabled = computed(
     301              :   () => !isQueuePanelV2Enabled.value && !isActionBarsHidden.value
     302              : )
     303         2009 : const shouldShowInlineProgressSummary = computed(
     304              :   () =>
     305              :     isQueuePanelV2Enabled.value &&
     306              :     isActionbarEnabled.value &&
     307              :     isRunProgressBarEnabled.value &&
     308              :     !isActionBarsHidden.value
     309              : )
     310         2009 : const progressTarget = ref<HTMLElement | null>(null)
     311         4018 : function updateProgressTarget(target: HTMLElement | null) {
     312         4018 :   progressTarget.value = target
     313              : }
     314         2009 : const inlineProgressSummaryTarget = computed(() => {
     315         2011 :   if (!shouldShowInlineProgressSummary.value || !isActionbarFloating.value) {
     316         2011 :     return null
     317              :   }
     318            0 :   return progressTarget.value
     319              : })
     320         2009 : const shouldHideInlineProgressSummary = computed(
     321              :   () => isQueueProgressOverlayEnabled.value && isQueueOverlayExpanded.value
     322              : )
     323              : 
     324         2009 : const shouldShowRedDot = computed((): boolean => {
     325           15 :   return shouldShowConflictRedDot.value
     326              : })
     327              : 
     328         2009 : const { hasAnyError, isErrorOverlayOpen } = storeToRefs(executionErrorStore)
     329         2009 : const { viewErrorsInGraph } = useViewErrorsInGraph()
     330         2009 : provide(AskAgentPortKey, useAskAgentAboutIssues())
     331              : 
     332         2009 : const isErrorsTabEnabled = computed(() =>
     333              :   settingStore.get('Comfy.RightSidePanel.ShowErrorsTab')
     334              : )
     335              : 
     336         2009 : const showErrorIndicatorOnPanelButton = computed(
     337              :   () =>
     338              :     isErrorsTabEnabled.value &&
     339              :     hasAnyError.value &&
     340              :     !isPropertiesPanelOpen.value &&
     341              :     !isErrorOverlayOpen.value
     342              : )
     343              : 
     344         2009 : const { isOpen: isPropertiesPanelOpen } = storeToRefs(propertiesPanelStore)
     345              : 
     346          103 : function openPropertiesPanel() {
     347          103 :   useTelemetry()?.trackUiButtonClicked({
     348              :     button_id: 'right_side_panel_opened',
     349              :     element_group: 'top_menu'
     350              :   })
     351          103 :   propertiesPanelStore.togglePanel()
     352              : }
     353              : 
     354         2009 : const legacyCommandsContainerRef = ref<HTMLElement>()
     355         2009 : const hasLegacyContent = ref(false)
     356         2009 : let legacyContentCheckRafId: number | null = null
     357              : 
     358         2009 : function checkLegacyContent() {
     359         2009 :   const el = legacyCommandsContainerRef.value
     360         2009 :   if (!el) {
     361            0 :     hasLegacyContent.value = false
     362            0 :     return
     363              :   }
     364         2009 :   hasLegacyContent.value =
     365              :     el.querySelector(':scope > * > *:not(:empty)') !== null
     366              : }
     367              : 
     368         2009 : useMutationObserver(
     369              :   legacyCommandsContainerRef,
     370              :   () => {
     371            0 :     if (legacyContentCheckRafId !== null) return
     372            0 :     legacyContentCheckRafId = requestAnimationFrame(() => {
     373            0 :       legacyContentCheckRafId = null
     374            0 :       checkLegacyContent()
     375              :     })
     376              :   },
     377              :   { childList: true, subtree: true }
     378              : )
     379              : 
     380         2009 : onMounted(() => {
     381         2009 :   const container = legacyCommandsContainerRef.value
     382         2009 :   if (!container) return
     383         2009 :   app.menu.element.style.width = 'fit-content'
     384         2009 :   container.appendChild(app.menu.element)
     385         2009 :   checkLegacyContent()
     386              : })
     387              : 
     388         2009 : onBeforeUnmount(() => {
     389           72 :   if (legacyContentCheckRafId === null) return
     390            0 :   cancelAnimationFrame(legacyContentCheckRafId)
     391              : })
     392              : 
     393              : async function pitchDeployingCustomNodes(): Promise<boolean> {
     394              :   await waitForDeploymentListing(DEPLOYMENT_LISTING_EXTENSIONS_WAIT_MS)
     395              :   if (!deploymentPickStore.isVisible) return false
     396              :   return openDeployCustomNodesDialog()
     397              : }
     398              : 
     399         2009 : const openCustomNodeManager = async () => {
     400              :   if (isCloud) {
     401              :     if (!(await pitchDeployingCustomNodes())) managerSurveyDialog.show()
     402              :     return
     403              :   }
     404            0 :   try {
     405            0 :     await useManagerDialog().openManager({
     406              :       initialTab: ManagerTab.All,
     407              :       showToastOnLegacyError: false
     408              :     })
     409              :   } catch (error) {
     410            0 :     try {
     411            0 :       toastErrorHandler(error)
     412              :     } catch (toastError) {
     413            0 :       console.error(error)
     414            0 :       console.error(toastError)
     415              :     }
     416              :   }
     417              : }
     418              : </script>
        

Generated by: LCOV version 2.0-1