Skip to content

fix leak + better logic for hidden tool calls#302294

Draft
justschen wants to merge 1 commit intomainfrom
justin/axew
Draft

fix leak + better logic for hidden tool calls#302294
justschen wants to merge 1 commit intomainfrom
justin/axew

Conversation

@justschen
Copy link
Collaborator

fix #302066 and some tests + better hiding logic.

Copilot AI review requested due to automatic review settings March 16, 2026 23:25
@justschen justschen marked this pull request as draft March 16, 2026 23:25
Copy link
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

Fixes a leaked disposable in the chat thinking/tool rendering pipeline (Issue #302066) and refines the “HiddenAfterComplete” behavior so tool invocations with user-visible output aren’t incorrectly hidden, with added regression tests.

Changes:

  • Centralize “hide vs keep visible after completion” logic for HiddenAfterComplete tool invocations.
  • Improve disposable registration for tool items associated with a toolCallId in ChatThinkingContentPart.
  • Add tests covering HiddenAfterComplete visibility and title refresh behavior when tools complete.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatThinkingContentPart.test.ts Adds tests for HiddenAfterComplete completion behavior and title refresh in the thinking container.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolInvocationVisibility.ts New shared helper to decide whether tool invocations should be hidden/kept visible after completion.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolInvocationPart.ts Switches tool part rendering to use the centralized hide-after-complete helper.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.ts Refactors disposable registration and ensures titles refresh when tool entries are removed.

You can also share your feedback on Copilot code review. Take the survey.

if (isToolResultOutputDetails(resultDetails) || isToolResultInputOutputDetails(resultDetails)) {
return true;
}

Comment on lines 1103 to 1108
if (this.isExpanded() || this.hasExpandedOnce || (this.fixedScrollingMode && !this.streamingCompleted)) {
const result = factory();
this.appendItemToDOM(result.domNode, toolInvocationId, toolInvocationOrMarkdown, originalParent);
if (result.disposable) {
const toolCallId = toolInvocationOrMarkdown && (toolInvocationOrMarkdown.kind === 'toolInvocation' || toolInvocationOrMarkdown.kind === 'toolInvocationSerialized') ? toolInvocationOrMarkdown.toolCallId : undefined;
if (toolCallId) {
this.toolDisposables.get(toolCallId)?.add(result.disposable);
} else {
this._register(result.disposable);
}
this.registerToolDisposable(result.disposable, toolInvocationOrMarkdown);
}
Comment on lines +76 to +84
function createMockToolInvocation(options?: {
toolCallId?: string;
toolId?: string;
invocationMessage?: string;
presentation?: ToolInvocationPresentation;
isAttachedToThinking?: boolean;
resultDetails?: unknown;
confirmationMessages?: unknown;
}) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LEAKED DISPOSABLE: createToolPart

2 participants