diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index d72e8c4cebb..94c08b28f29 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -1,4 +1,5 @@ import { ConfigResult } from "@continuedev/config-yaml"; +import * as YAML from "yaml"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, ILLMLogger } from "../../index.js"; @@ -10,6 +11,26 @@ import { getUriPathBasename } from "../../util/uri.js"; import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; +function getDisplayTitle(overrideAssistantFile?: { + path: string; + content: string; +}) { + if (!overrideAssistantFile?.path) { + return "Local Config"; + } + + try { + const parsed = YAML.parse(overrideAssistantFile.content); + if (typeof parsed?.name === "string" && parsed.name.trim()) { + return parsed.name; + } + } catch { + // Invalid YAML is handled during config loading; keep the selector usable. + } + + return getUriPathBasename(overrideAssistantFile.path); +} + export default class LocalProfileLoader implements IProfileLoader { static ID = "local"; @@ -32,9 +53,7 @@ export default class LocalProfileLoader implements IProfileLoader { versionSlug: "", }, iconUrl: "", - title: overrideAssistantFile?.path - ? getUriPathBasename(overrideAssistantFile.path) - : "Local Config", + title: getDisplayTitle(overrideAssistantFile), errors: undefined, uri: overrideAssistantFile?.path ?? diff --git a/core/config/profile/LocalProfileLoader.vitest.ts b/core/config/profile/LocalProfileLoader.vitest.ts index 7fdf3d18836..60b14113b5f 100644 --- a/core/config/profile/LocalProfileLoader.vitest.ts +++ b/core/config/profile/LocalProfileLoader.vitest.ts @@ -49,6 +49,38 @@ describe("LocalProfileLoader", () => { ); }); + it("should initialize override file title from config name", () => { + const overrideFile = { + path: "file:///workspace/.continue/agents/example.yaml", + content: "name: My Custom Config\nversion: 1.0.0\nschema: v1\n", + }; + + const loader = new LocalProfileLoader( + testIde, + controlPlaneClient, + llmLogger, + overrideFile, + ); + + expect(loader.description.title).toBe("My Custom Config"); + }); + + it("should fall back to filename when override file has no config name", () => { + const overrideFile = { + path: "file:///workspace/.continue/agents/example.yaml", + content: "version: 1.0.0\nschema: v1\n", + }; + + const loader = new LocalProfileLoader( + testIde, + controlPlaneClient, + llmLogger, + overrideFile, + ); + + expect(loader.description.title).toBe("example.yaml"); + }); + it("should not include content in packageIdentifier when no override file", async () => { const loader = new LocalProfileLoader( testIde,