Skip to content

fix(appearance): keep low-contrast themes legible in match-terminal sidebar and terminal ghost text - #17000

Closed
seedotlee wants to merge 7 commits into
stablyai:mainfrom
seedotlee:fix/low-contrast-theme-legibility
Closed

seedotlee wants to merge 7 commits into
stablyai:mainfrom
seedotlee:fix/low-contrast-theme-legibility

Conversation

@seedotlee

Copy link
Copy Markdown

ELI5

On "soft" low-contrast terminal themes (Solarized, Everforest, Rosé Pine Dawn, Catppuccin Latte…) two things fade out: sidebar text in Match terminal mode, and shell autosuggestion "ghost text" in the terminal, which gets pushed to the same gray as typed text. Both derive dim colors from the theme foreground using ratios tuned for a near-black/near-white foreground; this PR makes those derivations contrast-aware, so high-contrast themes look exactly as before and low-contrast ones stay readable.

What Changed

Two focused commits:

1. fix(sidebar) — match-terminal muted text (left-sidebar-appearance.ts, new muted-foreground-contrast.ts)

  • --muted-foreground was a fixed color-mix(fg 62%, bg). It is now gated on contrast: the mix is raised from 62 % until the result clears 4.5:1 against the background (the light default #737373/#fafafa sits at exactly 4.5:1), capped at the foreground itself. High-contrast pairs stay at 62 %, so existing expectations are unchanged.
  • Sidebar nav / task nav / dashboard entry / setup-guide entry / settings sidebar used text-worktree-sidebar-foreground/60|55|45|30 alpha tiers, which have the same flaw and can't be fixed by tokens. They now use text-muted-foreground tiers (/60→muted, /55→/90, /45→/75, /30→/50) chosen so the default light and dark looks are visually unchanged (e.g. dark /30 = 2.64:1 before and after).

2. fix(terminal) — xterm contrast floor (terminal-contrast-correction.ts, terminal-title-contrast.ts + 3 call sites)

Why

Fixed mix ratios and alpha tiers assume the default theme's foreground (~19:1). Solarized Light's #586e75 on #fdf6e3 is ~5:1, so:

Solarized Light GitHub Light (14.7:1 fg)
derived --muted-foreground (62 %) 2.2–2.4:1 4.3:1
nav icon tier fg/30 1.5:1 3.9:1
ghost text (brightBlack #93a1a1, 2.5:1) after xterm's 4.5 floor lifted to #5f6868 — fg is #586e75 untouched

Editing the theme is not a workaround: a 60 % alpha tier only reaches 4.5:1 on a light background with a near-black foreground (even Gruvbox Light's 10:1 fg yields 3.4:1), and any brightBlack under 4.5:1 is lifted onto the foreground by xterm regardless of its value. Gating on the actual contrast fixes the whole family of themes (Everforest Light, Rosé Pine Dawn, Catppuccin Latte, Solarized Dark…) without touching high-contrast ones.

Linked Issue

Fixes #16999

Visual Proof

Solarized Light, Left sidebar: Match terminal, macOS.

Before After
before worktree sidebar after worktree sidebar

Settings sidebar:

Before After
before settings sidebar after settings sidebar

Terminal (zsh-autosuggestions, fg=8): before, typed text and ghost text both render as ~#5f6868; after, ghost text stays at the theme's brightBlack (#93a1a1, 2.5:1) while typed text remains #586e75 (5:1).

Testing

  • macOS: pnpm dev with Solarized Light (builtin and a Ghostty/Warp-imported variant), sidebar in match-terminal mode; verified sidebar labels/subtitles/settings sidebar and ghost text in a zsh pane. Also checked GitHub Light / Ghostty Default Dark render unchanged.

  • Not a platform-specific change (pure color derivation in the renderer); no SSH/remote or path impact.

  • pnpm test (281 files / 2387 tests), pnpm tc:web, changed-file lint all pass locally.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

New/updated tests: muted-foreground-contrast.test.ts (7), left-sidebar-appearance.test.ts (+1 match-terminal Solarized case), terminal-contrast-correction.test.ts (+7 headroom cases, incl. pinning that Solarized's own brightBlack is no longer lifted and that high-contrast themes keep their floors).

AI Disclosure

Root-cause analysis, implementation and tests were done with Claude (Claude Code), reviewed and verified manually by me.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Renderer-only color derivation; no security, cross-platform, SSH, mobile, wire or performance surface. The contrast search in resolveMutedForegroundMixPercent is at most 38 iterations of a few multiplications and runs only when sidebar style variables are recomputed.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

lisi and others added 2 commits August 28, 2026 17:05
xterm's minimumContrastRatio lifts every below-floor color to the floor, so on
a low-contrast theme the 4.5 light-background floor lands beside the theme's
own foreground: Solarized Light's brightBlack #93a1a1 (2.5:1) was darkened to
#5f6868 next to fg #586e75 (5:1), making zsh-autosuggestions / fish ghost text
indistinguishable from typed text.

Cap the floor at half the foreground's contrast (the ~20 L* step theme
authors give their dim slot), bottoming out at 1. High-contrast themes are
unaffected: the floor only moves when fg is under 9:1 on light or 6:1 on dark.

Co-Authored-By: Claude Fable 5 <[email protected]>
…themes

Match-terminal derived --muted-foreground with a fixed 62% fg/bg mix, and the
sidebar nav used sidebar-foreground/60|55|45|30 alpha tiers. Both assume a
near-black/near-white foreground; Solarized Light's #586e75 on #fdf6e3 (5:1)
mixed down to ~2.4:1 and 1.5:1, so nav labels, worktree subtitles and the
settings sidebar faded into the background.

- Gate the muted mix on contrast: raise it from 62% until the result clears
  4.5:1 (the light default's own ratio). High-contrast themes stay at ~62%.
- Move the sidebar alpha tiers onto text-muted-foreground tiers chosen to
  keep the default light/dark look unchanged.

Fixes stablyai#16999

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 986d6b2b-87a8-4e85-8c4e-eae0cf18bea1

📥 Commits

Reviewing files that changed from the base of the PR and between b11a0e7 and 6ecc7d8.

📒 Files selected for processing (3)
  • src/renderer/src/lib/left-sidebar-appearance.ts
  • src/renderer/src/lib/muted-foreground-contrast.test.ts
  • src/renderer/src/lib/terminal-contrast-correction.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/lib/left-sidebar-appearance.ts

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


📝 Walkthrough

Walkthrough

The PR adds foreground-aware terminal contrast correction and passes theme foreground colors from terminal previews. It adds utilities for adaptive muted-foreground mixing with WCAG contrast checks and test coverage. Inactive sidebar elements now use semantic muted foreground tokens instead of worktree-specific color tokens. Active and hover styling remains unchanged.

Merge Risk: 🔵 Low · up to 6ecc7

This renderer-only change improves sidebar and terminal readability for low-contrast themes. A bounded risk remains that translucent foreground colors may still yield muted sidebar text below the intended contrast floor in some themes, so merge is reasonable with explicit owner awareness or follow-up.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary fix: improving legibility for low-contrast themes in the match-terminal sidebar and terminal ghost text.
Description check ✅ Passed The description follows the required template and provides a clear summary, rationale, linked issue, visual proof, testing details, AI disclosure, scope notes, and completed checklist items.
Docstring Coverage ✅ Passed Docstring coverage is 80.56% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 15 files.
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.

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 705ddb5d-b2d6-454b-866b-8b0541af7b16

📥 Commits

Reviewing files that changed from the base of the PR and between 83320bf and da7ba7d.

📒 Files selected for processing (15)
  • src/renderer/src/components/dashboard-popout/preview-terminal-options.ts
  • src/renderer/src/components/settings/SettingsSidebar.tsx
  • src/renderer/src/components/settings/TerminalSettingsPreview.tsx
  • src/renderer/src/components/sidebar/AgentDashboardSidebarEntry.tsx
  • src/renderer/src/components/sidebar/SetupGuideSidebarEntry.tsx
  • src/renderer/src/components/sidebar/SidebarNav.tsx
  • src/renderer/src/components/sidebar/SidebarTaskNavButton.tsx
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/lib/left-sidebar-appearance.test.ts
  • src/renderer/src/lib/left-sidebar-appearance.ts
  • src/renderer/src/lib/muted-foreground-contrast.test.ts
  • src/renderer/src/lib/muted-foreground-contrast.ts
  • src/renderer/src/lib/terminal-contrast-correction.test.ts
  • src/renderer/src/lib/terminal-contrast-correction.ts
  • src/renderer/src/lib/terminal-title-contrast.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

lisi and others added 3 commits August 28, 2026 22:51
CodeRabbit's docstring-coverage pre-merge check flagged 28.57% on the
functions this PR touches; brief one-liners bring every touched function
in the diff over the 80% threshold.

Co-Authored-By: Claude Fable 5 <[email protected]>
CodeRabbit still counted the test file's nested arrows and a few
context-line functions as undocumented (70.37% < 80%). Hoist the
luminance/channel helpers into named, documented functions and add
one-liners to the remaining touched functions.

Co-Authored-By: Claude Fable 5 <[email protected]>
Address CodeRabbit review on stablyai#17000:
- resolveMutedForegroundMixPercent composites a translucent background over
  the app surface first: color-mix(fg P%, rgba-bg) rendered over the surface
  equals mixSrgb(fg, composited-bg, P), so the gate now rates what is seen.
  The sidebar passes the effective app mode as the surface.
- resolveTerminalTextContrastRatio composites a translucent foreground over
  the composited background instead of rating it as opaque.

Co-Authored-By: Claude Fable 5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR makes muted sidebar colors and terminal ghost-text correction responsive to the active theme’s foreground contrast.

  • Computes match-terminal muted foreground mixes against the rendered sidebar surface, including translucent backgrounds.
  • Replaces fixed sidebar alpha tiers with contrast-aware muted-foreground tiers.
  • Caps xterm’s minimum contrast ratio to preserve intentional dim-text separation in low-contrast themes.
  • Adds coverage for low-contrast, translucent, and high-contrast theme cases.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/renderer/src/lib/muted-foreground-contrast.ts Models premultiplied CSS color mixing and compositing to select the minimum muted-foreground percentage meeting the contrast target.
src/renderer/src/lib/left-sidebar-appearance.ts Applies the contrast-aware muted foreground to match-terminal sidebar variables using the actual app surface mode.
src/renderer/src/lib/terminal-contrast-correction.ts Caps xterm contrast correction according to foreground headroom while retaining existing floors for high-contrast themes.
src/renderer/src/lib/terminal-title-contrast.ts Exposes shared parsing and compositing helpers and adds rendered foreground-to-background contrast calculation.
src/renderer/src/lib/muted-foreground-contrast.test.ts Covers opaque, translucent, low-contrast, unparseable, and unattainable contrast scenarios.

Reviews (3): Last reviewed commit: "fix(appearance): rate muted text by the ..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: da0aba20-10a3-411b-b01b-90c1fa6cce39

📥 Commits

Reviewing files that changed from the base of the PR and between 031bbfc and b11a0e7.

📒 Files selected for processing (6)
  • src/renderer/src/lib/left-sidebar-appearance.test.ts
  • src/renderer/src/lib/left-sidebar-appearance.ts
  • src/renderer/src/lib/muted-foreground-contrast.test.ts
  • src/renderer/src/lib/muted-foreground-contrast.ts
  • src/renderer/src/lib/terminal-contrast-correction.test.ts
  • src/renderer/src/lib/terminal-title-contrast.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Inline .map / nested lambdas count as undocumented functions for the
docstring-coverage gate; hoist them into named helpers with JSDoc.

Co-Authored-By: Claude Fable 5 <[email protected]>
…a translucent sidebar

Address Greptile + CodeRabbit review on stablyai#17000. The previous model
composited the background first and mixed opaquely, but the emitted CSS
mixes color-mix(fg P%, rgba-bg) premultiplied (CSS Color 4 §12.3) and the
browser composites that still-translucent text over the sidebar — whose
own transparent part shows the raw background layer again. Model exactly:

  text  = P·a_fg·fg + (1-P)·a_bg·bg + (1 - P·a_fg - (1-P)·a_bg)·S
  S     = a_bg·bg + (1-a_bg)·appSurface

and rate text against S. Verified against Chromium 152's computed
color-mix values. Foreground alpha is now part of the same formula, so
rgba(0,0,0,0.5) on white correctly falls back to 100.

Co-Authored-By: Claude Fable 5 <[email protected]>
@bitconym

Copy link
Copy Markdown

+1. I use Rosé Pine themes, and readable muted text in match-terminal mode matters once more of the app follows the terminal theme (see #16768).

@nwparker

nwparker commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #36567: Match Terminal is now a full app theme that colors the whole window and keeps low-contrast terminal palettes legible. Thank you for this PR, it shaped the design.

@nwparker nwparker closed this Nov 2, 2026
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.

[Bug]: Match-terminal sidebar text is nearly invisible on low-contrast themes (Solarized etc.) — fixed 62% muted mix

3 participants