From e89e35c6fd658bc50c6648787a12251b617db52e Mon Sep 17 00:00:00 2001 From: wuyang6 Date: Mon, 11 May 2026 21:16:41 +0800 Subject: [PATCH] Fix activity replay after refresh --- .../app/components/assistant-ui/activity-panel.tsx | 13 +++++++++++-- .../app/components/assistant-ui/thread-list.tsx | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/assistant-ui/activity-panel.tsx b/frontend/app/components/assistant-ui/activity-panel.tsx index 50c4903..1c065b2 100644 --- a/frontend/app/components/assistant-ui/activity-panel.tsx +++ b/frontend/app/components/assistant-ui/activity-panel.tsx @@ -45,6 +45,7 @@ type ActivityContextValue = { selectedId: string | null; sessionId: string | null; filesRefreshToken: number; + openActivity: () => void; openItem: (id: string) => void; openFiles: (sessionId?: string | null) => void; close: () => void; @@ -58,6 +59,11 @@ export function ActivityProvider({ children }: { children: ReactNode }) { const [selectedId, setSelectedId] = useState(null); const [sessionId, setSessionId] = useState(null); const [filesRefreshToken, setFilesRefreshToken] = useState(0); + const openActivity = useCallback(() => { + setMode("activity"); + setSelectedId(null); + setOpen(true); + }, []); const openItem = useCallback((id: string) => { setMode("activity"); setSelectedId(id); @@ -82,6 +88,7 @@ export function ActivityProvider({ children }: { children: ReactNode }) { selectedId, sessionId, filesRefreshToken, + openActivity, openItem, openFiles, close, @@ -92,6 +99,7 @@ export function ActivityProvider({ children }: { children: ReactNode }) { selectedId, sessionId, filesRefreshToken, + openActivity, openItem, openFiles, close, @@ -133,6 +141,7 @@ export function ActivityPanel() { selectedId, sessionId, filesRefreshToken, + openActivity, openItem, close, } = useActivityPanel(); @@ -151,10 +160,10 @@ export function ActivityPanel() { latestId && latestId !== prevLatestIdRef.current ) { - openItem(latestId); + openActivity(); } prevLatestIdRef.current = latestId; - }, [items, mode, openItem]); + }, [items, mode, openActivity]); if (!open) return null; diff --git a/frontend/app/components/assistant-ui/thread-list.tsx b/frontend/app/components/assistant-ui/thread-list.tsx index 9c1aff1..20b6677 100644 --- a/frontend/app/components/assistant-ui/thread-list.tsx +++ b/frontend/app/components/assistant-ui/thread-list.tsx @@ -406,13 +406,13 @@ export function toReplayRepository( if (message.role === "tool") continue; if (message.role !== "user" && message.role !== "assistant") continue; const content = cleanStoredContent(message.content ?? ""); - if (!content) continue; - if (content.trimStart().startsWith("")) continue; - const id = `${fallbackSessionId}-${index}`; const toolParts = message.role === "assistant" ? toToolParts(message.tool_calls ?? [], toolResults, content) : []; + if (!content && !toolParts.length) continue; + if (content.trimStart().startsWith("")) continue; + const id = `${fallbackSessionId}-${index}`; const shouldShowAssistantText = message.role !== "assistant" || !toolParts.length ||