Skip to content

Fix terminal text contrast with images enabled on opaque themes - #340776

Open
Davlatjon Sh (dalisoft) wants to merge 2 commits into
microsoft:mainfrom
dalisoft:fix/terminal-images-light-theme
Open

Davlatjon Sh (dalisoft) wants to merge 2 commits into
microsoft:mainfrom
dalisoft:fix/terminal-images-light-theme

Conversation

@dalisoft

@dalisoft Davlatjon Sh (dalisoft) commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Enabling terminal.integrated.enableImages currently forces allowTransparency: true, including on opaque terminal backgrounds. On Quiet Light this changes normal glyph weight and turns dim text nearly white. Both reports share this configuration-dependent regression; the #338199 reproduction already uses terminal.integrated.fontRendering: "grayscale".

This change derives glyph transparency from the effective terminal background instead. Opaque themes retain the same text-rendering path with image support on or off; translucent backgrounds use the alpha path. Image pixels retain their own canvas alpha.

Fixes #338199
Fixes #299442

AI disclosure and attribution: AI-assisted fix contributed by Davlatjon Sh (@dalisoft). The implementation, investigation, regression tests, and validation were AI-generated with OpenAI Codex under Davlatjon Sh (@dalisoft)'s direction. The description and screenshots identify the automated validation and its platform limits.

Changes

  • Derive allowTransparency from the effective background color at terminal construction and theme updates, using the same color provider as the xterm theme. This includes terminal/editor/panel/sidebar background fallbacks.
  • Remove the assignment that makes image configuration changes force glyph transparency. Transparent backgrounds use the alpha path independently of image support.
  • Remove the obsolete setting-description sentence claiming that enabling images always turns on transparency.
  • Add regression coverage for image and font-rendering configuration changes, image-addon activation, opaque/translucent light/dark themes, regular/detached terminals, and theme-opacity transitions.

The image addon uses separate alpha-enabled image canvases. Real RGBA Kitty/iTerm images with opaque, partial-alpha, and zero-alpha regions still render, and SIXEL still decodes. Negative-z Kitty layers remain present on translucent backgrounds; returning to an opaque background restores the original opaque capture exactly.

The investigation also covered the linked font-rendering work in #337208 / #335625, the duplicate #300536, the similar Linux report #240774, and the image-transparency motivation in #295634 / #295701 / #308691 and RGBA report #297073.

Before / after

These captures use the repository-pinned xterm, WebGL, and image addons on Quiet Light. Both have image support enabled. The before capture reproduces the former unconditional glyph transparency; the after capture uses the fixed opaque-background path. They contain regular, dim, bold, italic, and ANSI-colored text.

Before After
Before: dim text becomes nearly white with images enabled After: normal and dim text keep their contrast with images enabled

The fixed path also renders the transparent PNG sectors and hole correctly through the real iTerm protocol:

Fixed light-theme text with a real RGBA iTerm image

Validation and complete evidence

The published evidence was checked for credentials, private keys, email addresses, and private settings; none were found. The local workspace path in the Electron log is sanitized, with test results unchanged. All final screenshots, measurements, observations, logs, source provenance, and SHA-256 hashes are retained in an immutable evidence commit. The source PR changes only three files; the proof lives on a separate branch of Davlatjon Sh (@dalisoft)'s fork so it remains available after local temporary files are removed.

Check Result Evidence
Targeted Electron XtermTerminal suite 37 passing Log
Targeted Chromium XtermTerminal suite 36 passing Log
Regression tests against original production implementation All nine new regression cases fail; fixed output was restored and the full Chromium suite rerun successfully Original failures, fixed suite
Client build Pass Log
ESLint on all three changed files Pass Log
git diff --check Pass Clean source diff
Actual WebGL text with images enabled vs disabled, opaque light and dark themes Zero different pixels at DPR 1 (151,300 pixels per comparison) and DPR 2 (844,800 pixels per comparison) Metrics, all screenshots and observations
Reproducing the former transparency path 8,877 changed light-theme pixels and 8,986 changed dark-theme pixels at DPR 1 Metrics
Real Kitty/iTerm/SIXEL image paths 30 DPR 1 states, all with real WebGL loaded and no reported errors; additional DPR 2 image captures Observations, capture notes
RGBA image holes iTerm: 256/256 pixels match the background; Kitty hole interior: 144/144 match. Opaque and partial-alpha sectors render Metrics
Opaque → translucent → opaque theme transition Returned opaque screenshot matches the initial screenshot exactly in both themes Metrics

Tests and captures ran on Linux. Electron unit tests used Xvfb with GPU disabled and a mocked WebGL renderer; the separate pixel harness used the real pinned WebGL and image addons with Chromium software WebGL. These are focused renderer captures, not native macOS or full-workbench screenshots. The DPR 1 protocol captures combine text and images; supplementary DPR 2 protocol captures omit text and are separate from the full DPR 2 text comparisons.

The source branch was rebased onto current upstream main; the terminal code, addon loader, and dependency lockfiles used for validation are unchanged by that rebase. Exact commits and dependency versions are recorded in provenance and capture notes.

How to test

Run the targeted checks:

npm run build-fast -- --client-only
scripts/test.sh --run src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts
npm run test-browser-no-install -- --browser chromium --run src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts
npm run eslint -- src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts

For a manual check, use Quiet Light with the reported configuration:

{
  "workbench.colorTheme": "Quiet Light",
  "workbench.fontAliasing": "antialiased",
  "terminal.integrated.gpuAcceleration": "on",
  "terminal.integrated.fontRendering": "grayscale",
  "terminal.integrated.enableImages": true,
  "terminal.integrated.fontFamily": "JetBrains Mono, Fira Code, Monaco",
  "terminal.integrated.fontSize": 14
}

Open a terminal and print normal/dim/bold/italic/colored text, then toggle image support and reopen the terminal for each setting:

printf 'Normal text\n\033[2mDim text\033[0m\n\033[1mBold text\033[0m\n\033[3mItalic text\033[0m\n\033[36mColored text\033[0m\n'

Expected: on an opaque background, enabling images keeps the same text contrast and weight. Check a dark theme too, render an RGBA image with Kitty/iTerm and a SIXEL image, and switch the terminal background between opaque and translucent. Image alpha remains independent of opaque text rendering.

Derive glyph transparency from the effective terminal background instead of image support. Keep image alpha independent and cover image/font configuration and theme changes in regular and detached terminals.

AI-assisted fix contributed by @dalisoft; implementation, investigation and validation generated with OpenAI Codex.

Fixes microsoft#338199

Fixes microsoft#299442
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:25
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts
  • src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts
  • src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts

@dalisoft

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

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.

🟢 Approval recommended

The focused implementation is well covered, with only a non-blocking inline-comment cleanup remaining.

1 open finding
What changed in this PR

Fixes terminal text contrast by deriving glyph transparency from the effective terminal background rather than image support.

Changes:

  • Updates transparency during terminal creation and theme changes.
  • Removes outdated image-setting documentation.
  • Adds opaque/translucent theme regression coverage.
File Description
xtermTerminal.ts Derives transparency from background opacity.
terminalConfiguration.ts Updates image-setting documentation.
xtermTerminal.test.ts Tests configuration and theme transitions.

🧠 Review effort: Balanced


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

…le comment to one line'

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

This branch has not been deployed

No deployments
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.

Font rendering and antialias problem Terminal font broken on latest stable

3 participants