Repository navigation
fix(terminal): tint the scrollbar thumb from the terminal foreground so it shows on light themes - #36583
Conversation
1b776d8 to
8617517
Compare
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
60c9e49 to
671d49a
Compare
…so it shows on light themes
…gacy grey on muted dark themes
671d49a to
470c692
Compare
Summary
The xterm scrollbar thumb now takes its tint from the terminal theme's foreground at alpha 0.35 / 0.55 / 0.7 (idle / hover / drag). It also has a contrast floor: on a theme where that tint would be fainter than main's fixed grey, the alpha is raised until it matches, capped at opaque. Before, it was a fixed light grey,
rgba(180, 180, 185, 0.4).On light terminal themes the old grey blended almost completely into the background: about 1.2:1 contrast on Solarized Light, 1.3:1 on Tango Light. The thumb was effectively invisible. A theme's foreground always contrasts with its own background, so the thumb now shows on light and dark themes alike.
A few edge cases:
scrollbarSlider*colors keeps them.Muted dark themes
On dark themes with a muted foreground, a plain 0.35 / 0.55 tint was fainter than main's grey. The WITH FLOOR variant shipped (user's choice): the alpha rises until the thumb is at least as visible as main's grey on that same background. It is capped at opaque, and Solarized Dark's drag state reaches that cap at 4.75:1, against the grey's 5.16:1. The "NEW" column below is the pre-floor revision, kept for comparison. The shipped build reproduces the WITH FLOOR alphas exactly (verified over CDP).
Implementation:
sliderAlphainterminal-appearance.ts. It reusescontrastRatioandoverfromplugin-theme-tokens, stepping the alpha in 0.01 increments, at most 65 steps. The floor is skipped when the background isn't hex.Alpha tuning (dark themes between old and foreground-at-0.4)
Review feedback was that a foreground tint at 0.4 / 0.6 / 0.8 looked a little too bright on dark themes. 0.35 / 0.55 / 0.7 puts the dark-theme median contrast at about the midpoint between the old grey and that tint, in every state. Light themes stay well above the old grey.
Thumb-vs-background contrast (WCAG ratio of the composited thumb against the terminal background, opaque background), across all built-in themes with hex colors:
Per theme (idle / hover):
Root-cause investigation for #12635 (why this is
Refs, notCloses)I reproduced on Windows 11 Pro (
awin), both with a build of current main and with the reporter's own version (v1.4.167, built from the tag). I captured the real desktop (CopyFromScreenin the interactive session) as well as CDP.1. In the normal screen buffer, the vertical scrollbar does render on Windows 11, in both themes and both versions.
.xterm-slider: 7px wide,z-index: 11, sitting above everything else.ScrollbarVisibility.AUTO, the same as VS Code..xterm-viewportis an empty layer under it. That is why fix(terminal): render the vertical scrollbar again while keeping the gutter transparent #12806 (restyling.xterm .xterm-viewport) could not have changed anything, and the deadmain.cssrules for it don't hide anything either.2. The reported symptom matches a full-screen TUI exactly. The symptom: "wheel and PageUp/PageDown move through history, but there is no vertical scrollbar, on light and dark".
less, run in the alternate screen buffer. The alternate buffer has no scrollback, so xterm correctly shows no scrollbar.lesson a 400-line file: the wheel scrolls the content, and the scrollbar staysxterm-invisiblewith the slider at full height (no scrollback).3. The one real defect (what this PR fixes): in the normal buffer on light themes, the thumb is nearly invisible.
rgba(180,180,185,0.4)gives about 1.2:1 contrast on Solarized Light.So #12635 as reported is expected terminal behavior in a full-screen TUI plus a low-contrast thumb on light themes. I'd close the issue once this merges, with an explanation comment, rather than having the PR auto-close it.
Follow-up (not in this PR): the
.xterm .xterm-viewportscrollbar rules inmain.cssare dead on xterm 6. Removing them changes the native gutter on Windows and Linux classic scrollbars, so it deserves its own small PR.Windows 11 evidence (real desktop captures):
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
Refs #12635
Visual proof
Final build (with floor): main vs this PR, idle and hover. Real-app CDP captures from the same crop at 2x, with contrast in each caption.
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
Earlier tuning comparison (before the floor):
Real app (dev build, CDP, hidden window): the terminal's right edge with 400 lines of scrollback, rendered at old grey (origin/main), previous revision (fg @ 0.4/0.6) and this PR (fg @ 0.35/0.55), idle and hovered. The crops are 2x nearest-neighbour.
Dark themes:
(screenshot removed: contained real product data)
Light themes:
(screenshot removed: contained real product data)
Earlier captures from the first revision (fg @ 0.4):
Terminal right edge with 400 lines of scrollback, thumb revealed by hover.
Full window, before and after (light):
(screenshot removed: contained real product data)
(screenshot removed: contained real product data)
Perf
Scanned the diff vs main with the perf-scan checklist. The only hot path is
composeActiveTerminalTheme. It runs once per pane on each appearance apply, and the result is deduped by value viacomposedTerminalThemesEqual. The new work is one regex and three string formats per call. No new listeners, timers, IPC or persistence.composeActiveTerminalThemecall, before the floor vs with it: Dracula 0.4 vs 1.1 µs; Solarized Dark 0.4 vs 7.4 µs; worst case fg = bg (alpha search runs to 1) 0.3 vs 15 µs. It runs once per appearance apply or settings-preview memo, not per frame, so this is negligible.<style>, base vs branch, same workload):<style>and removes it on dispose (verified with the settings preview).Merge-risk assessment
Low.
composeActiveTerminalTheme, and only when the theme doesn't set them.Negative user-facing tradeoffs
rgba(255,255,255,0.35)instead ofrgba(180,180,185,0.4).terminalBackgroundOpacitybelow 1, the real contrast depends on what shows through, the same as with main's grey. A background override typed asrgb()skips the floor.rgb()or 8-digit hex (the override text field accepts free text) gets xterm's own fainter foreground tint at 0.2/0.4/0.5 instead of these alphas.Validation
pnpm tc:web, plusoxlintandoxfmton changed files.pnpm testwith the compose and appearance tests, together with the fix(terminal): scope terminal color overrides to their light/dark theme slot #36581 suite (105 files, 939 tests passing).awin): builds of origin/main and v1.4.167 on a real desktop; normal-buffer scrollback in light and dark; alternate-screenlessrepro.rgba(255, 255, 255, 0.35)idle andrgba(255, 255, 255, 0.55)hover on Default dark. The contrast numbers come from a script over the built-in theme catalog. I ran the focusedcompose-active-terminal-themetest.rgba(180, 180, 185, 0.4)rgba(101, 123, 131, 0.4)on Solarized Light,rgba(255, 255, 255, 0.4)on darkrgba(131,148,150,0.53)/0.8, and light themes stay at 0.35 / 0.55. Also ranpnpm tc:web, oxlint and the compose test, which now includes a muted-theme floor case.rgb()backgrounds are documented above as tradeoffs.<style>, so the last-mounted terminal's colors apply document-wide. With per-theme tints that can leak across terminals that use different themes. In the app this never shows: only the settings preview uses a different theme, it mounts one xterm at a time while the main terminals are hidden behind Settings, and its style is removed on close. I checked this over CDP, and the main slider went back torgba(248,248,242,0.35). (2) Foreground overrides typed asrgb()or 8-digit hex fall back to xterm's own foreground tint at 0.2/0.4/0.5. That predates this tuning, and the thumb stays visible. (3) Muted-foreground dark themes end up fainter than the old grey (see tradeoffs).