Can't use custom themes that use ANSI colors #2798

Open
opened 2026-02-16 17:37:18 -05:00 by yindo · 10 comments
Owner

Originally created by @jason0x43 on GitHub (Nov 11, 2025).

Originally assigned to: @kommander on GitHub.

Description

Trying to load a theme that uses ANSI colors causes opencode to error.

TypeError: undefined is not an object (evaluating 'c3[mode2]')
    at resolveColor (src/cli/cmd/tui/context/theme.tsx:64:25)
    at <anonymous> (src/cli/cmd/tui/context/theme.tsx:67:18)
    at map (native:1:11)
    at resolveTheme (src/cli/cmd/tui/context/theme.tsx:66:57)
    at runComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:742:22)
    at updateComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:724:3)
    at readSignal (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:660:67)
    at get (src/cli/cmd/tui/context/theme.tsx:106:18)
    at <anonymous> (src/cli/cmd/tui/app.tsx:531:17)
    at runComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:742:22)...

OpenCode version

1.0.61

Steps to reproduce

  1. Create a custom theme using the my-theme.json example
  2. Change one of the color definitions to be a palette number, like "nord9": 9,.
  3. Set the custom theme as the default in the opencode config
  4. Start opencode and see error

Screenshot and/or share link

No response

Operating System

macOS 26.1

Terminal

kitty

Originally created by @jason0x43 on GitHub (Nov 11, 2025). Originally assigned to: @kommander on GitHub. ### Description Trying to load a theme that uses ANSI colors causes opencode to error. ``` TypeError: undefined is not an object (evaluating 'c3[mode2]') at resolveColor (src/cli/cmd/tui/context/theme.tsx:64:25) at <anonymous> (src/cli/cmd/tui/context/theme.tsx:67:18) at map (native:1:11) at resolveTheme (src/cli/cmd/tui/context/theme.tsx:66:57) at runComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:742:22) at updateComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:724:3) at readSignal (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:660:67) at get (src/cli/cmd/tui/context/theme.tsx:106:18) at <anonymous> (src/cli/cmd/tui/app.tsx:531:17) at runComputation (../../node_modules/.bun/solid-js@1.9.9/node_modules/solid-js/dist/dev.js:742:22)... ``` ### OpenCode version 1.0.61 ### Steps to reproduce 1. Create a custom theme using the my-theme.json example 2. Change one of the color definitions to be a palette number, like `"nord9": 9,`. 3. Set the custom theme as the default in the opencode config 4. Start opencode and see error ### Screenshot and/or share link _No response_ ### Operating System macOS 26.1 ### Terminal kitty
yindo added the opentui label 2026-02-16 17:37:18 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 11, 2025):

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

  • #4175: Both issues involve custom themes not working in OpenTUI after version 1.0+ upgrade. While #4175 doesn't mention the specific TypeError, it could be the same underlying theme parsing issue with ANSI colors.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 11, 2025): This issue might be a duplicate of existing issues. Please check: - #4175: Both issues involve custom themes not working in OpenTUI after version 1.0+ upgrade. While #4175 doesn't mention the specific TypeError, it could be the same underlying theme parsing issue with ANSI colors. Feel free to ignore if none of these address your specific case.
Author
Owner

@kommander commented on GitHub (Nov 12, 2025):

This is not supported currently.

@kommander commented on GitHub (Nov 12, 2025): This is not supported currently.
Author
Owner

@jason0x43 commented on GitHub (Nov 12, 2025):

Drat. That was the reason I was excited about custom theme support being added back.

@jason0x43 commented on GitHub (Nov 12, 2025): Drat. That was the reason I was excited about custom theme support being added back.
Author
Owner

@kommander commented on GitHub (Nov 12, 2025):

What are you trying to achieve? I may be supported at some point, but really can't tell when that would be. Maybe what you are trying to do can be done with what is available.

@kommander commented on GitHub (Nov 12, 2025): What are you trying to achieve? I may be supported at some point, but really can't tell when that would be. Maybe what you are trying to do can be done with what is available.
Author
Owner

@jason0x43 commented on GitHub (Nov 12, 2025):

I have two main goals:

  1. I want apps to react immediately to system appearance changes without me having to restart them.
  2. I like apps to use my terminal palette so that I don't have to update a bunch of individual app themes if I ever change the palette.

I use a terminal theme named Selenized. One of its properties is that it swaps the white and black ends of the palette in light mode. If apps are configured properly, when my terminal switches from light to dark mode they'll handle the change transparently (they don't have to change themes or even be aware that anything happened).

I do use a truecolor theme in Neovim, but it's based on my terminal theme (at startup neovim dumps kitty's active colors and builds the theme from that), and it will dynamically react to system appearance changes.

@jason0x43 commented on GitHub (Nov 12, 2025): I have two main goals: 1. I want apps to react immediately to system appearance changes without me having to restart them. 2. I like apps to use my terminal palette so that I don't have to update a bunch of individual app themes if I ever change the palette. I use a terminal theme named Selenized. One of its properties is that it swaps the white and black ends of the palette in light mode. If apps are configured properly, when my terminal switches from light to dark mode they'll handle the change transparently (they don't have to change themes or even be aware that anything happened). I do use a truecolor theme in Neovim, but it's based on my terminal theme (at startup neovim dumps kitty's active colors and builds the theme from that), and it will dynamically react to system appearance changes.
Author
Owner

@jason0x43 commented on GitHub (Nov 12, 2025):

Opencode's system theme does use the terminal palette (so it wouldn't be a huge extension to allow custom themes to do the same). However, the system theme makes some (reasonable) assumptions about the black and white palette slots that don't work well for me in light mode.

@jason0x43 commented on GitHub (Nov 12, 2025): Opencode's system theme does use the terminal palette (so it wouldn't be a huge extension to allow custom themes to do the same). However, the system theme makes some (reasonable) assumptions about the black and white palette slots that don't work well for me in light mode.
Author
Owner

@kommander commented on GitHub (Nov 12, 2025):

Yes, terminal palette is used and supported and we could expose that to the theme as well somehow. Automatic palette updates, if the terminal supports that, will be supported shortly as well.

@kommander commented on GitHub (Nov 12, 2025): Yes, terminal palette is used and supported and we could expose that to the theme as well somehow. Automatic palette updates, if the terminal supports that, will be supported shortly as well.
Author
Owner

@Nemo157 commented on GitHub (Jan 15, 2026):

Automatic palette updates, if the terminal supports that, will be supported shortly as well.

Automatic isn't really enough. I often have the same TUI app instance displayed in two different terminals via shared tmux sessions, which may or may not have the same colorscheme. If opencode used only a limited ansi color palette like base24 then it would render fine in all locations, even if one terminal is light mode and another dark mode (standards like base24 use inverse scales for gradients between light and dark mode so that they render correctly).

@Nemo157 commented on GitHub (Jan 15, 2026): > Automatic palette updates, if the terminal supports that, will be supported shortly as well. Automatic isn't really enough. I often have the same TUI app instance displayed in two different terminals via shared tmux sessions, which may or may not have the same colorscheme. If opencode used only a limited ansi color palette like base24 then it would render fine in all locations, even if one terminal is light mode and another dark mode (standards like `base24` use inverse scales for gradients between light and dark mode so that they render correctly).
Author
Owner

@jason0x43 commented on GitHub (Jan 15, 2026):

I would love to see true ANSI support. I added an implementation a few weeks ago, and it worked reasonably well, but there were a few places in the UI that relied on truecolor features to render properly.

@jason0x43 commented on GitHub (Jan 15, 2026): I would love to see true ANSI support. I added an implementation a few weeks ago, and it worked reasonably well, but there were a few places in the UI that relied on truecolor features to render properly.
Author
Owner

@nihil2501 commented on GitHub (Jan 17, 2026):

Yes, terminal palette is used and supported and we could expose that to the theme as well somehow. Automatic palette updates, if the terminal supports that, will be supported shortly as well.

@kommander, this PR adds the feature system-like custom themes for referencing the generated "system" theme values within custom themes.

{
  "theme": {
    "background": "system",
    "foreground": "system",
    "primary": "#ff5500"
  }
}
tui-theme
@nihil2501 commented on GitHub (Jan 17, 2026): > Yes, terminal palette is used and supported and we could expose that to the theme as well somehow. Automatic palette updates, if the terminal supports that, will be supported shortly as well. @kommander, this [PR](https://github.com/anomalyco/opencode/pull/9184) adds the feature `system-like custom themes` for referencing the generated "system" theme values within custom themes. ```json { "theme": { "background": "system", "foreground": "system", "primary": "#ff5500" } } ``` <img src="https://github.com/user-attachments/assets/e5384fac-27f9-4a87-9940-783b5c1951d3" alt="tui-theme" width="600" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2798