From 943fccf65563f7db6d86bbb79e2e06119be7a280 Mon Sep 17 00:00:00 2001 From: icarus Date: Sun, 14 Sep 2025 00:15:45 +0800 Subject: [PATCH] refactor(useAgents): simplify addAgent_ by accepting complete agent entity --- src/renderer/src/hooks/useAgents.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/hooks/useAgents.ts b/src/renderer/src/hooks/useAgents.ts index 69aeb94d08..9d66c36890 100644 --- a/src/renderer/src/hooks/useAgents.ts +++ b/src/renderer/src/hooks/useAgents.ts @@ -1,22 +1,17 @@ import { useAppDispatch } from '@renderer/store' import { addAgent, removeAgent, setAgents, updateAgent } from '@renderer/store/agents' import { AgentEntity } from '@renderer/types' -import { uuid } from '@renderer/utils' import { useCallback } from 'react' export const useAgents = () => { const dispatch = useAppDispatch() /** * Adds a new agent to the store - * @param config - The configuration object for the new agent (without id) + * @param agent - The complete agent entity to add */ const addAgent_ = useCallback( - (config: Omit) => { - const entity = { - ...config, - id: uuid() - } as const - dispatch(addAgent(entity)) + (agent: AgentEntity) => { + dispatch(addAgent(agent)) }, [dispatch] )