Skip to content

fix(chat): cancel in-flight streaming tool invocations when response is cancelled (#288701)#310979

Merged
lramos15 merged 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-288701-spinner-after-stop
Apr 17, 2026
Merged

fix(chat): cancel in-flight streaming tool invocations when response is cancelled (#288701)#310979
lramos15 merged 1 commit intomicrosoft:mainfrom
maruthang:fix/issue-288701-spinner-after-stop

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

What — Pressing Stop while a tool call is still streaming partial input now also transitions that tool invocation to Cancelled, so the "Editing files" label and spinner on the thinking row clear immediately instead of hanging on-screen.

WhyChatResponseModel.cancel() only flipped its own state. Any ChatToolInvocation that was in StateKind.Streaming (LM still producing tool arguments) stayed there forever. UI consumers (the autorun in chatThinkingContentPart.ts) kept treating the tool as in-progress, so the spinner/shimmer never cleared (#288701).

How — Inside cancel(), walk this._response.value for ChatToolInvocation parts and call the existing cancelFromStreaming(ToolConfirmKind.Skipped) on each. No new API surface. The ToolConfirmKind symbol was already available; just added it to the existing import line.

Test plan — New regression test in chatModel.test.ts (ChatResponseModel suite): create a streaming ChatToolInvocation on a ChatModel, assert state Streaming, call cancelRequest(request), assert state Cancelled and IChatToolInvocation.isComplete true. Manual: trigger a multi-file edit via an agent-mode request, press Stop while the thinking row shows "Editing files"; the label/spinner clears immediately.

Fixes #288701

@lramos15 lramos15 enabled auto-merge (squash) April 17, 2026 15:37
@connor4312
Copy link
Copy Markdown
Member

thanks!

@lramos15 lramos15 merged commit 27bc1e2 into microsoft:main Apr 17, 2026
26 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.117.0 milestone Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editing files and spinner remains after stopping session

3 participants