Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/opencode/src/cli/cmd/tui/context/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,16 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
init: (props: { mode: "dark" | "light" }) => {
const sync = useSync()
const kv = useKV()

function configMode(): "dark" | "light" | undefined {
const override = sync.data.config.theme_mode
if (override === "light" || override === "dark") return override
return undefined
}

const [store, setStore] = createStore({
themes: DEFAULT_THEMES,
mode: kv.get("theme_mode", props.mode),
mode: configMode() ?? kv.get("theme_mode", props.mode),
active: (sync.data.config.theme ?? kv.get("theme", "opencode")) as string,
ready: false,
})
Expand All @@ -294,6 +301,11 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
if (theme) setStore("active", theme)
})

createEffect(() => {
const override = configMode()
if (override) setStore("mode", override)
})

function init() {
resolveSystemTheme()
getCustomThemes()
Expand Down
6 changes: 6 additions & 0 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,12 @@ export namespace Config {
.object({
$schema: z.string().optional().describe("JSON schema reference for configuration validation"),
theme: z.string().optional().describe("Theme name to use for the interface"),
theme_mode: z
.enum(["light", "dark", "system"])
.optional()
.describe(
"Override the detected terminal color scheme. Set to 'light' or 'dark' to force a mode, or 'system' to auto-detect from terminal.",
),
keybinds: Keybinds.optional().describe("Custom keybind configurations"),
logLevel: Log.Level.optional().describe("Log level"),
tui: TUI.optional().describe("TUI specific settings"),
Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/js/src/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,10 @@ export type Config = {
* Theme name to use for the interface
*/
theme?: string
/**
* Override the detected terminal color scheme. Set to 'light' or 'dark' to force a mode, or 'system' to auto-detect from terminal.
*/
theme_mode?: "light" | "dark" | "system"
keybinds?: KeybindsConfig
/**
* Log level
Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,10 @@ export type Config = {
* Theme name to use for the interface
*/
theme?: string
/**
* Override the detected terminal color scheme. Set to 'light' or 'dark' to force a mode, or 'system' to auto-detect from terminal.
*/
theme_mode?: "light" | "dark" | "system"
keybinds?: KeybindsConfig
logLevel?: LogLevel
/**
Expand Down
Loading