feat(FN-1887): merge fusion/fn-1887
This commit is contained in:
@@ -2025,6 +2025,25 @@ describe("TaskStore", () => {
|
||||
expect(globalStore.getSettingsPath()).toContain("settings.json");
|
||||
});
|
||||
|
||||
it("ignores legacy project-level globalMaxConcurrent values", async () => {
|
||||
const db = (store as any).db;
|
||||
const row = db.prepare("SELECT settings FROM config WHERE id = 1").get() as { settings?: string } | undefined;
|
||||
const existingSettings = row?.settings ? JSON.parse(row.settings) : {};
|
||||
existingSettings.maxConcurrent = 9;
|
||||
existingSettings.globalMaxConcurrent = 4;
|
||||
db.prepare("UPDATE config SET settings = ? WHERE id = 1").run(JSON.stringify(existingSettings));
|
||||
|
||||
const settings = await store.getSettings();
|
||||
const fastSettings = await store.getSettingsFast();
|
||||
const { project } = await store.getSettingsByScope();
|
||||
|
||||
expect(settings.maxConcurrent).toBe(9);
|
||||
expect(fastSettings.maxConcurrent).toBe(9);
|
||||
expect((settings as any).globalMaxConcurrent).toBeUndefined();
|
||||
expect((fastSettings as any).globalMaxConcurrent).toBeUndefined();
|
||||
expect((project as any).globalMaxConcurrent).toBeUndefined();
|
||||
});
|
||||
|
||||
it("updateSettings creates config row if missing and persists settings", async () => {
|
||||
// Manually delete the config row to simulate corruption/edge case
|
||||
const db = (store as any).db;
|
||||
|
||||
@@ -28,7 +28,8 @@ const LEGACY_BACKUP_DIR = ".kb/backups";
|
||||
|
||||
/**
|
||||
* Canonicalizes a settings object by resolving legacy defaults.
|
||||
* Currently handles the .kb/backups → .fusion/backups migration.
|
||||
* Currently handles the .kb/backups → .fusion/backups migration and
|
||||
* strips legacy fields that are no longer valid.
|
||||
*
|
||||
* This function applies only the exact-match legacy alias transformation.
|
||||
* Other custom .kb/* paths are preserved as-is.
|
||||
@@ -43,6 +44,14 @@ function canonicalizeSettings(settings: Settings): Settings {
|
||||
autoBackupDir: ".fusion/backups",
|
||||
};
|
||||
}
|
||||
|
||||
// Strip legacy globalMaxConcurrent from project settings - this field was
|
||||
// deprecated in favor of the global-level maxConcurrent in concurrency settings.
|
||||
const { globalMaxConcurrent, ...rest } = settings as Settings & { globalMaxConcurrent?: number };
|
||||
if (globalMaxConcurrent !== undefined) {
|
||||
return rest as Settings;
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user