opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Support dark/light mode os sync

Open stordahl opened this issue 5 months ago • 15 comments

Support for dark/light modes to sync with the os would be great

stordahl avatar Jun 27 '25 19:06 stordahl

it should already support this, can you share more about what you're seeing?

adamdotdevin avatar Jun 27 '25 19:06 adamdotdevin

Just did some testing and it seems to be an issue in Wezterm where I only get dark mode for all themes

stordahl avatar Jun 27 '25 20:06 stordahl

Just did some testing and it seems to be an issue in Wezterm where I only get dark mode for all themes

Same using Zellij with kitty. (kitty outside of zellij works fine though)

ChristianPavilonis avatar Aug 26 '25 00:08 ChristianPavilonis

I believe I am experiencing this same issue.

Running opencode within tmux in Gnome Terminal always shows dark mode, even though my system is always configured for light mode.

treyhunner avatar Sep 24 '25 14:09 treyhunner

@adamdotdevin I've recently moved to ghostty and, inside tmux, more of the UI seems to adapt when I change from dark mode to light mode, but the chat input and status bar don't update. Sometimes I even have to quit all opencode sessions, quit ghostty, and then the ui renders correctly

stordahl avatar Sep 24 '25 14:09 stordahl

The same problem occurs with zellij + wezterm; the system theme does not change the input fields:

Image

Artawower avatar Oct 02 '25 08:10 Artawower

I'm using Ghostty on MacOS Thaoe and have it configured for both light and dark mode. If i change the OS theme from light to dark mode, the terminal will change theme as well. If i run opencode , it will show the same mode - however opencode won't detect OS theme changes when already running. Is it possible to listen for these changes?

Note: i haven't configured theme for opencode but relying on the Ghostty configuration

erf avatar Nov 16 '25 06:11 erf

I think @kommander would know best as to if it's possible and what may not be

rekram1-node avatar Nov 16 '25 07:11 rekram1-node

It is possible, with the caveat that not all terminals support it, but I'll support that event from opentui so opencode will be able to change the theme type automatically.

kommander avatar Nov 16 '25 09:11 kommander

I've started using the new opentui version of this. I'm finding that I have to manually switch it to light mode each time I open it. I'm also using a terminal and custom color scheme which most software is unable to detect as being either light or dark.

I investigated how to fix this in the past and found a solution using an environment variable called COLORFGBG (it's supported by a bunch of terminals and software). So in software I've written in the past I've included a fallback to reading this variable if the normal detection doesn't work. Would you be willing to include that feature in opencode please?

If not; is there some way to change the default from dark to light?

astrolox avatar Nov 21 '25 13:11 astrolox

@astrolox I fixed it so the light vs dark is persisted

rekram1-node avatar Nov 25 '25 05:11 rekram1-node

Having it persisted is certainly an improvement. Thank you.

That said; sometimes I switch from light to dark depending on environment (day time office usage vs late night on call work). So improving the detection would be ideal as a future enhancement.

astrolox avatar Nov 25 '25 14:11 astrolox

Having it persisted is certainly an improvement. Thank you.

That said; sometimes I switch from light to dark depending on environment (day time office usage vs late night on call work). So improving the detection would be ideal as a future enhancement.

This is my workflow as well so +1 on this callout

stordahl avatar Nov 25 '25 16:11 stordahl

ill also put a repro here. i have iterm to swap colors on macos appearance change, so light mode has light grey background, and dark mode has black background.

so with that, when i have an iterm window open, and i toggle from light to dark mode, my iterm window changes its colors.

but if i do that while having opencode running, it never changes.

see here. claude, opencode and codex. claude is the only one handling things correctly.

dark mode Image

flip to light mode Image

pvinis avatar Dec 05 '25 15:12 pvinis

I think I've found the root cause!

After investigation, I've deduced that tmux captures the system theme in some variable on attachment. This is why on my setup (Macbook, Ghostty, Oh-my-tmux, Neovim, Opencode), I have to detach and re-attach to tmux, then restart OpenCode for it to actually get the proper theme.

The reason Neovim automatically switches is because for most people (including me) neovim is set up to check the actual system settings to see if its on dark mode.

But for OpenCode (and even other CLI's like git-delta), the theme data seems to rely on information that tmux captures and updates when the user creates a new session or attaches to an existing session.

I believe that is the key issue. You guys can test this theory. I have tested it rigorously and it has checked out consistently for me.

Let me know if this helps!!

smrdotgg avatar Dec 20 '25 16:12 smrdotgg