// import { useState } from 'react' import { useTranslation } from 'react-i18next' import { useStore } from '../store' import Button from '@/app/components/base/button' // import ActionButton from '@/app/components/base/action-button' // import Tooltip from '@/app/components/base/tooltip' import Group from './group' import useCurrentVars from '../hooks/use-inspect-vars-crud' import { useNodesInteractions } from '../hooks/use-nodes-interactions' import type { currentVarType } from './panel' import type { VarInInspect } from '@/types/workflow' import { VarInInspectType } from '@/types/workflow' import cn from '@/utils/classnames' type Props = { currentNodeVar?: currentVarType handleVarSelect: (state: any) => void } const Left = ({ currentNodeVar, handleVarSelect, }: Props) => { const { t } = useTranslation() const environmentVariables = useStore(s => s.environmentVariables) const setCurrentFocusNodeId = useStore(s => s.setCurrentFocusNodeId) const { conversationVars, systemVars, nodesWithInspectVars, deleteAllInspectorVars, deleteNodeInspectorVars, } = useCurrentVars() const { handleNodeSelect } = useNodesInteractions() 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 */}
{/* group ENV */} {environmentVariables.length > 0 && ( )} {/* group CHAT VAR */} {conversationVars.length > 0 && ( )} {/* group SYSTEM VAR */} {systemVars.length > 0 && ( )} {/* divider */} {showDivider && (
)} {/* group nodes */} {nodesWithInspectVars.length > 0 && nodesWithInspectVars.map(group => ( handleNodeSelect(group.nodeId, false, true)} handleClear={() => handleClearNode(group.nodeId)} /> ))}
) } export default Left