Dispose autorun listeners upon completion of operations#324035
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
DisposableStoreto track per-tool state/iconautorundisposables and remove them onCompleted/Cancelled. - Updates
trackToolStateand the tool icon/confirmation tracking inappendToolPartToDOMto dispose theirautorunlisteners 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
Contributor
Author
|
Posted to the issue asking for help with verification. |
connor4312
approved these changes
Jul 2, 2026
justschen
approved these changes
Jul 3, 2026
justschen
left a comment
Collaborator
There was a problem hiding this comment.
thanks for giving this a look!
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.
Fixes #300339