mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
perf(desktop): drop redundant 30s polls on personas/teams/managed agents
L6 finding: usePersonasQuery, useTeamsQuery, and useManagedAgentsQuery's idle branch each ran a 30s refetchInterval that duplicated an existing event-driven refresh path. Inbound relay changes to PERSONA/TEAM/MANAGED_AGENT records emit agents-data-changed (personas/mod.rs), which useAgentsDataRefresh coalesces into a query invalidate (200ms window). The 30s poll was belt-and-suspenders disk-read IPC on top of correct event invalidation. Removed the interval from personas and teams entirely. For managed agents, kept the 5s branch for locally-running agents (process state can change with no relay event, so that poll is their only liveness signal) and dropped the idle 30s fallback (control-plane changes have the event path; the 5s branch already captures the running->stopped transition on its last poll, and user actions invalidate directly). Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
This commit is contained in:
co-authored by
Tyler Longwell
parent
fc1d1aed91
commit
f64dc32dd9
@@ -176,7 +176,10 @@ export function usePersonasQuery() {
|
||||
queryKey: personasQueryKey,
|
||||
queryFn: listPersonas,
|
||||
staleTime: 30_000,
|
||||
refetchInterval: 30_000,
|
||||
// No refetchInterval: inbound relay changes to personas emit
|
||||
// `agents-data-changed`, which `useAgentsDataRefresh` coalesces into an
|
||||
// invalidate (200ms window). The 30s poll was belt-and-suspenders on top of
|
||||
// that event path — redundant disk-read IPC.
|
||||
});
|
||||
}
|
||||
|
||||
@@ -231,12 +234,14 @@ export function useManagedAgentsQuery(options?: { enabled?: boolean }) {
|
||||
staleTime: 5_000,
|
||||
refetchInterval: (query) => {
|
||||
const agents = query.state.data as ManagedAgent[] | undefined;
|
||||
// Only local "running" agents need fast polling (process state can
|
||||
// change). "deployed" is static control-plane state — presence polling
|
||||
// handles the live signal for remote agents separately.
|
||||
// Only local "running" agents need polling: process state can change
|
||||
// with no relay event to signal it, so this poll is the only liveness
|
||||
// path for them. When nothing is running there IS an event path —
|
||||
// `agents-data-changed` (control-plane changes) — so the idle branch
|
||||
// drops its poll entirely rather than falling back to 30s.
|
||||
return agents?.some((agent) => agent.status === "running")
|
||||
? 5_000
|
||||
: 30_000;
|
||||
: false;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -689,7 +694,9 @@ export function useTeamsQuery() {
|
||||
queryKey: teamsQueryKey,
|
||||
queryFn: listTeams,
|
||||
staleTime: 30_000,
|
||||
refetchInterval: 30_000,
|
||||
// No refetchInterval: inbound relay team changes emit `agents-data-changed`
|
||||
// (handled by useAgentsDataRefresh). Same redundant-poll removal as
|
||||
// usePersonasQuery.
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user