From 81715426d284e9dbee9ad79d9d8ac8bbed0fd3ac Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 6 Feb 2026 17:21:10 +0800 Subject: [PATCH] chore: plugin in sandbox auto set to true --- web/app/components/base/prompt-editor/index.tsx | 2 +- .../workflow/skill/editor/skill-editor/index.tsx | 2 +- .../skill-editor/plugins/tool-block/component.tsx | 9 +++++++-- .../tool-block/tool-group-block-component.tsx | 9 +++++++-- .../plugins/tool-block/tool-picker-block.tsx | 13 ++++++++++--- .../tool-setting/tool-settings-section.tsx | 7 +++++-- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsx index 86335f05b6..3169b7098f 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -377,7 +377,7 @@ const PromptEditor: FC = ({ - {editable && !disableToolBlocks && } + {editable && !disableToolBlocks && } )} {editable && } - {editable && } + {editable && } {editable && autoFocus && } diff --git a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx index 3074269f4c..475c8727ff 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx @@ -60,7 +60,7 @@ const normalizeProviderIcon = (icon?: ToolWithProvider['icon']) => { type ToolConfigField = { id: string value: unknown - auto: boolean + auto?: boolean } type ToolConfigMetadata = { @@ -87,6 +87,9 @@ const getVarKindType = (type: FormTypeEnum | string) => { return VarKindType.constant } +const canUseAutoByType = (type: string) => + ![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum) + const normalizeCredentialId = (credentialId?: string) => { if (!credentialId || credentialId === '__workspace_default__') return undefined @@ -230,7 +233,9 @@ const ToolBlockComponent = ({ const field = fieldsById.get(schema.variable) if (!field) return - const isAuto = Boolean(field.auto) + const isAuto = field.auto === undefined + ? canUseAutoByType(schema.type) + : Boolean(field.auto) if (isAuto) { nextValue[schema.variable] = { auto: 1, value: null } return diff --git a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-group-block-component.tsx b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-group-block-component.tsx index ed8a937f71..fa646b2573 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-group-block-component.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-group-block-component.tsx @@ -47,7 +47,7 @@ type ToolGroupBlockComponentProps = { type ToolConfigField = { id: string value: unknown - auto: boolean + auto?: boolean } type ToolConfigMetadata = { @@ -223,6 +223,9 @@ const ToolGroupBlockComponent = ({ return VarKindType.constant } + const canUseAutoByType = (type: string) => + ![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum) + const normalizeCredentialId = (credentialId?: string) => { if (!credentialId || credentialId === '__workspace_default__') return undefined @@ -266,7 +269,9 @@ const ToolGroupBlockComponent = ({ const field = fieldsById.get(schema.variable) if (!field) return - const isAuto = Boolean(field.auto) + const isAuto = field.auto === undefined + ? canUseAutoByType(schema.type) + : Boolean(field.auto) if (isAuto) { nextValue[schema.variable] = { auto: 1, value: null } return diff --git a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx index 55bcad86f5..8d0f79eb2d 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx @@ -15,6 +15,7 @@ import ReactDOM from 'react-dom' import { v4 as uuid } from 'uuid' import { useBasicTypeaheadTriggerMatch } from '@/app/components/base/prompt-editor/hooks' import { $splitNodeContainingQuery } from '@/app/components/base/prompt-editor/utils' +import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import ToolPicker from '@/app/components/workflow/block-selector/tool-picker' import { START_TAB_ID } from '@/app/components/workflow/skill/constants' @@ -31,9 +32,10 @@ class ToolPickerMenuOption extends MenuOption { type ToolPickerBlockProps = { scope?: string + enableAutoDefault?: boolean } -const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => { +const ToolPickerBlock = ({ scope = 'all', enableAutoDefault = false }: ToolPickerBlockProps) => { const [editor] = useLexicalComposerContext() const checkForTriggerMatch = useBasicTypeaheadTriggerMatch('@', { minLength: 0, @@ -44,6 +46,11 @@ const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => { const isUsingExternalMetadata = Boolean(toolBlockContext?.onMetadataChange) const [queryString, setQueryString] = useState('') + const canUseAutoByType = useCallback( + (type: string) => ![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum), + [], + ) + const options = useMemo(() => [new ToolPickerMenuOption()], []) const getMatchFromSelection = useCallback(() => { @@ -70,7 +77,7 @@ const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => { const fields = schemas.map(schema => ({ id: schema.variable, value: schema.default ?? null, - auto: schema.form === 'llm', + auto: enableAutoDefault ? canUseAutoByType(schema.type) : schema.form === 'llm', })) nextTools[configId] = { type: tool.provider_type, @@ -81,7 +88,7 @@ const ToolPickerBlock = ({ scope = 'all' }: ToolPickerBlockProps) => { ...metadata, tools: nextTools, } - }, []) + }, [canUseAutoByType, enableAutoDefault]) const insertTools = useCallback((tools: ToolDefaultValue[]) => { const toolEntries = tools.map(tool => ({ diff --git a/web/app/components/workflow/skill/editor/skill-editor/tool-setting/tool-settings-section.tsx b/web/app/components/workflow/skill/editor/skill-editor/tool-setting/tool-settings-section.tsx index b0a4399b93..c18db03580 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/tool-setting/tool-settings-section.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/tool-setting/tool-settings-section.tsx @@ -93,6 +93,8 @@ const ToolSettingsSection = ({ const showSettingsSection = currentToolSettings.length > 0 const showParamsSection = currentToolParams.length > 0 + const canUseAutoByType = (type: string) => + ![FormTypeEnum.modelSelector, FormTypeEnum.appSelector].includes(type as FormTypeEnum) const getVarKindType = (type: FormTypeEnum | string) => { if (type === FormTypeEnum.file || type === FormTypeEnum.files) return VarKindType.variable @@ -107,8 +109,9 @@ const ToolSettingsSection = ({ schemas.forEach((schema) => { const currentValue = nextValue[schema.variable] if (!currentValue) { + const canUseAuto = canUseAutoByType(schema.type) nextValue[schema.variable] = { - auto: 0, + auto: canUseAuto ? 1 : 0, value: { type: getVarKindType(schema.type), value: schema.default ?? null, @@ -117,7 +120,7 @@ const ToolSettingsSection = ({ return } if (currentValue.auto === undefined) - currentValue.auto = 0 + currentValue.auto = canUseAutoByType(schema.type) ? 1 : 0 if (currentValue.value === undefined) { currentValue.value = { type: getVarKindType(schema.type),