From a4a0677ce46872396abdb9849c05557aa3b62652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E9=98=B3?= Date: Thu, 7 May 2026 15:54:27 +0800 Subject: [PATCH] Focus latest activity item by id --- .../app/components/assistant-ui/activity-panel.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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;