continue-custom/core/config/profile/LocalProfileLoader.ts
MumuTW bcd514aa55
fix: use config.yaml name for default Local Config profile (#11110)
* fix(core): pass config name through ConfigResult instead of re-reading file

Rework per reviewer feedback: instead of reading config.yaml separately
in LocalProfileLoader's constructor, propagate the name field through
ConfigResult from the existing config loading pipeline.

Changes:
- Add optional configName to ConfigResult interface
- Populate configName in unroll.ts where AssistantUnrolled is built
- Propagate through loadContinueConfigFromYaml → doLoadConfig
- LocalProfileLoader now reads configName from doLoadConfig result
- Remove duplicate fs.readFileSync + parseConfigYaml from constructor
- Works in WSL and other environments where file paths may differ

Addresses: https://github.com/continuedev/continue/issues/11061

* style: fix prettier formatting in doLoadConfig.ts

---------

Co-authored-by: Dallin Romney <dallinromney@gmail.com>
2026-03-24 13:37:52 -07:00

75 lines
2.4 KiB
TypeScript

import { ConfigResult } from "@continuedev/config-yaml";
import { ControlPlaneClient } from "../../control-plane/client.js";
import { ContinueConfig, IDE, ILLMLogger } from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";
import { getPrimaryConfigFilePath } from "../../util/paths.js";
import { localPathToUri } from "../../util/pathToUri.js";
import { getUriPathBasename } from "../../util/uri.js";
import doLoadConfig from "./doLoadConfig.js";
import { IProfileLoader } from "./IProfileLoader.js";
export default class LocalProfileLoader implements IProfileLoader {
static ID = "local";
description: ProfileDescription;
constructor(
private ide: IDE,
private controlPlaneClient: ControlPlaneClient,
private llmLogger: ILLMLogger,
private overrideAssistantFile?:
| { path: string; content: string }
| undefined,
) {
this.description = {
id: overrideAssistantFile?.path ?? LocalProfileLoader.ID,
profileType: "local",
fullSlug: {
ownerSlug: "",
packageSlug: "",
versionSlug: "",
},
iconUrl: "",
title: overrideAssistantFile?.path
? getUriPathBasename(overrideAssistantFile.path)
: "Local Config",
errors: undefined,
uri:
overrideAssistantFile?.path ??
localPathToUri(getPrimaryConfigFilePath()),
rawYaml: undefined,
};
}
async doLoadConfig(): Promise<ConfigResult<ContinueConfig>> {
const result = await doLoadConfig({
ide: this.ide,
controlPlaneClient: this.controlPlaneClient,
llmLogger: this.llmLogger,
profileId: this.description.id,
overrideConfigYamlByPath: this.overrideAssistantFile?.path,
orgScopeId: null,
packageIdentifier: {
uriType: "file",
fileUri: this.overrideAssistantFile?.path ?? getPrimaryConfigFilePath(),
// Pass pre-read content to bypass fs.readFileSync, which fails for
// vscode-remote:// URIs when Windows host connects to WSL (#10450)
content: this.overrideAssistantFile?.content,
},
});
this.description.errors = result.errors;
// Use the config name from the loaded config (avoids duplicate file reads
// and works in environments like WSL where paths may differ)
if (result.configName) {
this.description.title = result.configName;
}
return result;
}
setIsActive(isActive: boolean): void {}
}