LCOV - code coverage report
Current view: top level - src/renderer/extensions/vueNodes/components - InputSlot.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 87.5 % 32 28
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2        53021 :   <div v-if="renderError" class="node-error p-1 text-xs text-destructive">
       3              :     ⚠️
       4              :   </div>
       5              :   <Tooltip v-else :disabled="!tooltipText">
       6              :     <TooltipTrigger as-child>
       7              :       <div
       8              :         :aria-label="standalone ? accessibleName : undefined"
       9              :         :class="
      10              :           cn(
      11              :             'lg-slot lg-slot--input group m-0 flex items-center rounded-r-lg',
      12              :             'cursor-crosshair',
      13              :             effectiveDotOnly ? 'lg-slot--dot-only' : 'h-5 pr-2',
      14              :             {
      15              :               'lg-slot--connected': props.connected,
      16              :               'lg-slot--compatible': props.compatible,
      17              :               'opacity-40': shouldDim
      18              :             },
      19              :             props.socketless && 'pointer-events-none invisible'
      20              :           )
      21              :         "
      22              :         @pointerenter="revealLinks"
      23              :         @pointerleave="unrevealLinks"
      24              :       >
      25              :         <!-- Connection Dot -->
      26              :         <SlotConnectionDot
      27              :           :slot-key
      28              :           :class="
      29              :             cn(
      30              :               'w-3 -translate-x-1/2',
      31              :               hasError &&
      32              :                 'before:pointer-events-none before:absolute before:size-4 before:rounded-full before:ring-2 before:ring-destructive before:ring-offset-0'
      33              :             )
      34              :           "
      35              :           :slot-data
      36              :           @click="onClick"
      37              :           @dblclick="onDoubleClick"
      38              :           @pointerdown="onPointerDown"
      39              :         />
      40              : 
      41              :         <!-- Slot Name -->
      42              :         <div class="flex h-full min-w-0 items-center">
      43              :           <EditableText
      44              :             v-if="!props.dotOnly && !hasNoLabel"
      45              :             class="min-w-0"
      46              :             :label-class="
      47              :               cn('block truncate', hasError && 'font-medium text-destructive')
      48              :             "
      49              :             :is-editing
      50              :             :model-value="
      51              :               slotData.label ||
      52              :               slotData.localized_name ||
      53              :               (slotData.name ?? `Input ${index}`)
      54              :             "
      55              :             @cancel="isEditing = false"
      56              :             @dblclick="isEditing = true"
      57              :             @edit="onEditLabel"
      58              :           />
      59              :         </div>
      60              :       </div>
      61              :     </TooltipTrigger>
      62              :     <TooltipContent side="left">{{ tooltipText }}</TooltipContent>
      63              :   </Tooltip>
      64              : </template>
      65              : 
      66              : <script setup lang="ts">
      67              : import { computed, onErrorCaptured, ref } from 'vue'
      68              : 
      69              : import EditableText from '@comfyorg/design-system/common/EditableText'
      70              : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
      71              : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
      72              : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
      73              : import { useErrorHandling } from '@/composables/useErrorHandling'
      74              : import type { INodeSlot } from '@/lib/litegraph/src/litegraph'
      75              : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
      76              : import { useSlotLinkDragUIState } from '@/renderer/core/canvas/links/slotLinkDragUIState'
      77              : import { getSlotKey } from '@/renderer/core/layout/slots/slotIdentifier'
      78              : import { useNodeTooltips } from '@/renderer/extensions/vueNodes/composables/useNodeTooltips'
      79              : import { useSlotLinkInteraction } from '@/renderer/extensions/vueNodes/composables/useSlotLinkInteraction'
      80              : import { useSlotLinkReveal } from '@/renderer/extensions/vueNodes/composables/useSlotLinkReveal'
      81              : import { cn } from '@comfyorg/tailwind-utils'
      82              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
      83              : 
      84              : import SlotConnectionDot from './SlotConnectionDot.vue'
      85              : 
      86              : interface InputSlotProps {
      87              :   slotData: INodeSlot
      88              :   compatible?: boolean
      89              :   connected?: boolean
      90              :   dotOnly?: boolean
      91              :   hasError?: boolean
      92              :   index: number
      93              :   nodeType?: string
      94              :   nodeId?: NodeId
      95              :   socketless?: boolean
      96              :   /** The slot is the input's only rendered representation, so the dot carries the accessible name. */
      97              :   standalone?: boolean
      98              : }
      99              : 
     100        25449 : const props = defineProps<InputSlotProps>()
     101              : 
     102        25449 : const hasNoLabel = computed(
     103              :   () =>
     104              :     !props.slotData.label &&
     105              :     !props.slotData.localized_name &&
     106              :     props.slotData.name === ''
     107              : )
     108        25449 : const effectiveDotOnly = computed(() => props.dotOnly || hasNoLabel.value)
     109        25449 : const accessibleName = computed(
     110              :   () =>
     111              :     props.slotData.label ||
     112              :     props.slotData.localized_name ||
     113              :     props.slotData.name ||
     114              :     undefined
     115              : )
     116        25449 : const renderError = ref<string | null>(null)
     117        25449 : const { toastErrorHandler } = useErrorHandling()
     118              : 
     119        25449 : const { getInputSlotTooltip } = useNodeTooltips(props.nodeType || '')
     120        25449 : const tooltipText = computed(() => getInputSlotTooltip(props.slotData))
     121              : 
     122        25449 : const { revealLinks, unrevealLinks } = useSlotLinkReveal({
     123              :   nodeId: props.nodeId,
     124              :   index: props.index,
     125              :   type: 'input'
     126              : })
     127              : 
     128        25449 : onErrorCaptured((error) => {
     129            0 :   unrevealLinks()
     130            0 :   renderError.value = error.message
     131            0 :   toastErrorHandler(error)
     132            0 :   return false
     133              : })
     134              : 
     135        25449 : const { state: dragState } = useSlotLinkDragUIState()
     136        25449 : const slotKey = computed(() =>
     137              :   props.nodeId ? getSlotKey(props.nodeId, props.index, true) : undefined
     138              : )
     139        25449 : const shouldDim = computed(() => {
     140        27108 :   if (!dragState.active) return false
     141         3192 :   if (!slotKey.value) return false
     142          841 :   return !dragState.compatible.get(slotKey.value)
     143              : })
     144              : 
     145        25449 : const { onClick, onDoubleClick, onPointerDown } = useSlotLinkInteraction({
     146              :   nodeId: props.nodeId,
     147              :   index: props.index,
     148              :   type: 'input'
     149              : })
     150              : 
     151        25449 : const isEditing = ref(false)
     152            1 : function onEditLabel(val: string) {
     153            1 :   const canvas = useCanvasStore().getCanvas()
     154            1 :   isEditing.value = false
     155            1 :   if (!props.nodeId) return
     156              : 
     157            1 :   const newLabel = val.trim() || undefined
     158            1 :   const slot = canvas.graph?.getNodeById(props.nodeId)?.inputs?.[props.index]
     159            1 :   if (!slot || slot.label === newLabel) return
     160              : 
     161            1 :   slot.label = newLabel
     162            1 :   canvas.setDirty(true, true)
     163              : }
     164              : </script>
        

Generated by: LCOV version 2.0-1