Repository navigation
fix(terminal): stop the bottom workbench terminal from painting black - #1104
Merged
Menghuan1918 merged 1 commit intoNov 4, 2026
Merged
Conversation
The terminal area was a solid black rectangle inside a panel that was not,
which read as a surface the plugin had chosen rather than the emulator
showing through.
Two independent causes, both needed:
1. CSS Modules hashed xterm's own class names. `.screen .xterm-viewport`
compiled to `.o8IiwG_screen .o8IiwG_xterm-viewport`, while the real DOM
carries xterm's unhashed `.xterm-viewport` — the rule never matched
anything. Wrapped in `:global()`.
2. xterm.css ships `.xterm .xterm-viewport { background-color: #000 }` and
injects that sheet when `open()` runs, after this module. Matching its
specificity (0,2,0) therefore loses on source order every time, so the
selector climbs to 0,3,0 with the extra `.xterm`. Measured in Chromium:
0,2,0 leaves `rgb(0, 0, 0)`, 0,3,0 resolves to `rgba(0, 0, 0, 0)`.
`.screen` itself also stops painting `--dsw-alias-bg-base`, which was a second
surface inside the panel.
No `!important` (outranking by specificity is enough) and no
`allowTransparency` (measured no effect on the viewport background under the
DOM renderer xterm 6 uses by default).
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.
问题
底部工作台的终端区域是一整块纯黑矩形,而它所在的 tab 条和面板都不是。看起来像是插件自己选了一块深色底,而不是终端透出面板表面。
两处独立原因,缺一不可。
1. CSS Modules 把 xterm 自己的类名也一起哈希了
原规则写的是:
编译产物却是:
而真实 DOM 里是
<div class="xterm-viewport">(xterm 自己生成,不带 hash)。这条规则从头到尾没有匹配到任何元素,所以无论怎么改颜色都毫无反应。2. xterm 自带样式表硬编码黑底,且注入时机更晚
xterm 的
css/xterm.css里有:特异性 0,2,0。即便把选择器包上
:global(),.screen .xterm-viewport也仍是 0,2,0 —— 与它相同。而 xterm 是在open()时才把这张样式表插进文档的,晚于本插件的模块 CSS,同特异性下源顺序后者胜,于是 xterm 赢。改动
.screen :global(.xterm .xterm-viewport) { background: transparent }:global()修掉哈希导致的失配;.xterm把特异性抬到 0,3,0,压过 xterm 的 0,2,0,不依赖!important。.screen自身不再画--dsw-alias-bg-base(那是面板里的第二块底)。Chromium 实测(我们的样式先注入、xterm.css 在
open()时后注入,复现真实时序):viewport背景.o8IiwG_screen .xterm-viewportrgb(0, 0, 0)❌ 仍是黑.o8IiwG_screen .xterm .xterm-viewportrgba(0, 0, 0, 0)✅!importantrgba(0, 0, 0, 0)✅(!important非必需)实测无效、因此没有采用的写法
!important:提高特异性已经足够。allowTransparency: true:在 xterm 6.0.0 默认使用的 DOM 渲染器下,它对.xterm-viewport的内联背景没有任何影响(实测两档结果相同),故未纳入本 PR。效果
修复前:终端是一块纯黑矩形。
修复后:终端与工作台同色,只留下文字与光标。
验证
pnpm typecheck通过。pnpm build通过;产物确认选择器为.o8IiwG_screen .xterm .xterm-viewport{background:0 0}。link:方式挂载到 desktop profile,刷新后终端黑底消失、文字与光标正常。范围
仅
src/client/terminal.module.css与CHANGELOG.md。dev上工作台与 tab 条的背景(另一处皮肤色差问题)不在本 PR 内。