Skip to content

Commit

Permalink
Merge pull request #3749 from continuedev/dallin/config-file-uri
Browse files Browse the repository at this point in the history
config file uri bug
  • Loading branch information
sestinj authored Jan 18, 2025
2 parents 508e242 + e19f0d3 commit 625755b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/config/ConfigHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { GlobalContext } from "../util/GlobalContext.js";
import { getConfigJsonPath } from "../util/paths.js";

import { ConfigResult } from "@continuedev/config-yaml";
import { pathToFileURL } from "url";
import { controlPlaneEnv } from "../control-plane/env.js";
import { usePlatform } from "../control-plane/flags.js";
import {
Expand All @@ -29,6 +28,7 @@ import {
ProfileDescription,
ProfileLifecycleManager,
} from "./ProfileLifecycleManager.js";
import { localPathToUri } from "../util/pathToUri.js";

export type { ProfileDescription };

Expand Down Expand Up @@ -95,7 +95,7 @@ export class ConfigHandler {
async openConfigProfile(profileId?: string) {
let openProfileId = profileId || this.selectedProfileId;
if (openProfileId === "local") {
await this.ide.openFile(pathToFileURL(getConfigJsonPath()).toString());
await this.ide.openFile(localPathToUri(getConfigJsonPath()));
} else {
await this.ide.openUrl(`${controlPlaneEnv.APP_URL}${openProfileId}`);
}
Expand Down
3 changes: 2 additions & 1 deletion core/config/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
// import { isSupportedLanceDbCpuTarget } from "./util";
import { validateConfig } from "./validation.js";
import { localPathToUri } from "../util/pathToUri";

function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
let content = fs.readFileSync(filepath, "utf8");
Expand Down Expand Up @@ -813,7 +814,7 @@ async function loadFullConfigNode(
"Could not load config.ts as absolute path, retrying as file url ...",
);
try {
module = await import(`file://${configJsPath}`);
module = await import(localPathToUri(configJsPath));
} catch (e) {
throw new Error("Could not load config.ts as file url either", {
cause: e,
Expand Down
4 changes: 2 additions & 2 deletions core/indexing/CodebaseIndexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
} from "../test/testDir.js";
import { getIndexSqlitePath } from "../util/paths.js";

import { pathToFileURL } from "node:url";
import { CodebaseIndexer, PauseToken } from "./CodebaseIndexer.js";
import { getComputeDeleteAddRemove } from "./refreshIndex.js";
import { TestCodebaseIndex } from "./TestCodebaseIndex.js";
import { CodebaseIndex } from "./types.js";
import { walkDir } from "./walkDir.js";
import { localPathToUri } from "../util/pathToUri.js";

jest.useFakeTimers();

Expand Down Expand Up @@ -159,7 +159,7 @@ describe("CodebaseIndexer", () => {

test("should have created index folder with all necessary files", async () => {
const exists = await testIde.fileExists(
pathToFileURL(getIndexSqlitePath()).toString(),
localPathToUri(getIndexSqlitePath()),
);
expect(exists).toBe(true);
});
Expand Down
10 changes: 5 additions & 5 deletions core/promptFiles/v2/getPromptFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export async function getPromptFilesFromDir(
return [];
}

const paths = await walkDir(dir, ide, { ignoreFiles: [] });
const promptFilePaths = paths.filter((p) => p.endsWith(".prompt"));
const results = promptFilePaths.map(async (path) => {
const content = await ide.readFile(path); // make a try catch
return { path, content };
const uris = await walkDir(dir, ide, { ignoreFiles: [] });
const promptFilePaths = uris.filter((p) => p.endsWith(".prompt"));
const results = promptFilePaths.map(async (uri) => {
const content = await ide.readFile(uri); // make a try catch
return { path: uri, content };
});
return Promise.all(results);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion core/util/pathToUri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as URI from "uri-js";

// CAN ONLY BE USED IN CORE

// Converts a local path to a file:// URI
// Converts a local path to a file:/// URI
export function localPathToUri(path: string) {
const url = pathToFileURL(path);
return URI.normalize(url.toString());
Expand Down

0 comments on commit 625755b

Please sign in to comment.