Fix listener leak in chat inline anchor widgets#301896
Merged
bryanchen-d merged 1 commit intomainfrom Mar 16, 2026
Merged
Conversation
Move per-widget configurationService.onDidChangeConfiguration listener to a single listener on the ChatListWidget container. Each InlineAnchorWidget previously registered its own listener to toggle a link-style CSS class, causing a listener leak warning when 175+ widgets existed in a session. The fix uses a parent container class (chat-inline-references-link-style) toggled by a single listener, with CSS descendant selectors to style all child widgets. Fixes #301185
Contributor
There was a problem hiding this comment.
Pull request overview
Reduces event-listener churn/leaks in the chat UI by moving per-InlineAnchorWidget configuration listeners to a single listener on the ChatListWidget container, and switching inline-reference “link style” rendering to be controlled via a parent CSS class.
Changes:
- Add a single
configurationService.onDidChangeConfigurationlistener inChatListWidgetto toggle a container class for inline reference styling. - Update inline anchor widget CSS to use descendant selectors driven by the container class.
- Remove per-widget appearance updates and configuration listeners from
InlineAnchorWidget.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/widget/chatListWidget.ts | Adds one configuration listener that toggles a container class controlling inline reference link-style appearance. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatInlineAnchorWidget.css | Switches link-style rules from per-widget class to a parent container class via descendant selectors. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatInlineAnchorWidget.ts | Removes per-widget configuration listener and class toggling to prevent listener leaks. |
roblourens
approved these changes
Mar 16, 2026
Member
roblourens
left a comment
There was a problem hiding this comment.
Thanks! Not a leak per se but a listener leak warning false alarm.
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.
Move per-widget
configurationService.onDidChangeConfigurationlistener to a single listener on theChatListWidgetcontainer. EachInlineAnchorWidgetpreviously registered its own listener to toggle a link-style CSS class, causing a listener leak warning when 175+ widgets existed in a session.The fix uses a parent container class (
chat-inline-references-link-style) toggled by a single listener, with CSS descendant selectors to style all child widgets.Fixes #301185