Feat: Deleting the last tool of the agent will delete the tool node #3221 (#8376)

### What problem does this PR solve?

Feat: Deleting the last tool of the agent will delete the tool node
#3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-19 19:23:16 +08:00
committed by GitHub
parent fa3e90c72e
commit 972fd919b4
14 changed files with 245 additions and 94 deletions

View File

@ -35,6 +35,7 @@ export type RFState = {
selectedNodeIds: string[];
selectedEdgeIds: string[];
clickedNodeId: string; // currently selected node
clickedToolId: string; // currently selected tool id
onNodesChange: OnNodesChange<RAGFlowNodeType>;
onEdgesChange: OnEdgesChange;
onConnect: OnConnect;
@ -73,6 +74,7 @@ export type RFState = {
updateNodeName: (id: string, name: string) => void;
generateNodeName: (name: string) => string;
setClickedNodeId: (id?: string) => void;
setClickedToolId: (id?: string) => void;
};
// this is our useStore hook that we can use in our components to get parts of the store and call actions
@ -84,6 +86,7 @@ const useGraphStore = create<RFState>()(
selectedNodeIds: [] as string[],
selectedEdgeIds: [] as string[],
clickedNodeId: '',
clickedToolId: '',
onNodesChange: (changes) => {
set({
nodes: applyNodeChanges(changes, get().nodes),
@ -465,6 +468,9 @@ const useGraphStore = create<RFState>()(
return generateNodeNamesWithIncreasingIndex(name, nodes);
},
setClickedToolId: (id?: string) => {
set({ clickedToolId: id });
},
})),
{ name: 'graph', trace: true },
),