fix(tui): probe palette only for system theme

This commit is contained in:
Dax Raad
2026-09-12 18:16:21 -04:00
parent dbc63955b0
commit c82340a97b
2 changed files with 7 additions and 4 deletions
+5 -1
View File
@@ -159,7 +159,9 @@ const themeContext = createSimpleContext({
createEffect(() => {
const theme = config.theme?.name
if (theme) setStore("active", theme)
if (!theme) return
setStore("active", theme)
if (theme === "system") refreshPalette()
})
createEffect(() => {
@@ -204,6 +206,7 @@ const themeContext = createSimpleContext({
let queued = false
let disposed = false
function refreshPalette() {
if (store.active !== "system") return
queued = true
if (!canProbe || probing || disposed) return
@@ -347,6 +350,7 @@ const themeContext = createSimpleContext({
set(theme: string) {
if (!hasTheme(theme)) return false
setStore("active", theme)
if (theme === "system") refreshPalette()
void configState
.update((draft) => {
draft.theme = { ...draft.theme, name: theme }
+2 -3
View File
@@ -15,17 +15,16 @@ const listeners = new Set<(themes: Record<string, ThemeDocumentSource>) => void>
const parsed = new WeakMap<object, ThemeDocument>()
const decodeThemeDocument = Schema.decodeUnknownSync(ThemeDocument, { reportInput: true })
function listThemes() {
function listThemes(): Record<string, ThemeDocumentSource> {
// Priority: defaults < plugin installs < custom files < generated system.
const themes: Record<string, ThemeDocumentSource> = {
...DEFAULT_THEMES,
...pluginThemes,
...customThemes,
}
if (!systemTheme) return themes
return {
...themes,
system: systemTheme,
system: systemTheme ?? themes.system ?? themes.opencode,
}
}