diff --git a/frontend/app/components/assistant-ui/activity-panel.tsx b/frontend/app/components/assistant-ui/activity-panel.tsx index 8dff7df..561f028 100644 --- a/frontend/app/components/assistant-ui/activity-panel.tsx +++ b/frontend/app/components/assistant-ui/activity-panel.tsx @@ -120,13 +120,18 @@ export function ActivityPanel() { const visibleItems = selectedMessageId ? items.filter((item) => activityMessageId(item.id) === selectedMessageId) : items; - const prevCountRef = useRef(0); + const prevLatestIdRef = useRef(null); useEffect(() => { - if (mode === "activity" && items.length > prevCountRef.current) { - openItem(items.at(-1)?.id ?? items[0]?.id ?? ""); + const latestId = items.at(-1)?.id ?? null; + if ( + mode === "activity" && + latestId && + latestId !== prevLatestIdRef.current + ) { + openItem(latestId); } - prevCountRef.current = items.length; + prevLatestIdRef.current = latestId; }, [items, mode, openItem]); if (!open) return null;