Skip to content

Improve CSS selector performance safeguards - #333818

Merged
Justin Chen (justschen) merged 3 commits into
mainfrom
agents/css-performance-audit-and-fixes
Sep 2, 2026
Merged

Justin Chen (justschen) merged 3 commits into
mainfrom
agents/css-performance-audit-and-fixes

Conversation

@justschen

Copy link
Copy Markdown
Collaborator

Summary

  • replace non-codicon class-substring selectors with stable decoration markers or exact generated classes
  • remove disconnected editor-header CSS, including an unused descendant-dependent :has() rule
  • extend stylelint to reject new non-codicon class-substring selectors across core and built-in extension CSS
  • add a repeatable Modern UI benchmark covering resize, class mutation, tab open/switch/close, and sidebar/panel toggles
  • document the audit, retained :has() inventory, correctness rationale, and measurement limitations

Existing codicon-family selectors are intentionally unchanged and grandfathered by the lint rule. The experimental transform shimmer work was fully reverted and is not part of this PR.

Performance

Bracketed before/after runs observed these median wall-time changes:

Scenario Wall time
Resize -7.8%
Open tabs -16.4%
Switch tabs -13.7%
Close tabs -4.5%
Toggle sidebar/panel -12.7%

These are observed timings, not isolated causal gains. Generic style-recalculation counts did not materially decrease because codicon substring selectors remain, so the PR conservatively claims no broad proven speedup and focuses on targeted invalidation prevention.

Validation

  • npm run compile
  • npm run hygiene
  • client and build TypeScript checks
  • full production stylelint (core + built-in extension CSS)
  • stylelint parser tests
  • targeted Modern UI, decoration, debug, and Chat tests
  • repeated before/after benchmark runs with scenario state verification and process cleanup

Replace non-codicon class substring selectors with stable markers, remove disconnected editor header styles, and prevent new high-cost selector patterns. Add a repeatable Modern UI CSS benchmark and document the observed results and limitations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: aa457496-6844-4e4c-b182-07866a0a7506
Copilot AI balanced review requested due to automatic review settings September 1, 2026 17:34
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/workbench/browser/parts/editor/media/editorgroupview.css
  • src/vs/workbench/browser/parts/views/media/views.css

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity .github/​skills/​auto-perf-optimize/​scripts/​workbench-css-performance.mts — These setup steps run before both summary initialization and the try/catch. If transpilation…
Medium severity build/​stylelint.ts — This also classifies CSS under src/vs/**/test/** as production (for example, the…
What changed in this PR

Improves CSS selector invalidation safeguards and adds repeatable performance measurement.

Changes:

  • Replaces non-codicon class-substring selectors with stable or exact classes.
  • Extends stylelint enforcement to core and extension CSS.
  • Adds a Modern UI CSS benchmark and audit documentation.
File Description
src/​vs/​workbench/​services/​decorations/​common/​decorations.ts Defines a stable badge marker.
src/​vs/​workbench/​contrib/​modernUI/​README.md Links performance documentation.
src/​vs/​workbench/​contrib/​modernUI/​CSS_PERFORMANCE.md Documents audit and benchmark results.
src/​vs/​workbench/​contrib/​inlineChat/​browser/​media/​inlineChat.css Uses an exact decoration class.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​media/​chat.css Replaces placeholder substring matching.
src/​vs/​workbench/​browser/​parts/​views/​media/​views.css Uses stable decoration markers.
src/​vs/​workbench/​browser/​parts/​editor/​media/​editorgroupview.css Removes disconnected header styles.
src/​vs/​workbench/​browser/​labels.ts Applies the badge marker.
package.json Adds the CSS benchmark command.
build/​stylelint.ts Enforces the new selector restriction.
build/​lib/​test/​stylelint.test.ts Checks extension CSS filtering.
build/​lib/​test/​rootAnchoredHas.test.ts Tests substring-selector parsing.
build/​lib/​stylelint/​validateHasSelectors.ts Implements selector detection.
build/​filters.ts Includes production extension CSS.
.github/​skills/​auto-perf-optimize/​scripts/​workbench-css-performance.mts Implements the benchmark runner.
.github/​skills/​auto-perf-optimize/​scratchpad/​README.md Documents the runner.
.github/​instructions/​css-best-practices.instructions.md Documents the codicon exception.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/skills/auto-perf-optimize/scripts/workbench-css-performance.mts Outdated
Comment thread build/stylelint.ts
Move process-exit error propagation outside benchmark cleanup and use the repository's preferred string quoting in the selector regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: aa457496-6844-4e4c-b182-07866a0a7506
@justschen

Copy link
Copy Markdown
Collaborator Author

CI follow-up:

@justschen
Justin Chen (justschen) marked this pull request as draft September 1, 2026 18:03
Ensure benchmark setup failures retain a diagnostic summary artifact and exclude test fixture paths from the production-only class substring selector safeguard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: aa457496-6844-4e4c-b182-07866a0a7506

@mrleemurray Lee Murray (mrleemurray) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome!

@justschen
Justin Chen (justschen) enabled auto-merge (squash) September 2, 2026 09:25
@justschen
Justin Chen (justschen) merged commit 02e057f into main Sep 2, 2026
41 checks passed
@justschen
Justin Chen (justschen) deleted the agents/css-performance-audit-and-fixes branch September 2, 2026 09:27
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Sep 2, 2026
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.

4 participants