Skip to content

Commit 6c81c7f

Browse files
committed
fix(greenhouse): clear incompatible operation inputs
1 parent 5038a3a commit 6c81c7f

4 files changed

Lines changed: 57 additions & 15 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tools/sub-block-renderer.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ToolSubBlockRendererProps {
2323
/** The tool's block type (e.g. `gmail`), so its params' selectors resolve dependencies. */
2424
toolType: string
2525
toolParams: Record<string, string> | undefined
26+
operation?: string
2627
onParamChange: (toolIndex: number, paramId: string, value: string) => void
2728
disabled: boolean
2829
canonicalToggle?: {
@@ -44,6 +45,7 @@ export function ToolSubBlockRenderer({
4445
effectiveParamId,
4546
toolType,
4647
toolParams,
48+
operation,
4749
onParamChange,
4850
disabled,
4951
canonicalToggle,
@@ -128,7 +130,7 @@ export function ToolSubBlockRenderer({
128130
isPreview={false}
129131
disabled={disabled}
130132
canonicalToggle={canonicalToggle}
131-
dependencyContext={toolParams}
133+
dependencyContext={{ ...toolParams, operation }}
132134
/>
133135
</DependencyBlockTypeProvider>
134136
)

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/param-dependents.ts‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,32 @@ export function getParamsForToolOperation(
3737
.filter(([, param]) => isUserFacingToolParam(param))
3838
.map(([paramId]) => paramId)
3939
)
40+
const subBlocks = getBlock(tool.type)?.subBlocks ?? []
41+
if (nextTool.oauth) {
42+
const credentialControls = subBlocks.filter(
43+
(subBlock) =>
44+
subBlock.type === 'oauth-input' && subBlock.serviceId === nextTool.oauth?.provider
45+
)
46+
const credentialCanonicalIds = new Set(
47+
credentialControls.flatMap((subBlock) =>
48+
subBlock.canonicalParamId ? [subBlock.canonicalParamId] : []
49+
)
50+
)
51+
for (const subBlock of subBlocks) {
52+
if (
53+
credentialControls.includes(subBlock) ||
54+
(subBlock.canonicalParamId &&
55+
credentialCanonicalIds.has(subBlock.canonicalParamId) &&
56+
(!subBlock.serviceId || subBlock.serviceId === nextTool.oauth.provider))
57+
) {
58+
newParamIds.add(subBlock.id)
59+
if (subBlock.canonicalParamId) newParamIds.add(subBlock.canonicalParamId)
60+
}
61+
}
62+
}
4063
const preservedParams: Record<string, string> = {}
4164
Object.entries(tool.params || {}).forEach(([paramId, value]) => {
4265
if (newParamIds.has(paramId) && value) preservedParams[paramId] = value
4366
})
44-
return preservedParams
67+
return clearDependentToolParams(tool.type, preservedParams, 'operation')
4568
}

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,9 +1520,18 @@ export const ToolInput = memo(function ToolInput({
15201520
? (toolBlocks.find((block) => block.type === tool.type) ?? getBlock(tool.type))
15211521
: null
15221522

1523+
const hasOperations =
1524+
!isCustomTool && !isMcpFamily && hasMultipleOperations(toolBlock ?? undefined)
1525+
const operationChoices = hasOperations
1526+
? getOperationChoices(toolBlock ?? undefined)
1527+
: null
1528+
const selectedOperation =
1529+
tool.operation ||
1530+
operationChoices?.options.find((option) => !operationChoices.denied.has(option.id))?.id
1531+
15231532
const currentToolId =
15241533
!isCustomTool && !isMcpFamily
1525-
? getToolIdForOperation(tool.type, tool.operation, toolBlock ?? undefined) ||
1534+
? getToolIdForOperation(tool.type, selectedOperation, toolBlock ?? undefined) ||
15261535
tool.toolId ||
15271536
''
15281537
: tool.toolId || ''
@@ -1546,8 +1555,8 @@ export const ToolInput = memo(function ToolInput({
15461555
currentToolId,
15471556
tool.type,
15481557
{
1549-
operation: tool.operation,
15501558
...tool.params,
1559+
operation: selectedOperation,
15511560
},
15521561
toolScopedOverrides,
15531562
toolBlock ?? undefined
@@ -1600,8 +1609,6 @@ export const ToolInput = memo(function ToolInput({
16001609
toolCredential?.type === sb.reactiveCondition.requiredType
16011610
)
16021611

1603-
const hasOperations =
1604-
!isCustomTool && !isMcpFamily && hasMultipleOperations(toolBlock ?? undefined)
16051612
const showToolControl = supportsToolControl && !(isMcpTool && isMcpToolUnavailable(tool))
16061613
const hasToolBody = showToolControl || hasOperations || displaySubBlocks.length > 0
16071614

@@ -1860,10 +1867,8 @@ export const ToolInput = memo(function ToolInput({
18601867
)}
18611868
{/* Operation dropdown for tools with multiple operations */}
18621869
{(() => {
1863-
if (!hasOperations) return null
1864-
const { options: operationOptions, denied } = getOperationChoices(
1865-
toolBlock ?? undefined
1866-
)
1870+
if (!operationChoices) return null
1871+
const { options: operationOptions, denied } = operationChoices
18671872
if (operationOptions.length === 0) return null
18681873

18691874
return (
@@ -1875,10 +1880,7 @@ export const ToolInput = memo(function ToolInput({
18751880
value: option.id,
18761881
hidden: denied.has(option.id),
18771882
}))}
1878-
value={
1879-
tool.operation ||
1880-
operationOptions.find((option) => !denied.has(option.id))?.id
1881-
}
1883+
value={selectedOperation}
18821884
onChange={(value) => handleOperationChange(toolIndex, value)}
18831885
placeholder='Select operation'
18841886
/* Denied operations only drop out once the config
@@ -1903,7 +1905,7 @@ export const ToolInput = memo(function ToolInput({
19031905
canonicalGroup && hasCanonicalPair
19041906
? resolveCanonicalMode(
19051907
canonicalGroup,
1906-
{ operation: tool.operation, ...tool.params },
1908+
{ ...tool.params, operation: selectedOperation },
19071909
toolScopedOverrides
19081910
)
19091911
: undefined
@@ -1940,6 +1942,7 @@ export const ToolInput = memo(function ToolInput({
19401942
effectiveParamId={effectiveParamId}
19411943
toolType={tool.type}
19421944
toolParams={tool.params}
1945+
operation={selectedOperation}
19431946
onParamChange={handleParamChange}
19441947
disabled={disabled}
19451948
canonicalToggle={canonicalToggleProp}

‎apps/sim/blocks/blocks/greenhouse.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ export const GreenhouseV2Block: BlockConfig = {
701701
},
702702
{
703703
id: 'id',
704+
dependsOn: ['operation'],
704705
title: 'Resource ID',
705706
type: 'short-input',
706707
placeholder: 'Enter resource ID',
@@ -747,6 +748,7 @@ export const GreenhouseV2Block: BlockConfig = {
747748
},
748749
{
749750
id: 'cursor',
751+
dependsOn: ['operation'],
750752
title: 'Cursor',
751753
type: 'short-input',
752754
placeholder: 'Enter cursor',
@@ -831,6 +833,7 @@ export const GreenhouseV2Block: BlockConfig = {
831833
},
832834
{
833835
id: 'ids',
836+
dependsOn: ['operation'],
834837
title: 'Ids',
835838
type: 'short-input',
836839
placeholder: '123,456',
@@ -878,6 +881,7 @@ export const GreenhouseV2Block: BlockConfig = {
878881
},
879882
{
880883
id: 'created_at',
884+
dependsOn: ['operation'],
881885
title: 'Created At',
882886
type: 'long-input',
883887
placeholder: 'Date, timestamp, or JSON range for the selected operation',
@@ -1021,6 +1025,7 @@ export const GreenhouseV2Block: BlockConfig = {
10211025
},
10221026
{
10231027
id: 'fields',
1028+
dependsOn: ['operation'],
10241029
title: 'Fields',
10251030
type: 'short-input',
10261031
placeholder: 'id,name',
@@ -1108,6 +1113,7 @@ export const GreenhouseV2Block: BlockConfig = {
11081113
},
11091114
{
11101115
id: 'job_ids',
1116+
dependsOn: ['operation'],
11111117
title: 'Job IDs',
11121118
type: 'long-input',
11131119
placeholder: 'List filter: 123,456; prospect creation: [123,456]',
@@ -1213,6 +1219,7 @@ export const GreenhouseV2Block: BlockConfig = {
12131219
},
12141220
{
12151221
id: 'status',
1222+
dependsOn: ['operation'],
12161223
title: 'Status',
12171224
type: 'dropdown',
12181225
condition: {
@@ -1368,6 +1375,7 @@ export const GreenhouseV2Block: BlockConfig = {
13681375
},
13691376
{
13701377
id: 'type',
1378+
dependsOn: ['operation'],
13711379
title: 'Type',
13721380
type: 'combobox',
13731381
placeholder: 'Select a type, or enter comma-separated note types',
@@ -1599,6 +1607,7 @@ export const GreenhouseV2Block: BlockConfig = {
15991607
},
16001608
{
16011609
id: 'name',
1610+
dependsOn: ['operation'],
16021611
title: 'Name',
16031612
type: 'short-input',
16041613
placeholder: 'Enter name',
@@ -1616,6 +1625,7 @@ export const GreenhouseV2Block: BlockConfig = {
16161625
},
16171626
{
16181627
id: 'parent_id',
1628+
dependsOn: ['operation'],
16191629
title: 'Parent ID',
16201630
type: 'short-input',
16211631
placeholder: 'Enter numeric parent id',
@@ -1625,6 +1635,7 @@ export const GreenhouseV2Block: BlockConfig = {
16251635
},
16261636
{
16271637
id: 'external_id',
1638+
dependsOn: ['operation'],
16281639
title: 'External ID',
16291640
type: 'short-input',
16301641
placeholder: 'Enter external id',
@@ -1912,6 +1923,7 @@ export const GreenhouseV2Block: BlockConfig = {
19121923
},
19131924
{
19141925
id: 'visibility',
1926+
dependsOn: ['operation'],
19151927
title: 'Visibility',
19161928
type: 'dropdown',
19171929
condition: {
@@ -2063,6 +2075,7 @@ export const GreenhouseV2Block: BlockConfig = {
20632075
},
20642076
{
20652077
id: 'opening_id',
2078+
dependsOn: ['operation'],
20662079
title: 'Opening ID',
20672080
type: 'short-input',
20682081
placeholder: 'Enter opening id',
@@ -2394,6 +2407,7 @@ export const GreenhouseV2Block: BlockConfig = {
23942407
},
23952408
{
23962409
id: 'custom_fields',
2410+
dependsOn: ['operation'],
23972411
title: 'Custom Fields',
23982412
type: 'code',
23992413
placeholder: '[]',

0 commit comments

Comments
 (0)