Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

Fixes https://github.com/microsoft/vscode/issues/[issue_number]

The applyTheme method was dynamically generating CSS rules and injecting them via a <style> element. This moves all theme-dependent styles to the static CSS file using CSS variables.

Changes

commentThreadWidget.ts:

  • Removed _styleElement field and initialization
  • Simplified applyTheme to only set font custom properties (fontFamily, fontSize, fontWeight)
  • Removed unused imports: domStylesheets, theme color constants

review.css:

  • Added theme-dependent styles using CSS variables:
    • Links: --vscode-textLink-foreground, --vscode-textLink-activeForeground
    • Focus: --vscode-focusBorder
    • Blockquote: --vscode-textBlockQuote-background
    • Borders: --vscode-panel-border, --vscode-contrastBorder
    • Validation: --vscode-inputValidation-error*
    • Thread state: --comment-thread-state-color, --comment-thread-state-background-color
    • Code fonts: --comment-thread-editor-font-*

Net: -25 lines, no runtime CSS generation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Don't inline the CSS for the comment widget</issue_title>
<issue_description>https://github.com/microsoft/vscode/blob/kycutler/markdownalerts/src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts#L385C2-L385C12</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Remove inline CSS for comment widget Don't inline CSS for comment widget Nov 10, 2025
Copilot AI requested a review from alexr00 November 10, 2025 12:09
Copilot finished work on behalf of alexr00 November 10, 2025 12:09
@alexr00 alexr00 marked this pull request as ready for review November 11, 2025 10:15
Copilot AI review requested due to automatic review settings November 11, 2025 10:15
@alexr00 alexr00 enabled auto-merge (squash) November 11, 2025 10:15
@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 11, 2025
Copilot finished reviewing on behalf of alexr00 November 11, 2025 10:19
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

This PR refactors the comment widget theme styling by replacing dynamically generated inline CSS with static CSS rules that use CSS custom properties (variables). This eliminates runtime CSS generation and reduces code complexity.

Key changes:

  • Removed dynamic CSS generation code from applyTheme method
  • Moved all theme-dependent styles to static CSS file using CSS variables
  • Retained only font-related CSS custom property assignments in TypeScript

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/vs/workbench/contrib/comments/browser/commentThreadWidget.ts Removed _styleElement field, dynamic CSS content generation, and unused theme color imports; simplified applyTheme to only set font custom properties
src/vs/workbench/contrib/comments/browser/media/review.css Added static CSS rules using CSS variables for theme colors (links, focus, blockquotes, borders, validation errors, thread state, code fonts)

Comment on lines 380 to 383
const fontSizeVar = '--comment-thread-editor-font-size';
const fontWeightVar = '--comment-thread-editor-font-weight';
this.container?.style.setProperty(fontFamilyVar, fontInfo.fontFamily);
this.container?.style.setProperty(fontSizeVar, `${fontInfo.fontSize}px`);
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The --comment-thread-editor-font-size CSS custom property is being set but is never used in the CSS file. Consider either using it in review.css (e.g., in the .review-widget .body code rule) or removing the fontSizeVar assignment to avoid setting unused CSS properties.

Copilot uses AI. Check for mistakes.
dbaeumer
dbaeumer previously approved these changes Nov 11, 2025
@alexr00 alexr00 merged commit 0297176 into main Nov 11, 2025
28 checks passed
@alexr00 alexr00 deleted the copilot/remove-inline-css-comment-widget branch November 11, 2025 17:36
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.

Don't inline the CSS for the comment widget

4 participants