Compare commits

..

1 Commits

Author SHA1 Message Date
waleed
95b17ff820 fix(copilot): abort in-progress tools when stream ends
Calls abortAllInProgressTools in the stream_end handler so tools
stuck in generating/executing state are resolved when the stream
closes, regardless of whether a done event was received.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 15:58:55 -07:00

View File

@@ -3,6 +3,7 @@ import { STREAM_STORAGE_KEY } from '@/lib/copilot/constants'
import { asRecord } from '@/lib/copilot/orchestrator/sse/utils'
import type { SSEEvent } from '@/lib/copilot/orchestrator/types'
import {
abortAllInProgressTools,
isBackgroundState,
isRejectedState,
isReviewState,
@@ -956,7 +957,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
}))
context.streamComplete = true
},
stream_end: (_data, context, _get, set) => {
stream_end: (_data, context, get, set) => {
if (context.pendingContent) {
if (context.isInThinkingBlock && context.currentThinkingBlock) {
appendThinkingContent(context, context.pendingContent)
@@ -967,6 +968,7 @@ export const sseHandlers: Record<string, SSEHandler> = {
}
finalizeThinkingBlock(context)
updateStreamingMessage(set, context)
abortAllInProgressTools(set, get)
},
default: () => {},
}