From 668741b40c9177c19f4b964d4eb89714816b5bcb Mon Sep 17 00:00:00 2001 From: roboomp Date: Thu, 9 Jul 2026 11:06:35 +0000 Subject: [PATCH] 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. --- packages/coding-agent/src/config/settings.ts | 1 + .../coding-agent/test/settings-manager.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/coding-agent/src/config/settings.ts b/packages/coding-agent/src/config/settings.ts index 23ae1d0c6..cab46a635 100644 --- a/packages/coding-agent/src/config/settings.ts +++ b/packages/coding-agent/src/config/settings.ts @@ -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]; diff --git a/packages/coding-agent/test/settings-manager.test.ts b/packages/coding-agent/test/settings-manager.test.ts index f721c5640..daf6e15a0 100644 --- a/packages/coding-agent/test/settings-manager.test.ts +++ b/packages/coding-agent/test/settings-manager.test.ts @@ -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; + 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");