@@ -278,11 +278,8 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
278278 const blockConfig = getBlock ( type )
279279
280280 const canonicalIndex = useMemo (
281- ( ) =>
282- lightweight
283- ? { groupsById : { } , canonicalIdBySubBlockId : { } }
284- : buildCanonicalIndex ( blockConfig ?. subBlocks || [ ] ) ,
285- [ blockConfig ?. subBlocks , lightweight ]
281+ ( ) => buildCanonicalIndex ( blockConfig ?. subBlocks || [ ] ) ,
282+ [ blockConfig ?. subBlocks ]
286283 )
287284
288285 const rawValues = useMemo ( ( ) => {
@@ -294,37 +291,59 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
294291 } , [ subBlockValues , lightweight ] )
295292
296293 const visibleSubBlocks = useMemo ( ( ) => {
297- if ( lightweight || ! blockConfig ?. subBlocks ) return [ ]
294+ if ( ! blockConfig ?. subBlocks ) return [ ]
298295
299- const isStarterOrTrigger =
300- blockConfig . category === 'triggers' || type === 'starter' || isTrigger
296+ const isPureTriggerBlock = blockConfig . triggers ?. enabled && blockConfig . category === 'triggers'
297+ const effectiveTrigger = isTrigger || type === 'starter'
301298
302299 return blockConfig . subBlocks . filter ( ( subBlock ) => {
303300 if ( subBlock . hidden ) return false
304301 if ( subBlock . hideFromPreview ) return false
305302 if ( ! isSubBlockFeatureEnabled ( subBlock ) ) return false
306- if ( subBlock . mode === 'trigger' && ! isStarterOrTrigger ) return false
303+
304+ if ( effectiveTrigger ) {
305+ const isValidTriggerSubblock = isPureTriggerBlock
306+ ? subBlock . mode === 'trigger' || ! subBlock . mode
307+ : subBlock . mode === 'trigger'
308+ if ( ! isValidTriggerSubblock ) return false
309+ } else {
310+ if ( subBlock . mode === 'trigger' ) return false
311+ }
312+
313+ /** Skip value-dependent visibility checks in lightweight mode */
314+ if ( lightweight ) return ! subBlock . condition
315+
307316 if ( ! isSubBlockVisibleForMode ( subBlock , false , canonicalIndex , rawValues , undefined ) ) {
308317 return false
309318 }
310319 if ( ! subBlock . condition ) return true
311320 return evaluateSubBlockCondition ( subBlock . condition , rawValues )
312321 } )
313322 } , [
323+ lightweight ,
314324 blockConfig ?. subBlocks ,
325+ blockConfig ?. triggers ?. enabled ,
315326 blockConfig ?. category ,
316327 type ,
317328 isTrigger ,
318329 canonicalIndex ,
319330 rawValues ,
320- lightweight ,
321331 ] )
322332
323333 /**
324- * Compute condition rows for condition blocks
334+ * Compute condition rows for condition blocks.
335+ * In lightweight mode, returns default structure without parsing values.
325336 */
326337 const conditionRows = useMemo ( ( ) => {
327- if ( lightweight || type !== 'condition' ) return [ ]
338+ if ( type !== 'condition' ) return [ ]
339+
340+ /** Default structure for lightweight mode or when no values */
341+ const defaultRows = [
342+ { id : 'if' , title : 'if' , value : '' } ,
343+ { id : 'else' , title : 'else' , value : '' } ,
344+ ]
345+
346+ if ( lightweight ) return defaultRows
328347
329348 const conditionsValue = rawValues . conditions
330349 const raw = typeof conditionsValue === 'string' ? conditionsValue : undefined
@@ -348,17 +367,20 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
348367 /* empty */
349368 }
350369
351- return [
352- { id : 'if' , title : 'if' , value : '' } ,
353- { id : 'else' , title : 'else' , value : '' } ,
354- ]
370+ return defaultRows
355371 } , [ type , rawValues , lightweight ] )
356372
357373 /**
358- * Compute router rows for router_v2 blocks
374+ * Compute router rows for router_v2 blocks.
375+ * In lightweight mode, returns default structure without parsing values.
359376 */
360377 const routerRows = useMemo ( ( ) => {
361- if ( lightweight || type !== 'router_v2' ) return [ ]
378+ if ( type !== 'router_v2' ) return [ ]
379+
380+ /** Default structure for lightweight mode or when no values */
381+ const defaultRows = [ { id : 'route1' , value : '' } ]
382+
383+ if ( lightweight ) return defaultRows
362384
363385 const routesValue = rawValues . routes
364386 const raw = typeof routesValue === 'string' ? routesValue : undefined
@@ -380,7 +402,7 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
380402 /* empty */
381403 }
382404
383- return [ { id : 'route1' , value : '' } ]
405+ return defaultRows
384406 } , [ type , rawValues , lightweight ] )
385407
386408 if ( ! blockConfig ) {
@@ -457,32 +479,36 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
457479 < div className = 'flex flex-col gap-[8px] p-[8px]' >
458480 { type === 'condition' ? (
459481 conditionRows . map ( ( cond ) => (
460- < SubBlockRow key = { cond . id } title = { cond . title } value = { getDisplayValue ( cond . value ) } />
482+ < SubBlockRow
483+ key = { cond . id }
484+ title = { cond . title }
485+ value = { lightweight ? undefined : getDisplayValue ( cond . value ) }
486+ />
461487 ) )
462488 ) : type === 'router_v2' ? (
463489 < >
464490 < SubBlockRow
465491 key = 'context'
466492 title = 'Context'
467- value = { getDisplayValue ( rawValues . context ) }
493+ value = { lightweight ? undefined : getDisplayValue ( rawValues . context ) }
468494 />
469495 { routerRows . map ( ( route , index ) => (
470496 < SubBlockRow
471497 key = { route . id }
472498 title = { `Route ${ index + 1 } ` }
473- value = { getDisplayValue ( route . value ) }
499+ value = { lightweight ? undefined : getDisplayValue ( route . value ) }
474500 />
475501 ) ) }
476502 </ >
477503 ) : (
478504 visibleSubBlocks . map ( ( subBlock ) => {
479- const rawValue = rawValues [ subBlock . id ]
505+ const rawValue = lightweight ? undefined : rawValues [ subBlock . id ]
480506 return (
481507 < SubBlockRow
482508 key = { subBlock . id }
483509 title = { subBlock . title ?? subBlock . id }
484- value = { getDisplayValue ( rawValue ) }
485- subBlock = { subBlock }
510+ value = { lightweight ? undefined : getDisplayValue ( rawValue ) }
511+ subBlock = { lightweight ? undefined : subBlock }
486512 rawValue = { rawValue }
487513 />
488514 )
0 commit comments