diff --git a/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx b/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx index caf7d3f764..252f3d3f7e 100644 --- a/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx +++ b/src/renderer/src/pages/home/Messages/Blocks/ThinkingBlock.tsx @@ -89,7 +89,8 @@ const ThinkingBlock: React.FC = ({ block }) => { return () => { if (intervalId.current) { - window.clearInterval(intervalId.current) + clearInterval(intervalId.current) + intervalId.current = null } } }, [isThinking]) diff --git a/src/renderer/src/store/thunk/messageThunk.ts b/src/renderer/src/store/thunk/messageThunk.ts index aafe8bc652..a98b69f39d 100644 --- a/src/renderer/src/store/thunk/messageThunk.ts +++ b/src/renderer/src/store/thunk/messageThunk.ts @@ -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) {