From fea02b74b7c35507cdc70d24b910089070103a90 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 29 Apr 2025 14:11:12 +0800 Subject: [PATCH] feat: iteration output type change --- .../workflow/hooks/use-inspect-vars-crud.ts | 6 +----- .../components/workflow/nodes/iteration/use-config.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts index 838ecb6cca..8826965036 100644 --- a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts +++ b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts @@ -66,6 +66,7 @@ const useInspectVarsCrud = () => { } const deleteNodeInspectorVars = async (nodeId: string) => { + // console.log('delete node inspector vars', nodeId) if (hasNodeInspectVars(nodeId)) await doDeleteNodeInspectorVars(nodeId) @@ -114,10 +115,6 @@ const useInspectVarsCrud = () => { renameInspectVarNameInStore(nodeId, varId, newSelector) } - const editInspectVarValueType = async (nodeId: string) => { - return await deleteNodeInspectorVars(nodeId) - } - const resetToLastRunVar = (nodeId: string, varId: string) => { setCurrNodeId(nodeId) setCurrEditVarId(varId) @@ -132,7 +129,6 @@ const useInspectVarsCrud = () => { fetchInspectVarValue, editInspectVarValue, renameInspectVarName, - editInspectVarValueType, deleteInspectVar, deleteNodeInspectorVars, deleteAllInspectorVars, diff --git a/web/app/components/workflow/nodes/iteration/use-config.ts b/web/app/components/workflow/nodes/iteration/use-config.ts index fd69fecaf0..7b67347d6f 100644 --- a/web/app/components/workflow/nodes/iteration/use-config.ts +++ b/web/app/components/workflow/nodes/iteration/use-config.ts @@ -15,9 +15,14 @@ import useOneStepRun from '../_base/hooks/use-one-step-run' import type { IterationNodeType } from './types' import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' import type { Item } from '@/app/components/base/select' +import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud' +import { isEqual } from 'lodash-es' const DELIMITER = '@@@@@' const useConfig = (id: string, payload: IterationNodeType) => { + const { + deleteNodeInspectorVars, + } = useInspectVarsCrud() const { nodesReadOnly: readOnly } = useNodesReadOnly() const { isNodeInIteration } = useIsNodeInIteration(id) const isChatMode = useIsChatMode() @@ -43,6 +48,9 @@ const useConfig = (id: string, payload: IterationNodeType) => { const childrenNodeVars = toNodeOutputVars(iterationChildrenNodes, isChatMode) const handleOutputVarChange = useCallback((output: ValueSelector | string, _varKindType: VarKindType, varInfo?: Var) => { + if (isEqual(inputs.output_selector, output as ValueSelector)) + return + const newInputs = produce(inputs, (draft) => { draft.output_selector = output as ValueSelector || [] const outputItemType = varInfo?.type || VarType.string @@ -61,7 +69,8 @@ const useConfig = (id: string, payload: IterationNodeType) => { } as Record)[outputItemType] || VarType.arrayString }) setInputs(newInputs) - }, [inputs, setInputs]) + deleteNodeInspectorVars(id) + }, [deleteNodeInspectorVars, id, inputs, setInputs]) // single run const iteratorInputKey = `${id}.input_selector`