From 041e7477efc5dcbc45e2d460298816a040cd62e0 Mon Sep 17 00:00:00 2001 From: kevinWangSheng Date: Sat, 21 Mar 2026 22:53:48 -0700 Subject: [PATCH 1/2] fix(config): write PATCH /config to opencode.json instead of config.json Config.update() was writing to config.json which is not read by the project config loader. This caused PATCH /config changes to silently disappear on restart. Now it follows the same lookup order as the config loader: prefer existing opencode.jsonc, fall back to opencode.json. Closes #4194 --- packages/opencode/src/config/config.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index c464fcb64ab8..2fc6f5075b7d 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -1347,12 +1347,20 @@ export namespace Config { } export async function update(config: Info) { - const filepath = path.join(Instance.directory, "config.json") + const filepath = projectConfigFile() const existing = await loadFile(filepath) await Filesystem.writeJson(filepath, mergeDeep(existing, config)) await Instance.dispose() } + function projectConfigFile() { + const candidates = ["opencode.jsonc", "opencode.json"].map((file) => path.join(Instance.directory, file)) + for (const file of candidates) { + if (existsSync(file)) return file + } + return candidates[1] + } + function globalConfigFile() { const candidates = ["opencode.jsonc", "opencode.json", "config.json"].map((file) => path.join(Global.Path.config, file), From f52521750dab203ca64e1eec8b42c125f8cb0ecb Mon Sep 17 00:00:00 2001 From: kevinWangSheng Date: Sun, 22 Mar 2026 00:23:54 -0700 Subject: [PATCH 2/2] fix(config): update test to match new opencode.json write path The test was asserting config.json but update() now correctly writes to opencode.json. --- packages/opencode/test/config/config.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/test/config/config.test.ts b/packages/opencode/test/config/config.test.ts index eb9c763fa757..9cce5348341d 100644 --- a/packages/opencode/test/config/config.test.ts +++ b/packages/opencode/test/config/config.test.ts @@ -685,7 +685,7 @@ test("updates config and writes to file", async () => { const newConfig = { model: "updated/model" } await Config.update(newConfig as any) - const writtenConfig = await Filesystem.readJson(path.join(tmp.path, "config.json")) + const writtenConfig = await Filesystem.readJson(path.join(tmp.path, "opencode.json")) expect(writtenConfig.model).toBe("updated/model") }, })