File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as FS from "node:fs" ;
22import * as Path from "node:path" ;
33
4- import type { ClientSettings , PersistedSavedEnvironmentRecord } from "@t3tools/contracts" ;
4+ import {
5+ ClientSettingsSchema ,
6+ type ClientSettings ,
7+ type PersistedSavedEnvironmentRecord ,
8+ } from "@t3tools/contracts" ;
59import { Predicate } from "effect" ;
10+ import * as Schema from "effect/Schema" ;
611
712interface ClientSettingsDocument {
813 readonly settings : ClientSettings ;
@@ -83,7 +88,15 @@ function toPersistedSavedEnvironmentRecord(
8388}
8489
8590export function readClientSettings ( settingsPath : string ) : ClientSettings | null {
86- return readJsonFile < ClientSettingsDocument > ( settingsPath ) ?. settings ?? null ;
91+ const raw = readJsonFile < ClientSettingsDocument > ( settingsPath ) ?. settings ;
92+ if ( ! raw ) {
93+ return null ;
94+ }
95+ try {
96+ return Schema . decodeUnknownSync ( ClientSettingsSchema ) ( raw ) ;
97+ } catch {
98+ return null ;
99+ }
87100}
88101
89102export function writeClientSettings ( settingsPath : string , settings : ClientSettings ) : void {
Original file line number Diff line number Diff line change @@ -1379,7 +1379,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
13791379 const overrideKey = deriveProjectGroupingOverrideKey ( member ) ;
13801380 setProjectGroupingTarget ( member ) ;
13811381 setProjectGroupingSelection (
1382- projectGroupingSettings . sidebarProjectGroupingOverrides [ overrideKey ] ?? "inherit" ,
1382+ projectGroupingSettings . sidebarProjectGroupingOverrides ?. [ overrideKey ] ?? "inherit" ,
13831383 ) ;
13841384 } ,
13851385 [ projectGroupingSettings . sidebarProjectGroupingOverrides ] ,
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ async function hydrateClientSettings(): Promise<void> {
6464 try {
6565 const persistedSettings = await ensureLocalApi ( ) . persistence . getClientSettings ( ) ;
6666 if ( persistedSettings ) {
67- replaceClientSettingsSnapshot ( persistedSettings ) ;
67+ replaceClientSettingsSnapshot ( { ... DEFAULT_CLIENT_SETTINGS , ... persistedSettings } ) ;
6868 }
6969 } catch ( error ) {
7070 console . error ( `${ CLIENT_SETTINGS_PERSISTENCE_ERROR_SCOPE } hydrate failed` , error ) ;
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export function resolveProjectGroupingMode(
7070 settings : ProjectGroupingSettings ,
7171) : SidebarProjectGroupingMode {
7272 return (
73- settings . sidebarProjectGroupingOverrides [ deriveProjectGroupingOverrideKey ( project ) ] ??
73+ settings . sidebarProjectGroupingOverrides ?. [ deriveProjectGroupingOverrideKey ( project ) ] ??
7474 settings . sidebarProjectGroupingMode
7575 ) ;
7676}
You can’t perform that action at this time.
0 commit comments