mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 20:03:05 +00:00
fix: preserve externally-added settings when saving
When a user edits settings.json while pi is running (e.g., adding enabledModels), those settings would be lost when pi saved other changes (e.g., changing thinking level via Shift+Tab). The fix re-reads the file before saving and merges the current file contents with in-memory changes, so external edits are preserved. Adds test coverage for SettingsManager.
This commit is contained in:
parent
1f2dbb57f6
commit
e0dbdc56d6
2 changed files with 115 additions and 1 deletions
|
|
@ -178,7 +178,13 @@ export class SettingsManager {
|
|||
mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
// Save only global settings (project settings are read-only)
|
||||
// Re-read current file to preserve any settings added externally while running
|
||||
const currentFileSettings = SettingsManager.loadFromFile(this.settingsPath);
|
||||
// Merge: file settings as base, globalSettings (in-memory changes) as overrides
|
||||
const mergedSettings = deepMergeSettings(currentFileSettings, this.globalSettings);
|
||||
this.globalSettings = mergedSettings;
|
||||
|
||||
// Save merged settings (project settings are read-only)
|
||||
writeFileSync(this.settingsPath, JSON.stringify(this.globalSettings, null, 2), "utf-8");
|
||||
} catch (error) {
|
||||
console.error(`Warning: Could not save settings file: ${error}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue