Skip to content

Commit c3634c2

Browse files
committed
updated tag dropdown to parse non-operation fields as well
1 parent 51ed4f5 commit c3634c2

File tree

3 files changed

+42
-32
lines changed

3 files changed

+42
-32
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,20 @@ export function OutputSelect({
146146
outputsToProcess = blockConfig?.outputs || {}
147147
}
148148
} else {
149-
const toolOutputs =
150-
blockConfig && typeof operationValue === 'string'
151-
? getToolOutputs(blockConfig, operationValue)
152-
: {}
149+
// Build subBlocks object for tool selector
150+
const rawSubBlockValues =
151+
shouldUseBaseline && baselineWorkflow
152+
? baselineWorkflow.blocks?.[block.id]?.subBlocks
153+
: subBlockValues?.[block.id]
154+
const subBlocks: Record<string, { value: unknown }> = {}
155+
if (rawSubBlockValues && typeof rawSubBlockValues === 'object') {
156+
for (const [key, val] of Object.entries(rawSubBlockValues)) {
157+
// Handle both { value: ... } and raw value formats
158+
subBlocks[key] = val && typeof val === 'object' && 'value' in val ? val : { value: val }
159+
}
160+
}
161+
162+
const toolOutputs = blockConfig ? getToolOutputs(blockConfig, subBlocks) : {}
153163
outputsToProcess =
154164
Object.keys(toolOutputs).length > 0 ? toolOutputs : blockConfig?.outputs || {}
155165
}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ const getOutputTypeForPath = (
242242
const subBlocks = mergedSubBlocksOverride ?? (blockState?.subBlocks || {})
243243
return getBlockOutputType(block.type, outputPath, subBlocks)
244244
} else if (blockConfig) {
245-
const operationValue = getSubBlockValue(blockId, 'operation')
246-
return getToolOutputType(blockConfig, operationValue || '', outputPath)
245+
// Pass full subBlocks to support tool selectors that use any field (operation, provider, etc.)
246+
const blockState = useWorkflowStore.getState().blocks[blockId]
247+
const subBlocks = mergedSubBlocksOverride ?? (blockState?.subBlocks || {})
248+
return getToolOutputType(blockConfig, subBlocks, outputPath)
247249
}
248250
return 'any'
249251
}
@@ -1209,13 +1211,8 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
12091211
: allTags
12101212
}
12111213
} else {
1212-
const operationValue =
1213-
mergedSubBlocks?.operation?.value ?? getSubBlockValue(activeSourceBlockId, 'operation')
1214-
const toolOutputPaths = getToolOutputPaths(
1215-
blockConfig,
1216-
operationValue || '',
1217-
mergedSubBlocks
1218-
)
1214+
// Pass full subBlocks to support tool selectors that use any field (operation, provider, etc.)
1215+
const toolOutputPaths = getToolOutputPaths(blockConfig, mergedSubBlocks)
12191216

12201217
if (toolOutputPaths.length > 0) {
12211218
blockTags = toolOutputPaths.map((path) => `${normalizedBlockName}.${path}`)
@@ -1535,21 +1532,14 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
15351532

15361533
if (dynamicOutputs.length > 0) {
15371534
const allTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
1538-
// For self-reference, only show url and resumeEndpoint (not response format fields)
15391535
blockTags = isSelfReference
15401536
? allTags.filter((tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint'))
15411537
: allTags
15421538
} else {
15431539
blockTags = [`${normalizedBlockName}.url`, `${normalizedBlockName}.resumeEndpoint`]
15441540
}
15451541
} else {
1546-
const operationValue =
1547-
mergedSubBlocks?.operation?.value ?? getSubBlockValue(accessibleBlockId, 'operation')
1548-
const toolOutputPaths = getToolOutputPaths(
1549-
blockConfig,
1550-
operationValue || '',
1551-
mergedSubBlocks
1552-
)
1542+
const toolOutputPaths = getToolOutputPaths(blockConfig, mergedSubBlocks)
15531543

15541544
if (toolOutputPaths.length > 0) {
15551545
blockTags = toolOutputPaths.map((path) => `${normalizedBlockName}.${path}`)

apps/sim/lib/workflows/blocks/block-outputs.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,22 +545,34 @@ function generateOutputPathsWithTypes(
545545
* Gets the tool outputs for a block operation.
546546
*
547547
* @param blockConfig - The block configuration containing tools config
548-
* @param operation - The selected operation for the tool
548+
* @param subBlocks - SubBlock values to pass to the tool selector
549549
* @returns Outputs schema for the tool, or empty object on error
550550
*/
551-
export function getToolOutputs(blockConfig: BlockConfig, operation: string): Record<string, any> {
551+
export function getToolOutputs(
552+
blockConfig: BlockConfig,
553+
subBlocks?: Record<string, SubBlockWithValue>
554+
): Record<string, any> {
552555
if (!blockConfig?.tools?.config?.tool) return {}
553556

554557
try {
555-
const toolId = blockConfig.tools.config.tool({ operation })
558+
// Build params object from subBlock values for tool selector
559+
// This allows tool selectors to use any field (operation, provider, etc.)
560+
const params: Record<string, any> = {}
561+
if (subBlocks) {
562+
for (const [key, subBlock] of Object.entries(subBlocks)) {
563+
params[key] = subBlock.value
564+
}
565+
}
566+
567+
const toolId = blockConfig.tools.config.tool(params)
556568
if (!toolId) return {}
557569

558570
const toolConfig = getTool(toolId)
559571
if (!toolConfig?.outputs) return {}
560572

561573
return toolConfig.outputs
562574
} catch (error) {
563-
logger.warn('Failed to get tool outputs for operation', { operation, error })
575+
logger.warn('Failed to get tool outputs', { error })
564576
return {}
565577
}
566578
}
@@ -569,16 +581,14 @@ export function getToolOutputs(blockConfig: BlockConfig, operation: string): Rec
569581
* Generates output paths for a tool-based block.
570582
*
571583
* @param blockConfig - The block configuration containing tools config
572-
* @param operation - The selected operation for the tool
573-
* @param subBlocks - Optional subBlock values for condition evaluation
584+
* @param subBlocks - SubBlock values for tool selection and condition evaluation
574585
* @returns Array of output paths for the tool, or empty array on error
575586
*/
576587
export function getToolOutputPaths(
577588
blockConfig: BlockConfig,
578-
operation: string,
579589
subBlocks?: Record<string, SubBlockWithValue>
580590
): string[] {
581-
const outputs = getToolOutputs(blockConfig, operation)
591+
const outputs = getToolOutputs(blockConfig, subBlocks)
582592

583593
if (!outputs || Object.keys(outputs).length === 0) return []
584594

@@ -613,16 +623,16 @@ export function getOutputPathsFromSchema(outputs: Record<string, any>): string[]
613623
* Gets the output type for a specific path in a tool's outputs.
614624
*
615625
* @param blockConfig - The block configuration containing tools config
616-
* @param operation - The selected operation for the tool
626+
* @param subBlocks - SubBlock values for tool selection
617627
* @param path - The dot-separated path to the output field
618628
* @returns The type of the output field, or 'any' if not found
619629
*/
620630
export function getToolOutputType(
621631
blockConfig: BlockConfig,
622-
operation: string,
632+
subBlocks: Record<string, SubBlockWithValue> | undefined,
623633
path: string
624634
): string {
625-
const outputs = getToolOutputs(blockConfig, operation)
635+
const outputs = getToolOutputs(blockConfig, subBlocks)
626636
if (!outputs || Object.keys(outputs).length === 0) return 'any'
627637

628638
const pathsWithTypes = generateOutputPathsWithTypes(outputs)

0 commit comments

Comments
 (0)