Reduce token usage of "add element to chat"#314201
Merged
Conversation
Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces the context/token footprint of the Integrated Browser “Add Element to Chat” attachment by switching from attaching large, verbose CSS payloads to attaching a compact set of applicable author rules plus a filtered/resolved subset of computed properties and referenced CSS variables. It also removes the chat.sendElementsToChat.attachCSS setting, making CSS attachment effectively always-on.
Changes:
- Remove the
chat.sendElementsToChat.attachCSSconfiguration setting. - Introduce shared CSS compaction helpers to (a) format matched author styles and (b) collapse resolved computed longhands into shorthands where possible, with unit tests.
- Update the element-inspection + attachment pipeline to attach the compact CSS payload unconditionally and to filter the hover/metadata computed-style record.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/chat.contribution.ts | Removes the chat.sendElementsToChat.attachCSS setting registration. |
| src/vs/workbench/contrib/browserView/electron-browser/features/browserEditorChatFeatures.ts | Makes CSS attachment unconditional and simplifies the attached element context formatting. |
| src/vs/platform/browserView/electron-main/browserViewElementInspector.ts | Builds a compact CSS payload using new helpers; filters computed styles to key props + referenced vars. |
| src/vs/platform/browserView/common/cssHelpers.ts | New helpers for formatting author rules and collapsing computed styles into shorthands. |
| src/vs/platform/browserView/test/common/cssHelpers.test.ts | Adds unit coverage for shorthand collapsing and author-style formatting behavior. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 2
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @jrualesMatched files:
|
benvillalobos
approved these changes
May 4, 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.
Closes #314188
Fixes #291005
Reduces the attachment size by ~97-99% or more on some sites. This is mostly by eliding CSS properties that have not been changed, as well as rules and variables that do not apply to the element.
Also removes the
chat.sendElementsToChat.attachCSSsetting as it shouldn't be necessary to toggle anymore.