Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: imporve the condition for stopping the think timer. (#25365)

17hz928bef9d82c8
diff --git a/web/app/components/base/markdown-blocks/think-block.tsx b/web/app/components/base/markdown-blocks/think-block.tsx
index 46f992d7584..a5813266f15 100644
--- a/web/app/components/base/markdown-blocks/think-block.tsx
+++ b/web/app/components/base/markdown-blocks/think-block.tsx
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import { useChatContext } from '../chat/chat/context'
const hasEndThink = (children: any): boolean => {
if (typeof children === 'string')
@@ -35,6 +36,7 @@ const removeEndThink = (children: any): any => {
}
const useThinkTimer = (children: any) => {
+ const { isResponding } = useChatContext()
const [startTime] = useState(Date.now())
const [elapsedTime, setElapsedTime] = useState(0)
const [isComplete, setIsComplete] = useState(false)
@@ -54,9 +56,9 @@ const useThinkTimer = (children: any) => {
}, [startTime, isComplete])
useEffect(() => {
- if (hasEndThink(children))
+ if (hasEndThink(children) || !isResponding)
setIsComplete(true)
- }, [children])
+ }, [children, isResponding])
return { elapsedTime, isComplete }
}