fix: track disposables for serialized tool invocations in thinking part#302641
Open
vikeychen wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: track disposables for serialized tool invocations in thinking part#302641vikeychen wants to merge 1 commit intomicrosoft:mainfrom
vikeychen wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The `trackToolMetadata` method only created a `DisposableStore` entry in `toolDisposables` for live `toolInvocation` kind, but not for `toolInvocationSerialized`. This caused `appendItem` to silently drop the disposable via the optional chaining `toolDisposables.get(id)?.add()` when rendering serialized tools (e.g. when loading session history). As a result, `ChatToolInvocationPart` instances (and their child parts including `CodeBlockPart` with `MenuWorkbenchToolBar`) were never disposed, leading to listener accumulation on `ActionViewItemService.onDidChange`. Fix by creating the `DisposableStore` for all tool invocation kinds (both live and serialized) before the kind-specific state tracking branch.
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.
Summary
toolInvocationSerialized) inChatThinkingContentParttrackToolMetadataonly created aDisposableStoreintoolDisposablesfor livetoolInvocationkind, causingappendItemto silently drop disposables for serialized tools viatoolDisposables.get(id)?.add()ChatToolInvocationPartinstances (and childCodeBlockPart/MenuWorkbenchToolBar) when loading session history, accumulating listeners onActionViewItemService.onDidChangeDetails
The recent fix in #302595 correctly added
disposableto thecreateToolPartreturn value. However, the disposable is still silently dropped fortoolInvocationSerializedbecausetrackToolMetadataonly callstoolDisposables.set(toolCallId, toolStore)inside thekind === 'toolInvocation'branch.This fix creates the
DisposableStorefor all tool invocation kinds before the kind-specific state tracking branch, ensuring serialized tools' disposables are properly tracked and cleaned up when the thinking part is disposed.