Prevent memory leaks in title file widget in chat components#319176
Merged
Conversation
Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents listener/memory leaks caused by re-rendering chat content part titles that can contain inline file-link widgets. It introduces a dedicated DisposableStore for title file widgets and clears it whenever the title is re-rendered, ensuring previously-registered widgets/listeners are disposed.
Changes:
- Introduce a
_titleFileWidgetStoreonChatCollapsibleContentPartand clear it before re-rendering title widgets. - Update
ChatThinkingContentPartandChatSubagentContentPartto clear title widget disposables on title updates and register new widgets into the dedicated store (instead of the part’s long-lived_store). - Add a regression test asserting that title updates clear previous title widget disposables.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatSubagentContentPart.test.ts | Adds regression coverage asserting title re-render clears prior title widget disposables. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.ts | Clears and reuses a dedicated title widget disposable store on title updates to avoid leaks. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.ts | Clears and reuses a dedicated title widget disposable store when updating the title detail. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatCollapsibleContentPart.ts | Adds a dedicated DisposableStore for title file widgets and clears it before re-rendering title markdown widgets. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 0
justschen
approved these changes
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #314005
Thank you @ishaq2321!