Skip to content

Commit 8af5617

Browse files
committed
add sibling values to subblock context since subblock store isn't relevant in tool input, and removed unused param
1 parent a0ebe08 commit 8af5617

File tree

3 files changed

+29
-35
lines changed

3 files changed

+29
-35
lines changed

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export function ToolSubBlockRenderer({
104104
disabled={disabled}
105105
canonicalToggle={canonicalToggle}
106106
labelSuffix={labelSuffix}
107+
dependencyContext={toolParams}
107108
/>
108109
)
109110
}

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

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { isEqual } from 'lodash'
33
import { AlertTriangle, ArrowLeftRight, ArrowUp, Check, Clipboard } from 'lucide-react'
44
import { Button, Input, Label, Tooltip } from '@/components/emcn/components'
55
import { cn } from '@/lib/core/utils/cn'
6-
import type { FieldDiffStatus } from '@/lib/workflows/diff/types'
76
import {
87
CheckboxList,
98
Code,
@@ -69,14 +68,15 @@ interface SubBlockProps {
6968
isPreview?: boolean
7069
subBlockValues?: Record<string, any>
7170
disabled?: boolean
72-
fieldDiffStatus?: FieldDiffStatus
7371
allowExpandInPreview?: boolean
7472
canonicalToggle?: {
7573
mode: 'basic' | 'advanced'
7674
disabled?: boolean
7775
onToggle?: () => void
7876
}
7977
labelSuffix?: React.ReactNode
78+
/** Provides sibling values for dependency resolution in non-preview contexts (e.g. tool-input) */
79+
dependencyContext?: Record<string, unknown>
8080
}
8181

8282
/**
@@ -163,16 +163,14 @@ const getPreviewValue = (
163163
/**
164164
* Renders the label with optional validation and description tooltips.
165165
*
166-
* @remarks
167-
* Handles JSON validation indicators for code blocks and required field markers.
168-
* Includes inline AI generate button when wand is enabled.
169-
*
170166
* @param config - The sub-block configuration defining the label content
171167
* @param isValidJson - Whether the JSON content is valid (for code blocks)
172168
* @param subBlockValues - Current values of all subblocks for evaluating conditional requirements
173-
* @param wandState - Optional state and handlers for the AI wand feature
174-
* @param canonicalToggle - Optional canonical toggle metadata and handlers
175-
* @param canonicalToggleIsDisabled - Whether the canonical toggle is disabled
169+
* @param wandState - State and handlers for the inline AI generate feature
170+
* @param canonicalToggle - Metadata and handlers for the basic/advanced mode toggle
171+
* @param canonicalToggleIsDisabled - Whether the canonical toggle is disabled (includes dependsOn gating)
172+
* @param copyState - State and handler for the copy-to-clipboard button
173+
* @param labelSuffix - Additional content rendered after the label text
176174
* @returns The label JSX element, or `null` for switch types or when no title is defined
177175
*/
178176
const renderLabel = (
@@ -386,40 +384,36 @@ const arePropsEqual = (prevProps: SubBlockProps, nextProps: SubBlockProps): bool
386384
prevProps.isPreview === nextProps.isPreview &&
387385
valueEqual &&
388386
prevProps.disabled === nextProps.disabled &&
389-
prevProps.fieldDiffStatus === nextProps.fieldDiffStatus &&
390387
prevProps.allowExpandInPreview === nextProps.allowExpandInPreview &&
391388
canonicalToggleEqual &&
392-
prevProps.labelSuffix === nextProps.labelSuffix
389+
prevProps.labelSuffix === nextProps.labelSuffix &&
390+
prevProps.dependencyContext === nextProps.dependencyContext
393391
)
394392
}
395393

396394
/**
397395
* Renders a single workflow sub-block input based on config.type.
398396
*
399-
* @remarks
400-
* Supports multiple input types including short-input, long-input, dropdown,
401-
* combobox, slider, table, code, switch, tool-input, and many more.
402-
* Handles preview mode, disabled states, and AI wand generation.
403-
*
404397
* @param blockId - The parent block identifier
405398
* @param config - Configuration defining the input type and properties
406399
* @param isPreview - Whether to render in preview mode
407400
* @param subBlockValues - Current values of all subblocks
408401
* @param disabled - Whether the input is disabled
409-
* @param fieldDiffStatus - Optional diff status for visual indicators
410402
* @param allowExpandInPreview - Whether to allow expanding in preview mode
411-
* @returns The rendered sub-block input component
403+
* @param canonicalToggle - Metadata and handlers for the basic/advanced mode toggle
404+
* @param labelSuffix - Additional content rendered after the label text
405+
* @param dependencyContext - Sibling values for dependency resolution in non-preview contexts (e.g. tool-input)
412406
*/
413407
function SubBlockComponent({
414408
blockId,
415409
config,
416410
isPreview = false,
417411
subBlockValues,
418412
disabled = false,
419-
fieldDiffStatus,
420413
allowExpandInPreview,
421414
canonicalToggle,
422415
labelSuffix,
416+
dependencyContext,
423417
}: SubBlockProps): JSX.Element {
424418
const [isValidJson, setIsValidJson] = useState(true)
425419
const [isSearchActive, setIsSearchActive] = useState(false)
@@ -428,7 +422,6 @@ function SubBlockComponent({
428422
const searchInputRef = useRef<HTMLInputElement>(null)
429423
const wandControlRef = useRef<WandControlHandlers | null>(null)
430424

431-
// Use webhook management hook when config has useWebhookUrl enabled
432425
const webhookManagement = useWebhookManagement({
433426
blockId,
434427
triggerId: undefined,
@@ -515,10 +508,12 @@ function SubBlockComponent({
515508
| null
516509
| undefined
517510

511+
const contextValues = dependencyContext ?? (isPreview ? subBlockValues : undefined)
512+
518513
const { finalDisabled: gatedDisabled } = useDependsOnGate(blockId, config, {
519514
disabled,
520515
isPreview,
521-
previewContextValues: isPreview ? subBlockValues : undefined,
516+
previewContextValues: contextValues,
522517
})
523518

524519
const isDisabled = gatedDisabled
@@ -802,7 +797,7 @@ function SubBlockComponent({
802797
disabled={isDisabled}
803798
isPreview={isPreview}
804799
previewValue={previewValue}
805-
previewContextValues={isPreview ? subBlockValues : undefined}
800+
previewContextValues={contextValues}
806801
/>
807802
)
808803

@@ -814,7 +809,7 @@ function SubBlockComponent({
814809
disabled={isDisabled}
815810
isPreview={isPreview}
816811
previewValue={previewValue}
817-
previewContextValues={isPreview ? subBlockValues : undefined}
812+
previewContextValues={contextValues}
818813
/>
819814
)
820815

@@ -826,7 +821,7 @@ function SubBlockComponent({
826821
disabled={isDisabled}
827822
isPreview={isPreview}
828823
previewValue={previewValue}
829-
previewContextValues={isPreview ? subBlockValues : undefined}
824+
previewContextValues={contextValues}
830825
/>
831826
)
832827

@@ -838,7 +833,7 @@ function SubBlockComponent({
838833
disabled={isDisabled}
839834
isPreview={isPreview}
840835
previewValue={previewValue}
841-
previewContextValues={isPreview ? subBlockValues : undefined}
836+
previewContextValues={contextValues}
842837
/>
843838
)
844839

@@ -850,7 +845,7 @@ function SubBlockComponent({
850845
disabled={isDisabled}
851846
isPreview={isPreview}
852847
previewValue={previewValue}
853-
previewContextValues={isPreview ? subBlockValues : undefined}
848+
previewContextValues={contextValues}
854849
/>
855850
)
856851

@@ -873,7 +868,7 @@ function SubBlockComponent({
873868
disabled={isDisabled}
874869
isPreview={isPreview}
875870
previewValue={previewValue as any}
876-
previewContextValues={isPreview ? subBlockValues : undefined}
871+
previewContextValues={contextValues}
877872
/>
878873
)
879874

@@ -885,7 +880,7 @@ function SubBlockComponent({
885880
disabled={isDisabled}
886881
isPreview={isPreview}
887882
previewValue={previewValue as any}
888-
previewContextValues={isPreview ? subBlockValues : undefined}
883+
previewContextValues={contextValues}
889884
/>
890885
)
891886

@@ -897,7 +892,7 @@ function SubBlockComponent({
897892
disabled={isDisabled}
898893
isPreview={isPreview}
899894
previewValue={previewValue as any}
900-
previewContextValues={isPreview ? subBlockValues : undefined}
895+
previewContextValues={contextValues}
901896
/>
902897
)
903898

@@ -922,7 +917,7 @@ function SubBlockComponent({
922917
isPreview={isPreview}
923918
previewValue={previewValue as any}
924919
disabled={isDisabled}
925-
previewContextValues={isPreview ? subBlockValues : undefined}
920+
previewContextValues={contextValues}
926921
/>
927922
)
928923

@@ -958,7 +953,7 @@ function SubBlockComponent({
958953
disabled={isDisabled}
959954
isPreview={isPreview}
960955
previewValue={previewValue}
961-
previewContextValues={isPreview ? subBlockValues : undefined}
956+
previewContextValues={contextValues}
962957
/>
963958
)
964959

@@ -992,7 +987,7 @@ function SubBlockComponent({
992987
disabled={isDisabled}
993988
isPreview={isPreview}
994989
previewValue={previewValue as any}
995-
previewContextValues={isPreview ? subBlockValues : undefined}
990+
previewContextValues={contextValues}
996991
/>
997992
)
998993

@@ -1004,7 +999,7 @@ function SubBlockComponent({
1004999
disabled={isDisabled}
10051000
isPreview={isPreview}
10061001
previewValue={previewValue}
1007-
previewContextValues={isPreview ? subBlockValues : undefined}
1002+
previewContextValues={contextValues}
10081003
/>
10091004
)
10101005

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ export function Editor() {
571571
isPreview={false}
572572
subBlockValues={subBlockState}
573573
disabled={!canEditBlock}
574-
fieldDiffStatus={undefined}
575574
allowExpandInPreview={false}
576575
canonicalToggle={
577576
isCanonicalSwap && canonicalMode && canonicalId
@@ -635,7 +634,6 @@ export function Editor() {
635634
isPreview={false}
636635
subBlockValues={subBlockState}
637636
disabled={!canEditBlock}
638-
fieldDiffStatus={undefined}
639637
allowExpandInPreview={false}
640638
/>
641639
{index < advancedOnlySubBlocks.length - 1 && (

0 commit comments

Comments
 (0)