Skip to content

Dispose autorun listeners upon completion of operations#324035

Merged
dmitrivMS merged 1 commit into
mainfrom
dev/dmitriv/subagent-tool-renderer-leak
Jul 3, 2026
Merged

Dispose autorun listeners upon completion of operations#324035
dmitrivMS merged 1 commit into
mainfrom
dev/dmitriv/subagent-tool-renderer-leak

Conversation

@dmitrivMS

Copy link
Copy Markdown
Contributor

Fixes #300339

Copilot AI review requested due to automatic review settings July 2, 2026 10:50
@dmitrivMS dmitrivMS added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues chat-subagents labels Jul 2, 2026
@dmitrivMS dmitrivMS self-assigned this Jul 2, 2026

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

This PR addresses an event-listener leak in the Chat subagent tool-invocation UI by ensuring per-tool autorun observers are disposed once a tool invocation reaches a terminal state. This directly targets the renderer OOM/leak pattern described in #300339, where tool-heavy sessions accumulate listeners over time.

Changes:

  • Introduces a dedicated DisposableStore to track per-tool state/icon autorun disposables and remove them on Completed/Cancelled.
  • Updates trackToolState and the tool icon/confirmation tracking in appendToolPartToDOM to dispose their autorun listeners via a deferred microtask.
  • Adds a browser test that asserts the observable no longer has observers after the tool reaches a terminal state.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.ts Tracks per-tool autorun disposables and disposes them on terminal tool states to prevent listener accumulation.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatSubagentContentPart.test.ts Adds coverage to verify tool-state tracking stops observing once the tool completes.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Low

@dmitrivMS

dmitrivMS commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Posted to the issue asking for help with verification.

@dmitrivMS dmitrivMS marked this pull request as ready for review July 2, 2026 19:02

@justschen justschen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks for giving this a look!

@dmitrivMS dmitrivMS merged commit 4e6fd6e into main Jul 3, 2026
86 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/subagent-tool-renderer-leak branch July 3, 2026 02:09
@vs-code-engineering vs-code-engineering Bot added this to the 1.128.0 milestone Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chat-subagents freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues perf perf-bloat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renderer OOM crash: event listener leak in chat tool invocation UI (appendToolInvocation/trackToolState)

4 participants