LCOV - code coverage report
Current view: top level - src/renderer/core/thumbnail - graphThumbnailRenderer.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 94.4 % 18 17
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { LGraph } from '@/lib/litegraph/src/litegraph'
       2              : import {
       3              :   calculateMinimapScale,
       4              :   calculateNodeBounds
       5              : } from '@/renderer/core/spatial/boundsCalculator'
       6              : 
       7              : import { renderMinimapToCanvas } from '@/renderer/extensions/minimap/minimapCanvasRenderer'
       8              : 
       9              : /**
      10              :  * Render a graph to a thumbnail data URL.
      11              :  * Used by workflow thumbnail generation.
      12              :  */
      13         1548 : export function createGraphThumbnail(
      14              :   graph: LGraph | null | undefined
      15              : ): string | null {
      16         1548 :   if (!graph || graph._nodes.length === 0) {
      17          147 :     return null
      18              :   }
      19              : 
      20         1401 :   const width = 250
      21         1401 :   const height = 200
      22              : 
      23              :   // Calculate bounds using spatial calculator
      24         1401 :   const bounds = calculateNodeBounds(graph._nodes)
      25         1536 :   if (!bounds) {
      26            0 :     return null
      27              :   }
      28              : 
      29         1401 :   const scale = calculateMinimapScale(bounds, width, height)
      30              : 
      31              :   // Create detached canvas
      32         1401 :   const canvas = document.createElement('canvas')
      33         1401 :   canvas.width = width
      34         1401 :   canvas.height = height
      35              : 
      36              :   // Render the minimap
      37         1401 :   renderMinimapToCanvas(canvas, graph, {
      38              :     bounds,
      39              :     scale,
      40              :     settings: {
      41              :       nodeColors: true,
      42              :       showLinks: false,
      43              :       showGroups: true,
      44              :       renderBypass: false,
      45              :       renderError: false
      46              :     },
      47              :     width,
      48              :     height
      49              :   })
      50              : 
      51         1401 :   const dataUrl = canvas.toDataURL()
      52              : 
      53              :   // Explicit cleanup (optional but good practice)
      54         1401 :   const ctx = canvas.getContext('2d')
      55         1401 :   if (ctx) {
      56         1401 :     ctx.clearRect(0, 0, width, height)
      57              :   }
      58              : 
      59         1401 :   return dataUrl
      60              : }
        

Generated by: LCOV version 2.0-1