From f8bc06261464cd46c31a23cc8cbc0e76fb642d18 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 21 Jun 2023 08:47:06 -0700 Subject: purging old extension code --- extension/src/activation/activate.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'extension/src/activation') diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index 32726c86..bfe9ab3f 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -2,12 +2,10 @@ import * as vscode from "vscode"; import { registerAllCommands } from "../commands"; import { registerAllCodeLensProviders } from "../lang-server/codeLens"; import { sendTelemetryEvent, TelemetryEvent } from "../telemetry"; -import { getExtensionUri } from "../util/vscode"; -import * as path from "path"; // import { openCapturedTerminal } from "../terminal/terminalEmulator"; import IdeProtocolClient from "../continueIdeClient"; import { getContinueServerUrl } from "../bridge"; -import { setupDebugPanel, ContinueGUIWebviewViewProvider } from "../debugPanel"; +import { ContinueGUIWebviewViewProvider } from "../debugPanel"; import { CapturedTerminal } from "../terminal/terminalEmulator"; export let extensionContext: vscode.ExtensionContext | undefined = undefined; -- cgit v1.2.3-70-g09d2 From cc7ef4631f8f1bd141788c8e3117df1aca16b308 Mon Sep 17 00:00:00 2001 From: Ty Dunn Date: Wed, 21 Jun 2023 15:02:20 -0700 Subject: removing captured terminal --- extension/src/activation/activate.ts | 37 +++--------------------------------- extension/src/commands.ts | 5 ----- extension/src/continueIdeClient.ts | 14 +++----------- 3 files changed, 6 insertions(+), 50 deletions(-) (limited to 'extension/src/activation') diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index 32726c86..34abdff7 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -8,7 +8,7 @@ import * as path from "path"; import IdeProtocolClient from "../continueIdeClient"; import { getContinueServerUrl } from "../bridge"; import { setupDebugPanel, ContinueGUIWebviewViewProvider } from "../debugPanel"; -import { CapturedTerminal } from "../terminal/terminalEmulator"; +// import { CapturedTerminal } from "../terminal/terminalEmulator"; export let extensionContext: vscode.ExtensionContext | undefined = undefined; @@ -49,41 +49,10 @@ export function activateExtension( })(); // All opened terminals should be replaced by our own terminal - vscode.window.onDidOpenTerminal((terminal) => { - if (terminal.name === "Continue") { - return; - } - const options = terminal.creationOptions; - const capturedTerminal = new CapturedTerminal({ - ...options, - name: "Continue", - }); - terminal.dispose(); - if (!ideProtocolClient.continueTerminal) { - ideProtocolClient.continueTerminal = capturedTerminal; - } - }); + // vscode.window.onDidOpenTerminal((terminal) => {}); // If any terminals are open to start, replace them - vscode.window.terminals.forEach((terminal) => { - if (terminal.name === "Continue") { - return; - } - const options = terminal.creationOptions; - const capturedTerminal = new CapturedTerminal( - { - ...options, - name: "Continue", - }, - (commandOutput: string) => { - ideProtocolClient.sendCommandOutput(commandOutput); - } - ); - terminal.dispose(); - if (!ideProtocolClient.continueTerminal) { - ideProtocolClient.continueTerminal = capturedTerminal; - } - }); + // vscode.window.terminals.forEach((terminal) => {} extensionContext = context; } diff --git a/extension/src/commands.ts b/extension/src/commands.ts index 22e15c43..291a3ceb 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -13,7 +13,6 @@ import { } from "./suggestions"; import * as bridge from "./bridge"; import { debugPanelWebview, setupDebugPanel } from "./debugPanel"; -// import { openCapturedTerminal } from "./terminal/terminalEmulator"; import { getRightViewColumn } from "./util/vscode"; import { findSuspiciousCode, @@ -67,10 +66,6 @@ const commandsMap: { [command: string]: (...args: any) => any } = { type: "focusContinueInput", }); }, - "continue.openCapturedTerminal": () => { - // Happens in webview resolution function - // openCapturedTerminal(); - }, "continue.findSuspiciousCode": async ( debugContext: SerializedDebugContext ) => { diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index fbad5f5d..202077de 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -12,7 +12,6 @@ import { debugPanelWebview, setupDebugPanel } from "./debugPanel"; import { FileEditWithFullContents } from "../schema/FileEditWithFullContents"; import fs = require("fs"); import { WebsocketMessenger } from "./util/messenger"; -import { CapturedTerminal } from "./terminal/terminalEmulator"; import { decorationManager } from "./decorations"; class IdeProtocolClient { @@ -326,17 +325,10 @@ class IdeProtocolClient { return rangeInFiles; } - public continueTerminal: CapturedTerminal | undefined; - async runCommand(command: string) { - if (!this.continueTerminal || this.continueTerminal.isClosed()) { - this.continueTerminal = new CapturedTerminal({ - name: "Continue", - }); - } - - this.continueTerminal.show(); - return await this.continueTerminal.runCommand(command); + const terminal = vscode.window.createTerminal(); + terminal.show(); + terminal.sendText(command); } sendCommandOutput(output: string) { -- cgit v1.2.3-70-g09d2 From 2d37d2bd1ee8022aa4eb5db1285c50feced14771 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 25 Jun 2023 14:19:07 -0700 Subject: run locally without interference --- extension/src/activation/activate.ts | 12 ++++++------ extension/src/activation/environmentSetup.ts | 2 +- extension/src/extension.ts | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'extension/src/activation') diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index c4bdbaa9..0c92f095 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -7,24 +7,26 @@ import IdeProtocolClient from "../continueIdeClient"; import { getContinueServerUrl } from "../bridge"; import { CapturedTerminal } from "../terminal/terminalEmulator"; import { setupDebugPanel, ContinueGUIWebviewViewProvider } from "../debugPanel"; +import { startContinuePythonServer } from "./environmentSetup"; // import { CapturedTerminal } from "../terminal/terminalEmulator"; export let extensionContext: vscode.ExtensionContext | undefined = undefined; export let ideProtocolClient: IdeProtocolClient; -export function activateExtension( +export async function activateExtension( context: vscode.ExtensionContext, showTutorial: boolean ) { - sendTelemetryEvent(TelemetryEvent.ExtensionActivated); + extensionContext = context; + sendTelemetryEvent(TelemetryEvent.ExtensionActivated); registerAllCodeLensProviders(context); registerAllCommands(context); // vscode.window.registerWebviewViewProvider("continue.continueGUIView", setupDebugPanel); - - let serverUrl = getContinueServerUrl(); + await startContinuePythonServer(); + const serverUrl = getContinueServerUrl(); ideProtocolClient = new IdeProtocolClient( `${serverUrl.replace("http", "ws")}/ide/ws`, @@ -52,6 +54,4 @@ export function activateExtension( // If any terminals are open to start, replace them // vscode.window.terminals.forEach((terminal) => {} - - extensionContext = context; } diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 593b727e..54c263bd 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -180,7 +180,7 @@ export async function startContinuePythonServer() { await setupPythonEnv(); // Check vscode settings - let serverUrl = getContinueServerUrl(); + const serverUrl = getContinueServerUrl(); if (serverUrl !== "http://localhost:8000") { return; } diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 88af0d19..de8f55e3 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -13,7 +13,7 @@ async function dynamicImportAndActivate( showTutorial: boolean ) { const { activateExtension } = await import("./activation/activate"); - activateExtension(context, showTutorial); + await activateExtension(context, showTutorial); } export function activate(context: vscode.ExtensionContext) { @@ -25,7 +25,6 @@ export function activate(context: vscode.ExtensionContext) { cancellable: false, }, async () => { - await startContinuePythonServer(); dynamicImportAndActivate(context, true); } ); -- cgit v1.2.3-70-g09d2 From cc96a49bc576bd25ccf338108d29540df3204de3 Mon Sep 17 00:00:00 2001 From: Ty Dunn Date: Sun, 25 Jun 2023 21:33:01 -0700 Subject: && -> ; --- extension/src/activation/environmentSetup.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'extension/src/activation') diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 54c263bd..66e1c722 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -121,7 +121,7 @@ async function setupPythonEnv() { activateCmd, pipUpgradeCmd, `${pipCmd} install -r requirements.txt`, - ].join(" && "); + ].join(" ; "); const [, stderr] = await runCommand(installRequirementsCommand); if (stderr) { throw new Error(stderr); @@ -199,7 +199,7 @@ export async function startContinuePythonServer() { let command = `cd ${path.join( getExtensionUri().fsPath, "scripts" - )} && ${activateCmd} && cd .. && ${pythonCmd} -m scripts.run_continue_server`; + )} ; ${activateCmd} ; cd .. ; ${pythonCmd} -m scripts.run_continue_server`; return new Promise(async (resolve, reject) => { try { @@ -255,10 +255,10 @@ export async function downloadPython3() { throw new Error("python3 not found"); } else if (os === "linux") { command = - "sudo apt update && upgrade && sudo apt install python3 python3-pip"; + "sudo apt update ; upgrade ; sudo apt install python3 python3-pip"; } else if (os === "win32") { command = - "wget -O python_installer.exe https://www.python.org/ftp/python/3.11.3/python-3.11.3-amd64.exe && python_installer.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0"; + "wget -O python_installer.exe https://www.python.org/ftp/python/3.11.3/python-3.11.3-amd64.exe ; python_installer.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0"; pythonCmd = "python"; } -- cgit v1.2.3-70-g09d2 From 45601fdd7cdcb4c7a229c11f7d9b381b86927856 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 26 Jun 2023 13:27:56 -0700 Subject: check for requirements installed separately of env --- extension/src/activation/environmentSetup.ts | 85 ++++++++++++++++------------ 1 file changed, 49 insertions(+), 36 deletions(-) (limited to 'extension/src/activation') diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 66e1c722..364b6af2 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -77,54 +77,67 @@ function checkEnvExists() { ); } +function checkRequirementsInstalled() { + return fs.existsSync( + path.join(getExtensionUri().fsPath, "scripts", ".continue_env_installed") + ); +} + async function setupPythonEnv() { console.log("Setting up python env for Continue extension..."); - if (checkEnvExists()) return; - - // Assemble the command to create the env const [pythonCmd, pipCmd] = await getPythonPipCommands(); const [activateCmd, pipUpgradeCmd] = getActivateUpgradeCommands( pythonCmd, pipCmd ); - const createEnvCommand = [ - `cd ${path.join(getExtensionUri().fsPath, "scripts")}`, - `${pythonCmd} -m venv env`, - ].join("; "); + if (checkEnvExists()) { + console.log("Python env already exists, skipping..."); + } else { + // Assemble the command to create the env + const createEnvCommand = [ + `cd ${path.join(getExtensionUri().fsPath, "scripts")}`, + `${pythonCmd} -m venv env`, + ].join("; "); - // Repeat until it is successfully created (sometimes it fails to generate the bin, need to try again) - while (true) { - const [, stderr] = await runCommand(createEnvCommand); - if (stderr) { - throw new Error(stderr); - } - if (checkEnvExists()) { - break; - } else { - // Remove the env and try again - const removeCommand = `rm -rf ${path.join( - getExtensionUri().fsPath, - "scripts", - "env" - )}`; - await runCommand(removeCommand); + // Repeat until it is successfully created (sometimes it fails to generate the bin, need to try again) + while (true) { + const [, stderr] = await runCommand(createEnvCommand); + if (stderr) { + throw new Error(stderr); + } + if (checkEnvExists()) { + break; + } else { + // Remove the env and try again + const removeCommand = `rm -rf ${path.join( + getExtensionUri().fsPath, + "scripts", + "env" + )}`; + await runCommand(removeCommand); + } } + console.log( + "Successfully set up python env at ", + getExtensionUri().fsPath + "/scripts/env" + ); } - console.log( - "Successfully set up python env at ", - getExtensionUri().fsPath + "/scripts/env" - ); - const installRequirementsCommand = [ - `cd ${path.join(getExtensionUri().fsPath, "scripts")}`, - activateCmd, - pipUpgradeCmd, - `${pipCmd} install -r requirements.txt`, - ].join(" ; "); - const [, stderr] = await runCommand(installRequirementsCommand); - if (stderr) { - throw new Error(stderr); + 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); + } } } -- cgit v1.2.3-70-g09d2 From 292d4d10ce28d720d61f97918c490b0d9cdae9e7 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 26 Jun 2023 14:50:04 -0700 Subject: retry setup patch --- extension/package-lock.json | 4 +- extension/package.json | 2 +- extension/react-app/src/tabs/gui.tsx | 4 +- extension/scripts/.continue_env_installed | 0 extension/scripts/.gitignore | 4 +- .../scripts/continuedev-0.1.1-py3-none-any.whl | Bin 89627 -> 0 bytes extension/src/activation/environmentSetup.ts | 108 +++++++++++++-------- 7 files changed, 73 insertions(+), 49 deletions(-) delete mode 100644 extension/scripts/.continue_env_installed delete mode 100644 extension/scripts/continuedev-0.1.1-py3-none-any.whl (limited to 'extension/src/activation') 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" && ( <> -

- Trying to reconnect with server... -

+

Loading Continue server...

)} {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 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.whl deleted file mode 100644 index 4d1c8fb2..00000000 Binary files a/extension/scripts/continuedev-0.1.1-py3-none-any.whl and /dev/null differ 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, + retries: number = MAX_RETRIES +): Promise { + 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(); } - } + }); }); } -- cgit v1.2.3-70-g09d2