Skip to content

fix: memory leaks in chat widgets - #326876

Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leaks-chat
Aug 13, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leaks-chat

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

When a chat editor is opened, services like voiceSessionController add event listeners to the chat widgets. But it seems those event listeners are not removed when the chat widget or chat editor closes.

Change

The change ensures that chat widgets event listeners like in voiceSessionController or ‎agentHostModeSynchronizer are being removed when the chat widget gets disposed.

Before

When opening two chat editors then closing all editors 37 times, the number of various functions seems to grow each time:

chat-editor-open-side-by-side

After

When opening two chat editors then closing all editors 37 times, all but one function count stay constant:

chat-editor-open-side-by-side2

Test Video

video-edited.mp4

Copilot AI review requested due to automatic review settings July 21, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents chat widget lifecycle listeners from being retained after widgets close.

Changes:

  • Adds an onDidRemoveWidget lifecycle event.
  • Disposes per-widget listeners in voice and agent-host controllers.
  • Adds focused regression tests and updates mocks.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/chat.ts Adds the removal event contract.
src/vs/workbench/contrib/chat/browser/widget/chatWidgetService.ts Emits widget removal events.
src/vs/workbench/contrib/chat/browser/voiceClient/voiceSessionController.ts Disposes widget session listeners.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostModeSynchronizer.ts Disposes widget mode listeners.
src/vs/workbench/contrib/chat/test/browser/voiceClient/voiceSessionController.test.ts Tests voice listener cleanup.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostModeSynchronizer.test.ts Tests mode listener cleanup.
src/vs/workbench/contrib/chat/test/browser/widget/mockChatWidget.ts Updates the widget service mock.
src/vs/workbench/test/browser/workbenchTestServices.ts Updates shared test services.

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Please resolve conflicts.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 2c0cd3e into microsoft:main Aug 13, 2026
27 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.134.0 milestone Aug 13, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leaks-chat branch August 13, 2026 20:14
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants