diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 61026ee9e..75da2acd2 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -714,6 +714,25 @@ await goto(`/?q=${encodeURIComponent(event.data.query)}`); return; } + if (event.type === 'theme:update' && event.data?.theme) { + const newTheme = event.data.theme; + localStorage.setItem('theme', newTheme); + theme.set(newTheme); + + // Apply theme classes (mirrors logic from chat/Settings/General.svelte) + const themes = ['dark', 'light', 'oled-dark']; + let themeToApply = newTheme === 'oled-dark' ? 'dark' : newTheme === 'her' ? 'light' : newTheme; + if (newTheme === 'system') { + themeToApply = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; + } + themes + .filter((e) => e !== themeToApply) + .forEach((e) => { + e.split(' ').forEach((cls) => document.documentElement.classList.remove(cls)); + }); + themeToApply.split(' ').forEach((cls) => document.documentElement.classList.add(cls)); + return; + } if (event.type === 'models:refresh') { const token = localStorage.token; if (token) {