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 () => { return () => {
if (intervalId.current) { if (intervalId.current) {
window.clearInterval(intervalId.current) clearInterval(intervalId.current)
intervalId.current = null
} }
} }
}, [isThinking]) }, [isThinking])

View File

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