11import { scopedThreadKey , scopeThreadRef } from "@t3tools/client-runtime/environment" ;
22import type { ClientSettings } from "@t3tools/contracts/settings" ;
33import { createBrowserHistory , createHashHistory } from "@tanstack/react-router" ;
4+ import * as Schema from "effect/Schema" ;
45
56import { applyAppearanceContrast } from "./appearanceContrast" ;
6- import { applyAppearanceFontVariables } from "./appearanceFonts" ;
7+ import { applyAppearanceFontVariables , TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "./appearanceFonts" ;
78import { startElectronBrowserHost } from "./browser/ElectronBrowserHost" ;
89import { startBrowserProfileReporting } from "./browser/BrowserProfileReporter" ;
910import { startPreviewTitleRecording } from "./browserHistoryStore" ;
@@ -30,6 +31,7 @@ import {
3031} from "./composerDraftStore" ;
3132import { startDefaultThemeAdoption } from "./hooks/useDefaultTheme" ;
3233import { startEnvironmentThemeRepaint } from "./hooks/useEnvironmentTheme" ;
34+ import { readLocalStorageValue , subscribeLocalStorageKey } from "./hooks/useLocalStorage" ;
3335import {
3436 getClientSettings ,
3537 startModelPreferencesMigration ,
@@ -58,10 +60,18 @@ import { resolveThreadRouteTarget } from "./threadRoutes";
5860function startClientAppearance ( ) : void {
5961 const root = document . documentElement ;
6062 let applied : ClientSettings | null = null ;
63+ let appliedSeparateFonts : boolean | null = null ;
6164 const apply = ( ) => {
6265 const settings = getClientSettings ( ) ;
6366 const previous = applied ;
6467 applied = settings ;
68+ const separateFonts = readLocalStorageValue (
69+ TYPOGRAPHY_ADVANCED_STORAGE_KEY ,
70+ false ,
71+ Schema . Boolean ,
72+ ) ;
73+ const previousSeparateFonts = appliedSeparateFonts ;
74+ appliedSeparateFonts = separateFonts ;
6575 if ( previous ?. diffColorScheme !== settings . diffColorScheme ) {
6676 root . dataset . diffColorScheme = settings . diffColorScheme ;
6777 }
@@ -86,7 +96,8 @@ function startClientAppearance(): void {
8696 previous . fontSizeInterface !== settings . fontSizeInterface ||
8797 previous . fontSizePrompt !== settings . fontSizePrompt ||
8898 previous . fontSizeCode !== settings . fontSizeCode ||
89- previous . fontSmoothing !== settings . fontSmoothing
99+ previous . fontSmoothing !== settings . fontSmoothing ||
100+ previousSeparateFonts !== separateFonts
90101 ) {
91102 applyAppearanceFontVariables ( root , {
92103 sans : settings . fontFamilySans ,
@@ -96,10 +107,12 @@ function startClientAppearance(): void {
96107 sizePrompt : settings . fontSizePrompt ,
97108 sizeCode : settings . fontSizeCode ,
98109 smoothing : settings . fontSmoothing ,
110+ separate : separateFonts ,
99111 } ) ;
100112 }
101113 } ;
102114 subscribeClientSettings ( apply ) ;
115+ subscribeLocalStorageKey ( TYPOGRAPHY_ADVANCED_STORAGE_KEY , apply ) ;
103116 apply ( ) ;
104117}
105118
0 commit comments