Skip to content

fix(terminal): scope terminal color overrides to their light/dark theme slot - #36581

Merged
nwparker merged 1 commit into
mainfrom
nwparker/theme-terminal-overrides-per-mode
Oct 31, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/theme-terminal-overrides-per-mode

Conversation

@nwparker

@nwparker nwparker commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74
Prod 36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​362 $\color{#cf222e}{\Huge{\mathbf{−}}}$​204 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158

Summary

Terminal Color Overrides now belong to a terminal theme slot (Dark / Light), the same way the theme picker and divider color already do. Setting a dark background override no longer repaints the light terminal.

Root cause: terminalColorOverrides was one bag that every reader spread over whatever theme was active. That happened in six places: xterm panes, the OSC 10/11 replies (desktop, headless orca serve) and native chat, the left sidebar's Match Terminal, the mobile terminal theme, and the pane title projection.

Fix:

  • Settings. terminalColorOverrides stays as the dark slot's bag, and a new terminalColorOverridesLight holds the light slot's. The light bag is used only when light mode has its own terminal theme; when light matches dark, light mode keeps using the dark slot.
  • One resolver. resolveTerminalPalette (shared/terminal-theme-selection.ts) returns the slot's theme with its overrides already painted on. resolveEffectiveTerminalAppearance and resolveConfiguredTerminalColors (OSC 10/11 and chat) both use it, so every downstream reader gets the right colors. All six copies of the override spreading are deleted. The dead appearance.theme ?? getBuiltinTheme(...) fallbacks are gone too, because the resolver already falls back to the slot's default theme.
  • Editor. The Color Overrides editor follows the Terminal Themes Dark/Light target, which already sits directly above it with the live preview below. No second mode switch was added. "Reset" only resets that slot.
  • Clearing on theme change. Choosing a theme in the picker, or applying a plugin terminal theme, clears only that slot's overrides. Applying a light-slot plugin theme no longer wipes the dark overrides, and the plugin "Switch back" restores both bags.
  • Ghostty import (settings and onboarding) merges into the slot that is showing once the import applies. This replaces two duplicated merge blocks with one helper.
  • Smaller fixes. An override field cleared during the session (held in memory as undefined until reload) no longer blanks the theme's color. The settings preview memo now re-derives when either bag changes.

Migration is a one-shot step in the desktop/orca serve profile load and in the web client's localStorage load, guarded by a stamp so it never runs twice.

  • The legacy bag stays on the dark slot.
  • If the light slot could have shown it (the light theme is separate and the app isn't pinned to dark), it is copied to the light slot too.
  • So nothing changes visually on upgrade, and the user can then edit or reset either slot on its own.

Mixed versions:

  • Older client reading newer settings: it only knows terminalColorOverrides, so it shows the dark slot's colors in both modes. That is the old behavior, and nothing is lost.
  • Newer client reading settings an older client wrote later: it reads them as the dark slot.
  • Mobile: it keeps receiving the theme the desktop resolved.
  • Headless orca serve: it answers OSC 10/11 through the same resolver.

Builds on #10581 by @innocarpe, who first scoped the overrides per mode and spotted that light mode matching dark must reuse the dark bag. This PR differs in three ways:

  • It keeps the original key as the dark slot instead of adding two new keys plus a legacy fallback, so older clients keep working without dual reads.
  • It resolves overrides inside the single palette resolver rather than threading mode through every caller.
  • It reuses the existing Dark/Light target instead of adding a second segmented control.

Closes #10561
Supersedes #10581

Visual proof

The test profile has a dark-slot override (background #3b0d1f, foreground #ffd6e0) and a separate light theme.

Before (origin/main), app in light mode: the dark override still paints the light terminal, and the editor is one shared bag.

before light terminal
before settings

After, dark mode: the dark slot's override applies, and the editor is labelled for the dark theme.

after dark terminal
after settings dark

After, light mode: the light slot starts empty. A light background typed into the editor on the Light target shows in the preview and the live terminal, and the dark slot is unchanged.

after settings light
after settings light edited
after light terminal

Merge-risk assessment

Low. It was "low to medium" before I exercised the risky paths on real installs. The settings were read straight from the persisted profile-state.db with node:sqlite, not just from the in-memory store.

  • Upgrade, then downgrade, on one real profile (Windows 11, dev builds):
    1. Created the profile on main with a dark override (#3b0d1f/#ffd6e0), app on system, separate light theme. The database holds only terminalColorOverrides.
    2. Upgraded to this branch. The database now holds the dark bag unchanged, the same bag copied to terminalColorOverridesLight, and terminalColorOverridesSplit: true. The terminal looks the same as before the upgrade.
    3. On the branch, edited the light slot to #fff4d6. The dark bag was untouched.
    4. Downgraded to main. Main keeps the dark bag intact, carries the unknown light keys through untouched, and paints the dark override in both modes (its pre-split behavior). Nothing is lost.
    5. Edited the override on main (the old client writes terminalColorOverrides = #0d3b1f), then upgraded to the branch again. There was no re-migration: dark mode paints #0d3b1f, light mode keeps #fff4d6.
  • Mixed versions with a remote orca serve (headless serve on Linux openclaw, desktop client on Windows awin, paired over LAN, remote bash terminal, client app in light mode with dark bag #3b0d1f and light bag #fff4d6):
    • Client on main, server on the branch: OSC 11 answers rgb:3b3b/0d0d/1f1f. That is the old client's dark-everywhere color, matching what it paints.
    • Client on the branch, server on main: OSC 11 answers rgb:ffff/f4f4/d6d6. That is the light slot, matching the light terminal.
    • The answer always follows the viewing client's resolved palette, so neither direction mismatches what the user sees.
  • Mobile: the phone renders the palette the desktop resolves through the same resolver (unit-tested: the light slot in light mode, opacity, no mutation of the catalog). There is no mobile-side settings reader, so there is no mixed-version path. I did not pair a physical phone.
  • Blast radius and perf: unchanged from before. The rewiring is mechanical, 939 tests in 105 related files pass, there is one object spread per palette resolution only when overrides exist, and xterm theme writes stay value-gated.

Negative user-facing tradeoffs

  • Users whose overrides used to bleed into light mode ([Bug]: Appearance terminal color overrides affects both light/dark mode #10561's case) still see them in light mode right after upgrading, because the migration copies the bag to both slots so nothing changes silently. They need to press "Reset light color overrides" once.
  • After upgrading, editing overrides on one slot no longer changes the other. Anyone who relied on one edit covering both modes now edits both slots.
  • Ghostty import colors now land only on the slot that is showing at import time, not on both modes.
  • Older Orca clients sharing the same settings still apply the dark slot's colors in light mode, which is the old behavior.
  • The Color Overrides description text changed and the reset button is now per slot. New strings are translated for all 11 locales, by hand rather than by the translation pipeline, so they may need a polish pass.

Validation

  • pnpm tc, oxlint and oxfmt on all changed files.
  • pnpm test on 105 related files: 939 passing. Coverage includes:
    • the resolver: each slot, light matching dark, a field cleared in memory, and the Ghostty import slot
    • the persisted-profile migration: copied to both slots, dark-only, and never re-split
    • picker clearing only its own slot
    • plugin apply leaving the dark slot alone
    • mobile theme, native chat palette and Ghostty import
  • Real app: a dev Electron build on a throwaway profile, driven over CDP in the background. On origin/main and on this branch I:
    • toggled the app between dark and light with a dark override
    • edited a light-slot background through the real Color Overrides field and confirmed the store holds terminalColorOverridesLight while the dark bag stays unchanged
    • checked the live terminal and the settings preview in both modes
  • Real installs (phase 2): upgrade, downgrade and re-upgrade on one Windows 11 profile with on-disk checks; mixed-version orca serve in both directions with OSC 11 replies (see the merge-risk section).
  • Review: two independent reviews (an Opus sub-agent and Codex). Fixed the Ghostty import slot routing, the migration (it now copies, keeping older clients intact and covering system-light users and stored profiles missing the separate-light flag), and the dead built-in theme fallbacks.

remote-clientA-servermain

remote-clientmain-serverA

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 0b4407cf-ca0d-4333-8327-ba2507818296
Commits

Reviewing files that changed from the base of the PR and between 1f504e9 and b783b71.

Files selected for processing: 43
  • src/main/persistence/loading-store/normalize-loaded-global-settings.test.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/main/persistence/loading-store/prepare-loaded-terminal-settings.ts
  • src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
  • src/renderer/src/components/native-chat/native-chat-appearance-palette.test.ts
  • src/renderer/src/components/native-chat/native-chat-appearance-style.ts
  • src/renderer/src/components/onboarding/ThemeStep.tsx
  • src/renderer/src/components/plain-ssh-terminal/PlainSshTerminalView.tsx
  • src/renderer/src/components/plugins/page/PluginThemeUseNow.test.tsx
  • src/renderer/src/components/plugins/state/plugin-theme-apply.ts
  • src/renderer/src/components/settings/AgentDefaultSurfacePreviews.tsx
  • src/renderer/src/components/settings/TerminalAppearanceSection.tsx
  • src/renderer/src/components/settings/TerminalSettingsPreview.tsx
  • src/renderer/src/components/settings/TerminalThemeSections.lifecycle.test.ts
  • src/renderer/src/components/settings/TerminalThemeSections.tsx
  • src/renderer/src/components/settings/TerminalWindowSection.tsx
  • src/renderer/src/components/settings/useGhosttyImport.ts
  • src/renderer/src/components/terminal-pane/compose-active-terminal-theme.test.ts
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-projection.ts
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ru.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/left-sidebar-appearance.ts
  • src/renderer/src/lib/terminal-theme.ts
  • src/renderer/src/runtime/sync-runtime-graph-terminal-surface-projection.test.ts
  • src/renderer/src/runtime/sync-runtime-graph/mobile-terminal-theme.ts
  • src/renderer/src/web/preload-api/web-preference-normalization.ts
  • src/renderer/src/web/preload-api/web-preferences-store.ts
  • src/shared/default-global-settings.ts
  • src/shared/global-settings-base.ts
  • src/shared/global-settings-types.ts
  • src/shared/terminal-color-overrides.ts
  • src/shared/terminal-theme-selection.test.ts
  • src/shared/terminal-theme-selection.ts
  • 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

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]: Appearance terminal color overrides affects both light/dark mode

1 participant