[PR #9184] feat(tui): system-like custom themes #13021

Closed
opened 2026-02-16 18:17:54 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9184

State: closed
Merged: No


Issues

Feature

tui-theme

Custom themes can now reference the system theme that is generated from the user's terminal color palette by using "system" as a color value:

{
  "theme": {
    "background": "system",
    "foreground": "system",
    "primary": "#ff5500"
  }
}

Performance optimization

The theme context now readies 10x faster in the by-far most common case (using one of the default themes). The speedup is due to not waiting for resources to load that are irrelevant for the requested theme.
Timed using this patch that calls console.time inside createSimpleContext.

After = 3.558ms

...
[17:05:25] [LOG] '%s: %s' 'context:Theme' '3.558ms'
...

Before = 31.264ms

...
[17:04:19] [LOG] '%s: %s' 'context:Theme' '31.264ms'
...

More details

Key behaviors

  • Custom theme loading and system palette detection each modeled w/ SolidJS's createResource
  • These in turn are accessed in SolidJS's createMemo returning (requested theme, resource loading status)
    • Considers only the relevant resource loading statuses for the given requested theme
    • Drives the reactivity into theme resolution
  • Somewhat conservative & simplistic design choices

Miscellany

  • Warning toasts on errored (this functionality could easily be removed)
  • System theme now responds to Toggle appearance
  • Theme picker list now updates on reload

Commits

Three atomic commits build up to this feature:

  1. fix(tui): system theme light & dark variants
  2. refactor(tui): theme switching & loading reactivity
  3. feat(tui): system-like custom themes

Notes

  • This can be split into 3 sequential PRs if preferred, one per atomic commit above
  • The first 2 commits might be valuable without adding this feature in the 3rd commit
  • The performance optimization is in the 2nd, refactor commit
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9184 **State:** closed **Merged:** No --- ### Issues - Closes #6322 - Closes #4236 - _Something akin to this feature is discussed within the comments_ ### Feature <img src="https://github.com/user-attachments/assets/e5384fac-27f9-4a87-9940-783b5c1951d3" alt="tui-theme" width="600" /> --- Custom themes can now reference the `system` theme that is generated from the user's terminal color palette by using `"system"` as a color value: ```json { "theme": { "background": "system", "foreground": "system", "primary": "#ff5500" } } ``` ### Performance optimization The theme context now readies **10x faster** in the by-far most common case (using one of the default themes). The speedup is due to not waiting for resources to load that are irrelevant for the requested theme. _Timed using this [patch](https://github.com/user-attachments/files/24698744/ready-timing.patch) that calls `console.time` inside `createSimpleContext`._ #### After = 3.558ms ``` ... [17:05:25] [LOG] '%s: %s' 'context:Theme' '3.558ms' ... ``` #### Before = 31.264ms ``` ... [17:04:19] [LOG] '%s: %s' 'context:Theme' '31.264ms' ... ``` ### More details **Key behaviors** - Custom theme loading and system palette detection each modeled w/ SolidJS's `createResource` - These in turn are accessed in SolidJS's `createMemo` returning `(requested theme, resource loading status)` - Considers only the relevant resource loading statuses for the given requested theme - Drives the reactivity into theme resolution - Somewhat conservative & simplistic design choices **Miscellany** - Warning toasts on errored (this functionality could easily be removed) - System theme now responds to `Toggle appearance` - Theme picker list now updates on reload ### Commits Three atomic commits build up to this feature: 1. `fix(tui): system theme light & dark variants` 2. `refactor(tui): theme switching & loading reactivity` 3. `feat(tui): system-like custom themes` #### Notes - This can be split into 3 sequential PRs if preferred, one per atomic commit above - The first 2 commits might be valuable without adding this feature in the 3rd commit - The performance optimization is in the 2nd, refactor commit
yindo added the pull-request label 2026-02-16 18:17:54 -05:00
yindo closed this issue 2026-02-16 18:17:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13021