Compare commits

...

1 Commits

Author SHA1 Message Date
celestial-vault 4d8ed77e4e add setters guards for remote config and add missing override to global state 2025-10-12 17:27:30 -07:00
+37
View File
@@ -126,6 +126,11 @@ export class StateManager {
throw new Error(STATE_MANAGER_NOT_INITIALIZED)
}
// Prevent setting keys managed by remote config
if (key in this.remoteConfigCache) {
throw new Error(`Cannot set '${key}': This setting is managed by remote configuration`)
}
// Update cache immediately for instant access
this.globalStateCache[key] = value
@@ -142,6 +147,12 @@ export class StateManager {
throw new Error(STATE_MANAGER_NOT_INITIALIZED)
}
// Prevent setting keys managed by remote config
const remoteKeys = Object.keys(updates).filter((key) => key in this.remoteConfigCache)
if (remoteKeys.length > 0) {
throw new Error(`Cannot set remote-managed keys: ${remoteKeys.join(", ")}`)
}
// Update cache in one go
// Using object.assign to because typescript is not able to infer the type of the updates object when using Object.entries
Object.assign(this.globalStateCache, updates)
@@ -163,6 +174,11 @@ export class StateManager {
throw new Error(STATE_MANAGER_NOT_INITIALIZED)
}
// Prevent setting keys managed by remote config
if (key in this.remoteConfigCache) {
throw new Error(`Cannot set '${key}': This setting is managed by remote configuration`)
}
// Update cache immediately for instant access
this.taskStateCache[key] = value
@@ -182,6 +198,12 @@ export class StateManager {
throw new Error(STATE_MANAGER_NOT_INITIALIZED)
}
// Prevent setting keys managed by remote config
const remoteKeys = Object.keys(updates).filter((key) => key in this.remoteConfigCache)
if (remoteKeys.length > 0) {
throw new Error(`Cannot set remote-managed keys: ${remoteKeys.join(", ")}`)
}
// Update cache in one go
Object.assign(this.taskStateCache, updates)
@@ -323,6 +345,18 @@ export class StateManager {
this.remoteConfigCache[key] = value
}
/**
* Set method for remote config field - updates cache immediately (no persistence)
* Remote config is read-only from the extension's perspective and only stored in memory
*/
getRemoteConfigSettings(): Partial<GlobalStateAndSettings> {
if (!this.isInitialized) {
throw new Error(STATE_MANAGER_NOT_INITIALIZED)
}
return this.remoteConfigCache
}
/**
* Clear remote config cache
* Used when switching organizations or when remote config is no longer applicable
@@ -727,6 +761,9 @@ export class StateManager {
if (!this.isInitialized) {
throw new Error(STATE_MANAGER_NOT_INITIALIZED)
}
if (this.remoteConfigCache[key] !== undefined) {
return this.remoteConfigCache[key]
}
return this.globalStateCache[key]
}