diff options
Diffstat (limited to 'extension/src')
| -rw-r--r-- | extension/src/activation/activate.ts | 103 | ||||
| -rw-r--r-- | extension/src/activation/environmentSetup.ts | 19 | ||||
| -rw-r--r-- | extension/src/commands.ts | 3 | ||||
| -rw-r--r-- | extension/src/continueIdeClient.ts | 18 | ||||
| -rw-r--r-- | extension/src/debugPanel.ts | 13 | ||||
| -rw-r--r-- | extension/src/lang-server/codeActions.ts | 5 | ||||
| -rw-r--r-- | extension/src/suggestions.ts | 3 | ||||
| -rw-r--r-- | extension/src/telemetry.ts | 53 | 
8 files changed, 74 insertions, 143 deletions
| diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index a7f6c55b..a1d88a31 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -1,7 +1,4 @@  import * as vscode from "vscode"; -import { registerAllCommands } from "../commands"; -import { registerAllCodeLensProviders } from "../lang-server/codeLens"; -import { sendTelemetryEvent, TelemetryEvent } from "../telemetry";  import IdeProtocolClient from "../continueIdeClient";  import { getContinueServerUrl } from "../bridge";  import { ContinueGUIWebviewViewProvider } from "../debugPanel"; @@ -10,8 +7,6 @@ import {    startContinuePythonServer,  } from "./environmentSetup";  import fetch from "node-fetch"; -import registerQuickFixProvider from "../lang-server/codeActions"; -// import { CapturedTerminal } from "../terminal/terminalEmulator";  const PACKAGE_JSON_RAW_GITHUB_URL =    "https://raw.githubusercontent.com/continuedev/continue/HEAD/extension/package.json"; @@ -37,60 +32,60 @@ export async function activateExtension(context: vscode.ExtensionContext) {      .catch((e) => console.log("Error checking for extension updates: ", e));    // Start the server and display loader if taking > 2 seconds -  await new Promise((resolve) => { -    let serverStarted = false; +  const sessionIdPromise = (async () => { +    await new Promise((resolve) => { +      let serverStarted = false; -    // Start the server and set serverStarted to true when done -    startContinuePythonServer().then(() => { -      serverStarted = true; -      resolve(null); -    }); +      // Start the server and set serverStarted to true when done +      startContinuePythonServer().then(() => { +        serverStarted = true; +        resolve(null); +      }); -    // Wait for 2 seconds -    setTimeout(() => { -      // If the server hasn't started after 2 seconds, show the notification -      if (!serverStarted) { -        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) => { -            // Wait for the server to start -            while (!serverStarted) { -              await new Promise((innerResolve) => -                setTimeout(innerResolve, 1000) -              ); +      // Wait for 2 seconds +      setTimeout(() => { +        // If the server hasn't started after 2 seconds, show the notification +        if (!serverStarted) { +          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) => { +              // Wait for the server to start +              while (!serverStarted) { +                await new Promise((innerResolve) => +                  setTimeout(innerResolve, 1000) +                ); +              } +              return Promise.resolve();              } -            return Promise.resolve(); -          } -        ); -      } -    }, 2000); -  }); +          ); +        } +      }, 2000); +    }); -  // Initialize IDE Protocol Client -  const serverUrl = getContinueServerUrl(); -  ideProtocolClient = new IdeProtocolClient( -    `${serverUrl.replace("http", "ws")}/ide/ws`, -    context -  ); +    // Initialize IDE Protocol Client +    const serverUrl = getContinueServerUrl(); +    ideProtocolClient = new IdeProtocolClient( +      `${serverUrl.replace("http", "ws")}/ide/ws`, +      context +    ); +    return await ideProtocolClient.getSessionId(); +  })();    // Register Continue GUI as sidebar webview, and beging a new session -  { -    const sessionIdPromise = await ideProtocolClient.getSessionId(); -    const provider = new ContinueGUIWebviewViewProvider(sessionIdPromise); +  const provider = new ContinueGUIWebviewViewProvider(sessionIdPromise); -    context.subscriptions.push( -      vscode.window.registerWebviewViewProvider( -        "continue.continueGUIView", -        provider, -        { -          webviewOptions: { retainContextWhenHidden: true }, -        } -      ) -    ); -  } +  context.subscriptions.push( +    vscode.window.registerWebviewViewProvider( +      "continue.continueGUIView", +      provider, +      { +        webviewOptions: { retainContextWhenHidden: true }, +      } +    ) +  );  } diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index c341db39..5a9345a6 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -9,7 +9,6 @@ import fetch from "node-fetch";  import * as vscode from "vscode";  import * as os from "os";  import fkill from "fkill"; -import { sendTelemetryEvent, TelemetryEvent } from "../telemetry";  const WINDOWS_REMOTE_SIGNED_SCRIPTS_ERROR =    "A Python virtual enviroment cannot be activated because running scripts is disabled for this user. In order to use Continue, please enable signed scripts to run with this command in PowerShell: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`, reload VS Code, and then try again."; @@ -57,9 +56,6 @@ async function retryThenFail(        vscode.window.showErrorMessage(msg);      } -    sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { -      error: e.message, -    });      throw e;    }  } @@ -83,12 +79,6 @@ async function runCommand(cmd: string): Promise<[string, string | undefined]> {      stdout = "";    } -  if (stderr) { -    sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { -      error: stderr, -    }); -  } -    return [stdout, stderr];  } @@ -139,7 +129,7 @@ export async function getPythonPipCommands() {      if (!versionExists) {        vscode.window.showErrorMessage( -        "Continue requires Python3 version 3.8 or greater. Please update your Python3 installation, reload VS Code, and try again." +        "Continue requires Python version 3.8 or greater. Please update your Python installation, reload VS Code, and try again."        );        throw new Error("Python3.8 or greater is not installed.");      } @@ -480,16 +470,11 @@ export async function startContinuePythonServer() {              console.log("Successfully started Continue python server");              resolve(null);            } else if (data.includes("ERROR") || data.includes("Traceback")) { -            sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { -              error: data, -            }); +            console.log("Error starting Continue python server: ", data);            }          });          child.on("error", (error: any) => {            console.log(`error: ${error.message}`); -          sendTelemetryEvent(TelemetryEvent.ExtensionSetupError, { -            error: error.message, -          });          });          // Write the current version of vscode to a file called server_version.txt diff --git a/extension/src/commands.ts b/extension/src/commands.ts index 2b7f4c0c..1da2f04e 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -40,6 +40,9 @@ const commandsMap: { [command: string]: (...args: any) => any } = {          edit ? "/edit " : ""        }${code}\n\nHow do I fix this problem in the above code?: ${message}`      ); +    if (!edit) { +      vscode.commands.executeCommand("continue.continueGUIView.focus"); +    }    },    "continue.focusContinueInput": async () => {      if (focusedOnContinueInput) { diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index a1370a01..802afc1d 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -16,7 +16,6 @@ import fs = require("fs");  import { WebsocketMessenger } from "./util/messenger";  import { diffManager } from "./diffs";  import path = require("path"); -import { sendTelemetryEvent, TelemetryEvent } from "./telemetry";  import { registerAllCodeLensProviders } from "./lang-server/codeLens";  import { registerAllCommands } from "./commands";  import registerQuickFixProvider from "./lang-server/codeActions"; @@ -81,7 +80,6 @@ class IdeProtocolClient {      this._newWebsocketMessenger();      // Register commands and providers -    sendTelemetryEvent(TelemetryEvent.ExtensionActivated);      registerAllCodeLensProviders(context);      registerAllCommands(context);      registerQuickFixProvider(); @@ -167,6 +165,22 @@ class IdeProtocolClient {          documentContentProvider        )      ); + +    // Listen for changes to settings.json +    vscode.workspace.onDidChangeConfiguration((event) => { +      if (event.affectsConfiguration("continue")) { +        vscode.window +          .showInformationMessage( +            "Please reload VS Code for changes to Continue settings to take effect.", +            "Reload" +          ) +          .then((selection) => { +            if (selection === "Reload") { +              vscode.commands.executeCommand("workbench.action.reloadWindow"); +            } +          }); +      } +    });    }    async handleMessage( diff --git a/extension/src/debugPanel.ts b/extension/src/debugPanel.ts index dd24a8d8..f97cf846 100644 --- a/extension/src/debugPanel.ts +++ b/extension/src/debugPanel.ts @@ -181,19 +181,6 @@ export function setupDebugPanel(              .getConfiguration("continue")              .get<boolean>("dataSwitch"),          }); - -        // // Listen for changes to server URL in settings -        // vscode.workspace.onDidChangeConfiguration((event) => { -        //   if (event.affectsConfiguration("continue.serverUrl")) { -        //     debugPanelWebview?.postMessage({ -        //       type: "onLoad", -        //       vscMachineId: vscode.env.machineId, -        //       apiUrl: getContinueServerUrl(), -        //       sessionId, -        //     }); -        //   } -        // }); -          break;        }        case "toggleDataSwitch": { diff --git a/extension/src/lang-server/codeActions.ts b/extension/src/lang-server/codeActions.ts index f0d61ace..892c69be 100644 --- a/extension/src/lang-server/codeActions.ts +++ b/extension/src/lang-server/codeActions.ts @@ -39,7 +39,10 @@ class ContinueQuickFixProvider implements vscode.CodeActionProvider {        };        return quickFix;      }; -    return [createQuickFix(true), createQuickFix(false)]; +    return [ +      // createQuickFix(true), +      createQuickFix(false), +    ];    }  } diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts index c2373223..5c2b8860 100644 --- a/extension/src/suggestions.ts +++ b/extension/src/suggestions.ts @@ -1,5 +1,4 @@  import * as vscode from "vscode"; -import { sendTelemetryEvent, TelemetryEvent } from "./telemetry";  import { openEditorAndRevealRange } from "./util/vscode";  import { translate } from "./util/vscode";  import { registerAllCodeLensProviders } from "./lang-server/codeLens"; @@ -244,7 +243,6 @@ function selectSuggestion(  }  export function acceptSuggestionCommand(key: SuggestionRanges | null = null) { -  sendTelemetryEvent(TelemetryEvent.SuggestionAccepted);    selectSuggestion("selected", key);  } @@ -271,7 +269,6 @@ export function rejectAllSuggestionsCommand() {  export async function rejectSuggestionCommand(    key: SuggestionRanges | null = null  ) { -  sendTelemetryEvent(TelemetryEvent.SuggestionRejected);    selectSuggestion("old", key);  } diff --git a/extension/src/telemetry.ts b/extension/src/telemetry.ts deleted file mode 100644 index db5cb8ca..00000000 --- a/extension/src/telemetry.ts +++ /dev/null @@ -1,53 +0,0 @@ -import * as Segment from "@segment/analytics-node"; -import * as vscode from "vscode"; - -// Setup Segment -const SEGMENT_WRITE_KEY = "57yy2uYXH2bwMuy7djm9PorfFlYqbJL1"; -const analytics = new Segment.Analytics({ writeKey: SEGMENT_WRITE_KEY }); -analytics.identify({ -  userId: vscode.env.machineId, -  //   traits: { -  //     name: "Michael Bolton", -  //     email: "mbolton@example.com", -  //     createdAt: new Date("2014-06-14T02:00:19.467Z"), -  //   }, -}); - -// Enum of telemetry events -export enum TelemetryEvent { -  // Extension has been activated -  ExtensionActivated = "ExtensionActivated", -  // Suggestion has been accepted -  SuggestionAccepted = "SuggestionAccepted", -  // Suggestion has been rejected -  SuggestionRejected = "SuggestionRejected", -  // Queried universal prompt -  UniversalPromptQuery = "UniversalPromptQuery", -  // `Explain Code` button clicked -  ExplainCode = "ExplainCode", -  // `Generate Ideas` button clicked -  GenerateIdeas = "GenerateIdeas", -  // `Suggest Fix` button clicked -  SuggestFix = "SuggestFix", -  // `Create Test` button clicked -  CreateTest = "CreateTest", -  // `AutoDebug This Test` button clicked -  AutoDebugThisTest = "AutoDebugThisTest", -  // Command run to generate docstring -  GenerateDocstring = "GenerateDocstring", -  // Error setting up the extension -  ExtensionSetupError = "ExtensionSetupError", -} - -export function sendTelemetryEvent( -  event: TelemetryEvent, -  properties?: Record<string, any> -) { -  if (!vscode.env.isTelemetryEnabled) return; - -  analytics.track({ -    event, -    userId: vscode.env.machineId, -    properties, -  }); -} | 
