From 4f7cb7cd2a1fdec3b994617caac1d47b6b88e182 Mon Sep 17 00:00:00 2001 From: GuanMu Date: Fri, 17 Oct 2025 14:42:58 +0800 Subject: [PATCH] Fix type error (#27044) --- web/app/components/base/textarea/index.tsx | 4 ++-- .../metadata/condition-list/condition-number.tsx | 2 +- .../metadata/condition-list/condition-string.tsx | 2 +- .../workflow/nodes/knowledge-retrieval/types.ts | 4 ++-- .../json-schema-config-modal/json-importer.tsx | 2 +- .../visual-editor/context.tsx | 2 +- web/app/components/workflow/nodes/llm/use-config.ts | 2 +- web/app/components/workflow/nodes/llm/utils.ts | 2 +- .../extract-parameter/import-from-tool.tsx | 12 +++++++++--- 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/web/app/components/base/textarea/index.tsx b/web/app/components/base/textarea/index.tsx index 63eae48e31..7813eb7209 100644 --- a/web/app/components/base/textarea/index.tsx +++ b/web/app/components/base/textarea/index.tsx @@ -25,8 +25,8 @@ export type TextareaProps = { destructive?: boolean styleCss?: CSSProperties ref?: React.Ref - onFocus?: () => void - onBlur?: () => void + onFocus?: React.FocusEventHandler + onBlur?: React.FocusEventHandler } & React.TextareaHTMLAttributes & VariantProps const Textarea = React.forwardRef( diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx index 7016e8bd2a..6421401a2a 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx +++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-number.tsx @@ -18,7 +18,7 @@ type ConditionNumberProps = { nodesOutputVars: NodeOutPutVar[] availableNodes: Node[] isCommonVariable?: boolean - commonVariables: { name: string, type: string }[] + commonVariables: { name: string; type: string; value: string }[] } & ConditionValueMethodProps const ConditionNumber = ({ value, diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx index cf85f1259b..d5cb06e690 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx +++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/metadata/condition-list/condition-string.tsx @@ -18,7 +18,7 @@ type ConditionStringProps = { nodesOutputVars: NodeOutPutVar[] availableNodes: Node[] isCommonVariable?: boolean - commonVariables: { name: string, type: string }[] + commonVariables: { name: string; type: string; value: string }[] } & ConditionValueMethodProps const ConditionString = ({ value, diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts index 1cae4ecd3b..65f7dc2493 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts +++ b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts @@ -128,6 +128,6 @@ export type MetadataShape = { availableNumberVars?: NodeOutPutVar[] availableNumberNodesWithParent?: Node[] isCommonVariable?: boolean - availableCommonStringVars?: { name: string; type: string; }[] - availableCommonNumberVars?: { name: string; type: string; }[] + availableCommonStringVars?: { name: string; type: string; value: string }[] + availableCommonNumberVars?: { name: string; type: string; value: string }[] } diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx index 6368397b74..463d87d7d1 100644 --- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx +++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-importer.tsx @@ -24,7 +24,7 @@ const JsonImporter: FC = ({ const [open, setOpen] = useState(false) const [json, setJson] = useState('') const [parseError, setParseError] = useState(null) - const importBtnRef = useRef(null) + const importBtnRef = useRef(null) const advancedEditing = useVisualEditorStore(state => state.advancedEditing) const isAddingNewField = useVisualEditorStore(state => state.isAddingNewField) const { emit } = useMittContext() diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx index 5bf4b22f11..268683aec3 100644 --- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx +++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context.tsx @@ -18,7 +18,7 @@ type VisualEditorProviderProps = { export const VisualEditorContext = createContext(null) export const VisualEditorContextProvider = ({ children }: VisualEditorProviderProps) => { - const storeRef = useRef() + const storeRef = useRef(null) if (!storeRef.current) storeRef.current = createVisualEditorStore() diff --git a/web/app/components/workflow/nodes/llm/use-config.ts b/web/app/components/workflow/nodes/llm/use-config.ts index 45635be3f2..d11fb6db28 100644 --- a/web/app/components/workflow/nodes/llm/use-config.ts +++ b/web/app/components/workflow/nodes/llm/use-config.ts @@ -23,7 +23,7 @@ const useConfig = (id: string, payload: LLMNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() const isChatMode = useIsChatMode() - const defaultConfig = useStore(s => s.nodesDefaultConfigs)[payload.type] + const defaultConfig = useStore(s => s.nodesDefaultConfigs)?.[payload.type] const [defaultRolePrefix, setDefaultRolePrefix] = useState<{ user: string; assistant: string }>({ user: '', assistant: '' }) const { inputs, setInputs: doSetInputs } = useNodeCrud(id, payload) const inputRef = useRef(inputs) diff --git a/web/app/components/workflow/nodes/llm/utils.ts b/web/app/components/workflow/nodes/llm/utils.ts index 29591d76ad..10c287f86b 100644 --- a/web/app/components/workflow/nodes/llm/utils.ts +++ b/web/app/components/workflow/nodes/llm/utils.ts @@ -10,7 +10,7 @@ export const checkNodeValid = (_payload: LLMNodeType) => { export const getFieldType = (field: Field) => { const { type, items } = field - if(field.schemaType === 'file') return 'file' + if(field.schemaType === 'file') return Type.file if (type !== Type.array || !items) return type diff --git a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx index bfb664aef1..d93d08a0ac 100644 --- a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx +++ b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx @@ -9,7 +9,10 @@ import BlockSelector from '../../../../block-selector' import type { Param, ParamType } from '../../types' import cn from '@/utils/classnames' import { useStore } from '@/app/components/workflow/store' -import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types' +import type { + DataSourceDefaultValue, + ToolDefaultValue, +} from '@/app/components/workflow/block-selector/types' import type { ToolParameter } from '@/app/components/tools/types' import { CollectionType } from '@/app/components/tools/types' import type { BlockEnum } from '@/app/components/workflow/types' @@ -43,8 +46,11 @@ const ImportFromTool: FC = ({ const customTools = useStore(s => s.customTools) const workflowTools = useStore(s => s.workflowTools) - const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: ToolDefaultValue) => { - const { provider_id, provider_type, tool_name } = toolInfo! + const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: ToolDefaultValue | DataSourceDefaultValue) => { + if (!toolInfo || 'datasource_name' in toolInfo) + return + + const { provider_id, provider_type, tool_name } = toolInfo const currentTools = (() => { switch (provider_type) { case CollectionType.builtIn: