Skip to content

theme = "system" detects dark on macOS Light mode with Ghostty #1670

@baofu100year

Description

@baofu100year
**Describe the bug**
When `theme` is unset (default `"system"`), deepseek-tui always renders in dark mode even when macOS is in Light mode. The issue occurs wit
h the Ghostty terminal emulator.

**Environment**
- deepseek-tui: 0.8.37 (4c32a316bea2)
- macOS: Sequoia, Light appearance
- Terminal: Ghostty with `theme = light:GitHub Light Default, dark:GitHub Dark Default`
- `COLORFGBG`: unset
- `AppleInterfaceStyle`: not present (Light mode)
- Auto-switch enabled: `AppleInterfaceStyleSwitchesAutomatically = 1`

**To Reproduce**
1. Set macOS to Light mode
2. Use Ghostty terminal (which does not set `COLORFGBG`)
3. Run deepseek-tui with default `theme = "system"`
4. TUI renders in dark colors

**Expected behavior**
TUI should render in light colors matching the macOS Light appearance.

**Root cause**
deepseek-tui's system theme detection appears to rely solely on the `COLORFGBG` environment variable (or terminal background-color query). 
Ghostty does not set `COLORFGBG`, and the background-color query may not return a value usable for light-mode detection. In contrast, Claud
e Code and Codex TUI correctly detect Light mode because they read macOS's `AppleInterfaceStyle` defaults key.

**Suggested fix**
On macOS, fall back to reading `defaults read -g AppleInterfaceStyle` when `COLORFGBG` is unset or ambiguous. If the key does not exist → L
ight mode; if it returns `"Dark"` → Dark mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions