mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
fix(tui): defer palette probe until first frame
This commit is contained in:
@@ -285,8 +285,6 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
|
||||
)
|
||||
renderer.once("destroy", () => shutdown.openUnsafe())
|
||||
yield* Effect.tryPromise(async () => {
|
||||
// Prewarm palette before ThemeProvider mounts so `system` theme avoids a first-paint fallback flash.
|
||||
void renderer.getPalette({ size: 16 }).catch(() => undefined)
|
||||
const mode = handoff?.mode ?? (await renderer.waitForThemeMode(1000)) ?? "dark"
|
||||
if (renderer.isDestroyed) return
|
||||
|
||||
|
||||
@@ -184,11 +184,9 @@ const themeContext = createSimpleContext({
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const systemTheme = resolveSystemTheme(store.mode)
|
||||
void Promise.allSettled([
|
||||
store.active === "system" ? systemTheme : Promise.resolve(),
|
||||
syncCustomThemes(),
|
||||
]).finally(() => {
|
||||
// Terminal palette queries serialize with frame output. Use the mode fallback for the first paint;
|
||||
// App asks for the system palette after that frame and updates the theme in place.
|
||||
void syncCustomThemes().finally(() => {
|
||||
valuesV2()
|
||||
setStore("ready", true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user