Skip to content

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

Closed

Description

@jason0x43

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 12, 2025
  2. github-actions commented on Nov 12, 2025

    @github-actions
    Contributor

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

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

  3. kommander commented on Nov 12, 2025

    @kommander
    Contributor

    This is not supported currently.

  4. jason0x43 commented on Nov 12, 2025

    @jason0x43
    ContributorAuthor

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

  5. kommander commented on Nov 12, 2025

    @kommander
    Contributor

    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.

  6. jason0x43 commented on Nov 12, 2025

    @jason0x43
    ContributorAuthor

    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.

  7. jason0x43 commented on Nov 12, 2025

    @jason0x43
    ContributorAuthor

    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.

  8. kommander commented on Nov 12, 2025

    @kommander
    Contributor

    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.

  9. self-assigned this
    on Nov 13, 2025
  10. Nemo157 commented on Jan 15, 2026

    @Nemo157

    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).

  11. jason0x43 commented on Jan 15, 2026

    @jason0x43
    ContributorAuthor

    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.

  12. nihil2501 commented on Jan 18, 2026

    @nihil2501

    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
  13. github-actions commented on Mar 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 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

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions