[FEATURE]: Add support for OpenTUI's new themeMode detection (Mode 2031) #9124

Closed
opened 2026-02-16 18:11:41 -05:00 by yindo · 0 comments
Owner

Originally created by @kavhnr on GitHub (Feb 11, 2026).

Originally assigned to: @kommander on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

OpenCode detects dark/light once at startup via OSC 11 luminance and never reacts to changes. Users who switch appearance mid-session have to restart or manually toggle.

We added Mode 2031 dark/light theme detection to OpenTUI in opentui#657 (shipped in v0.1.78, included in v0.1.79 which OpenCode is already on via #13036). The renderer.themeMode / renderer.on("theme_mode", ...) API is available but OpenCode doesn't use it yet.

This proposes integrating that API into OpenCode's theme system:

1. Tri-state mode (auto / dark / light) replacing the binary toggle. auto follows OS via Mode 2031, falling back to OSC 11 on unsupported terminals. dark / light are manual overrides.

2. Per-mode theme config (backward compatible):

// existing — works as before
{ "theme": "opencode" }

// new — different themes per mode
{ "theme": { "light": "github", "dark": "catppuccin" } }

3. Appearance selector in the existing theme dialog — / arrow keys cycle modes, clickable, reverts on cancel.

Mode 2031 is the same approach used by Neovim and Helix. Terminal-native, event-driven, zero overhead. Supported on Ghostty 1.0+, kitty 0.38.1+, Contour 0.4+, VTE 0.82+. Unsupported terminals silently ignore the sequences.

31 of 33 built-in themes have { dark, light } color variants and work out of the box. The two without (aura, ayu) are unaffected.

Previously requested via different approaches (this uses OpenTUI's new themeMode, which none of them had):

  • #480 — dark/light mode OS sync
  • #9697 — light/dark mode auto-switching
  • #3244 — different theme for light and dark mode
  • #11151 — dark mode in NeoVim's light terminal (manual override)
  • #1587 — system theme requires hard reboot
  • #4464 — light mode in Zellij (manual mode selector)
Originally created by @kavhnr on GitHub (Feb 11, 2026). Originally assigned to: @kommander on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request OpenCode detects dark/light once at startup via OSC 11 luminance and never reacts to changes. Users who switch appearance mid-session have to restart or manually toggle. We added Mode 2031 dark/light theme detection to OpenTUI in [opentui#657](https://github.com/anomalyco/opentui/pull/657) (shipped in v0.1.78, included in v0.1.79 which OpenCode is already on via [#13036](https://github.com/anomalyco/opencode/pull/13036)). The `renderer.themeMode` / `renderer.on("theme_mode", ...)` API is available but OpenCode doesn't use it yet. This proposes integrating that API into OpenCode's theme system: **1. Tri-state mode** (`auto` / `dark` / `light`) replacing the binary toggle. `auto` follows OS via Mode 2031, falling back to OSC 11 on unsupported terminals. `dark` / `light` are manual overrides. **2. Per-mode theme config** (backward compatible): ```jsonc // existing — works as before { "theme": "opencode" } // new — different themes per mode { "theme": { "light": "github", "dark": "catppuccin" } } ``` **3. Appearance selector** in the existing theme dialog — `←`/`→` arrow keys cycle modes, clickable, reverts on cancel. Mode 2031 is the same approach used by [Neovim](https://github.com/neovim/neovim/pull/31350) and [Helix](https://github.com/helix-editor/helix/pull/14356). Terminal-native, event-driven, zero overhead. Supported on Ghostty 1.0+, kitty 0.38.1+, Contour 0.4+, VTE 0.82+. Unsupported terminals silently ignore the sequences. 31 of 33 built-in themes have `{ dark, light }` color variants and work out of the box. The two without (`aura`, `ayu`) are unaffected. **Previously requested via different approaches (this uses OpenTUI's new themeMode, which none of them had):** - #480 — dark/light mode OS sync - #9697 — light/dark mode auto-switching - #3244 — different theme for light and dark mode - #11151 — dark mode in NeoVim's light terminal (manual override) - #1587 — system theme requires hard reboot - #4464 — light mode in Zellij (manual mode selector)
yindo added the opentuidiscussion labels 2026-02-16 18:11:41 -05:00
yindo closed this issue 2026-02-16 18:11:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9124