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");