theme: "auto" selects the dark theme on a light terminal (inverted)

Status Open
Reported on v2.1.228
Maintainer reply None cached
Activity 0 comments · opened Aug 12, 2026

What happened

With "theme": "auto", Claude Code selects the dark theme on a light terminal, and the light theme on a dark terminal. It is consistently inverted rather than stuck: toggling the desktop light/dark mode does flip Claude Code's theme, always to the wrong side.

The most visible symptom is diff rendering — added/removed hunks get dark backgrounds with near-white text on a light background terminal, so they look inverted against the surrounding UI.

The terminal reports its colours correctly, so the inversion appears to be in the resolution step rather than the query. The observed behaviour is consistent with the OSC 10 (foreground) reply being used where the OSC 11 (background) reply is intended — that would invert in exactly this way and would still flip on every theme change.

Environment

| | |
|---|---|
| Claude Code | 2.1.228 |
| OS | CachyOS (Linux 7.1.8), Wayland / niri |
| Terminal | kitty 0.48.2 |
| Multiplexer | herdr 0.8.0 |
| TERM | xterm-256color |
| COLORTERM | truecolor |
| COLORFGBG | unset |

Evidence

Terminal background is light (#fff8f7, foreground #22191a). Querying the terminal from inside the same pane Claude Code runs in returns the correct values:

OSC 10 (foreground) -> rgb:2222/1919/1a1a   #22191a  dark
OSC 11 (background) -> rgb:ffff/f8f8/f7f7   #fff8f7  light

Capturing the SGR sequences Claude Code emits while rendering a diff, on that same light terminal:

removed line:  fg 220,90,90    bg 61,1,0    (#3D0100  very dark red)
added line:    fg 80,200,80    bg 2,40,0    (#022800  very dark green)
context text:  fg 248,248,242  (#F8F8F2  near-white)

These are truecolor values from the dark theme, emitted while the terminal background is #fff8f7.

Not a stale read: forcing a re-measure with SIGWINCH while the theme is stable, and with the background verified light, still yields the dark theme. It reproduces in both directions — switching the desktop to dark makes Claude Code render the light theme.

Steps to reproduce

  1. Run Claude Code with "theme": "auto" in a terminal with a light background.
  2. Display any diff (edit a file).
  3. Diff hunks render with dark-theme backgrounds and near-white text.
  4. Switch the terminal to a dark background and repeat — the light theme is used instead.

Expected

auto resolves to the light theme on a light terminal background and the dark theme on a dark one.

Workaround

Setting "theme" explicitly to light or dark renders correctly, but it only applies at startup, so it cannot follow a desktop light/dark switch in a running session. /config changes it live but has to be done by hand after each switch.

Note

This was observed through a terminal multiplexer (herdr), which is where the OSC replies above were captured — those confirm the multiplexer is answering the queries correctly. I have not tested whether the inversion also reproduces in kitty directly, so it may be specific to the multiplexer path.

View original on GitHub ↗