diff --git a/web/src/pages/agent/canvas/edge/index.tsx b/web/src/pages/agent/canvas/edge/index.tsx index 2b67cdbad..aa6e8f94d 100644 --- a/web/src/pages/agent/canvas/edge/index.tsx +++ b/web/src/pages/agent/canvas/edge/index.tsx @@ -1,5 +1,6 @@ import { BaseEdge, + Edge, EdgeLabelRenderer, EdgeProps, getBezierPath, @@ -8,7 +9,9 @@ import useGraphStore from '../../store'; import { useTheme } from '@/components/theme-provider'; import { useFetchAgent } from '@/hooks/use-agent-request'; +import { cn } from '@/lib/utils'; import { useMemo } from 'react'; +import { NodeHandleId, Operator } from '../../constant'; import styles from './index.less'; export function ButtonEdge({ @@ -24,7 +27,9 @@ export function ButtonEdge({ style = {}, markerEnd, selected, -}: EdgeProps) { + data, + sourceHandleId, +}: EdgeProps>) { const deleteEdgeById = useGraphStore((state) => state.deleteEdgeById); const [edgePath, labelX, labelY] = getBezierPath({ sourceX, @@ -72,6 +77,14 @@ export function ButtonEdge({ return {}; }, [source, target, graphPath]); + const visible = useMemo(() => { + return ( + data?.isHovered && + sourceHandleId !== NodeHandleId.Tool && // The connection between the agent node and the tool node does not need to display the delete button + !target.startsWith(Operator.Tool) + ); + }, [data?.isHovered, sourceHandleId, target]); + return ( <> +