Skip to content

Fix listener leak in chat inline anchor widgets#301896

Merged
bryanchen-d merged 1 commit intomainfrom
brchen/fix-inline-anchor-listener-leak
Mar 16, 2026
Merged

Fix listener leak in chat inline anchor widgets#301896
bryanchen-d merged 1 commit intomainfrom
brchen/fix-inline-anchor-listener-leak

Conversation

@bryanchen-d
Copy link
Contributor

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

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
Copilot AI review requested due to automatic review settings March 15, 2026 21: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

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.onDidChangeConfiguration listener in ChatListWidget to 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.

Copy link
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Not a leak per se but a listener leak warning false alarm.

@bryanchen-d bryanchen-d merged commit 083bf70 into main Mar 16, 2026
24 checks passed
@bryanchen-d bryanchen-d deleted the brchen/fix-inline-anchor-listener-leak branch March 16, 2026 16:44
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.

[Unhandled Error] [5af] potential listener LEAK detected, having 285 listeners already. MOST frequent listener (78):

3 participants