(partial: Partial<Preferences>)
| 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 |
no test coverage detected