feat(themes): apply OpenCode color themes app-wide with a settings picker (#364)

- Vendor the 36 OpenCode theme palettes into the shared package, synced
  from the pinned OpenCode release tag via pnpm themes:sync.
- Add a colorTheme user preference across the settings schema, defaults,
  and the assistant internal API.
- Extend palettes with success, warning, info, and diff colors, and add a
  resolver that maps palettes to CSS tokens and applies them to the DOM.
- Apply the theme app-wide through a ThemeProvider context, adopting the
  tokens in message, repo, session, and settings components, agent
  colors, git status styles, and diff viewers.
- Add a theme picker to General settings and make model quick-select
  follow the active theme (fixes #355).
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-28 00:19:32 -04:00
1 parent 702e3c4e13
commit 5bd688de4b
116 files changed
+2702 -760

No files matched your search

+1
View File
@@ -47,6 +47,7 @@ export const AssistantSTTPatchSchema = z.object({
export const AssistantSettingsPatchSchema = UserPreferencesSchema.pick({
theme: true,
colorTheme: true,
mode: true,
defaultModel: true,
defaultAgent: true,
+3
View File
@@ -1,6 +1,7 @@
import { z } from "zod";
import { NotificationPreferencesSchema, DEFAULT_NOTIFICATION_PREFERENCES } from "./notifications";
import { OPENCODE_CONFIG_SOURCE_NAMES } from "../config/defaults";
import { ColorThemeIdSchema, MANAGER_COLOR_THEME_ID } from "../themes";
export const CustomCommandSchema = z.object({
name: z.string(),
@@ -143,6 +144,7 @@ export const DEFAULT_SANDBOX_PREFERENCES: SandboxPreferences = {
export const UserPreferencesSchema = z.object({
theme: z.enum(["dark", "light", "system"]),
colorTheme: ColorThemeIdSchema.optional(),
mode: z.enum(["plan", "build"]),
defaultModel: z.string().optional(),
defaultAgent: z.string().optional(),
@@ -197,6 +199,7 @@ export const DEFAULT_STT_CONFIG: STTConfig = {
export const DEFAULT_USER_PREFERENCES = {
theme: "dark" as const,
colorTheme: MANAGER_COLOR_THEME_ID,
mode: "build" as const,
autoScroll: true,
expandDiffs: true,
+23
View File
@@ -0,0 +1,23 @@
The color palettes in opencode-palettes.ts are derived from github.com/anomalyco/opencode tag v2.0.15, packages/ui/src/theme/themes.
MIT License
Copyright (c) 2025 opencode
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+24
View File
@@ -0,0 +1,24 @@
import { z } from 'zod'
import { OPENCODE_THEMES } from './opencode-palettes'
import type { OpenCodeThemeDefinition } from './types'
export type { HexColor } from './types'
export { OPENCODE_THEMES } from './opencode-palettes'
export const MANAGER_COLOR_THEME_ID = 'manager' as const
type OpenCodeThemeId = (typeof OPENCODE_THEMES)[number]['id']
export type ColorThemeId = typeof MANAGER_COLOR_THEME_ID | OpenCodeThemeId
export function isColorThemeId(value: unknown): value is ColorThemeId {
return value === MANAGER_COLOR_THEME_ID || OPENCODE_THEMES.some((theme) => theme.id === value)
}
export function getOpenCodeTheme(id: ColorThemeId): OpenCodeThemeDefinition | undefined {
if (id === MANAGER_COLOR_THEME_ID) return undefined
return OPENCODE_THEMES.find((theme) => theme.id === id)
}
export const ColorThemeIdSchema: z.ZodType<ColorThemeId> = z.custom<ColorThemeId>(isColorThemeId, {
message: 'Unknown color theme',
})
File diff suppressed because it is too large. Load diff
+22
View File
@@ -0,0 +1,22 @@
export type HexColor = `#${string}`
export interface OpenCodeThemePalette {
neutral: HexColor
ink: HexColor
primary: HexColor
accent?: HexColor
success: HexColor
warning: HexColor
error: HexColor
info: HexColor
diffAdd?: HexColor
diffDelete?: HexColor
textWeak?: HexColor
}
export interface OpenCodeThemeDefinition {
id: string
name: string
light: OpenCodeThemePalette
dark: OpenCodeThemePalette
}