perf(desktop): relax relay-agents poll 30s->5min, pause when backgrounded

L6 finding: useRelayAgentsQuery ran a 30s refetchInterval backed by an
unfiltered relay query for ALL kind:10100 agent profiles, mounted on ~13
always-live surfaces (channel screen, members bar, mentions, sidebar,
profile popovers). It re-pulled the full profile set app-wide every 30s.

Relay agent profiles are near-static; 30s is far too aggressive. This poll
is also the ONLY refresh path for kind:10100 (the agents-data-changed event
fires only for local PERSONA/TEAM/MANAGED_AGENT reconcile, never kind:10100),
so it cannot be dropped. Relaxing to 5min drops relay traffic ~10x, and
refetchIntervalInBackground:false (matches channels/hooks.ts house style)
pauses it while the window is unfocused. No semantics change: the set of
relay agents still refreshes, just less often.

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
This commit is contained in:
npub1jmc9dt2lyvzu3h0kxlwxt5zg4fxp9476awyxw6gwxn72g6cw7exqs64whm
2026-07-08 10:52:10 -04:00
co-authored by Tyler Longwell
parent 53ba1f8269
commit fc1d1aed91
+10 -1
View File
@@ -209,7 +209,16 @@ export function useRelayAgentsQuery(options?: { enabled?: boolean }) {
queryKey: relayAgentsQueryKey,
queryFn: listRelayAgents,
staleTime: 30_000,
refetchInterval: 30_000,
// Relay agent profiles (kind:10100) are near-static and the backing
// `list_relay_agents` command is an unfiltered relay query for the whole
// profile set — mounted on ~13 always-live surfaces (channel screen,
// members bar, mentions, sidebar, profile popovers), so a tight interval
// re-pulls the full set app-wide. This poll is also the ONLY refresh path:
// the `agents-data-changed` event fires only for local persona/team/managed
// reconcile (kinds PERSONA/TEAM/MANAGED_AGENT), never for kind:10100. So we
// keep polling but at a relaxed cadence and pause it while backgrounded.
refetchInterval: 5 * 60_000,
refetchIntervalInBackground: false,
enabled: options?.enabled,
});
}