fix: timer stop (#5914)

This commit is contained in:
SuYao 2025-05-13 08:47:14 +08:00 committed by kangfenmao
parent 6a48b76c5e
commit 044420dd7e
2 changed files with 6 additions and 1 deletions

View File

@ -89,7 +89,8 @@ const ThinkingBlock: React.FC<Props> = ({ block }) => {
return () => {
if (intervalId.current) {
window.clearInterval(intervalId.current)
clearInterval(intervalId.current)
intervalId.current = null
}
}
}, [isThinking])

View File

@ -348,6 +348,7 @@ const fetchAndProcessAssistantResponseImpl = async (
}
},
onTextComplete: async (finalText) => {
cancelThrottledBlockUpdate()
if (lastBlockType === MessageBlockType.MAIN_TEXT && lastBlockId) {
const changes = {
content: finalText,
@ -405,6 +406,8 @@ const fetchAndProcessAssistantResponseImpl = async (
}
},
onThinkingComplete: (finalText, final_thinking_millsec) => {
cancelThrottledBlockUpdate()
if (lastBlockType === MessageBlockType.THINKING && lastBlockId) {
const changes = {
type: MessageBlockType.THINKING,
@ -446,6 +449,7 @@ const fetchAndProcessAssistantResponseImpl = async (
}
},
onToolCallComplete: (toolResponse: MCPToolResponse) => {
cancelThrottledBlockUpdate()
const existingBlockId = toolCallIdToBlockIdMap.get(toolResponse.id)
if (toolResponse.status === 'done' || toolResponse.status === 'error') {
if (!existingBlockId) {