mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
fix(tui): probe palette only for system theme
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user