From 1ce2076185e9cbe355f6ec0757741d9ffc34e22a Mon Sep 17 00:00:00 2001 From: Calvin Date: Sat, 13 Dec 2025 23:07:09 +0800 Subject: [PATCH] fix: also preserve thinking time when stopping during thinking This extends the previous fix to also handle the case when the user stops the reply while thinking is still in progress (not just after thinking is complete). Signed-off-by: Calvin --- .../messageStreaming/callbacks/baseCallbacks.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/services/messageStreaming/callbacks/baseCallbacks.ts b/src/renderer/src/services/messageStreaming/callbacks/baseCallbacks.ts index 146266fd9d..7000ad3d58 100644 --- a/src/renderer/src/services/messageStreaming/callbacks/baseCallbacks.ts +++ b/src/renderer/src/services/messageStreaming/callbacks/baseCallbacks.ts @@ -108,10 +108,17 @@ export const createBaseCallbacks = (deps: BaseCallbacksDependencies) => { const possibleBlockId = findBlockIdForCompletion() if (possibleBlockId) { - // 更改上一个block的状态为ERROR - const changes = { + // 更改上一个block的状态为ERROR/PAUSED + const changes: Record = { status: isErrorTypeAbort ? MessageBlockStatus.PAUSED : MessageBlockStatus.ERROR } + // 如果是 thinking block,保留实际思考时间 + if (blockManager.lastBlockType === MessageBlockType.THINKING) { + const thinkingInfo = getCurrentThinkingInfo?.() + if (thinkingInfo?.blockId === possibleBlockId && thinkingInfo?.millsec && thinkingInfo.millsec > 0) { + changes.thinking_millsec = thinkingInfo.millsec + } + } blockManager.smartBlockUpdate(possibleBlockId, changes, blockManager.lastBlockType!, true) }