Skip to content

Commit 08ddf19

Browse files
committed
Checkpoint
1 parent 991b0e3 commit 08ddf19

6 files changed

Lines changed: 54 additions & 16 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/channel-selector/channel-selector-input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function ChannelSelectorInput({
5151
const { finalDisabled, dependsOn, dependencyValues } = useDependsOnGate(blockId, subBlock, {
5252
disabled,
5353
isPreview,
54+
previewContextValues,
5455
})
5556

5657
// Choose credential strictly based on auth method - use effective values

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/file-selector/file-selector-input.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export function FileSelectorInput({
4242
const params = useParams()
4343
const workflowIdFromUrl = (params?.workflowId as string) || activeWorkflowId || ''
4444
// Central dependsOn gating for this selector instance
45-
const { finalDisabled } = useDependsOnGate(blockId, subBlock, { disabled, isPreview })
45+
const { finalDisabled } = useDependsOnGate(blockId, subBlock, {
46+
disabled,
47+
isPreview,
48+
previewContextValues
49+
})
4650

4751
// Helper to coerce various preview value shapes into a string ID
4852
const coerceToIdString = (val: unknown): string => {
@@ -63,12 +67,20 @@ export function FileSelectorInput({
6367

6468
// Use the proper hook to get the current value and setter
6569
const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlock.id)
66-
const [connectedCredential] = useSubBlockValue(blockId, 'credential')
67-
const [domainValue] = useSubBlockValue(blockId, 'domain')
68-
const [projectIdValue] = useSubBlockValue(blockId, 'projectId')
69-
const [planIdValue] = useSubBlockValue(blockId, 'planId')
70-
const [teamIdValue] = useSubBlockValue(blockId, 'teamId')
71-
const [operationValue] = useSubBlockValue(blockId, 'operation')
70+
const [connectedCredentialFromStore] = useSubBlockValue(blockId, 'credential')
71+
const [domainValueFromStore] = useSubBlockValue(blockId, 'domain')
72+
const [projectIdValueFromStore] = useSubBlockValue(blockId, 'projectId')
73+
const [planIdValueFromStore] = useSubBlockValue(blockId, 'planId')
74+
const [teamIdValueFromStore] = useSubBlockValue(blockId, 'teamId')
75+
const [operationValueFromStore] = useSubBlockValue(blockId, 'operation')
76+
77+
// Use previewContextValues if provided (for tools inside agent blocks), otherwise use store values
78+
const connectedCredential = previewContextValues?.credential ?? connectedCredentialFromStore
79+
const domainValue = previewContextValues?.domain ?? domainValueFromStore
80+
const projectIdValue = previewContextValues?.projectId ?? projectIdValueFromStore
81+
const planIdValue = previewContextValues?.planId ?? planIdValueFromStore
82+
const teamIdValue = previewContextValues?.teamId ?? teamIdValueFromStore
83+
const operationValue = previewContextValues?.operation ?? operationValueFromStore
7284

7385
// Determine if the persisted credential belongs to the current viewer
7486
// Use service providerId where available (e.g., onedrive/sharepoint) instead of base provider ("microsoft")

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/project-selector/project-selector-input.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface ProjectSelectorInputProps {
2828
onProjectSelect?: (projectId: string) => void
2929
isPreview?: boolean
3030
previewValue?: any | null
31+
previewContextValues?: Record<string, any>
3132
}
3233

3334
export function ProjectSelectorInput({
@@ -37,30 +38,40 @@ export function ProjectSelectorInput({
3738
onProjectSelect,
3839
isPreview = false,
3940
previewValue,
41+
previewContextValues,
4042
}: ProjectSelectorInputProps) {
4143
const { collaborativeSetSubblockValue } = useCollaborativeWorkflow()
4244
const [selectedProjectId, setSelectedProjectId] = useState<string>('')
4345
const [_projectInfo, setProjectInfo] = useState<any | null>(null)
4446
// Use the proper hook to get the current value and setter
4547
const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlock.id)
46-
const [connectedCredential] = useSubBlockValue(blockId, 'credential')
48+
const [connectedCredentialFromStore] = useSubBlockValue(blockId, 'credential')
49+
const [linearTeamIdFromStore] = useSubBlockValue(blockId, 'teamId')
50+
const [jiraDomainFromStore] = useSubBlockValue(blockId, 'domain')
51+
52+
// Use previewContextValues if provided (for tools inside agent blocks), otherwise use store values
53+
const connectedCredential = previewContextValues?.credential ?? connectedCredentialFromStore
54+
const linearCredential = previewContextValues?.credential ?? connectedCredentialFromStore
55+
const linearTeamId = previewContextValues?.teamId ?? linearTeamIdFromStore
56+
const jiraDomain = previewContextValues?.domain ?? jiraDomainFromStore
57+
4758
const { isForeignCredential } = useForeignCredential(
4859
subBlock.provider || subBlock.serviceId || 'jira',
4960
(connectedCredential as string) || ''
5061
)
51-
// Reactive dependencies from store for Linear
52-
const [linearCredential] = useSubBlockValue(blockId, 'credential')
53-
const [linearTeamId] = useSubBlockValue(blockId, 'teamId')
5462
const activeWorkflowId = useWorkflowRegistry((s) => s.activeWorkflowId) as string | null
55-
const { finalDisabled } = useDependsOnGate(blockId, subBlock, { disabled, isPreview })
63+
const { finalDisabled } = useDependsOnGate(blockId, subBlock, {
64+
disabled,
65+
isPreview,
66+
previewContextValues
67+
})
5668

5769
// Get provider-specific values
5870
const provider = subBlock.provider || 'jira'
5971
const isLinear = provider === 'linear'
6072

61-
// Jira/Discord upstream fields
62-
const [jiraDomain] = useSubBlockValue(blockId, 'domain')
63-
const [jiraCredential] = useSubBlockValue(blockId, 'credential')
73+
// Jira/Discord upstream fields - use values from previewContextValues or store
74+
const jiraCredential = connectedCredential
6475
const domain = (jiraDomain as string) || ''
6576

6677
// Verify Jira credential belongs to current user; if not, treat as absent

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ function FileSelectorSyncWrapper({
168168
mimeType: uiComponent.mimeType,
169169
requiredScopes: uiComponent.requiredScopes || [],
170170
placeholder: uiComponent.placeholder,
171+
dependsOn: uiComponent.dependsOn,
171172
}}
172173
disabled={disabled}
173174
previewContextValues={previewContextValues}
@@ -433,6 +434,7 @@ function ChannelSelectorSyncWrapper({
433434
title: paramId,
434435
provider: uiComponent.provider || 'slack',
435436
placeholder: uiComponent.placeholder,
437+
dependsOn: uiComponent.dependsOn,
436438
}}
437439
onChannelSelect={onChange}
438440
disabled={disabled}
@@ -1174,9 +1176,11 @@ export function ToolInput({
11741176
serviceId: uiComponent.serviceId,
11751177
placeholder: uiComponent.placeholder,
11761178
requiredScopes: uiComponent.requiredScopes,
1179+
dependsOn: uiComponent.dependsOn,
11771180
}}
11781181
onProjectSelect={onChange}
11791182
disabled={disabled}
1183+
previewContextValues={currentToolParams as any}
11801184
/>
11811185
)
11821186

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/hooks/use-depends-on-gate.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import { useSubBlockStore } from '@/stores/workflows/subblock/store'
1313
export function useDependsOnGate(
1414
blockId: string,
1515
subBlock: SubBlockConfig,
16-
opts?: { disabled?: boolean; isPreview?: boolean }
16+
opts?: { disabled?: boolean; isPreview?: boolean; previewContextValues?: Record<string, any> }
1717
) {
1818
const disabledProp = opts?.disabled ?? false
1919
const isPreview = opts?.isPreview ?? false
20+
const previewContextValues = opts?.previewContextValues
2021

2122
const activeWorkflowId = useWorkflowRegistry((s) => s.activeWorkflowId)
2223

@@ -25,6 +26,12 @@ export function useDependsOnGate(
2526

2627
const dependencyValues = useSubBlockStore((state) => {
2728
if (dependsOn.length === 0) return [] as any[]
29+
30+
// If previewContextValues are provided (e.g., tool parameters), use those first
31+
if (previewContextValues) {
32+
return dependsOn.map((depKey) => previewContextValues[depKey] ?? null)
33+
}
34+
2835
if (!activeWorkflowId) return dependsOn.map(() => null)
2936
const workflowValues = state.workflowValues[activeWorkflowId] || {}
3037
const blockValues = (workflowValues as any)[blockId] || {}

apps/sim/tools/params.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface UIComponentConfig {
3636
acceptedTypes?: string[]
3737
multiple?: boolean
3838
maxSize?: number
39+
dependsOn?: string[]
3940
}
4041

4142
export interface SubBlockConfig {
@@ -61,6 +62,7 @@ export interface SubBlockConfig {
6162
acceptedTypes?: string[]
6263
multiple?: boolean
6364
maxSize?: number
65+
dependsOn?: string[]
6466
}
6567

6668
export interface BlockConfig {
@@ -236,6 +238,7 @@ export function getToolParametersConfig(
236238
acceptedTypes: subBlock.acceptedTypes,
237239
multiple: subBlock.multiple,
238240
maxSize: subBlock.maxSize,
241+
dependsOn: subBlock.dependsOn,
239242
}
240243
}
241244
}

0 commit comments

Comments
 (0)