11import { diff } from 'deep-object-diff' ;
22import { DeepReadonly } from 'ts-essentials' ;
33import { LspWorkspace } from '../protocol/LspWorkspace' ;
4+ import { ReadinessStatus } from '../system/SystemTypes' ;
45import { LoggerFactory } from '../telemetry/LoggerFactory' ;
56import { ScopedTelemetry } from '../telemetry/ScopedTelemetry' ;
67import { Measure , Telemetry } from '../telemetry/TelemetryDecorator' ;
@@ -18,7 +19,7 @@ export class SettingsManager implements ISettingsSubscriber {
1819 @Telemetry ( ) private readonly telemetry ! : ScopedTelemetry ;
1920 private readonly settingsState = new SettingsState ( ) ;
2021 private readonly subscriptionManager = new SubscriptionManager < Settings > ( ) ;
21- private isUpdatingSettings = false ;
22+ private readinessStatus : ReadinessStatus = { ready : false , reason : 'Not initialized' } ;
2223
2324 constructor (
2425 private readonly workspace : LspWorkspace ,
@@ -34,11 +35,8 @@ export class SettingsManager implements ISettingsSubscriber {
3435 return this . settingsState . toSettings ( ) ;
3536 }
3637
37- /**
38- * Check if settings update is in progress
39- */
40- isSettingsUpdateInProgress ( ) : boolean {
41- return this . isUpdatingSettings ;
38+ getReadinessStatus ( ) : ReadinessStatus {
39+ return this . readinessStatus ;
4240 }
4341
4442 reset ( ) {
@@ -82,7 +80,10 @@ export class SettingsManager implements ISettingsSubscriber {
8280
8381 const settings = parseWithPrettyError ( parseSettings , mergedConfig , this . getCurrentSettings ( ) ) ;
8482 this . validateAndUpdate ( settings ) ;
83+ this . readinessStatus = { ready : true } ;
8584 } catch ( error ) {
85+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
86+ this . readinessStatus = { ready : false , reason : `Settings sync failed: ${ errorMessage } ` } ;
8687 logger . error ( error , `Failed to sync configuration, keeping previous settings` ) ;
8788 }
8889 }
@@ -166,13 +167,16 @@ export class SettingsManager implements ISettingsSubscriber {
166167 const hasChanged = Object . keys ( difference ) . length > 0 ;
167168
168169 if ( hasChanged ) {
169- this . isUpdatingSettings = true ;
170+ this . readinessStatus = { ready : false , reason : 'Settings updating' } ;
170171 try {
171172 this . settingsState . update ( newSettings ) ;
172173 logger . info ( `Settings updated: ${ toString ( difference ) } ` ) ;
173174 this . subscriptionManager . notify ( newSettings , oldSettings ) ;
174- } finally {
175- this . isUpdatingSettings = false ;
175+ this . readinessStatus = { ready : true } ;
176+ } catch ( error ) {
177+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
178+ this . readinessStatus = { ready : false , reason : `Settings update failed: ${ errorMessage } ` } ;
179+ logger . error ( error , 'Failed to update settings' ) ;
176180 }
177181 }
178182 }
0 commit comments