Feat: Filter the query variable drop-down box options by type #3221 (#8485)

### What problem does this PR solve?

Feat: Filter the query variable drop-down box options by type #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-25 16:23:20 +08:00
committed by GitHub
parent b705ff08fe
commit c4b58ed195
13 changed files with 124 additions and 23 deletions

View File

@ -232,8 +232,15 @@ function useAddToolNode() {
return { addToolNode };
}
function isBottomSubAgent(type: string, position: Position) {
return (
(type === Operator.Agent && position === Position.Bottom) ||
type === Operator.Tool
);
}
export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
const { edges, nodes, addEdge, addNode, getNode } = useGraphStore(
const { edges, nodes, addEdge, addNode, getNode, updateNode } = useGraphStore(
(state) => state,
);
const getNodeName = useGetNodeName();
@ -291,6 +298,18 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
if (node && node.parentId) {
newNode.parentId = node.parentId;
newNode.extent = 'parent';
const parentNode = getNode(node.parentId);
if (parentNode && !isBottomSubAgent(type, params.position)) {
const MoveRightDistance = 310;
updateNode({
...parentNode,
width: (parentNode.width || 0) + MoveRightDistance,
position: {
x: parentNode.position.x + MoveRightDistance / 2,
y: parentNode.position.y,
},
});
}
}
if (type === Operator.Iteration) {
@ -377,6 +396,7 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
initializeOperatorParams,
nodes,
reactFlowInstance,
updateNode,
],
);