Skip to content

Prevent memory leaks in title file widget in chat components#319176

Merged
dmitrivMS merged 1 commit into
mainfrom
dev/dmitriv/perf-title-file-widget-leak
May 31, 2026
Merged

Prevent memory leaks in title file widget in chat components#319176
dmitrivMS merged 1 commit into
mainfrom
dev/dmitriv/perf-title-file-widget-leak

Conversation

@dmitrivMS
Copy link
Copy Markdown
Contributor

Based on #314005
Thank you @ishaq2321!

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings May 30, 2026 23:22
@dmitrivMS dmitrivMS added the perf label May 30, 2026
@dmitrivMS dmitrivMS requested review from justschen and roblourens May 30, 2026 23:22
@dmitrivMS dmitrivMS enabled auto-merge (squash) May 30, 2026 23:22
@dmitrivMS dmitrivMS self-assigned this May 30, 2026
@dmitrivMS dmitrivMS added the chat label May 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 _titleFileWidgetStore on ChatCollapsibleContentPart and clear it before re-rendering title widgets.
  • Update ChatThinkingContentPart and ChatSubagentContentPart to 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

@dmitrivMS dmitrivMS merged commit c13a94e into main May 31, 2026
26 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/perf-title-file-widget-leak branch May 31, 2026 01:16
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants