From 85fa2675af81802de77d32e599099a06ce0063f2 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Fri, 11 Sep 2026 18:35:10 -0500 Subject: [PATCH] fix(tui): defer named-theme palette detection Named themes do not depend on terminal palette colors, but startup waited for the shared system-theme palette request before marking the theme ready. Some terminals answer palette support without answering every color query, adding a roughly 300ms idle timeout before the useful frame. Keep palette detection on the critical path for the explicit system theme. For named themes, paint immediately and prepare the system palette after the first frame so later theme switching remains available. Compiled warm-server startup to Ask anything improves from 538ms to 215ms for the default opencode theme. Explicit system theme startup remains flat at 554ms to 546ms. --- packages/tui/src/context/theme.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/tui/src/context/theme.tsx b/packages/tui/src/context/theme.tsx index 23cd3055f515..a8c9984f08c0 100644 --- a/packages/tui/src/context/theme.tsx +++ b/packages/tui/src/context/theme.tsx @@ -184,7 +184,11 @@ const themeContext = createSimpleContext({ } onMount(() => { - void Promise.allSettled([resolveSystemTheme(store.mode), syncCustomThemes()]).finally(() => { + const systemTheme = resolveSystemTheme(store.mode) + void Promise.allSettled([ + store.active === "system" ? systemTheme : Promise.resolve(), + syncCustomThemes(), + ]).finally(() => { valuesV2() setStore("ready", true) })