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 fbe91d015d..48921ae400 100644 --- a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts +++ b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts @@ -47,7 +47,6 @@ const useInspectVarsCrud = () => { const nodeId = selector[0] const isSystemVar = nodeId === 'sys' const isConversationVar = nodeId === 'conversation' - console.log(nodeId, isSystemVar, isConversationVar) if (isSystemVar) { invalidateSysVarValues() return diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx index 34c610c39e..e70a471cf3 100644 --- a/web/app/components/workflow/nodes/_base/node.tsx +++ b/web/app/components/workflow/nodes/_base/node.tsx @@ -44,7 +44,7 @@ import AddVariablePopupWithPosition from './components/add-variable-popup-with-p import cn from '@/utils/classnames' import BlockIcon from '@/app/components/workflow/block-icon' import Tooltip from '@/app/components/base/tooltip' -import { useWorkflowStore } from '../../store' +import { useStore } from '../../store' type BaseNodeProps = { children: ReactElement @@ -90,10 +90,7 @@ const BaseNode: FC = ({ } }, [data.isInLoop, data.selected, id, handleNodeLoopChildSizeChange]) - const workflowStore = useWorkflowStore() - const { - hasNodeInspectVars, - } = workflowStore.getState() + const hasNodeInspectVars = useStore(s => s.hasNodeInspectVars) const hasVarValue = hasNodeInspectVars(id) const showSelectedBorder = data.selected || data._isBundled || data._isEntering const { diff --git a/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts b/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts index 35ba111708..cd9d7026e3 100644 --- a/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts +++ b/web/app/components/workflow/store/workflow/debug/inspect-vars-slice.ts @@ -71,17 +71,24 @@ export const createInspectVarsSlice: StateCreator = (set, } }) }, + // after last run would call this appendNodeInspectVars: (nodeId, payload, allNodes) => { set((state) => { const nodes = state.nodesWithInspectVars const nodeInfo = allNodes.find(node => node.id === nodeId) if (nodeInfo) { - nodes.push({ - nodeId, - nodeType: nodeInfo.data.type, - title: nodeInfo.data.title, - vars: payload, - }) + const index = nodes.findIndex(node => node.nodeId === nodeId) + if (index === -1) { + nodes.push({ + nodeId, + nodeType: nodeInfo.data.type, + title: nodeInfo.data.title, + vars: payload, + }) + } + else { + nodes[index].vars = payload + } } return { nodesWithInspectVars: nodes, diff --git a/web/app/components/workflow/variable-inspect/trigger.tsx b/web/app/components/workflow/variable-inspect/trigger.tsx index 247e7ed6cb..3122c5d234 100644 --- a/web/app/components/workflow/variable-inspect/trigger.tsx +++ b/web/app/components/workflow/variable-inspect/trigger.tsx @@ -35,7 +35,7 @@ const VariableInspectTrigger: FC = () => { const currentVars = useMemo(() => { const allVars = [...environmentVariables, ...conversationVars, ...systemVars, ...nodesWithInspectVars] return allVars - }, [conversationVars, systemVars, nodesWithInspectVars]) + }, [environmentVariables, conversationVars, systemVars, nodesWithInspectVars]) // ##TODD stop handle