Skip to content

fix(terminal): tint the scrollbar thumb from the terminal foreground so it shows on light themes - #36583

Merged
nwparker merged 4 commits into
mainfrom
nwparker/theme-terminal-scrollbar-contrast
Nov 2, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/theme-terminal-scrollbar-contrast

Conversation

@nwparker

@nwparker nwparker commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33

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:

  • Explicit slider colors win. A theme that sets its own scrollbarSlider* colors keeps them.
  • Overrides count. The palette passed in already carries the slot's color overrides (fix(terminal): scope terminal color overrides to their light/dark theme slot #36581, now on main), so an override that flips light/dark tints the thumb correctly. The Codex review caught this when the change was not stacked.
  • Non-hex foregrounds fall back to xterm's own foreground-derived defaults rather than a magic constant.

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).

  • Bright-foreground themes, such as Default dark, and all light themes already beat main's grey, so the floor leaves them unchanged (verified in the app: Tango, Solarized and GitHub Light all stay at 0.35 / 0.55).
  • Each image is a real-app CDP capture: the same crop of the terminal's right edge at 2x, thumb dragged to the top. Contrast ratio and alpha are in each caption.
Theme · state OLD (main grey) Pre-floor revision WITH FLOOR (shipped)
Default dark (reference) · idle (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Default dark (reference) · hover (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Solarized Dark · idle (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Solarized Dark · hover (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
One Dark · idle (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
One Dark · hover (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Palenight · idle (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Palenight · hover (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Ayu Dark · idle (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Ayu Dark · hover (screenshot removed: contained real product data) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
Theme Idle contrast: main / this PR / floor Hover contrast: main / this PR / floor Floor alphas (idle / hover)
Default dark 2.31 / 3.07 / 3.07 3.44 / 5.35 / 5.35 unchanged (0.35 / 0.55)
Solarized Dark 2.31 / 1.71 / 2.31 3.52 / 2.39 / 3.55 0.53 / 0.80
One Dark 2.31 / 2.05 / 2.32 3.44 / 3.05 / 3.48 0.41 / 0.62
Palenight 2.29 / 1.99 / 2.33 3.38 / 2.92 / 3.43 0.43 / 0.64
Ayu Dark 2.41 / 2.08 / 2.42 4.00 / 3.45 / 4.08 0.41 / 0.62

Implementation: sliderAlpha in terminal-appearance.ts. It reuses contrastRatio and over from plugin-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:

Old grey Fg @ 0.4/0.6/0.8 (previous rev) Fg @ 0.35/0.55/0.7 (this PR)
Dark, idle (median of 22) 2.32 2.96 2.58
Dark, hover (median) 3.54 4.96 4.39
Dark, drag (median) 5.16 7.72 6.24
Light, idle (median of 9) 1.27 1.98 1.80
Light, idle (worst: Solarized Light) 1.27 1.63 1.53
Light, hover (median) 1.45 2.98 2.67

Per theme (idle / hover):

Theme Old grey Previous rev This PR
Default dark (Ghostty Default Style Dark) 2.31 / 3.44 3.56 / 6.06 3.07 / 5.35
Dracula 2.32 / 3.47 3.44 / 5.82 2.97 / 5.14
One Dark 2.31 / 3.44 2.27 / 3.36 2.05 / 3.05
Tokyo Night 2.43 / 3.83 2.80 / 4.64 2.45 / 4.12
Default light (Builtin Tango Light) 1.31 / 1.51 2.24 / 3.72 1.99 / 3.25
Solarized Light 1.27 / 1.45 1.63 / 2.16 1.53 / 2.01
GitHub Light 1.31 / 1.51 2.35 / 4.05 2.08 / 3.50

Root-cause investigation for #12635 (why this is Refs, not Closes)

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 (CopyFromScreen in 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.

  • It is xterm 6's own .xterm-slider: 7px wide, z-index: 11, sitting above everything else.
  • It appears on hover and while scrolling, and fades about 800ms after the pointer leaves. That is xterm's ScrollbarVisibility.AUTO, the same as VS Code.
  • .xterm-viewport is 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 dead main.css rules 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".

  • Agent CLIs such as Claude Code and Codex, and pagers such as less, run in the alternate screen buffer. The alternate buffer has no scrollback, so xterm correctly shows no scrollbar.
  • The wheel is turned into arrow keys for the app, so the app scrolls its own history.
  • I reproduced this on Windows with less on a 400-line file: the wheel scrolls the content, and the scrollbar stays xterm-invisible with the slider at full height (no scrollback).
  • Windows Terminal and VS Code behave the same way. This is not something Orca can draw a scrollbar for, because the history lives inside the app.

3. The one real defect (what this PR fixes): in the normal buffer on light themes, the thumb is nearly invisible.

  • The fixed rgba(180,180,185,0.4) gives about 1.2:1 contrast on Solarized Light.
  • The thumb is now tinted from the theme foreground.

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-viewport scrollbar rules in main.css are 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.

Solarized Light Default dark
Before (origin/main) (screenshot removed: contained real product data) (screenshot removed: contained real product data)
After (screenshot removed: contained real product data) (screenshot removed: contained real product data)

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 via composedTerminalThemesEqual. The new work is one regex and three string formats per call. No new listeners, timers, IPC or persistence.

  • Microbenchmark (100k calls, Vitest, dev machine), per composeActiveTerminalTheme call, 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 rewrites (real app, MutationObserver on xterm's slider <style>, base vs branch, same workload):
Workload Base Branch
Unrelated setting write (×2) 0 0
Re-set the same theme 0 0
Theme switch (×2, incl. to Solarized Dark with the floor active) 1 each 1 each
  • No findings. Six-question disposition: (1) no work before the skip gate beyond the existing value-equality dedupe; (2) one compose per pane, unchanged; (3) renderer main thread, sub-microsecond; (4) nothing grows; (5) host-independent; (6) xterm owns the <style> and removes it on dispose (verified with the settings preview).

Merge-risk assessment

Low.

  • It changes only three default theme keys in composeActiveTerminalTheme, and only when the theme doesn't set them.
  • No settings, migration or perf impact. Per theme compose it does three string formats plus a bounded alpha search, at most 15 µs.
  • Rebased onto main now that fix(terminal): scope terminal color overrides to their light/dark theme slot #36581 has merged. The diff is one function plus its test, plus a small contrast-floor helper.
  • Nothing is persisted or sent over the wire, so mixed client/server versions are unaffected. Mobile doesn't use this path; it keeps xterm's own foreground-derived defaults.

Negative user-facing tradeoffs

  • On bright-foreground dark themes (Default dark, Dracula) the thumb is still a bit brighter than the old grey, though dimmer than the first revision: rgba(255,255,255,0.35) instead of rgba(180,180,185,0.4).
  • On muted dark themes the floor makes the thumb about as visible as main's grey, not dimmer. The exception is Solarized Dark's drag state, which caps at an opaque foreground: 4.75:1 vs the grey's 5.16:1.
  • The floor compares against the opaque theme background. With terminalBackgroundOpacity below 1, the real contrast depends on what shows through, the same as with main's grey. A background override typed as rgb() skips the floor.
  • A foreground override entered as 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.
  • Light themes are slightly less prominent than in the first revision (Solarized Light idle 1.63 to 1.53), but still well above the old grey (1.27).
  • The thumb picks up the foreground's hue, so a theme with a colored foreground gets a matching tinted thumb.

Validation

  • pnpm tc:web, plus oxlint and oxfmt on changed files.
  • pnpm test with 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).
  • Windows 11 (awin): builds of origin/main and v1.4.167 on a real desktop; normal-buffer scrollback in light and dark; alternate-screen less repro.
  • Alpha tuning (this revision): a dev Electron build on a throwaway profile, driven over CDP in the background with a folder workspace. I captured old, previous and new alphas on 4 dark and 3 light built-in themes and read each slider's computed color in idle and hover state, for example rgba(255, 255, 255, 0.35) idle and rgba(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 focused compose-active-terminal-theme test.
  • Real app (first revision): a dev Electron build on a throwaway profile, driven over CDP in the background. I captured the slider's computed color and screenshots on origin/main and on this branch, with Solarized Light and the default dark theme:
    • before: rgba(180, 180, 185, 0.4)
    • after: rgba(101, 123, 131, 0.4) on Solarized Light, rgba(255, 255, 255, 0.4) on dark
  • Floor (final revision): re-verified over CDP on Default dark, Solarized Dark, One Dark, Palenight, Ayu Dark, Tango Light, Solarized Light and GitHub Light, idle and hover. Computed slider colors match the prototype, for example Solarized Dark rgba(131,148,150,0.53) / 0.8, and light themes stay at 0.35 / 0.55. Also ran pnpm tc:web, oxlint and the compose test, which now includes a muted-theme floor case.
  • Review of the floor delta: an Opus sub-agent and Codex. I fixed the comment overclaim and tightened the test, which now asserts the opaque drag cap. Not changed: (a) Solarized Dark's drag state at an opaque 4.75:1 is kept, because falling back to grey would switch hue mid-drag; (b) xterm's 8-bit alpha rounding shifts contrast by about 0.002, which is imperceptible; (c) transparent backgrounds and rgb() backgrounds are documented above as tradeoffs.
  • Review of the tuning delta: an Opus sub-agent and Codex. Opus found nothing significant. Codex raised three P2 findings. None changed the code, for these reasons: (1) xterm 6 writes its slider rules into an unscoped per-terminal <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 to rgba(248,248,242,0.35). (2) Foreground overrides typed as rgb() 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).
  • Review (first revision): two independent reviews (an Opus sub-agent and Codex). Fixed the tint being read before overrides by stacking on fix(terminal): scope terminal color overrides to their light/dark theme slot #36581, replaced the non-hex fallback with xterm's own derivation, and shortened the comment.

@nwparker
nwparker deleted the branch nwparker/theme-terminal-overrides-per-mode October 31, 2026 20:12
@nwparker nwparker closed this Oct 31, 2026
@nwparker nwparker reopened this Oct 31, 2026
@nwparker
nwparker changed the base branch from nwparker/theme-terminal-overrides-per-mode to main October 31, 2026 20:15
@nwparker
nwparker force-pushed the nwparker/theme-terminal-scrollbar-contrast branch from 1b776d8 to 8617517 Compare October 31, 2026 20:15
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a68e71ab-aa61-4f75-b70b-6e2708bc3558
Commits

Reviewing files that changed from the base of the PR and between 671d49a and 470c692.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ecdeac0-6d17-45ae-85fc-6bed16f1a85e
Commits

Reviewing files that changed from the base of the PR and between d235a9f and 60c9e49.

Files selected for processing: 3
  • src/renderer/src/components/terminal-pane/compose-active-terminal-theme.test.ts
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/lib/plugin-theme-tokens.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The terminal theme composer now derives default scrollbar slider colors from the foreground when it is valid hex. When the background is also valid hex, the composer increases each slider alpha in 0.01 steps until it reaches the legacy grey’s contrast at the corresponding alpha, or reaches 1. Explicit slider colors in the base theme take precedence. Tests cover light and muted dark themes. The over function is now exported.

Merge Risk: Low · previous review 60c9e

The thumb can be faint over some backdrops or after terminal color changes. The change is mergeable with awareness of these narrow cases.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: the xterm scrollbar thumb tint now comes from the terminal foreground, which makes it visible on light themes. The raw summary confirms the compose-active-terminal-the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is substantially complete. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, performance, risks, tradeoffs, compatibility, and validation. It…
Full details: Title check

Explanation

The title names the main change: the xterm scrollbar thumb tint now comes from the terminal foreground, which makes it visible on light themes. The raw summary confirms the compose-active-terminal-theme and terminal-appearance changes that do this. The title is specific and conveys the primary change, though it is long at 96 characters.

Full details: Description check

Explanation

The description is substantially complete. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, performance, risks, tradeoffs, compatibility, and validation. It does not reproduce every template heading or checklist item, and it uses “Refs #12635” instead of the template’s “Fixes #” format, but the required information is otherwise provided in detail.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nwparker
nwparker force-pushed the nwparker/theme-terminal-scrollbar-contrast branch 2 times, most recently from 60c9e49 to 671d49a Compare November 1, 2026 21:08
@nwparker
nwparker force-pushed the nwparker/theme-terminal-scrollbar-contrast branch from 671d49a to 470c692 Compare November 1, 2026 23:21
@nwparker
nwparker merged commit fdd77b9 into main Nov 2, 2026
49 checks passed
@nwparker
nwparker deleted the nwparker/theme-terminal-scrollbar-contrast branch November 2, 2026 00:09
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.

1 participant