From cc6fcda8565402e33e32ceb2f3293e93f31f771d Mon Sep 17 00:00:00 2001 From: Calvin Date: Sun, 14 Dec 2025 00:11:10 +0800 Subject: [PATCH] fix: auto-complete thinking when text output starts This fixes the issue where the thinking timer continues running after thinking is complete and text output begins. Some AI providers don't send a reasoning-end event explicitly, so we now auto-complete thinking when a text-start event is received with accumulated reasoning content. Fixes #11796 Signed-off-by: Calvin --- src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts b/src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts index 5de2ac3453..1c0dbe8aea 100644 --- a/src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts +++ b/src/renderer/src/aiCore/chunk/AiSdkToChunkAdapter.ts @@ -145,6 +145,15 @@ export class AiSdkToChunkAdapter { } // === 文本相关事件 === case 'text-start': + // 如果有未完成的思考内容,先生成 THINKING_COMPLETE + // 这处理了某些提供商不发送 reasoning-end 事件的情况 + if (final.reasoningContent) { + this.onChunk({ + type: ChunkType.THINKING_COMPLETE, + text: final.reasoningContent + }) + final.reasoningContent = '' + } this.onChunk({ type: ChunkType.TEXT_START })