feat(desktop): sync title bar theme with resolved app theme

This commit is contained in:
Mohamed Boudra
2026-03-29 09:26:21 +07:00
parent 921ddf47a8
commit 147482d6ed
3 changed files with 24 additions and 0 deletions
+14
View File
@@ -28,6 +28,7 @@ import {
import { shouldUseDesktopDaemon } from "@/desktop/daemon/desktop-daemon"; import { shouldUseDesktopDaemon } from "@/desktop/daemon/desktop-daemon";
import { StartupSplashScreen } from "@/screens/startup-splash-screen"; import { StartupSplashScreen } from "@/screens/startup-splash-screen";
import { loadSettingsFromStorage } from "@/hooks/use-settings"; import { loadSettingsFromStorage } from "@/hooks/use-settings";
import { useColorScheme } from "@/hooks/use-color-scheme";
import { SessionProvider } from "@/contexts/session-context"; import { SessionProvider } from "@/contexts/session-context";
import type { HostProfile } from "@/types/host-connection"; import type { HostProfile } from "@/types/host-connection";
import { import {
@@ -68,6 +69,7 @@ import {
ensureOsNotificationPermission, ensureOsNotificationPermission,
} from "@/utils/os-notifications"; } from "@/utils/os-notifications";
import { getDesktopHost } from "@/desktop/host"; import { getDesktopHost } from "@/desktop/host";
import { setDesktopTitleBarTheme } from "@/desktop/electron/window";
import { buildNotificationRoute } from "@/utils/notification-routing"; import { buildNotificationRoute } from "@/utils/notification-routing";
import { import {
buildHostRootRoute, buildHostRootRoute,
@@ -412,7 +414,9 @@ function ProvidersWrapper({ children }: { children: ReactNode }) {
const { settings, isLoading: settingsLoading } = useAppSettings(); const { settings, isLoading: settingsLoading } = useAppSettings();
const storeReady = useStoreReady(); const storeReady = useStoreReady();
const { upsertConnectionFromOfferUrl } = useHostMutations(); const { upsertConnectionFromOfferUrl } = useHostMutations();
const systemColorScheme = useColorScheme();
const isLoading = settingsLoading || !storeReady; const isLoading = settingsLoading || !storeReady;
const resolvedTheme = settings.theme === "auto" ? (systemColorScheme ?? "light") : settings.theme;
// Apply theme setting on mount and when it changes // Apply theme setting on mount and when it changes
useEffect(() => { useEffect(() => {
@@ -425,6 +429,16 @@ function ProvidersWrapper({ children }: { children: ReactNode }) {
} }
}, [isLoading, settings.theme]); }, [isLoading, settings.theme]);
useEffect(() => {
if (isLoading || Platform.OS !== "web") {
return;
}
void setDesktopTitleBarTheme(resolvedTheme).catch((error) => {
console.warn("[DesktopWindow] Failed to update title bar theme", error);
});
}, [isLoading, resolvedTheme]);
if (isLoading) { if (isLoading) {
const isDesktopManaged = const isDesktopManaged =
!settingsLoading && shouldUseDesktopDaemon() && settings.manageBuiltInDaemon; !settingsLoading && shouldUseDesktopDaemon() && settings.manageBuiltInDaemon;
@@ -27,3 +27,12 @@ export async function isDesktopFullscreen(): Promise<boolean> {
} }
return await win.isFullscreen(); return await win.isFullscreen();
} }
export async function setDesktopTitleBarTheme(theme: "light" | "dark"): Promise<void> {
const win = getDesktopWindow();
if (!win || typeof win.setTitleBarTheme !== "function") {
return;
}
await win.setTitleBarTheme(theme);
}
+1
View File
@@ -51,6 +51,7 @@ export interface DesktopWindowBridge {
endMove?: () => void; endMove?: () => void;
toggleMaximize?: () => Promise<void>; toggleMaximize?: () => Promise<void>;
isFullscreen?: () => Promise<boolean>; isFullscreen?: () => Promise<boolean>;
setTitleBarTheme?: (theme: "light" | "dark") => Promise<void>;
onResized?: <TEvent = unknown>( onResized?: <TEvent = unknown>(
handler: (event: TEvent) => void, handler: (event: TEvent) => void,
) => Promise<() => void> | (() => void); ) => Promise<() => void> | (() => void);