@@ -4,11 +4,8 @@ import type React from 'react'
44import { useMemo } from 'react'
55import { RepeatIcon , SplitIcon } from 'lucide-react'
66import { Combobox , type ComboboxOptionGroup } from '@/components/emcn'
7- import {
8- extractFieldsFromSchema ,
9- parseResponseFormatSafely ,
10- } from '@/lib/core/utils/response-format'
11- import { getToolOutputs } from '@/lib/workflows/blocks/block-outputs'
7+ import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
8+ import { hasTriggerCapability } from '@/lib/workflows/triggers/trigger-utils'
129import { getBlock } from '@/blocks'
1310import { useWorkflowDiffStore } from '@/stores/workflow-diff/store'
1411import { useSubBlockStore } from '@/stores/workflows/subblock/store'
@@ -124,42 +121,27 @@ export function OutputSelect({
124121 : `block-${ block . id } `
125122
126123 const blockConfig = getBlock ( block . type )
127- const responseFormatValue =
128- shouldUseBaseline && baselineWorkflow
129- ? baselineWorkflow . blocks ?. [ block . id ] ?. subBlocks ?. responseFormat ?. value
130- : subBlockValues ?. [ block . id ] ?. responseFormat
131- const responseFormat = parseResponseFormatSafely ( responseFormatValue , block . id )
124+ const isTriggerCapable = blockConfig ? hasTriggerCapability ( blockConfig ) : false
125+ const effectiveTriggerMode = Boolean ( block . triggerMode && isTriggerCapable )
132126
133127 let outputsToProcess : Record < string , unknown > = { }
134-
135- if ( responseFormat ) {
136- const schemaFields = extractFieldsFromSchema ( responseFormat )
137- if ( schemaFields . length > 0 ) {
138- schemaFields . forEach ( ( field ) => {
139- outputsToProcess [ field . name ] = { type : field . type }
140- } )
141- } else {
142- outputsToProcess = blockConfig ?. outputs || { }
143- }
144- } else {
145- // Build subBlocks object for tool selector
146- const rawSubBlockValues =
147- shouldUseBaseline && baselineWorkflow
148- ? baselineWorkflow . blocks ?. [ block . id ] ?. subBlocks
149- : subBlockValues ?. [ block . id ]
150- const subBlocks : Record < string , { value : unknown } > = { }
151- if ( rawSubBlockValues && typeof rawSubBlockValues === 'object' ) {
152- for ( const [ key , val ] of Object . entries ( rawSubBlockValues ) ) {
153- // Handle both { value: ... } and raw value formats
154- subBlocks [ key ] = val && typeof val === 'object' && 'value' in val ? val : { value : val }
155- }
128+ const rawSubBlockValues =
129+ shouldUseBaseline && baselineWorkflow
130+ ? baselineWorkflow . blocks ?. [ block . id ] ?. subBlocks
131+ : subBlockValues ?. [ block . id ]
132+ const subBlocks : Record < string , { value : unknown } > = { }
133+ if ( rawSubBlockValues && typeof rawSubBlockValues === 'object' ) {
134+ for ( const [ key , val ] of Object . entries ( rawSubBlockValues ) ) {
135+ // Handle both { value: ... } and raw value formats
136+ subBlocks [ key ] = val && typeof val === 'object' && 'value' in val ? val : { value : val }
156137 }
157-
158- const toolOutputs = blockConfig ? getToolOutputs ( blockConfig , subBlocks ) : { }
159- outputsToProcess =
160- Object . keys ( toolOutputs ) . length > 0 ? toolOutputs : blockConfig ?. outputs || { }
161138 }
162139
140+ outputsToProcess = getEffectiveBlockOutputs ( block . type , subBlocks , {
141+ triggerMode : effectiveTriggerMode ,
142+ preferToolOutputs : ! effectiveTriggerMode ,
143+ } ) as Record < string , unknown >
144+
163145 if ( Object . keys ( outputsToProcess ) . length === 0 ) return
164146
165147 const addOutput = ( path : string , outputObj : unknown , prefix = '' ) => {
0 commit comments