setIsCollapsed(!isCollapsed)}>
{nodeData && (
<>
diff --git a/web/app/components/workflow/variable-inspect/left.tsx b/web/app/components/workflow/variable-inspect/left.tsx
index d6028a9d52..6f795add46 100644
--- a/web/app/components/workflow/variable-inspect/left.tsx
+++ b/web/app/components/workflow/variable-inspect/left.tsx
@@ -25,6 +25,8 @@ const Left = ({
const { t } = useTranslation()
const environmentVariables = useStore(s => s.environmentVariables)
+ const setCurrentFocusNodeId = useStore(s => s.setCurrentFocusNodeId)
+
const {
conversationVars,
systemVars,
@@ -36,12 +38,22 @@ const Left = ({
const showDivider = environmentVariables.length > 0 || conversationVars.length > 0 || systemVars.length > 0
+ const handleClearAll = () => {
+ deleteAllInspectorVars()
+ setCurrentFocusNodeId('')
+ }
+
+ const handleClearNode = (nodeId: string) => {
+ deleteNodeInspectorVars(nodeId)
+ setCurrentFocusNodeId('')
+ }
+
return (
{/* header */}
{t('workflow.debug.variableInspect.title')}
-
+
{/* content */}
@@ -88,7 +100,7 @@ const Left = ({
currentVar={currentNodeVar}
handleSelect={handleVarSelect}
handleView={() => handleNodeSelect(group.nodeId)}
- handleClear={() => deleteNodeInspectorVars(group.nodeId)}
+ handleClear={() => handleClearNode(group.nodeId)}
/>
))}
diff --git a/web/app/components/workflow/variable-inspect/panel.tsx b/web/app/components/workflow/variable-inspect/panel.tsx
index 87d2eedc0c..e5441f8408 100644
--- a/web/app/components/workflow/variable-inspect/panel.tsx
+++ b/web/app/components/workflow/variable-inspect/panel.tsx
@@ -1,5 +1,5 @@
import type { FC } from 'react'
-import { useCallback, useMemo, useState } from 'react'
+import { useCallback, useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
RiCloseLine,
@@ -88,7 +88,7 @@ const Panel: FC = () => {
return res
}
if (currentFocusNodeId === VarInInspectType.system) {
- const currentVar = conversationVars.find(v => v.id === currentVarId)
+ const currentVar = systemVars.find(v => v.id === currentVarId)
const res = {
nodeId: VarInInspectType.system,
title: VarInInspectType.system,
@@ -128,10 +128,15 @@ const Panel: FC = () => {
const handleNodeVarSelect = useCallback((node: currentVarType) => {
setCurrentFocusNodeId(node.nodeId)
setCurrentVarId(node.var.id)
- const targetNode = nodesWithInspectVars.find(n => n.nodeId === node.nodeId)
- if (targetNode && !targetNode.isValueFetched)
- fetchInspectVarValue([node.nodeId])
- }, [fetchInspectVarValue, nodesWithInspectVars])
+ }, [setCurrentFocusNodeId, setCurrentVarId])
+
+ useEffect(() => {
+ if (currentFocusNodeId && currentVarId) {
+ const targetNode = nodesWithInspectVars.find(node => node.nodeId === currentFocusNodeId)
+ if (targetNode && !targetNode.isValueFetched)
+ fetchInspectVarValue([currentFocusNodeId])
+ }
+ }, [currentFocusNodeId, currentVarId, nodesWithInspectVars, fetchInspectVarValue])
if (isEmpty) {
return (
diff --git a/web/app/components/workflow/variable-inspect/right.tsx b/web/app/components/workflow/variable-inspect/right.tsx
index 94a35b5088..3b0920c6fa 100644
--- a/web/app/components/workflow/variable-inspect/right.tsx
+++ b/web/app/components/workflow/variable-inspect/right.tsx
@@ -35,6 +35,7 @@ const Right = ({
const { t } = useTranslation()
const bottomPanelWidth = useStore(s => s.bottomPanelWidth)
const setShowVariableInspectPanel = useStore(s => s.setShowVariableInspectPanel)
+ const setCurrentFocusNodeId = useStore(s => s.setCurrentFocusNodeId)
const {
resetToLastRunVar,
@@ -51,6 +52,11 @@ const Right = ({
resetToLastRunVar(currentNodeVar.nodeId, currentNodeVar.var.id)
}
+ const handleClose = () => {
+ setShowVariableInspectPanel(false)
+ setCurrentFocusNodeId('')
+ }
+
return (
{/* header */}
@@ -109,7 +115,7 @@ const Right = ({
)}
>
)}
-
setShowVariableInspectPanel(false)}>
+