mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-12 15:34:58 -05:00
add sibling values to subblock context since subblock store isn't relevant in tool input, and removed unused param
This commit is contained in:
@@ -104,6 +104,7 @@ export function ToolSubBlockRenderer({
|
||||
disabled={disabled}
|
||||
canonicalToggle={canonicalToggle}
|
||||
labelSuffix={labelSuffix}
|
||||
dependencyContext={toolParams}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { isEqual } from 'lodash'
|
||||
import { AlertTriangle, ArrowLeftRight, ArrowUp, Check, Clipboard } from 'lucide-react'
|
||||
import { Button, Input, Label, Tooltip } from '@/components/emcn/components'
|
||||
import { cn } from '@/lib/core/utils/cn'
|
||||
import type { FieldDiffStatus } from '@/lib/workflows/diff/types'
|
||||
import {
|
||||
CheckboxList,
|
||||
Code,
|
||||
@@ -69,7 +68,6 @@ interface SubBlockProps {
|
||||
isPreview?: boolean
|
||||
subBlockValues?: Record<string, any>
|
||||
disabled?: boolean
|
||||
fieldDiffStatus?: FieldDiffStatus
|
||||
allowExpandInPreview?: boolean
|
||||
canonicalToggle?: {
|
||||
mode: 'basic' | 'advanced'
|
||||
@@ -77,6 +75,8 @@ interface SubBlockProps {
|
||||
onToggle?: () => void
|
||||
}
|
||||
labelSuffix?: React.ReactNode
|
||||
/** Provides sibling values for dependency resolution in non-preview contexts (e.g. tool-input) */
|
||||
dependencyContext?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,16 +163,14 @@ const getPreviewValue = (
|
||||
/**
|
||||
* Renders the label with optional validation and description tooltips.
|
||||
*
|
||||
* @remarks
|
||||
* Handles JSON validation indicators for code blocks and required field markers.
|
||||
* Includes inline AI generate button when wand is enabled.
|
||||
*
|
||||
* @param config - The sub-block configuration defining the label content
|
||||
* @param isValidJson - Whether the JSON content is valid (for code blocks)
|
||||
* @param subBlockValues - Current values of all subblocks for evaluating conditional requirements
|
||||
* @param wandState - Optional state and handlers for the AI wand feature
|
||||
* @param canonicalToggle - Optional canonical toggle metadata and handlers
|
||||
* @param canonicalToggleIsDisabled - Whether the canonical toggle is disabled
|
||||
* @param wandState - State and handlers for the inline AI generate feature
|
||||
* @param canonicalToggle - Metadata and handlers for the basic/advanced mode toggle
|
||||
* @param canonicalToggleIsDisabled - Whether the canonical toggle is disabled (includes dependsOn gating)
|
||||
* @param copyState - State and handler for the copy-to-clipboard button
|
||||
* @param labelSuffix - Additional content rendered after the label text
|
||||
* @returns The label JSX element, or `null` for switch types or when no title is defined
|
||||
*/
|
||||
const renderLabel = (
|
||||
@@ -386,29 +384,25 @@ const arePropsEqual = (prevProps: SubBlockProps, nextProps: SubBlockProps): bool
|
||||
prevProps.isPreview === nextProps.isPreview &&
|
||||
valueEqual &&
|
||||
prevProps.disabled === nextProps.disabled &&
|
||||
prevProps.fieldDiffStatus === nextProps.fieldDiffStatus &&
|
||||
prevProps.allowExpandInPreview === nextProps.allowExpandInPreview &&
|
||||
canonicalToggleEqual &&
|
||||
prevProps.labelSuffix === nextProps.labelSuffix
|
||||
prevProps.labelSuffix === nextProps.labelSuffix &&
|
||||
prevProps.dependencyContext === nextProps.dependencyContext
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a single workflow sub-block input based on config.type.
|
||||
*
|
||||
* @remarks
|
||||
* Supports multiple input types including short-input, long-input, dropdown,
|
||||
* combobox, slider, table, code, switch, tool-input, and many more.
|
||||
* Handles preview mode, disabled states, and AI wand generation.
|
||||
*
|
||||
* @param blockId - The parent block identifier
|
||||
* @param config - Configuration defining the input type and properties
|
||||
* @param isPreview - Whether to render in preview mode
|
||||
* @param subBlockValues - Current values of all subblocks
|
||||
* @param disabled - Whether the input is disabled
|
||||
* @param fieldDiffStatus - Optional diff status for visual indicators
|
||||
* @param allowExpandInPreview - Whether to allow expanding in preview mode
|
||||
* @returns The rendered sub-block input component
|
||||
* @param canonicalToggle - Metadata and handlers for the basic/advanced mode toggle
|
||||
* @param labelSuffix - Additional content rendered after the label text
|
||||
* @param dependencyContext - Sibling values for dependency resolution in non-preview contexts (e.g. tool-input)
|
||||
*/
|
||||
function SubBlockComponent({
|
||||
blockId,
|
||||
@@ -416,10 +410,10 @@ function SubBlockComponent({
|
||||
isPreview = false,
|
||||
subBlockValues,
|
||||
disabled = false,
|
||||
fieldDiffStatus,
|
||||
allowExpandInPreview,
|
||||
canonicalToggle,
|
||||
labelSuffix,
|
||||
dependencyContext,
|
||||
}: SubBlockProps): JSX.Element {
|
||||
const [isValidJson, setIsValidJson] = useState(true)
|
||||
const [isSearchActive, setIsSearchActive] = useState(false)
|
||||
@@ -428,7 +422,6 @@ function SubBlockComponent({
|
||||
const searchInputRef = useRef<HTMLInputElement>(null)
|
||||
const wandControlRef = useRef<WandControlHandlers | null>(null)
|
||||
|
||||
// Use webhook management hook when config has useWebhookUrl enabled
|
||||
const webhookManagement = useWebhookManagement({
|
||||
blockId,
|
||||
triggerId: undefined,
|
||||
@@ -515,10 +508,12 @@ function SubBlockComponent({
|
||||
| null
|
||||
| undefined
|
||||
|
||||
const contextValues = dependencyContext ?? (isPreview ? subBlockValues : undefined)
|
||||
|
||||
const { finalDisabled: gatedDisabled } = useDependsOnGate(blockId, config, {
|
||||
disabled,
|
||||
isPreview,
|
||||
previewContextValues: isPreview ? subBlockValues : undefined,
|
||||
previewContextValues: contextValues,
|
||||
})
|
||||
|
||||
const isDisabled = gatedDisabled
|
||||
@@ -802,7 +797,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -814,7 +809,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -826,7 +821,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -838,7 +833,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -850,7 +845,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -873,7 +868,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue as any}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -885,7 +880,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue as any}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -897,7 +892,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue as any}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -922,7 +917,7 @@ function SubBlockComponent({
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue as any}
|
||||
disabled={isDisabled}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -958,7 +953,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -992,7 +987,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue as any}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -1004,7 +999,7 @@ function SubBlockComponent({
|
||||
disabled={isDisabled}
|
||||
isPreview={isPreview}
|
||||
previewValue={previewValue}
|
||||
previewContextValues={isPreview ? subBlockValues : undefined}
|
||||
previewContextValues={contextValues}
|
||||
/>
|
||||
)
|
||||
|
||||
|
||||
@@ -571,7 +571,6 @@ export function Editor() {
|
||||
isPreview={false}
|
||||
subBlockValues={subBlockState}
|
||||
disabled={!canEditBlock}
|
||||
fieldDiffStatus={undefined}
|
||||
allowExpandInPreview={false}
|
||||
canonicalToggle={
|
||||
isCanonicalSwap && canonicalMode && canonicalId
|
||||
@@ -635,7 +634,6 @@ export function Editor() {
|
||||
isPreview={false}
|
||||
subBlockValues={subBlockState}
|
||||
disabled={!canEditBlock}
|
||||
fieldDiffStatus={undefined}
|
||||
allowExpandInPreview={false}
|
||||
/>
|
||||
{index < advancedOnlySubBlocks.length - 1 && (
|
||||
|
||||
Reference in New Issue
Block a user