LCOV - code coverage report
Current view: top level - src/composables/node - useProgressTextPreviews.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 24 24
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { useEventListener } from '@vueuse/core'
       2              : 
       3              : import { useNodeProgressText } from '@/composables/node/useNodeProgressText'
       4              : import type { ProgressTextWsMessage } from '@comfyorg/api-client/executionTypes'
       5              : import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
       6              : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
       7              : import { api } from '@/scripts/api'
       8              : import type { QueuedJob } from '@/stores/executionStore'
       9              : import { useExecutionStore } from '@/stores/executionStore'
      10              : import { parseNodeId } from '@comfyorg/graph-model/nodeId'
      11              : 
      12         2355 : export function useProgressTextPreviews() {
      13         2355 :   const executionStore = useExecutionStore()
      14         2355 :   const workflowStore = useWorkflowStore()
      15         2355 :   const canvasStore = useCanvasStore()
      16         2355 :   const { showTextPreview, removeTextPreview } = useNodeProgressText()
      17              : 
      18          239 :   function findNode(currentId: string | undefined) {
      19          239 :     if (!currentId) return
      20          212 :     const nodeId = parseNodeId(currentId)
      21          238 :     if (!nodeId) return
      22          239 :     return canvasStore.canvas?.graph?.getNodeById(nodeId) ?? undefined
      23              :   }
      24              : 
      25           12 :   function handleProgressText(e: CustomEvent<ProgressTextWsMessage>) {
      26           12 :     const { nodeId, text, prompt_id } = e.detail
      27           12 :     if (!text || !nodeId) return
      28              : 
      29           12 :     if (!executionStore.rememberStampAndCheckActiveWorkflow(prompt_id)) return
      30              : 
      31           12 :     const executionId = String(nodeId)
      32              :     const currentId = executionId.includes(':')
      33              :       ? workflowStore.executionIdToCurrentId(executionId)
      34              :       : executionId
      35           12 :     const node = findNode(currentId)
      36           12 :     if (node) showTextPreview(node, text)
      37              :   }
      38              : 
      39           97 :   function clearTextPreviews(job: QueuedJob) {
      40           97 :     if (!job.workflow || job.workflow !== workflowStore.activeWorkflow) return
      41              : 
      42           88 :     for (const executionId of Object.keys(job.nodes)) {
      43          227 :       const node = findNode(workflowStore.executionIdToCurrentId(executionId))
      44          227 :       if (node) removeTextPreview(node)
      45              :     }
      46              :   }
      47              : 
      48         2355 :   useEventListener(api, 'progress_text', handleProgressText)
      49         2355 :   executionStore.onJobReset(clearTextPreviews)
      50              : }
        

Generated by: LCOV version 2.0-1