fix(tui): defer palette probe until first frame

This commit is contained in:
Dax Raad
2026-09-12 17:20:09 -04:00
parent 3dde11c392
commit 21dac524f3
2 changed files with 3 additions and 7 deletions
-2
View File
@@ -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
+3 -5
View File
@@ -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)
})