From 995d0c900db52265aca26c2d3eec75156847a393 Mon Sep 17 00:00:00 2001 From: jlightner Date: Fri, 3 Apr 2026 03:30:45 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20StageTabView=20useCallback=20dependency?= =?UTF-8?q?=20loop=20=E2=80=94=20use=20ref=20for=20initial=20tab=20selecti?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/AdminPipeline.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/AdminPipeline.tsx b/frontend/src/pages/AdminPipeline.tsx index da9805f..7263eea 100644 --- a/frontend/src/pages/AdminPipeline.tsx +++ b/frontend/src/pages/AdminPipeline.tsx @@ -537,6 +537,7 @@ function StageTabView({ videoId, runId, status }: { videoId: string; runId: stri const [events, setEvents] = useState([]); const [loading, setLoading] = useState(true); const [activeTab, setActiveTab] = useState(null); + const initialSelect = useRef(false); const load = useCallback(async (silent = false) => { if (!silent) setLoading(true); @@ -548,14 +549,14 @@ function StageTabView({ videoId, runId, status }: { videoId: string; runId: stri run_id: runId, }); setEvents(res.items); - // Auto-select the most interesting tab: latest active or error stage - if (!silent && activeTab === null && res.items.length > 0) { + // Auto-select tab on first load only + if (!initialSelect.current && res.items.length > 0) { + initialSelect.current = true; const stages = new Set(res.items.map((e) => e.stage)); const errorStage = res.items.find((e) => e.event_type === "error")?.stage; if (errorStage) { setActiveTab(errorStage); } else { - // Pick the latest stage that has events const lastStage = [...STAGE_TAB_ORDER].reverse().find((s) => stages.has(s.key)); if (lastStage) setActiveTab(lastStage.key); } @@ -565,7 +566,7 @@ function StageTabView({ videoId, runId, status }: { videoId: string; runId: stri } finally { if (!silent) setLoading(false); } - }, [videoId, runId, activeTab]); + }, [videoId, runId]); useEffect(() => { void load(); }, [load]);