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 config = useTuiConfig()
const kv = useKV()

function configMode(): "dark" | "light" | undefined {
const override = 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: (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/tui-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export const TuiInfo = z
.object({
$schema: z.string().optional(),
theme: z.string().optional(),
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: KeybindOverride.optional(),
})
.extend(TuiOptions.shape)
Expand Down
Loading