fix(desktop): refresh the agent-template catalog on inbound relay sync

The agent-templates query pins staleTime: Infinity, so a saved template
created, edited, or tombstoned on another device never reached the New
Agent catalog until app restart. Invalidate agentTemplatesQueryKey in the
agents-data-changed listener alongside the other relay-backed queries.

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w
2026-07-03 14:04:26 -07:00
co-authored by Taylor Ho
parent 28ca228e19
commit 99534b5d6f
@@ -3,6 +3,7 @@ import { useQueryClient } from "@tanstack/react-query";
import { useEffect } from "react";
import {
agentTemplatesQueryKey,
managedAgentsQueryKey,
personasQueryKey,
relayAgentsQueryKey,
@@ -34,6 +35,13 @@ export function useAgentsDataRefresh(): void {
void queryClient.invalidateQueries({ queryKey: teamsQueryKey });
void queryClient.invalidateQueries({ queryKey: managedAgentsQueryKey });
void queryClient.invalidateQueries({ queryKey: relayAgentsQueryKey });
// Saved templates are persona records, so an inbound persona
// upsert/tombstone from another device changes the New Agent
// catalog too. Without this line the catalog query (staleTime:
// Infinity) would serve the pre-sync list forever.
void queryClient.invalidateQueries({
queryKey: agentTemplatesQueryKey,
});
}, COALESCE_MS);
});