LCOV - code coverage report
Current view: top level - src/platform/workflowErrors/panel - MissingPackGroupRow.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 90.9 % 55 50
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2           34 :   <div class="mb-1 flex w-full flex-col gap-0.5 last:mb-0">
       3              :     <div
       4              :       :aria-current="highlighted ? 'true' : undefined"
       5              :       :class="
       6              :         cn(
       7              :           'flex min-h-8 items-center gap-1',
       8              :           selectionEmphasisClass(highlighted)
       9              :         )
      10              :       "
      11              :     >
      12              :       <Button
      13              :         v-if="hasMultipleNodeTypes"
      14              :         data-testid="missing-node-pack-expand"
      15              :         variant="textonly"
      16              :         size="unset"
      17              :         :aria-label="
      18              :           expanded
      19              :             ? t('rightSidePanel.missingNodePacks.collapse')
      20              :             : t('rightSidePanel.missingNodePacks.expand')
      21              :         "
      22              :         :aria-expanded="expanded"
      23              :         class="h-8 w-4 shrink-0 p-0 hover:bg-transparent focus-visible:ring-inset"
      24              :         @click="toggleExpand"
      25              :       >
      26              :         <i
      27              :           aria-hidden="true"
      28              :           :class="
      29              :             cn(
      30              :               'icon-[lucide--chevron-right] text-muted-foreground transition-transform duration-200',
      31              :               expanded && 'rotate-90'
      32              :             )
      33              :           "
      34              :         />
      35              :       </Button>
      36              :       <i
      37              :         v-if="isUnknownPack"
      38              :         class="icon-[lucide--triangle-alert] text-warning"
      39              :       />
      40              :       <span class="flex min-w-0 flex-1 items-center gap-2">
      41              :         <span class="flex min-w-0 items-center gap-2.5">
      42              :           <button
      43              :             v-if="hasMultipleNodeTypes && !group.isResolving"
      44              :             type="button"
      45              :             :class="
      46              :               cn(
      47              :                 packTextButtonClass,
      48              :                 isUnknownPack ? 'text-warning' : 'text-foreground'
      49              :               )
      50              :             "
      51              :             :aria-expanded="expanded"
      52              :             @click="toggleExpand"
      53              :           >
      54              :             {{ packDisplayName }}
      55              :           </button>
      56              :           <button
      57              :             v-else-if="primaryLocatableNodeType"
      58              :             type="button"
      59              :             :class="
      60              :               cn(
      61              :                 packTextButtonClass,
      62              :                 isUnknownPack ? 'text-warning' : 'text-foreground'
      63              :               )
      64              :             "
      65              :             @click="handleLocateNode(primaryLocatableNodeType)"
      66              :           >
      67              :             {{ packDisplayName }}
      68              :           </button>
      69              :           <span
      70              :             v-else
      71              :             class="min-w-0 truncate text-xs/relaxed font-normal"
      72              :             :class="isUnknownPack ? 'text-warning' : 'text-foreground'"
      73              :           >
      74              :             <span v-if="group.isResolving" class="text-muted-foreground italic">
      75              :               {{ t('g.loading') }}...
      76              :             </span>
      77              :             <span v-else>
      78              :               {{ packDisplayName }}
      79              :             </span>
      80              :           </span>
      81              :           <Button
      82              :             v-if="showInfoButton && group.packId !== null"
      83              :             variant="muted-textonly"
      84              :             size="icon-sm"
      85              :             class="size-6 shrink-0 hover:bg-transparent hover:text-foreground focus-visible:ring-inset"
      86              :             :aria-label="t('rightSidePanel.missingNodePacks.viewInManager')"
      87              :             @click="emit('openManagerInfo', group.packId ?? '')"
      88              :           >
      89              :             <i class="icon-[lucide--info]" />
      90              :           </Button>
      91              :           <span
      92              :             v-if="showNodeCount"
      93              :             data-testid="missing-node-pack-count"
      94              :             class="flex h-4 min-w-4 shrink-0 items-center justify-center rounded-sm bg-accent px-1 text-2xs font-semibold"
      95              :           >
      96              :             {{ group.nodeTypes.length }}
      97              :           </span>
      98              :         </span>
      99              :       </span>
     100              :       <div v-if="showInstallAction" class="ml-auto shrink-0">
     101              :         <Button
     102              :           variant="secondary"
     103              :           size="sm"
     104              :           class="shrink-0 focus-visible:ring-inset"
     105              :           :disabled="isPackInstalled || isInstalling"
     106              :           @click="handlePackInstallClick"
     107              :         >
     108              :           <DotSpinner
     109              :             v-if="isInstalling"
     110              :             duration="1s"
     111              :             :size="12"
     112              :             class="mr-1.5 shrink-0"
     113              :           />
     114              :           <span class="min-w-0 truncate text-foreground">
     115              :             {{
     116              :               isInstalling
     117              :                 ? t('rightSidePanel.missingNodePacks.installing')
     118              :                 : isPackInstalled
     119              :                   ? t('rightSidePanel.missingNodePacks.installed')
     120              :                   : t('g.install')
     121              :             }}
     122              :           </span>
     123              :         </Button>
     124              :       </div>
     125              :       <div
     126              :         v-else-if="showLoadingAction"
     127              :         class="ml-auto flex h-6 shrink-0 cursor-not-allowed items-center justify-center overflow-hidden rounded-sm bg-secondary px-2 py-1 text-xs opacity-60 select-none"
     128              :       >
     129              :         <DotSpinner duration="1s" :size="12" class="mr-1.5 shrink-0" />
     130              :         <span class="min-w-0 truncate">
     131              :           {{ t('g.loading') }}
     132              :         </span>
     133              :       </div>
     134              :       <div v-else-if="showSearchAction" class="ml-auto shrink-0">
     135              :         <Button
     136              :           variant="secondary"
     137              :           size="sm"
     138              :           class="shrink-0 focus-visible:ring-inset"
     139              :           @click="
     140              :             openManager({
     141              :               initialTab: 'all',
     142              :               initialPackId: group.packId!
     143              :             })
     144              :           "
     145              :         >
     146              :           <span class="min-w-0 truncate text-foreground">
     147              :             {{ t('g.search') }}
     148              :           </span>
     149              :         </Button>
     150              :       </div>
     151              :       <LocateNodeButton
     152              :         v-if="primaryLocatableNodeType"
     153              :         :label="
     154              :           t(
     155              :             'rightSidePanel.locateNodeFor',
     156              :             {
     157              :               item: getLabel(primaryLocatableNodeType)
     158              :             },
     159              :             { escapeParameter: false }
     160              :           )
     161              :         "
     162              :         @locate="handleLocateNode(primaryLocatableNodeType)"
     163              :       />
     164              :     </div>
     165              : 
     166              :     <p
     167              :       v-if="unsupportedPack"
     168              :       :class="
     169              :         cn(
     170              :           'm-0 text-xs/relaxed wrap-break-word text-muted-foreground',
     171              :           hasMultipleNodeTypes && 'pl-5'
     172              :         )
     173              :       "
     174              :     >
     175              :       {{
     176              :         unsupportedPack.cause
     177              :           ? t(
     178              :               'rightSidePanel.missingNodePacks.unsupportedOnBuild',
     179              :               { cause: unsupportedPack.cause },
     180              :               { escapeParameter: false }
     181              :             )
     182              :           : t('rightSidePanel.missingNodePacks.unsupportedOnBuildNoCause')
     183              :       }}
     184              :     </p>
     185              : 
     186              :     <TransitionCollapse>
     187              :       <ul
     188              :         v-if="showNodeTypeList"
     189              :         :class="
     190              :           cn(
     191              :             'm-0 list-none p-0',
     192              :             (hasMultipleNodeTypes || isUnknownPack) && 'pl-5'
     193              :           )
     194              :         "
     195              :       >
     196           19 :         <li
     197              :           v-for="nodeType in group.nodeTypes"
     198              :           :key="getKey(nodeType)"
     199              :           class="min-w-0"
     200              :         >
     201              :           <div class="flex min-w-0 items-center gap-2">
     202              :             <span class="flex min-w-0 flex-1 items-center gap-1">
     203              :               <button
     204              :                 v-if="isLocatableNodeType(nodeType)"
     205              :                 type="button"
     206              :                 :class="
     207              :                   cn(
     208              :                     packTextButtonClass,
     209              :                     'text-muted-foreground hover:text-foreground'
     210              :                   )
     211              :                 "
     212              :                 @click="handleLocateNode(nodeType)"
     213              :               >
     214              :                 {{ getLabel(nodeType) }}
     215              :               </button>
     216              :               <span
     217              :                 v-else
     218              :                 class="text-xs/relaxed wrap-break-word text-muted-foreground"
     219              :               >
     220              :                 {{ getLabel(nodeType) }}
     221              :               </span>
     222              :             </span>
     223              :             <LocateNodeButton
     224              :               v-if="isLocatableNodeType(nodeType)"
     225              :               :label="
     226              :                 t(
     227              :                   'rightSidePanel.locateNodeFor',
     228              :                   { item: getLabel(nodeType) },
     229              :                   { escapeParameter: false }
     230              :                 )
     231              :               "
     232              :               @locate="handleLocateNode(nodeType)"
     233              :             />
     234              :           </div>
     235              :         </li>
     236              :       </ul>
     237              :     </TransitionCollapse>
     238              :   </div>
     239              : </template>
     240              : 
     241              : <script setup lang="ts">
     242              : import { computed, ref } from 'vue'
     243              : import { useI18n } from 'vue-i18n'
     244              : import { cn } from '@comfyorg/tailwind-utils'
     245              : 
     246              : import { selectionEmphasisClass } from './selectionEmphasis'
     247              : import Button from '@comfyorg/design-system/button/Button'
     248              : import DotSpinner from '@comfyorg/design-system/common/DotSpinner'
     249              : import LocateNodeButton from '@/platform/workflowErrors/panel/LocateNodeButton.vue'
     250              : import TransitionCollapse from '@comfyorg/design-system/transition/TransitionCollapse'
     251              : import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore'
     252              : import { useWorkflowErrorManager } from '@/platform/workflowErrors/workflowErrorManager'
     253              : import type { MissingNodeType } from '@/platform/workflowErrors/nodeReplacement/types'
     254              : import type { MissingPackGroup } from '@/platform/workflowErrors/panel/useErrorGroups'
     255              : 
     256              : const { group, showInfoButton, highlighted } = defineProps<{
     257              :   group: MissingPackGroup
     258              :   showInfoButton: boolean
     259              :   /** Emphasize the header row (pack containing the canvas selection). */
     260              :   highlighted?: boolean
     261              : }>()
     262              : 
     263           15 : const emit = defineEmits<{
     264              :   locateNode: [nodeId: string]
     265              :   openManagerInfo: [packId: string]
     266              : }>()
     267              : 
     268           15 : const { t } = useI18n()
     269           15 : const expandedOverride = ref<boolean | null>(null)
     270              : 
     271         2355 : const packTextButtonClass =
     272              :   'm-0 inline max-w-full cursor-pointer appearance-none border-0 bg-transparent p-0 text-left text-xs/relaxed font-normal wrap-break-word outline-none focus:outline-none rounded-sm focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset focus-visible:outline-none'
     273              : 
     274           15 : const manager = useWorkflowErrorManager()
     275           15 : const { missingNodePacks, isLoading } = manager.useMissingNodes()
     276           15 : const { shouldShowManagerButtons } = manager.useManagerState()
     277           15 : const { openManager } = manager
     278           15 : const deploymentPick = useDeploymentPickStore()
     279              : 
     280           15 : const nodePack = computed(() => {
     281            2 :   if (!group.packId) return null
     282            2 :   return missingNodePacks.value.find((p) => p.id === group.packId) ?? null
     283              : })
     284              : 
     285           15 : const { isInstalling, installAllPacks } = manager.usePackInstall(() =>
     286              :   nodePack.value ? [nodePack.value] : []
     287              : )
     288              : 
     289           15 : const isUnknownPack = computed(
     290              :   () => group.packId === null && !group.isResolving
     291              : )
     292              : 
     293           15 : const packDisplayName = computed(() => {
     294           16 :   if (group.packId === null) {
     295           15 :     return t('rightSidePanel.missingNodePacks.unknownPack')
     296              :   }
     297           16 :   return nodePack.value?.name ?? group.packId
     298              : })
     299              : 
     300           15 : const isPackInstalled = computed(
     301              :   () => group.packId !== null && manager.isPackInstalled(group.packId)
     302              : )
     303              : 
     304           15 : const showInstallAction = computed(
     305              :   () =>
     306              :     shouldShowManagerButtons.value &&
     307              :     group.packId !== null &&
     308              :     (nodePack.value !== null || isPackInstalled.value)
     309              : )
     310              : 
     311           15 : const showLoadingAction = computed(
     312              :   () =>
     313              :     shouldShowManagerButtons.value &&
     314              :     group.packId !== null &&
     315              :     !showInstallAction.value &&
     316              :     isLoading.value
     317              : )
     318              : 
     319           15 : const showSearchAction = computed(
     320              :   () =>
     321              :     shouldShowManagerButtons.value &&
     322              :     group.packId !== null &&
     323              :     !showInstallAction.value &&
     324              :     !showLoadingAction.value
     325              : )
     326              : 
     327           15 : const unsupportedPack = computed(() => {
     328           29 :   for (const nodeType of group.nodeTypes) {
     329           30 :     if (typeof nodeType === 'string' || !nodeType.cnrId) continue
     330            2 :     const pack = deploymentPick.unsupportedPackFor(nodeType.cnrId)
     331            2 :     if (pack) return pack
     332              :   }
     333              :   return undefined
     334              : })
     335              : 
     336           15 : const hasMultipleNodeTypes = computed(() => group.nodeTypes.length > 1)
     337           15 : const showNodeCount = computed(() => group.nodeTypes.length !== 1)
     338           15 : const expanded = computed(
     339              :   () =>
     340              :     expandedOverride.value ??
     341              :     (isUnknownPack.value && hasMultipleNodeTypes.value)
     342              : )
     343           15 : const showNodeTypeList = computed(
     344              :   () =>
     345              :     (isUnknownPack.value && group.nodeTypes.length === 1) ||
     346              :     (hasMultipleNodeTypes.value && expanded.value)
     347              : )
     348           15 : const primaryLocatableNodeType = computed(() => {
     349           29 :   if (group.isResolving) return null
     350           16 :   if (isUnknownPack.value) return null
     351            1 :   if (group.nodeTypes.length !== 1) return null
     352            0 :   const [nodeType] = group.nodeTypes
     353           29 :   return isLocatableNodeType(nodeType) ? nodeType : null
     354              : })
     355              : 
     356            0 : function handlePackInstallClick() {
     357            0 :   if (!group.packId) return
     358            0 :   if (!isPackInstalled.value) {
     359            0 :     void installAllPacks()
     360              :   }
     361              : }
     362              : 
     363            3 : function toggleExpand() {
     364            3 :   expandedOverride.value = !expanded.value
     365              : }
     366              : 
     367           19 : function getKey(nodeType: MissingNodeType): string {
     368           19 :   if (typeof nodeType === 'string') return nodeType
     369           19 :   return nodeType.nodeId != null ? String(nodeType.nodeId) : nodeType.type
     370              : }
     371              : 
     372           38 : function getLabel(nodeType: MissingNodeType): string {
     373           38 :   return typeof nodeType === 'string' ? nodeType : nodeType.type
     374              : }
     375              : 
     376           39 : function isLocatableNodeType(
     377              :   nodeType: MissingNodeType
     378              : ): nodeType is Exclude<MissingNodeType, string> & { nodeId: string | number } {
     379           39 :   return typeof nodeType !== 'string' && nodeType.nodeId != null
     380              : }
     381              : 
     382            1 : function handleLocateNode(nodeType: MissingNodeType) {
     383            1 :   if (!isLocatableNodeType(nodeType)) return
     384            1 :   emit('locateNode', String(nodeType.nodeId))
     385              : }
     386              : </script>
        

Generated by: LCOV version 2.0-1