diff options
Diffstat (limited to 'extension')
| -rw-r--r-- | extension/package-lock.json | 4 | ||||
| -rw-r--r-- | extension/package.json | 2 | ||||
| -rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 4 | ||||
| -rw-r--r-- | extension/scripts/.continue_env_installed | 0 | ||||
| -rw-r--r-- | extension/scripts/.gitignore | 4 | ||||
| -rw-r--r-- | extension/scripts/continuedev-0.1.1-py3-none-any.whl | bin | 89627 -> 0 bytes | |||
| -rw-r--r-- | extension/src/activation/environmentSetup.ts | 108 | 
7 files changed, 73 insertions, 49 deletions
| diff --git a/extension/package-lock.json b/extension/package-lock.json index 98dfc223..fcd4c755 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@  {    "name": "continue", -  "version": "0.0.67", +  "version": "0.0.70",    "lockfileVersion": 2,    "requires": true,    "packages": {      "": {        "name": "continue", -      "version": "0.0.67", +      "version": "0.0.70",        "license": "Apache-2.0",        "dependencies": {          "@electron/rebuild": "^3.2.10", diff --git a/extension/package.json b/extension/package.json index a51bb6d0..b56c60f4 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@    "displayName": "Continue",    "pricing": "Free",    "description": "Accelerating software development with language models", -  "version": "0.0.67", +  "version": "0.0.70",    "publisher": "Continue",    "engines": {      "vscode": "^1.74.0" diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 445d5700..13b74423 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -352,9 +352,7 @@ function GUI(props: GUIProps) {          {typeof client === "undefined" && (            <>              <Loader></Loader> -            <p style={{ textAlign: "center" }}> -              Trying to reconnect with server... -            </p> +            <p style={{ textAlign: "center" }}>Loading Continue server...</p>            </>          )}          {history?.timeline.map((node: HistoryNode, index: number) => { diff --git a/extension/scripts/.continue_env_installed b/extension/scripts/.continue_env_installed deleted file mode 100644 index e69de29b..00000000 --- a/extension/scripts/.continue_env_installed +++ /dev/null diff --git a/extension/scripts/.gitignore b/extension/scripts/.gitignore index 7af27c08..fbb3bf9f 100644 --- a/extension/scripts/.gitignore +++ b/extension/scripts/.gitignore @@ -1,3 +1,5 @@  testdb  env -stdout.txt
\ No newline at end of file +stdout.txt +.continue_env_installed +**.whl
\ No newline at end of file diff --git a/extension/scripts/continuedev-0.1.1-py3-none-any.whl b/extension/scripts/continuedev-0.1.1-py3-none-any.whlBinary files differ deleted file mode 100644 index 4d1c8fb2..00000000 --- a/extension/scripts/continuedev-0.1.1-py3-none-any.whl +++ /dev/null diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 364b6af2..25b6f643 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -7,6 +7,25 @@ import * as fs from "fs";  import rebuild from "@electron/rebuild";  import { getContinueServerUrl } from "../bridge";  import fetch from "node-fetch"; +import * as vscode from "vscode"; + +const MAX_RETRIES = 5; +async function retryThenFail( +  fn: () => Promise<any>, +  retries: number = MAX_RETRIES +): Promise<any> { +  try { +    return await fn(); +  } catch (e) { +    if (retries > 0) { +      return await retryThenFail(fn, retries - 1); +    } +    vscode.window.showErrorMessage( +      "Failed to set up Continue extension. Please email nate@continue.dev and we'll get this fixed ASAP!" +    ); +    throw e; +  } +}  async function runCommand(cmd: string): Promise<[string, string | undefined]> {    console.log("Running command: ", cmd); @@ -91,6 +110,7 @@ async function setupPythonEnv() {      pythonCmd,      pipCmd    ); +    if (checkEnvExists()) {      console.log("Python env already exists, skipping...");    } else { @@ -124,21 +144,23 @@ async function setupPythonEnv() {      );    } -  if (checkRequirementsInstalled()) { -    console.log("Python requirements already installed, skipping..."); -  } else { -    const installRequirementsCommand = [ -      `cd ${path.join(getExtensionUri().fsPath, "scripts")}`, -      activateCmd, -      pipUpgradeCmd, -      `${pipCmd} install -r requirements.txt`, -      "touch .continue_env_installed", -    ].join(" ; "); -    const [, stderr] = await runCommand(installRequirementsCommand); -    if (stderr) { -      throw new Error(stderr); +  await retryThenFail(async () => { +    if (checkRequirementsInstalled()) { +      console.log("Python requirements already installed, skipping..."); +    } else { +      const installRequirementsCommand = [ +        `cd ${path.join(getExtensionUri().fsPath, "scripts")}`, +        activateCmd, +        pipUpgradeCmd, +        `${pipCmd} install -r requirements.txt`, +        "touch .continue_env_installed", +      ].join(" ; "); +      const [, stderr] = await runCommand(installRequirementsCommand); +      if (stderr) { +        throw new Error(stderr); +      }      } -  } +  });  }  function readEnvFile(path: string) { @@ -198,10 +220,6 @@ export async function startContinuePythonServer() {      return;    } -  console.log("Starting Continue python server..."); - -  if (await checkServerRunning(serverUrl)) return; -    let activateCmd = ". env/bin/activate";    let pythonCmd = "python3";    if (process.platform == "win32") { @@ -214,33 +232,39 @@ export async function startContinuePythonServer() {      "scripts"    )} ; ${activateCmd} ; cd .. ; ${pythonCmd} -m scripts.run_continue_server`; -  return new Promise(async (resolve, reject) => { -    try { -      const child = spawn(command, { -        shell: true, -      }); -      child.stdout.on("data", (data: any) => { -        console.log(`stdout: ${data}`); -      }); -      child.stderr.on("data", (data: any) => { -        console.log(`stderr: ${data}`); -        if (data.includes("Uvicorn running on")) { -          console.log("Successfully started Continue python server"); +  return await retryThenFail(async () => { +    console.log("Starting Continue python server..."); + +    if (await checkServerRunning(serverUrl)) return; + +    return new Promise(async (resolve, reject) => { +      try { +        const child = spawn(command, { +          shell: true, +        }); +        child.stdout.on("data", (data: any) => { +          console.log(`stdout: ${data}`); +        }); +        child.stderr.on("data", (data: any) => { +          console.log(`stderr: ${data}`); +          if (data.includes("Uvicorn running on")) { +            console.log("Successfully started Continue python server"); +            resolve(null); +          } +        }); +        child.on("error", (error: any) => { +          console.log(`error: ${error.message}`); +        }); +      } catch (e) { +        console.log("Failed to start Continue python server", e); +        // If failed, check if it's because the server is already running (might have happened just after we checked above) +        if (await checkServerRunning(serverUrl)) {            resolve(null); +        } else { +          reject();          } -      }); -      child.on("error", (error: any) => { -        console.log(`error: ${error.message}`); -      }); -    } catch (e) { -      console.log("Failed to start Continue python server", e); -      // If failed, check if it's because the server is already running (might have happened just after we checked above) -      if (await checkServerRunning(serverUrl)) { -        resolve(null); -      } else { -        reject();        } -    } +    });    });  } | 
