From c3634c2e3877e36b1df2018da6076d3c2825a67d Mon Sep 17 00:00:00 2001 From: waleed Date: Tue, 20 Jan 2026 15:59:40 -0800 Subject: [PATCH] updated tag dropdown to parse non-operation fields as well --- .../output-select/output-select.tsx | 18 ++++++++--- .../components/tag-dropdown/tag-dropdown.tsx | 24 ++++---------- .../sim/lib/workflows/blocks/block-outputs.ts | 32 ++++++++++++------- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx index 7911b4fab..a8a3730c2 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx @@ -146,10 +146,20 @@ export function OutputSelect({ outputsToProcess = blockConfig?.outputs || {} } } else { - const toolOutputs = - blockConfig && typeof operationValue === 'string' - ? getToolOutputs(blockConfig, operationValue) - : {} + // Build subBlocks object for tool selector + const rawSubBlockValues = + shouldUseBaseline && baselineWorkflow + ? baselineWorkflow.blocks?.[block.id]?.subBlocks + : subBlockValues?.[block.id] + const subBlocks: Record = {} + if (rawSubBlockValues && typeof rawSubBlockValues === 'object') { + for (const [key, val] of Object.entries(rawSubBlockValues)) { + // Handle both { value: ... } and raw value formats + subBlocks[key] = val && typeof val === 'object' && 'value' in val ? val : { value: val } + } + } + + const toolOutputs = blockConfig ? getToolOutputs(blockConfig, subBlocks) : {} outputsToProcess = Object.keys(toolOutputs).length > 0 ? toolOutputs : blockConfig?.outputs || {} } diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx index 220be8091..465d2c079 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx @@ -242,8 +242,10 @@ const getOutputTypeForPath = ( const subBlocks = mergedSubBlocksOverride ?? (blockState?.subBlocks || {}) return getBlockOutputType(block.type, outputPath, subBlocks) } else if (blockConfig) { - const operationValue = getSubBlockValue(blockId, 'operation') - return getToolOutputType(blockConfig, operationValue || '', outputPath) + // Pass full subBlocks to support tool selectors that use any field (operation, provider, etc.) + const blockState = useWorkflowStore.getState().blocks[blockId] + const subBlocks = mergedSubBlocksOverride ?? (blockState?.subBlocks || {}) + return getToolOutputType(blockConfig, subBlocks, outputPath) } return 'any' } @@ -1209,13 +1211,8 @@ export const TagDropdown: React.FC = ({ : allTags } } else { - const operationValue = - mergedSubBlocks?.operation?.value ?? getSubBlockValue(activeSourceBlockId, 'operation') - const toolOutputPaths = getToolOutputPaths( - blockConfig, - operationValue || '', - mergedSubBlocks - ) + // Pass full subBlocks to support tool selectors that use any field (operation, provider, etc.) + const toolOutputPaths = getToolOutputPaths(blockConfig, mergedSubBlocks) if (toolOutputPaths.length > 0) { blockTags = toolOutputPaths.map((path) => `${normalizedBlockName}.${path}`) @@ -1535,7 +1532,6 @@ export const TagDropdown: React.FC = ({ if (dynamicOutputs.length > 0) { const allTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`) - // For self-reference, only show url and resumeEndpoint (not response format fields) blockTags = isSelfReference ? allTags.filter((tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint')) : allTags @@ -1543,13 +1539,7 @@ export const TagDropdown: React.FC = ({ blockTags = [`${normalizedBlockName}.url`, `${normalizedBlockName}.resumeEndpoint`] } } else { - const operationValue = - mergedSubBlocks?.operation?.value ?? getSubBlockValue(accessibleBlockId, 'operation') - const toolOutputPaths = getToolOutputPaths( - blockConfig, - operationValue || '', - mergedSubBlocks - ) + const toolOutputPaths = getToolOutputPaths(blockConfig, mergedSubBlocks) if (toolOutputPaths.length > 0) { blockTags = toolOutputPaths.map((path) => `${normalizedBlockName}.${path}`) diff --git a/apps/sim/lib/workflows/blocks/block-outputs.ts b/apps/sim/lib/workflows/blocks/block-outputs.ts index c914227ab..4dccfcb43 100644 --- a/apps/sim/lib/workflows/blocks/block-outputs.ts +++ b/apps/sim/lib/workflows/blocks/block-outputs.ts @@ -545,14 +545,26 @@ function generateOutputPathsWithTypes( * Gets the tool outputs for a block operation. * * @param blockConfig - The block configuration containing tools config - * @param operation - The selected operation for the tool + * @param subBlocks - SubBlock values to pass to the tool selector * @returns Outputs schema for the tool, or empty object on error */ -export function getToolOutputs(blockConfig: BlockConfig, operation: string): Record { +export function getToolOutputs( + blockConfig: BlockConfig, + subBlocks?: Record +): Record { if (!blockConfig?.tools?.config?.tool) return {} try { - const toolId = blockConfig.tools.config.tool({ operation }) + // Build params object from subBlock values for tool selector + // This allows tool selectors to use any field (operation, provider, etc.) + const params: Record = {} + if (subBlocks) { + for (const [key, subBlock] of Object.entries(subBlocks)) { + params[key] = subBlock.value + } + } + + const toolId = blockConfig.tools.config.tool(params) if (!toolId) return {} const toolConfig = getTool(toolId) @@ -560,7 +572,7 @@ export function getToolOutputs(blockConfig: BlockConfig, operation: string): Rec return toolConfig.outputs } catch (error) { - logger.warn('Failed to get tool outputs for operation', { operation, error }) + logger.warn('Failed to get tool outputs', { error }) return {} } } @@ -569,16 +581,14 @@ export function getToolOutputs(blockConfig: BlockConfig, operation: string): Rec * Generates output paths for a tool-based block. * * @param blockConfig - The block configuration containing tools config - * @param operation - The selected operation for the tool - * @param subBlocks - Optional subBlock values for condition evaluation + * @param subBlocks - SubBlock values for tool selection and condition evaluation * @returns Array of output paths for the tool, or empty array on error */ export function getToolOutputPaths( blockConfig: BlockConfig, - operation: string, subBlocks?: Record ): string[] { - const outputs = getToolOutputs(blockConfig, operation) + const outputs = getToolOutputs(blockConfig, subBlocks) if (!outputs || Object.keys(outputs).length === 0) return [] @@ -613,16 +623,16 @@ export function getOutputPathsFromSchema(outputs: Record): string[] * Gets the output type for a specific path in a tool's outputs. * * @param blockConfig - The block configuration containing tools config - * @param operation - The selected operation for the tool + * @param subBlocks - SubBlock values for tool selection * @param path - The dot-separated path to the output field * @returns The type of the output field, or 'any' if not found */ export function getToolOutputType( blockConfig: BlockConfig, - operation: string, + subBlocks: Record | undefined, path: string ): string { - const outputs = getToolOutputs(blockConfig, operation) + const outputs = getToolOutputs(blockConfig, subBlocks) if (!outputs || Object.keys(outputs).length === 0) return 'any' const pathsWithTypes = generateOutputPathsWithTypes(outputs)