Skip to content

no longer respects system theme (macos ghostty) #20926

Closed as not planned
Closed as not planned

Description

@uloco

Description

themes that have both light and dark variant always use light theme, regardless of system theme. this used to work but broke recently.

Plugins

No response

OpenCode version

1.3.13

Steps to reproduce

  1. use macos dark theme
  2. use ghostty dark theme
  3. open opencode and set theme to opencode
  4. theme stays light

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    bugSomething isn't working
    on Apr 3, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 3, 2026
  3. github-actions commented on Apr 3, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from these (e.g. it previously worked and recently regressed specifically with Ghostty), please add that context to help distinguish it.

  4. uloco commented on Apr 3, 2026

    @uloco
    Author

    This is not related to tmux or the opencode system theme

  5. added a commit that references this issue on Apr 4, 2026
    1dce2a6
  6. tienbg-zigexn commented on Apr 11, 2026

    @tienbg-zigexn

    I have the opposite problem, opencode keep using dark variant even though everything else on my machine using light variant (OSX + kitty)

  7. Haume0 commented on Apr 17, 2026

    @Haume0

    I'm experiencing this issue in both Windows & MacOS in default terminals.
    While using "one-dark" opencode 1.4.7 using dark mode every time, opencode 1.4.0(i downgraded it) uses light mode in light dark mode in dark etc.

    So this is a new issue i hope its fixed.

  8. Haume0 commented on Apr 17, 2026

    @Haume0

    Version 1.4.8 also broke the "system" theme.

  9. Haume0 commented on Apr 17, 2026

    @Haume0

    in version 1.4.9 system theme fixed

  10. bewa1t commented on Apr 18, 2026

    @bewa1t

    same on nvim

  11. GuillenSanti commented on Apr 20, 2026

    @GuillenSanti

    Same issue here.

    • OpenCode version: 1.14.19
    • Terminal: Ghostty (theme: Dracula, window-theme = dark, background = #000000)
    • macOS: Tahoe (26), Appearance set to Dark
    • Shell env: COLORTERM=truecolor, TERM=xterm-256color, defaults read -g AppleInterfaceStyle returns Dark
      All OpenCode themes render in their light variant (white background). The system theme is even worse: text becomes invisible.
      Workarounds tried without success:
    • Force opencode theme via /theme
    • Create ~/.config/opencode/tui.json with "theme": "opencode"
    • Add window-theme = dark in Ghostty config
    • Launch with COLORFGBG="15;0" opencode
      None of them change the behavior. Dark/light detection seems completely broken in this version with Ghostty + macOS Tahoe.
  12. albestio commented on Apr 20, 2026

    @albestio

    I managed to turn it back to dark mode by manually switching theme, and later activating Dark Mode again.

  13. WolffTech commented on Apr 20, 2026

    @WolffTech

    Same thing is happening to me in 1.14.19 same as GuillenSanti. I took a look and this probably has to do with PR #23188.

    It looks like util/terminal.ts::getTerminalBackgroundColor was removed and replaced with renderer.waitForThemeMode(1000). I assume this was because the assumption was opentui already knows how to detect this, but it doesn't seem to be the case. This doesn't just affect Ghostty but Kitty and the default Terminal.app as well.

    Here's a diff of the change that are probably causing the issue we're seeing. Take this with a grain of salt though, this isn't my forte.

    diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx
      --- a/packages/opencode/src/cli/cmd/tui/app.tsx
      +++ b/packages/opencode/src/cli/cmd/tui/app.tsx
      @@ -1,7 +1,6 @@
       import { render, TimeToFirstDraw, useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
       import * as Clipboard from "@tui/util/clipboard"
       import * as Selection from "@tui/util/selection"
      -import * as Terminal from "@tui/util/terminal"
       import { createCliRenderer, MouseButton, type CliRendererConfig } from "@opentui/core"
      @@ -120,12 +119,6 @@ export function tui(input: {
           const unguard = win32InstallCtrlCGuard()
           win32DisableProcessedInput()
    
      -    const mode = await Terminal.getTerminalBackgroundColor()
      -
      -    // Re-clear after getTerminalBackgroundColor() — setRawMode(false) restores
      -    // the original console mode which re-enables ENABLE_PROCESSED_INPUT.
      -    win32DisableProcessedInput()
      -
           const onExit = async () => {
             unguard?.()
             resolve()
      @@ -136,6 +129,7 @@ export function tui(input: {
           }
    
           const renderer = await createCliRenderer(rendererConfig(input.config))
      +    const mode = (await renderer.waitForThemeMode(1000)) ?? "dark"
  14. 10 remaining items

  15. uloco commented on Apr 21, 2026

    @uloco
    Author

    if you are running in tmux, there might be a different issue. but running inside a native ghostty tab / split, this issue no longer occurs for me

  16. uloco commented on Apr 21, 2026

    @uloco
    Author

    I have also started to get this issues in 1.14.19, so it's not fixed. Maybe it just switched mode it defaults to? (dark -> light?)

    Previously it respected my system darkmode setting, but today I started opencode and got my eyes burned out with light mode.

    For anyone getting it there is a command to switch the light/dark mode just open the command menu and search for "switch" and it should be there.

    Image Os: Fedora 43 workstation, Terminal: Ghostty 1.3.1

    looks like if you did this once, the theme is stuck on the setting until you do 'unlock theme mode'. maybe this is the case for some of you guys. otherwise i just tested this on macOS so no clue how it is on linux etc

  17. jwkicklighter commented on Apr 21, 2026

    @jwkicklighter

    if you are running in tmux, there might be a different issue. but running inside a native ghostty tab / split, this issue no longer occurs for me

    The issue I described is also happening in a native Ghostty terminal, where the "system" theme is not picking up terminal colors properly. I don't know if that symptom is related to this issue, but it hasn't been fixed for me.

    edit: I now see #23599

  18. uloco commented on Apr 22, 2026

    @uloco
    Author

    on 1.14.20 it started happening again lol wtf...

  19. reopened this on Apr 22, 2026
  20. Klassikcat commented on Apr 23, 2026

    @Klassikcat

    @uloco I've addressed the cause on issue #23810

    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 [email protected] 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.

  21. karamanliev commented on Apr 24, 2026

    @karamanliev

    @uloco I've addressed the cause on issue #23810

    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"
    }

    3. run `OPENCODE_VERSION=1.14.20 npx -y [email protected] run --cwd packages/opencode build --single` to build.
    
    4. copy build binary using `cp $HOME/path/to/opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode" "$HOME/.opencode/bin/opencode"`
    
    5. run opencode as usual
    

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

    Can confirm, this fixes the issue on kitty +/- tmux for me. Without it opencode loads for me always in dark mode.

  22. uloco commented on Apr 24, 2026

    @uloco
    Author

    NO way I'm doing this. switching manually for now :D

  23. Haume0 commented on Apr 24, 2026

    @Haume0

    I gave up, started using system

  24. Klassikcat commented on Apr 25, 2026

    @Klassikcat

    @Haume0

    Brightness detection was moved into OpenTUI in 1.14.24. opencode pins OpenTUI 0.1.99, which only supports CSI ?997 — this breaks on terminals that don't support the sequence (kitty 0.32.2, apt/noble ghostty, etc.).

    Quick fix: clone repository, update opencode's OpenTUI dep to >=0.1.100, and rebuild. Will work as usual, with an adaptive theme.

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

  27. uloco commented on Jul 3, 2026

    @uloco
    Author

    This is still an issue

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