From c537e01aeee16e88c88ba59949c8e6b950f6e191 Mon Sep 17 00:00:00 2001 From: Harsh Date: Thu, 12 Mar 2026 01:08:26 +0530 Subject: [PATCH] fix: stabilize orchestrator detail zone refresh Keep the orchestrator detail page keyed on stable project-scoped values so zone-count polling does not recreate its callback on every session fetch and hammer the sessions API. --- packages/web/src/app/sessions/[id]/page.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/web/src/app/sessions/[id]/page.tsx b/packages/web/src/app/sessions/[id]/page.tsx index 00d021ef0..8a87bba57 100644 --- a/packages/web/src/app/sessions/[id]/page.tsx +++ b/packages/web/src/app/sessions/[id]/page.tsx @@ -52,6 +52,8 @@ export default function SessionPage() { const [zoneCounts, setZoneCounts] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const sessionProjectId = session?.projectId ?? null; + const sessionIsOrchestrator = session ? isOrchestratorSession(session) : false; // Update document title based on session data useEffect(() => { @@ -84,9 +86,9 @@ export default function SessionPage() { }, [id]); const fetchZoneCounts = useCallback(async () => { - if (!session || !isOrchestratorSession(session) || !session.projectId) return; + if (!sessionIsOrchestrator || !sessionProjectId) return; try { - const res = await fetch(`/api/sessions?project=${encodeURIComponent(session.projectId)}`); + const res = await fetch(`/api/sessions?project=${encodeURIComponent(sessionProjectId)}`); if (!res.ok) return; const body = (await res.json()) as { sessions: DashboardSession[] }; const sessions = body.sessions ?? []; @@ -105,9 +107,9 @@ export default function SessionPage() { } setZoneCounts(counts); } catch { - // non-critical — status strip just won't show + // non-critical - status strip just won't show } - }, [session]); + }, [sessionIsOrchestrator, sessionProjectId]); // Initial fetch — session first, zone counts after (avoids blocking on slow /api/sessions) useEffect(() => { @@ -150,7 +152,7 @@ export default function SessionPage() { return ( );