MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / save

Method save

packages/node-runtime/src/preferences.ts:105–126  ·  view source on GitHub ↗
(partial: Partial<Preferences>)

Source from the content-addressed store, hash-verified

103 }
104
105 save(partial: Partial<Preferences>): { success: boolean; error?: string } {
106 try {
107 const current = this.load()
108 const merged = this.deepMerge(
109 current as unknown as Record<string, unknown>,
110 partial as unknown as Record<string, unknown>
111 )
112 if (Object.prototype.hasOwnProperty.call(partial.aiPreprocessConfig ?? {}, 'desensitizeBuiltinRuleOverrides')) {
113 const mergedAiPreprocessConfig = merged.aiPreprocessConfig as Record<string, unknown>
114 mergedAiPreprocessConfig.desensitizeBuiltinRuleOverrides =
115 partial.aiPreprocessConfig?.desensitizeBuiltinRuleOverrides
116 }
117 this.cache = this.mergeDefaults(merged as unknown as Partial<Preferences>)
118
119 this.writePreferences(this.cache)
120 return { success: true }
121 } catch (err) {
122 const msg = err instanceof Error ? err.message : String(err)
123 console.error('[Preferences] Failed to save:', msg)
124 return { success: false, error: msg }
125 }
126 }
127
128 getFilePath(): string {
129 return this.filePath

Callers 1

Calls 6

loadMethod · 0.95
deepMergeMethod · 0.95
mergeDefaultsMethod · 0.95
writePreferencesMethod · 0.95
callMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected