* 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>
109 lines
2.8 KiB
TypeScript
109 lines
2.8 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { ControlPlaneClient } from "../../control-plane/client.js";
|
|
import { LLMLogger } from "../../llm/logger.js";
|
|
import { testIde } from "../../test/fixtures.js";
|
|
import LocalProfileLoader from "./LocalProfileLoader.js";
|
|
|
|
// Mock doLoadConfig to capture the arguments it receives
|
|
const mockDoLoadConfig = vi.fn().mockResolvedValue({
|
|
config: undefined,
|
|
errors: [],
|
|
configLoadInterrupted: false,
|
|
});
|
|
|
|
vi.mock("./doLoadConfig.js", () => ({
|
|
default: (...args: any[]) => mockDoLoadConfig(...args),
|
|
}));
|
|
|
|
describe("LocalProfileLoader", () => {
|
|
const controlPlaneClient = new ControlPlaneClient(
|
|
Promise.resolve(undefined),
|
|
testIde,
|
|
);
|
|
const llmLogger = new LLMLogger();
|
|
|
|
it("should pass pre-read content in packageIdentifier for override files", async () => {
|
|
const overrideFile = {
|
|
path: "vscode-remote://wsl+Ubuntu/home/user/.continue/agents/test.yaml",
|
|
content: "name: Test\nversion: 1.0.0\nschema: v1\n",
|
|
};
|
|
|
|
const loader = new LocalProfileLoader(
|
|
testIde,
|
|
controlPlaneClient,
|
|
llmLogger,
|
|
overrideFile,
|
|
);
|
|
|
|
await loader.doLoadConfig();
|
|
|
|
expect(mockDoLoadConfig).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
packageIdentifier: expect.objectContaining({
|
|
uriType: "file",
|
|
fileUri: overrideFile.path,
|
|
content: overrideFile.content,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("should not include content in packageIdentifier when no override file", async () => {
|
|
const loader = new LocalProfileLoader(
|
|
testIde,
|
|
controlPlaneClient,
|
|
llmLogger,
|
|
);
|
|
|
|
await loader.doLoadConfig();
|
|
|
|
expect(mockDoLoadConfig).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
packageIdentifier: expect.objectContaining({
|
|
uriType: "file",
|
|
content: undefined,
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("should update title from configName when available", async () => {
|
|
mockDoLoadConfig.mockResolvedValueOnce({
|
|
config: {},
|
|
errors: [],
|
|
configLoadInterrupted: false,
|
|
configName: "My Custom Config",
|
|
});
|
|
|
|
const loader = new LocalProfileLoader(
|
|
testIde,
|
|
controlPlaneClient,
|
|
llmLogger,
|
|
);
|
|
|
|
expect(loader.description.title).toBe("Local Config");
|
|
|
|
await loader.doLoadConfig();
|
|
|
|
expect(loader.description.title).toBe("My Custom Config");
|
|
});
|
|
|
|
it("should keep default title when configName is not set", async () => {
|
|
mockDoLoadConfig.mockResolvedValueOnce({
|
|
config: {},
|
|
errors: [],
|
|
configLoadInterrupted: false,
|
|
});
|
|
|
|
const loader = new LocalProfileLoader(
|
|
testIde,
|
|
controlPlaneClient,
|
|
llmLogger,
|
|
);
|
|
|
|
await loader.doLoadConfig();
|
|
|
|
expect(loader.description.title).toBe("Local Config");
|
|
});
|
|
});
|