diff --git a/web/src/components/originui/select-with-search.tsx b/web/src/components/originui/select-with-search.tsx
index cf0e2b469..fbf1584e0 100644
--- a/web/src/components/originui/select-with-search.tsx
+++ b/web/src/components/originui/select-with-search.tsx
@@ -153,7 +153,7 @@ export const SelectWithSearch = forwardRef<
{option.label}
- {option.value}
+
{value === option.value && (
)}
diff --git a/web/src/interfaces/database/flow.ts b/web/src/interfaces/database/flow.ts
index dd07f5847..f59f647ad 100644
--- a/web/src/interfaces/database/flow.ts
+++ b/web/src/interfaces/database/flow.ts
@@ -11,6 +11,7 @@ export interface DSL {
graph?: IGraph;
messages: Message[];
reference: IReference[];
+ globals: Record;
}
export interface IOperator {
diff --git a/web/src/pages/agent/canvas/edge/index.tsx b/web/src/pages/agent/canvas/edge/index.tsx
index d38b85ac0..2b67cdbad 100644
--- a/web/src/pages/agent/canvas/edge/index.tsx
+++ b/web/src/pages/agent/canvas/edge/index.tsx
@@ -57,7 +57,7 @@ export function ButtonEdge({
if (previousGraphPath.length > 0 && previousLatestElement) {
graphPath = [previousLatestElement, ...graphPath];
}
- return graphPath;
+ return Array.isArray(graphPath) ? graphPath : [];
}, [flowDetail.dsl?.path]);
const highlightStyle = useMemo(() => {
diff --git a/web/src/pages/agent/canvas/node/agent-node.tsx b/web/src/pages/agent/canvas/node/agent-node.tsx
index de3bc0720..528c077ce 100644
--- a/web/src/pages/agent/canvas/node/agent-node.tsx
+++ b/web/src/pages/agent/canvas/node/agent-node.tsx
@@ -2,7 +2,9 @@ import { useTheme } from '@/components/theme-provider';
import { IAgentNode } from '@/interfaces/database/flow';
import { Handle, NodeProps, Position } from '@xyflow/react';
import classNames from 'classnames';
-import { memo } from 'react';
+import { memo, useMemo } from 'react';
+import { Operator } from '../../constant';
+import useGraphStore from '../../store';
import { LeftHandleStyle, RightHandleStyle } from './handle-icon';
import styles from './index.less';
import NodeHeader from './node-header';
@@ -14,6 +16,15 @@ function InnerAgentNode({
selected,
}: NodeProps) {
const { theme } = useTheme();
+ const getNode = useGraphStore((state) => state.getNode);
+ const edges = useGraphStore((state) => state.edges);
+
+ const isNotParentAgent = useMemo(() => {
+ const edge = edges.find((x) => x.target === id);
+ const label = getNode(edge?.source)?.data.label;
+ return label !== Operator.Agent;
+ }, [edges, getNode, id]);
+
return (
-
-
+ {isNotParentAgent && (
+ <>
+
+
+ >
+ )}
{
+ const globalOptions = Object.keys(data?.dsl?.globals ?? {}).map((x) => ({
+ label: x,
+ value: x,
+ }));
+ return [
+ { ...options[0], options: [...options[0]?.options, ...globalOptions] },
+ ...options.slice(1),
+ ];
+ }, [data.dsl.globals, options]);
return (
{t('flow.query')}
-
+
diff --git a/web/src/pages/agent/hooks/use-add-node.ts b/web/src/pages/agent/hooks/use-add-node.ts
index b8166c92b..d2b8b7fba 100644
--- a/web/src/pages/agent/hooks/use-add-node.ts
+++ b/web/src/pages/agent/hooks/use-add-node.ts
@@ -128,9 +128,10 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance) {
const addNode = useGraphStore((state) => state.addNode);
const getNode = useGraphStore((state) => state.getNode);
const addEdge = useGraphStore((state) => state.addEdge);
+ const nodes = useGraphStore((state) => state.nodes);
+ const edges = useGraphStore((state) => state.edges);
const getNodeName = useGetNodeName();
const initializeOperatorParams = useInitializeOperatorParams();
- const nodes = useGraphStore((state) => state.nodes);
// const [reactFlowInstance, setReactFlowInstance] =
// useState>();
@@ -182,8 +183,19 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance) {
} else if (type === Operator.Agent) {
const agentNode = getNode(id);
if (agentNode) {
+ // Calculate the coordinates of child nodes to prevent newly added child nodes from covering other child nodes
+ const allChildAgentNodeIds = edges
+ .filter((x) => x.source === id && x.sourceHandle === 'e')
+ .map((x) => x.target);
+
+ const xAxises = nodes
+ .filter((x) => allChildAgentNodeIds.some((y) => y === x.id))
+ .map((x) => x.position.x);
+
+ const maxX = Math.max(...xAxises);
+
newNode.position = {
- x: agentNode.position.x + 82,
+ x: xAxises.length > 0 ? maxX + 262 : agentNode.position.x + 82,
y: agentNode.position.y + 140,
};
}