@@ -6,6 +6,7 @@ import { Variable } from '@/stores/panel/variables/types'
66import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
77import { useSubBlockStore } from '@/stores/workflows/subblock/store'
88import { useWorkflowStore } from '@/stores/workflows/workflow/store'
9+ import { ConnectedBlock , useBlockConnections } from '@/app/w/[id]/hooks/use-block-connections'
910import { getBlock } from '@/blocks'
1011
1112const logger = createLogger ( 'TagDropdown' )
@@ -88,6 +89,9 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
8889 const variables = useVariablesStore ( ( state ) => state . variables )
8990 const workflowVariables = workflowId ? getVariablesByWorkflowId ( workflowId ) : [ ]
9091
92+ // Get all connected blocks using useBlockConnections
93+ const { incomingConnections } = useBlockConnections ( blockId )
94+
9195 // Load variables when workflowId changes
9296 useEffect ( ( ) => {
9397 if ( workflowId ) {
@@ -207,42 +211,25 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
207211 }
208212 }
209213
210- // Otherwise, show tags from all incoming connections
211- const sourceEdges = edges . filter ( ( edge ) => edge . target === blockId )
212- const sourceTags = sourceEdges . flatMap ( ( edge ) => {
213- const sourceBlock = blocks [ edge . source ]
214- if ( ! sourceBlock ) return [ ]
215-
216- const blockName = sourceBlock . name || sourceBlock . type
214+ // Use all incoming connections instead of just direct edges
215+ const sourceTags = incomingConnections . flatMap ( ( connection : ConnectedBlock ) => {
216+ const blockName = connection . name || connection . type
217217 const normalizedBlockName = blockName . replace ( / \s + / g, '' ) . toLowerCase ( )
218218
219- // Check for response format first
220- try {
221- const responseFormatValue = useSubBlockStore
222- . getState ( )
223- . getValue ( edge . source , 'responseFormat' )
224- if ( responseFormatValue ) {
225- const responseFormat =
226- typeof responseFormatValue === 'string'
227- ? JSON . parse ( responseFormatValue )
228- : responseFormatValue
229-
230- if ( responseFormat ) {
231- const fields = extractFieldsFromSchema ( responseFormat )
232- if ( fields . length > 0 ) {
233- return fields . map ( ( field : Field ) => `${ normalizedBlockName } .response.${ field . name } ` )
234- }
235- }
219+ // Extract fields from response format
220+ if ( connection . responseFormat ) {
221+ const fields = extractFieldsFromSchema ( connection . responseFormat )
222+ if ( fields . length > 0 ) {
223+ return fields . map ( ( field : Field ) => `${ normalizedBlockName } .response.${ field . name } ` )
236224 }
237- } catch ( e ) {
238- logger . error ( 'Error parsing response format:' , { e } )
239225 }
240226
241- if ( sourceBlock . type === 'evaluator' ) {
227+ // For evaluator blocks, use metrics
228+ if ( connection . type === 'evaluator' ) {
242229 try {
243230 const metricsValue = useSubBlockStore
244231 . getState ( )
245- . getValue ( edge . source , 'metrics' ) as unknown as Metric [ ]
232+ . getValue ( connection . id , 'metrics' ) as unknown as Metric [ ]
246233 if ( Array . isArray ( metricsValue ) ) {
247234 return metricsValue . map (
248235 ( metric ) => `${ normalizedBlockName } .response.${ metric . name . toLowerCase ( ) } `
@@ -255,12 +242,15 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
255242 }
256243
257244 // Fall back to default outputs if no response format
245+ const sourceBlock = blocks [ connection . id ]
246+ if ( ! sourceBlock ) return [ ]
247+
258248 const outputPaths = getOutputPaths ( sourceBlock . outputs , '' , sourceBlock . type === 'starter' )
259249 return outputPaths . map ( ( path ) => `${ normalizedBlockName } .${ path } ` )
260250 } )
261251
262252 return { tags : [ ...variableTags , ...sourceTags ] , variableInfoMap }
263- } , [ blocks , edges , blockId , activeSourceBlockId , workflowVariables ] )
253+ } , [ blocks , incomingConnections , blockId , activeSourceBlockId , workflowVariables ] )
264254
265255 // Filter tags based on search term
266256 const filteredTags = useMemo ( ( ) => {
0 commit comments