summaryrefslogtreecommitdiff
path: root/extension/src/activation
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/activation')
-rw-r--r--extension/src/activation/activate.ts31
-rw-r--r--extension/src/activation/environmentSetup.ts34
2 files changed, 47 insertions, 18 deletions
diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts
index df8b6871..cd8f0cf3 100644
--- a/extension/src/activation/activate.ts
+++ b/extension/src/activation/activate.ts
@@ -24,19 +24,6 @@ export async function activateExtension(
registerAllCodeLensProviders(context);
registerAllCommands(context);
- await new Promise((resolve, reject) => {
- vscode.window.withProgress(
- {
- location: vscode.ProgressLocation.Notification,
- title: "Starting Continue Server...",
- cancellable: false,
- },
- async (progress, token) => {
- await startContinuePythonServer();
- resolve(null);
- }
- );
- });
const serverUrl = getContinueServerUrl();
ideProtocolClient = new IdeProtocolClient(
@@ -46,8 +33,8 @@ export async function activateExtension(
// Setup the left panel
(async () => {
- const sessionId = await ideProtocolClient.getSessionId();
- const provider = new ContinueGUIWebviewViewProvider(sessionId);
+ const sessionIdPromise = ideProtocolClient.getSessionId();
+ const provider = new ContinueGUIWebviewViewProvider(sessionIdPromise);
context.subscriptions.push(
vscode.window.registerWebviewViewProvider(
@@ -60,6 +47,20 @@ export async function activateExtension(
);
})();
+ await new Promise((resolve, reject) => {
+ vscode.window.withProgress(
+ {
+ location: vscode.ProgressLocation.Notification,
+ title:
+ "Starting Continue Server... (it may take a minute to download Python packages)",
+ cancellable: false,
+ },
+ async (progress, token) => {
+ await startContinuePythonServer();
+ resolve(null);
+ }
+ );
+ });
// All opened terminals should be replaced by our own terminal
// vscode.window.onDidOpenTerminal((terminal) => {});
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 168c79ad..823670fd 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -101,9 +101,34 @@ function checkEnvExists() {
}
function checkRequirementsInstalled() {
- return fs.existsSync(
- path.join(getExtensionUri().fsPath, "scripts", ".continue_env_installed")
+ let envLibsPath = path.join(
+ getExtensionUri().fsPath,
+ "scripts",
+ "env",
+ process.platform == "win32" ? "Lib" : "lib"
);
+ // If site-packages is directly under env, use that
+ if (fs.existsSync(path.join(envLibsPath, "site-packages"))) {
+ envLibsPath = path.join(envLibsPath, "site-packages");
+ } else {
+ // Get the python version folder name
+ const pythonVersions = fs.readdirSync(envLibsPath).filter((f: string) => {
+ return f.startsWith("python");
+ });
+ if (pythonVersions.length == 0) {
+ return false;
+ }
+ const pythonVersion = pythonVersions[0];
+ envLibsPath = path.join(envLibsPath, pythonVersion, "site-packages");
+ }
+
+ const continuePath = path.join(envLibsPath, "continuedev");
+
+ return fs.existsSync(continuePath);
+
+ // return fs.existsSync(
+ // path.join(getExtensionUri().fsPath, "scripts", ".continue_env_installed")
+ // );
}
async function setupPythonEnv() {
@@ -249,7 +274,10 @@ export async function startContinuePythonServer() {
});
child.stderr.on("data", (data: any) => {
console.log(`stderr: ${data}`);
- if (data.includes("Uvicorn running on")) {
+ if (
+ data.includes("Uvicorn running on") || // Successfully started the server
+ data.includes("address already in use") // The server is already running (probably a simultaneously opened VS Code window)
+ ) {
console.log("Successfully started Continue python server");
resolve(null);
}