Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
perf(community): stop refetching the servers() list on every channel switch
Shelly#3863a0db52b7539f
diff --git a/src/web/src/hooks/community/use-servers.ts b/src/web/src/hooks/community/use-servers.tsindex 90bf7918e..eab0da8c6 100644--- a/src/web/src/hooks/community/use-servers.ts+++ b/src/web/src/hooks/community/use-servers.ts@@ -54,6 +54,17 @@ export function useServers(): UseQueryResult<ServersResponse> & {const query = useQuery({queryKey: communityKeys.servers(),queryFn: serversQueryFn,+ // WS-maintained like the other server-scoped queries: server.update+ // live-patches this list (name/icon) and mention/member events invalidate+ // it to refresh counts. So a remount doesn't need to refetch — this is a+ // once-per-session seed. Without this, every channel switch that remounts a+ // `useServers` consumer re-fired `GET /api/community/servers` (the rail /+ // mention-badge list), a per-switch server-level request WS1/WS2 otherwise+ // eliminated. staleTime: Infinity stops that mount refetch; invalidations+ // still force a refresh regardless of staleTime, so counts stay live.+ // refetchOnReconnect backstops the socket-gap case (same as WS2).+ staleTime: Infinity,+ refetchOnReconnect: true,})return {...query,diff --git a/src/web/src/hooks/community/ws-live-query-config.test.ts b/src/web/src/hooks/community/ws-live-query-config.test.tsindex 47e31afc1..a572a8254 100644--- a/src/web/src/hooks/community/ws-live-query-config.test.ts+++ b/src/web/src/hooks/community/ws-live-query-config.test.ts@@ -93,6 +93,19 @@ describe("WS-live queries — staleTime: Infinity + refetchOnReconnect backstop"expect(cfg?.staleTime).toBe(Infinity)expect(cfg?.refetchOnReconnect).toBe(true)})++ it("useServers (the rail / mention-badge list) pairs Infinity staleTime with refetchOnReconnect", async () => {+ // Regression guard: without this the top-level servers() list refetched+ // `GET /api/community/servers` on every channel switch that remounted a+ // consumer — a per-switch server-level request WS1/WS2 were meant to kill.+ const { useServers } = await import("./use-servers")+ useServers()+ const cfg = queryConfigs.find(+ (c) => JSON.stringify(c.queryKey) === JSON.stringify(["community", "servers"]),+ )+ expect(cfg?.staleTime).toBe(Infinity)+ expect(cfg?.refetchOnReconnect).toBe(true)+ })})describe("non-WS-live queries — finite staleTime, never Infinity", () => {