Skip to content

Commit 426791f

Browse files
ShpetimAShpetim
andauthored
fix: system theme flicker (anomalyco#5842)
Co-authored-by: Shpetim <shpetim.alimi@ndbit.net>
1 parent c7cade2 commit 426791f

File tree

1 file changed

+36
-10
lines changed
  • packages/opencode/src/cli/cmd/tui/context

1 file changed

+36
-10
lines changed

packages/opencode/src/cli/cmd/tui/context/theme.tsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,23 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
281281
ready: false,
282282
})
283283

284-
createEffect(async () => {
285-
const custom = await getCustomThemes()
286-
setStore(
287-
produce((draft) => {
288-
Object.assign(draft.themes, custom)
289-
draft.ready = true
290-
}),
291-
)
284+
createEffect(() => {
285+
getCustomThemes()
286+
.then((custom) => {
287+
setStore(
288+
produce((draft) => {
289+
Object.assign(draft.themes, custom)
290+
}),
291+
)
292+
})
293+
.catch(() => {
294+
setStore("active", "opencode")
295+
})
296+
.finally(() => {
297+
if (store.active !== "system") {
298+
setStore("ready", true)
299+
}
300+
})
292301
})
293302

294303
const renderer = useRenderer()
@@ -297,8 +306,25 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
297306
size: 16,
298307
})
299308
.then((colors) => {
300-
if (!colors.palette[0]) return
301-
setStore("themes", "system", generateSystem(colors, store.mode))
309+
if (!colors.palette[0]) {
310+
if (store.active === "system") {
311+
setStore(
312+
produce((draft) => {
313+
draft.active = "opencode"
314+
draft.ready = true
315+
}),
316+
)
317+
}
318+
return
319+
}
320+
setStore(
321+
produce((draft) => {
322+
draft.themes.system = generateSystem(colors, store.mode)
323+
if (store.active === "system") {
324+
draft.ready = true
325+
}
326+
}),
327+
)
302328
})
303329

304330
const values = createMemo(() => {

0 commit comments

Comments
 (0)