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:
roboomp
2026-07-09 11:06:35 +00:00
committed by can1357
parent 9ce8b69b34
commit 668741b40c
2 changed files with 16 additions and 0 deletions
@@ -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");