From fd7ade8f3fe8c1ae51190d714fef9821bfb14b59 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 26 Mar 2026 18:19:54 -0700 Subject: [PATCH] fix: ensure config.yaml exists and is populated when accessed (#11915) * fix: ensure config.yaml exists and is populated when accessed - Opening a config profile (gear icon) now creates config.yaml with defaults if the file is missing, matching startup behavior - Empty config.yaml files are detected and populated with default config instead of causing parse errors * refactor: improve readability of config existence check --- core/config/ConfigHandler.ts | 2 ++ core/util/paths.ts | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 336c4b40b..0b20f557b 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -10,6 +10,7 @@ import { ILLMLogger, } from "../index.js"; import { GlobalContext } from "../util/GlobalContext.js"; +import { getConfigYamlPath } from "../util/paths.js"; import EventEmitter from "node:events"; import { @@ -637,6 +638,7 @@ export class ConfigHandler { } if (profile.profileDescription.profileType === "local") { + getConfigYamlPath(); const configFile = element?.sourceFile ?? profile.profileDescription.uri; await this.ide.openFile(configFile); } else { diff --git a/core/util/paths.ts b/core/util/paths.ts index 122ec2f94..323697f77 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -118,15 +118,12 @@ export function getConfigJsonPath(): string { export function getConfigYamlPath(ideType?: IdeType): string { const p = path.join(getContinueGlobalPath(), "config.yaml"); - if (!fs.existsSync(p) && !fs.existsSync(getConfigJsonPath())) { - if (ideType === "jetbrains") { - // https://github.com/continuedev/continue/pull/7224 - // This was here because we had different context provider support between jetbrains and vs code - // Leaving so we could differentiate later but for now configs are the same between IDEs - fs.writeFileSync(p, YAML.stringify(defaultConfig)); - } else { - fs.writeFileSync(p, YAML.stringify(defaultConfig)); - } + const exists = fs.existsSync(p); + const isEmpty = exists && fs.readFileSync(p, "utf8").trim() === ""; + const needsCreation = !exists && !fs.existsSync(getConfigJsonPath()); + + if (needsCreation || isEmpty) { + fs.writeFileSync(p, YAML.stringify(defaultConfig)); setConfigFilePermissions(p); } return p;