fix disposable leak + fix empty thinking container#302595
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a disposable leak in the chat tool-invocation rendering flow (notably when tool parts are created lazily inside a thinking container) and removes/disposes thinking containers that become empty after a tool is moved out (e.g. for confirmation), addressing #302066.
Changes:
- Extend the lazy tool-part factory return shape to include a
disposableso lazy-created tool parts can be lifecycle-managed. - Add
ChatThinkingContentPart.isEffectivelyEmpty()to detect thinking containers with no meaningful content. - When a tool is moved out of thinking during confirmation transition, remove/dispose the thinking container if it becomes empty.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts | Updates lazy tool-part factory return type and adds logic to remove/dispose empty thinking containers during confirmation transitions. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.ts | Adds isEffectivelyEmpty() helper to determine when a thinking container has no displayable content. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts:2055
- In the branch where the tool part wasn’t previously created, this code path creates a new
ChatToolInvocationPartviacreateToolPart()and appends itsdomNode, but does not register the returneddisposableanywhere. Since the renderer is currently holding a no-op placeholder part at this content index, this tool part may never be disposed, reintroducing the leaked-disposable issue. Suggestion: either (a) avoid creating/appending the tool part here and let the normal render/diff cycle create + track it, or (b) capturedisposableand add it to an appropriate disposable store (and ensure future renders don’t create a duplicate part).
templateData.value.appendChild(domNode);
}
You can also share your feedback on Copilot code review. Take the survey.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.ts
Show resolved
Hide resolved
Yoyokrazy
approved these changes
Mar 17, 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.
fix #302066