From d5e120f8f5b888ddf8a06423becb0cdbfab57db9 Mon Sep 17 00:00:00 2001 From: y00916259 Date: Sat, 10 May 2025 10:00:57 +0800 Subject: [PATCH] fix: Agent log modal fails to open and the timer is not cleared (#18900) --- web/app/components/base/chat/chat/hooks.ts | 2 ++ web/app/components/base/chat/chat/type.ts | 1 + .../components/base/markdown-blocks/think-block.tsx | 10 ++++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts index bff222ea38..fde4674539 100644 --- a/web/app/components/base/chat/chat/hooks.ts +++ b/web/app/components/base/chat/chat/hooks.ts @@ -424,6 +424,8 @@ export const useChat = ( const response = responseItem as any if (thought.message_id && !hasSetResponseId) response.id = thought.message_id + if (thought.conversation_id) + response.conversationId = thought.conversation_id if (response.agent_thoughts.length === 0) { response.agent_thoughts.push(thought) diff --git a/web/app/components/base/chat/chat/type.ts b/web/app/components/base/chat/chat/type.ts index 7f22ba05b7..b37151f8f9 100644 --- a/web/app/components/base/chat/chat/type.ts +++ b/web/app/components/base/chat/chat/type.ts @@ -41,6 +41,7 @@ export type ThoughtItem = { tool_input: string tool_labels?: { [key: string]: TypeWithI18N } message_id: string + conversation_id: string observation: string position: number files?: string[] diff --git a/web/app/components/base/markdown-blocks/think-block.tsx b/web/app/components/base/markdown-blocks/think-block.tsx index 282282db2b..565582e326 100644 --- a/web/app/components/base/markdown-blocks/think-block.tsx +++ b/web/app/components/base/markdown-blocks/think-block.tsx @@ -41,9 +41,10 @@ const useThinkTimer = (children: any) => { const timerRef = useRef() useEffect(() => { + if (isComplete) return + timerRef.current = setInterval(() => { - if (!isComplete) - setElapsedTime(Math.floor((Date.now() - startTime) / 100) / 10) + setElapsedTime(Math.floor((Date.now() - startTime) / 100) / 10) }, 100) return () => { @@ -53,11 +54,8 @@ const useThinkTimer = (children: any) => { }, [startTime, isComplete]) useEffect(() => { - if (hasEndThink(children)) { + if (hasEndThink(children)) setIsComplete(true) - if (timerRef.current) - clearInterval(timerRef.current) - } }, [children]) return { elapsedTime, isComplete }