Skip to content

Themes always render light variant on macOS regardless of terminal dark background (OSC 11 detection broken) #23196

Closed as not planned

Description

@jepachecoam

Description

Since April 17, 2026, OpenCode renders the light variant of all themes
regardless of the terminal's actual background color. The dark variant
never loads. This happens across multiple terminals on macOS.

This appears to be related to OC-13047, OC-11441, and OC-12486 but with a
broader scope — it is not limited to one terminal or theme.

Plugins

engram, "plugin": ["@mohak34/opencode-notifier@latest"],

OpenCode version

1.4.10

Steps to reproduce

open opencode.

Screenshot and/or share link

Image

Operating System

mac

Terminal

Ghostty

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 17, 2026
  2. github-actions commented on Apr 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct from these, please add details explaining what differs. Otherwise, consider adding a +1 or additional context to one of the existing issues.

  3. victoralensai commented on Apr 20, 2026

    @victoralensai

    same issue with ghostty on Arch Linux version on opencode 1.14.19

  4. wKich commented on Apr 20, 2026

    @wKich

    Interesting, until 1.14.19 I used to had correct theme rendering in macos in Ghostty.

  5. klement commented on Apr 20, 2026

    @klement

    I noticed solarized light becoming dark in wezterm. My theme is light and opencode was also light. After todays update, opencode turned dark with same setting.

  6. wKich commented on Apr 20, 2026

    @wKich

    It looks like #23188 this PR might be related to how theme become inverted in 1.14.19 release

  7. wKich commented on Apr 20, 2026

    @wKich

    @kommander, could you please check if my suggestion is correct? In iTerm opencode renders in correct theme, so maybe it's only Ghostty issue

  8. klement commented on Apr 20, 2026

    @klement

    @wKich I’m using wezterm and seeing the same (on macos)

  9. joaomj commented on Apr 20, 2026

    @joaomj

    same here (ghostty + ubuntu). Worked fine in 1.14.18

  10. kommander commented on Apr 20, 2026

    @kommander
    Contributor

    Can you try ctrl+p and then "Unlock theme mode"?

  11. WolffTech commented on Apr 20, 2026

    @WolffTech

    I'm having the same issue on ghostty + macOS regardless if I'm using tmux or not. Commented in #20926.

    @kommander If it helps, I attempted ctrl+p and then "unlock theme mode" with no visible changes. Attempted to restart opencode and then also tried restarting ghostly as well with no change after toggling that option. Behavior is still present. This seems to have only started occurring in the 1.14.19 release. 1.14.18 and lower work fine when this was fixed a few weeks ago originally.

  12. klement commented on Apr 20, 2026

    @klement

    Mine is

    opencode --version
    1.14.18

    and I am experiencing this issue, [un]lock theme mode doesn’t do anything.

  13. 5 remaining items

  14. coygeek commented on Apr 22, 2026

    @coygeek

    Adding another reproducible macOS + Ghostty report.

    On this machine:

    • OpenCode 1.14.20
    • Ghostty on macOS with theme = light:Catppuccin Latte,dark:Catppuccin Mocha and window-theme = auto
    • OpenCode TUI config set to theme: "github" in ~/.config/opencode/tui.json

    I removed all persisted mode overrides from ~/.local/state/opencode/kv.json, so it now only contains theme: "github":

    • no theme_mode_lock
    • no theme_mode

    Unlock theme mode had no effect.

    Behavior I am still seeing:

    1. Set macOS to dark mode
    2. Ghostty switches to dark correctly
    3. Fully quit OpenCode
    4. Reopen OpenCode
    5. OpenCode still renders the light variant

    I also tested theme: "system" and it still did not follow correctly, so this does not look specific to the github theme itself.

    This seems consistent with the CSI 996 / OSC 11 mismatch discussed above: startup mode detection still appears wrong even after removing the lock/cache state.

  15. coygeek commented on Apr 22, 2026

    @coygeek

    Adding a stronger repro/data point here. This is not just a stale lock/cache issue on my machine.

    Environment:

    • OpenCode 1.14.20
    • macOS
    • Ghostty
    • theme = light:Catppuccin Latte,dark:Catppuccin Mocha
    • window-theme = auto
    • OpenCode TUI theme set to github
    • tested in a plain native Ghostty tab, not inside tmux

    My persisted OpenCode state is clean:

    • ~/.config/opencode/tui.json contains only theme: "github"
    • ~/.local/state/opencode/kv.json contains only theme: "github"
    • no theme_mode_lock
    • no theme_mode

    I ran the maintainer probe script directly in the same Ghostty tab where I launch opencode.

    In macOS light mode, Ghostty reports light correctly:

    theme queries:
      CSI ?996n      light
      OSC 10 (fg)    #4c4f69   rgb( 76,  79, 105)
      OSC 11 (bg)    #eff1f5   rgb(239, 241, 245)
    

    In macOS dark mode, Ghostty reports dark correctly:

    theme queries:
      CSI ?996n      dark
      OSC 10 (fg)    #cdd6f4   rgb(205, 214, 244)
      OSC 11 (bg)    #1e1e2e   rgb( 30,  30,  46)
    

    So Ghostty itself is returning the expected mode/colors.

    But OpenCode is still wrong:

    • in macOS light mode, OpenCode command palette shows Lock theme mode and Switch to light mode
    • after switching macOS to dark mode, OpenCode still shows Lock theme mode and Switch to light mode

    That means OpenCode believes its current mode is already dark in both cases, even though the terminal probe in the same tab reports light and dark correctly.

    So on this machine the issue seems narrower than "Ghostty reports the wrong theme":

    • terminal probe outside OpenCode is correct
    • no persisted theme lock/cache is present
    • OpenCode 1.14.20 still starts/behaves as if mode is stuck on dark
  16. Klassikcat commented on Apr 23, 2026

    @Klassikcat

    Seems like related to this code block i guess:

    function mode(background: RGBA | null): "dark" | "light" {
      if (!background) return "dark"
      const luminance = (0.299 * background.r + 0.587 * background.g + 0.114 * background.b) / 255
      return luminance > 0.5 ? "light" : "dark"
    }
    
  17. coygeek commented on Apr 23, 2026

    @coygeek

    Fixed in v1.14.20

    • "Fixed a system theme regression in the TUI."

    Tested on 2 macs, works normally now.

  18. coygeek commented on Apr 23, 2026

    @coygeek

    @jepachecoam consider closing

  19. pearofducks commented on Apr 23, 2026

    @pearofducks

    @coygeek

    I'm seeing it always detect dark mode now instead (as in, even when the terminal is light). Happy to provide input.

    I guess this specific issue could be closed, but it seems like the root problem is ongoing?

  20. coygeek commented on Apr 23, 2026

    @coygeek

    I see this in dark mode (aka macos dark mode) which matches my opencode dark mode:

    Image

    I see this in light mode (aka macos light mode) which matches my opencode light mode:

    Image

    tui.json:

    {
      "$schema": "https://opencode.ai/tui.json",
      "theme": "vercel"
    }
    
    

    Looks normal to me. Using Ghostty, not terminal.

  21. Klassikcat commented on Apr 23, 2026

    @Klassikcat

    @pearofducks

    Quick fix:

    1. Clone the repository
    2. Fix packages/opencode/src/cli/cmd/tui/util/terminal.ts line 22
      from:
    function mode(background: RGBA | null): "dark" | "light" {
      if (!background) return "dark"
      const luminance = (0.299 * background.r + 0.587 * background.g + 0.114 * background.b) / 255
      return luminance > 0.5 ? "light" : "dark"
    }

    to:

    function mode(background: RGBA | null): "dark" | "light" {
      if (!background) return "dark"
      const luminance = 0.299 * background.r + 0.587 * background.g + 0.114 * background.b
      return luminance > 0.5 ? "light" : "dark"
    }
    1. run OPENCODE_VERSION=1.14.20 npx -y bun@1.3.11 run --cwd packages/opencode build --single to build.
    2. copy build binary using cp $HOME/path/to/opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode" "$HOME/.opencode/bin/opencode"
    3. run opencode as usual

    Tested on Ubuntu 24.04, hyprland WM, terminal emulator: kitty and warp terminal.

  22. pearofducks commented on Apr 23, 2026

    @pearofducks

    @coygeek - I'm not using the dynamic switcher and am rather modifying my config file to point to a light or dark theme. Like I said I'm happy to provide more info to help you reproduce the issue!

    I can confirm @Klassikcat's suggested fix works on light and dark mode.

    (I had to build using 1.3.13 of Bun instead)

  23. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  24. github-actions commented on Jul 3, 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