From fc1d1aed91ba61eb2473a443cf886185c8aa8dc9 Mon Sep 17 00:00:00 2001 From: npub1jmc9dt2lyvzu3h0kxlwxt5zg4fxp9476awyxw6gwxn72g6cw7exqs64whm <96f056ad5f2305c8ddf637dc65d048aa4c12d7daeb8867690e34fca46b0ef64c@sprout-oss.stage.blox.sqprod.co> Date: Wed, 8 Jul 2026 10:15:29 -0400 Subject: [PATCH] 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 Signed-off-by: Tyler Longwell --- desktop/src/features/agents/hooks.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/agents/hooks.ts b/desktop/src/features/agents/hooks.ts index 0958ff371..1ff313a92 100644 --- a/desktop/src/features/agents/hooks.ts +++ b/desktop/src/features/agents/hooks.ts @@ -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, }); }