From 4c4039283fa7fa3f4d03fa084090791c977202f5 Mon Sep 17 00:00:00 2001 From: icarus Date: Thu, 18 Sep 2025 22:46:24 +0800 Subject: [PATCH] fix(useSessions): correct session fetching logic to use API call Previously the getSession hook was only searching local data. Now it properly fetches from the API and updates the cache. This ensures data consistency when sessions are modified elsewhere. --- src/renderer/src/hooks/agents/useSessions.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/hooks/agents/useSessions.ts b/src/renderer/src/hooks/agents/useSessions.ts index b84cda5aaf..818eba7cc2 100644 --- a/src/renderer/src/hooks/agents/useSessions.ts +++ b/src/renderer/src/hooks/agents/useSessions.ts @@ -30,9 +30,11 @@ export const useSessions = (agent: AgentEntity) => { // TODO: including messages field const getSession = useCallback( async (id: string) => { - return data?.find((session) => session.id === id) + const result = await client.getSession(agent.id, id) + mutate((prev) => prev?.map((session) => (session.id === result.id ? result : session))) + return result }, - [data] + [agent.id, client, mutate] ) return {