LCOV - code coverage report
Current view: top level - src/platform/customNodes/manager/composables/nodePack - usePacksStatus.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 35.7 % 14 5
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { computed } from 'vue'
       2              : import type { Ref } from 'vue'
       3              : 
       4              : import type { components } from '@/types/comfyRegistryTypes'
       5              : import { useConflictDetectionStore } from '@/platform/customNodes/manager/stores/conflictDetectionStore'
       6              : 
       7              : type NodePack = components['schemas']['Node']
       8              : type NodeStatus = components['schemas']['NodeStatus']
       9              : type NodeVersionStatus = components['schemas']['NodeVersionStatus']
      10              : 
      11         2355 : const STATUS_PRIORITY = [
      12              :   'NodeStatusBanned',
      13              :   'NodeVersionStatusBanned',
      14              :   'NodeStatusDeleted',
      15              :   'NodeVersionStatusDeleted',
      16              :   'NodeVersionStatusFlagged',
      17              :   'NodeVersionStatusPending',
      18              :   'NodeStatusActive',
      19              :   'NodeVersionStatusActive'
      20              : ] as const
      21              : 
      22              : /**
      23              :  * Composable for managing package status with priority
      24              :  * Handles import failures and determines the most important status
      25              :  */
      26           15 : export function usePacksStatus(nodePacks: Ref<NodePack[]>) {
      27           15 :   const conflictDetectionStore = useConflictDetectionStore()
      28              : 
      29           15 :   const hasImportFailed = computed(() => {
      30            0 :     return nodePacks.value.some((pack) => {
      31            0 :       if (!pack.id) return false
      32              :       const conflicts = conflictDetectionStore.getConflictsForPackageByID(
      33              :         pack.id
      34              :       )
      35            0 :       return (
      36              :         conflicts?.conflicts.some((c) => c.type === 'import_failed') || false
      37              :       )
      38              :     })
      39              :   })
      40              : 
      41              :   const overallStatus = computed<NodeStatus | NodeVersionStatus>(() => {
      42              :     // Check for import failed first (highest priority for installed packages)
      43            0 :     if (hasImportFailed.value) {
      44              :       // Import failed doesn't have a specific status enum, so we return active
      45              :       // but the PackStatusMessage will handle it via hasImportFailed prop
      46            0 :       return 'NodeVersionStatusActive'
      47              :     }
      48              : 
      49              :     // Find the highest priority status from all packages
      50            0 :     for (const priorityStatus of STATUS_PRIORITY) {
      51            0 :       if (nodePacks.value.some((pack) => pack.status === priorityStatus)) {
      52            0 :         return priorityStatus
      53              :       }
      54              :     }
      55              : 
      56              :     // Default to active if no specific status found
      57            0 :     return 'NodeVersionStatusActive'
      58              :   })
      59              : 
      60           15 :   return {
      61              :     hasImportFailed,
      62              :     overallStatus
      63              :   }
      64              : }
        

Generated by: LCOV version 2.0-1