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 <calvinvwei@gmail.com>
This commit is contained in:
Calvin 2025-12-13 23:07:09 +08:00
parent a4eeb6c4b1
commit 1ce2076185

View File

@ -108,10 +108,17 @@ export const createBaseCallbacks = (deps: BaseCallbacksDependencies) => {
const possibleBlockId = findBlockIdForCompletion()
if (possibleBlockId) {
// 更改上一个block的状态为ERROR
const changes = {
// 更改上一个block的状态为ERROR/PAUSED
const changes: Record<string, any> = {
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)
}