fix(config): preserved selected path in clones
Copied the selected main config path into per-CWD settings clones so config.yaml-backed sessions keep writing to config.yaml. Added regression coverage for cloneForCwd updates against preseeded config.yaml.
This commit is contained in:
@@ -458,6 +458,7 @@ export class Settings {
|
||||
inMemory: !this.#persist,
|
||||
});
|
||||
cloned.#storage = this.#storage;
|
||||
cloned.#configPath = this.#configPath;
|
||||
cloned.#global = structuredClone(this.#global);
|
||||
cloned.#project = this.#persist ? await cloned.#loadProjectSettings() : structuredClone(this.#project);
|
||||
cloned.#configFiles = [...this.#configFiles];
|
||||
|
||||
@@ -87,6 +87,21 @@ describe("Settings", () => {
|
||||
expect(await Bun.file(getConfigPath()).exists()).toBe(false);
|
||||
});
|
||||
|
||||
it("clones the selected config.yaml path for persisted settings", async () => {
|
||||
const yamlConfigPath = path.join(agentDir, "config.yaml");
|
||||
await Bun.write(yamlConfigPath, YAML.stringify({ setupVersion: 1 }, null, 2));
|
||||
|
||||
const settings = await Settings.init({ cwd: projectDir, agentDir });
|
||||
const cloned = await settings.cloneForCwd(tempDir.join("other-project"));
|
||||
|
||||
cloned.set("setupVersion", 2);
|
||||
await cloned.flush();
|
||||
|
||||
const savedSettings = YAML.parse(await Bun.file(yamlConfigPath).text()) as Record<string, unknown>;
|
||||
expect(savedSettings.setupVersion).toBe(2);
|
||||
expect(await Bun.file(getConfigPath()).exists()).toBe(false);
|
||||
});
|
||||
|
||||
it("creates config.yml for new persisted settings when no main config exists", async () => {
|
||||
const yamlConfigPath = path.join(agentDir, "config.yaml");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user