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 af2e179854..adfd9f1068 100644 --- a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts +++ b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts @@ -21,10 +21,10 @@ const useInspectVarsCrud = () => { setInspectVarValue, renameInspectVarName: renameInspectVarNameInStore, deleteAllInspectVars: deleteAllInspectVarsInStore, + hasNodeInspectVars, deleteNodeInspectVars: deleteNodeInspectVarsInStore, deleteInspectVar: deleteInspectVarInStore, isInspectVarEdited, - getLastRunVar, } = workflowStore.getState() const { data: conversationVars } = useConversationVarValues(appId) @@ -61,7 +61,9 @@ const useInspectVarsCrud = () => { } const deleteNodeInspectorVars = async (nodeId: string) => { - await doDeleteNodeInspectorVars(nodeId) + if (hasNodeInspectVars(nodeId)) + await doDeleteNodeInspectorVars(nodeId) + deleteNodeInspectVarsInStore(nodeId) } @@ -95,9 +97,10 @@ const useInspectVarsCrud = () => { } const resetToLastRunVar = (nodeId: string, key: string) => { - const lastRunVar = getLastRunVar(nodeId, key) - if (lastRunVar) - editInspectVarValue(nodeId, key, lastRunVar) + // const lastRunVar = getLastRunVar(nodeId, key) + // if (lastRunVar) + // editInspectVarValue(nodeId, key, lastRunVar) + // TODO } // console.log(conversationVars, systemVars) diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts index 94b10c9929..e20215d64d 100644 --- a/web/app/components/workflow/hooks/use-nodes-interactions.ts +++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts @@ -60,6 +60,7 @@ import { useWorkflowReadOnly, } from './use-workflow' import { WorkflowHistoryEvent, useWorkflowHistory } from './use-workflow-history' +import useInspectVarsCrud from './use-inspect-vars-crud' export const useNodesInteractions = () => { const { t } = useTranslation() @@ -530,6 +531,8 @@ export const useNodesInteractions = () => { setEnteringNodePayload(undefined) }, [store, handleNodeConnect, getNodesReadOnly, workflowStore, reactflow]) + const { deleteNodeInspectorVars } = useInspectVarsCrud() + const handleNodeDelete = useCallback((nodeId: string) => { if (getNodesReadOnly()) return @@ -551,6 +554,7 @@ export const useNodesInteractions = () => { if (currentNode.data.type === BlockEnum.Start) return + deleteNodeInspectorVars(nodeId) if (currentNode.data.type === BlockEnum.Iteration) { const iterationChildren = nodes.filter(node => node.parentId === currentNode.id)