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 {