import { Sheet, SheetContent, SheetHeader, SheetTitle, } from '@/components/ui/sheet'; import { useTranslate } from '@/hooks/common-hooks'; import { IModalProps } from '@/interfaces/common'; import { RAGFlowNodeType } from '@/interfaces/database/flow'; import { cn } from '@/lib/utils'; import { lowerFirst } from 'lodash'; import { CirclePlay, X } from 'lucide-react'; import { Operator } from '../constant'; import { AgentFormContext } from '../context'; import { RunTooltip } from '../flow-tooltip'; import { useIsMcp } from '../hooks/use-is-mcp'; import OperatorIcon from '../operator-icon'; import useGraphStore from '../store'; import { needsSingleStepDebugging } from '../utils'; import { FormConfigMap } from './form-config-map'; import SingleDebugSheet from './single-debug-sheet'; import { TitleInput } from './title-input'; interface IProps { node?: RAGFlowNodeType; singleDebugDrawerVisible: IModalProps['visible']; hideSingleDebugDrawer: IModalProps['hideModal']; showSingleDebugDrawer: IModalProps['showModal']; chatVisible: boolean; } const EmptyContent = () =>
; const FormSheet = ({ visible, hideModal, node, singleDebugDrawerVisible, chatVisible, hideSingleDebugDrawer, showSingleDebugDrawer, }: IModalProps & IProps) => { const operatorName: Operator = node?.data.label as Operator; const clickedToolId = useGraphStore((state) => state.clickedToolId); const currentFormMap = FormConfigMap[operatorName]; const OperatorForm = currentFormMap?.component ?? EmptyContent; const isMcp = useIsMcp(operatorName); const { t } = useTranslate('flow'); return (
{needsSingleStepDebugging(operatorName) && ( )}
{isMcp || ( {t( `${lowerFirst(operatorName === Operator.Tool ? clickedToolId : operatorName)}Description`, )} )}
{visible && ( )}
{singleDebugDrawerVisible && ( )}
); }; export default FormSheet;