Skip to content

TUI dark/light mode does not follow Windows system theme #36252

Closed as not planned

Description

@JohnXu22786

Description

On Windows 11 Terminal, when the user toggles the system dark/light mode (Settings > Personalization > Colors > Choose your mode), the terminal title bar changes colour but the terminal background colour (queried via OSC 11 \e]11;?\e\) does NOT change.

Since opencode's TUI derives its dark/light mode exclusively from terminalMode() — which reads the terminal background colour — the TUI never detects the system theme switch and stays on the wrong colour mode.

Steps to reproduce

  1. Run opencode TUI on Windows 11 Terminal (Windows Terminal v1.20+)
  2. Observe the TUI is in light mode (or dark mode)
  3. Open Windows Settings → Personalization → Colors
  4. Toggle "Choose your default app mode" between Light and Dark
  5. The terminal title bar immediately reflects the change
  6. The opencode TUI does NOT switch its colour mode

Expected behaviour

The TUI should follow the Windows system theme when running on Windows 11 Terminal, just like it follows the terminal background colour on other platforms/terminals.

System info

  • Windows 11
  • Windows Terminal 1.20+
  • opencode dev branch

Suggested fix

Read the Windows registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme as an additional signal. On Windows Terminal the background colour is not a reliable indicator of the system theme because the title bar and buffer background are decoupled.

Activity

  1. CripWal commented on Aug 14, 2026

    @CripWal

    Additional environment worth covering: the same stale-mode behavior reproduces when opencode runs inside a terminal multiplexer that caches and replays the host palette (herdr 0.8.0), even on macOS.

    Mechanism there: opencode's system theme only refreshes on a \e[?997 color-scheme report or SIGUSR2 (packages/tui/src/context/theme.tsx resolveSystemTheme/refreshSystemTheme). The multiplexer only forwards ?997 when its host terminal emits one, and it additionally answers OSC 10/11/4 queries itself from a cached host_terminal_theme. So if the outer terminal doesn't emit ?997 (e.g. Terminal.app), the palette detection result stays cached at first paint and the theme never flips — the multiplexer-side equivalent of the Windows 11 title-bar/background decoupling described here.

    This parallels #42635 (filed from the same repro inside herdr). A focus-triggered or periodic getPalette() re-query would address both.

  2. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions