瀏覽代碼

fix: agent log modal fails to open and the timer is not cleared (#18900) (#19471)

tags/1.4.0
yangzheli 5 月之前
父節點
當前提交
87da155477
沒有連結到貢獻者的電子郵件帳戶。

+ 2
- 0
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)

+ 1
- 0
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[]

+ 4
- 6
web/app/components/base/markdown-blocks/think-block.tsx 查看文件

@@ -41,9 +41,10 @@ const useThinkTimer = (children: any) => {
const timerRef = useRef<NodeJS.Timeout>()

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 }

Loading…
取消
儲存