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.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user