@@ -56,6 +56,8 @@ interface WorkflowPreviewBlockData {
5656 executionStatus ?: ExecutionStatus
5757 /** Subblock values from the workflow state */
5858 subBlockValues ?: Record < string , SubBlockValueEntry | unknown >
59+ /** Skips expensive subblock computations for thumbnails/template previews */
60+ lightweight ?: boolean
5961}
6062
6163/**
@@ -270,25 +272,29 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
270272 isPreviewSelected = false ,
271273 executionStatus,
272274 subBlockValues,
275+ lightweight = false ,
273276 } = data
274277
275278 const blockConfig = getBlock ( type )
276279
277280 const canonicalIndex = useMemo (
278- ( ) => buildCanonicalIndex ( blockConfig ?. subBlocks || [ ] ) ,
279- [ blockConfig ?. subBlocks ]
281+ ( ) =>
282+ lightweight
283+ ? { groupsById : { } , canonicalIdBySubBlockId : { } }
284+ : buildCanonicalIndex ( blockConfig ?. subBlocks || [ ] ) ,
285+ [ blockConfig ?. subBlocks , lightweight ]
280286 )
281287
282288 const rawValues = useMemo ( ( ) => {
283- if ( ! subBlockValues ) return { }
289+ if ( lightweight || ! subBlockValues ) return { }
284290 return Object . entries ( subBlockValues ) . reduce < Record < string , unknown > > ( ( acc , [ key , entry ] ) => {
285291 acc [ key ] = extractValue ( entry )
286292 return acc
287293 } , { } )
288- } , [ subBlockValues ] )
294+ } , [ subBlockValues , lightweight ] )
289295
290296 const visibleSubBlocks = useMemo ( ( ) => {
291- if ( ! blockConfig ?. subBlocks ) return [ ]
297+ if ( lightweight || ! blockConfig ?. subBlocks ) return [ ]
292298
293299 const isStarterOrTrigger =
294300 blockConfig . category === 'triggers' || type === 'starter' || isTrigger
@@ -304,13 +310,21 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
304310 if ( ! subBlock . condition ) return true
305311 return evaluateSubBlockCondition ( subBlock . condition , rawValues )
306312 } )
307- } , [ blockConfig ?. subBlocks , blockConfig ?. category , type , isTrigger , canonicalIndex , rawValues ] )
313+ } , [
314+ blockConfig ?. subBlocks ,
315+ blockConfig ?. category ,
316+ type ,
317+ isTrigger ,
318+ canonicalIndex ,
319+ rawValues ,
320+ lightweight ,
321+ ] )
308322
309323 /**
310324 * Compute condition rows for condition blocks
311325 */
312326 const conditionRows = useMemo ( ( ) => {
313- if ( type !== 'condition' ) return [ ]
327+ if ( lightweight || type !== 'condition' ) return [ ]
314328
315329 const conditionsValue = rawValues . conditions
316330 const raw = typeof conditionsValue === 'string' ? conditionsValue : undefined
@@ -338,13 +352,13 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
338352 { id : 'if' , title : 'if' , value : '' } ,
339353 { id : 'else' , title : 'else' , value : '' } ,
340354 ]
341- } , [ type , rawValues ] )
355+ } , [ type , rawValues , lightweight ] )
342356
343357 /**
344358 * Compute router rows for router_v2 blocks
345359 */
346360 const routerRows = useMemo ( ( ) => {
347- if ( type !== 'router_v2' ) return [ ]
361+ if ( lightweight || type !== 'router_v2' ) return [ ]
348362
349363 const routesValue = rawValues . routes
350364 const raw = typeof routesValue === 'string' ? routesValue : undefined
@@ -367,7 +381,7 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
367381 }
368382
369383 return [ { id : 'route1' , value : '' } ]
370- } , [ type , rawValues ] )
384+ } , [ type , rawValues , lightweight ] )
371385
372386 if ( ! blockConfig ) {
373387 return null
@@ -582,11 +596,15 @@ function shouldSkipPreviewBlockRender(
582596 prevProps . data . horizontalHandles !== nextProps . data . horizontalHandles ||
583597 prevProps . data . enabled !== nextProps . data . enabled ||
584598 prevProps . data . isPreviewSelected !== nextProps . data . isPreviewSelected ||
585- prevProps . data . executionStatus !== nextProps . data . executionStatus
599+ prevProps . data . executionStatus !== nextProps . data . executionStatus ||
600+ prevProps . data . lightweight !== nextProps . data . lightweight
586601 ) {
587602 return false
588603 }
589604
605+ /** Skip subBlockValues comparison in lightweight mode */
606+ if ( nextProps . data . lightweight ) return true
607+
590608 const prevValues = prevProps . data . subBlockValues
591609 const nextValues = nextProps . data . subBlockValues
592610
0 commit comments