diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 69672bcb2..bd9914079 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -71,6 +71,36 @@ async function openTutorial(context: vscode.ExtensionContext) { } } +function showRefactorMigrationMessage() { + // Only if the vscode setting continue.manuallyRunningSserver is true + const manuallyRunningServer = + vscode.workspace + .getConfiguration("continue") + .get("manuallyRunningServer") || false; + if ( + manuallyRunningServer && + extensionContext?.globalState.get( + "continue.showRefactorMigrationMessage" + ) !== false + ) { + vscode.window + .showInformationMessage( + "The Continue server protocol was recently updated in a way that requires the latest server version to work properly. Since you are manually running the server, please be sure to upgrade with `pip install --upgrade continuedev`.", + "Got it", + "Don't show again" + ) + .then((selection) => { + if (selection === "Don't show again") { + // Get the global state + extensionContext?.globalState.update( + "continue.showRefactorMigrationMessage", + false + ); + } + }); + } +} + export async function activateExtension(context: vscode.ExtensionContext) { extensionContext = context; @@ -92,6 +122,7 @@ export async function activateExtension(context: vscode.ExtensionContext) { addPythonPathForConfig(); await openTutorial(context); setupInlineTips(context); + showRefactorMigrationMessage(); (async () => { // Start the server diff --git a/extensions/vscode/src/continueIdeClient.ts b/extensions/vscode/src/continueIdeClient.ts index 43d36ba87..bb6937a58 100644 --- a/extensions/vscode/src/continueIdeClient.ts +++ b/extensions/vscode/src/continueIdeClient.ts @@ -22,6 +22,7 @@ const path = require("path"); import { v4 } from "uuid"; import { windowId } from "./activation/activate"; import * as io from "socket.io-client"; +import { debugPanelWebview } from "./debugPanel"; const continueVirtualDocumentScheme = "continue"; @@ -711,7 +712,10 @@ class IdeProtocolClient { } sendMainUserInput(input: string) { - this.send("mainUserInput", v4(), { input }); + debugPanelWebview?.postMessage({ + type: "userInput", + input, + }); } async debugTerminal() { diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index fe5fc4638..2abdcc70f 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -1,6 +1,7 @@ from typing import Dict, List, Optional, Type from ..libs.util.edit_config import ( + create_bool_node, create_obj_node, display_llm_class, edit_config_property, @@ -217,3 +218,10 @@ class ContinueConfig(BaseModel): ["models"], create_obj_node("Models", models_args), ) + + @staticmethod + def set_telemetry_enabled(enabled: bool): + edit_config_property( + ["allow_anonymous_telemetry"], + create_bool_node(enabled), + ) diff --git a/server/continuedev/libs/util/edit_config.py b/server/continuedev/libs/util/edit_config.py index 1763b4c02..a54c89e55 100644 --- a/server/continuedev/libs/util/edit_config.py +++ b/server/continuedev/libs/util/edit_config.py @@ -147,6 +147,10 @@ def create_literal_node(literal: str) -> redbaron.RedBaron: return redbaron.RedBaron(literal)[0] +def create_bool_node(bool: bool) -> redbaron.RedBaron: + return redbaron.RedBaron(str(bool))[0] + + def create_float_node(float: float) -> redbaron.RedBaron: return redbaron.RedBaron(f"{float}")[0] diff --git a/server/continuedev/server/protocols/ide.py b/server/continuedev/server/protocols/ide.py index d536affd3..23fac5774 100644 --- a/server/continuedev/server/protocols/ide.py +++ b/server/continuedev/server/protocols/ide.py @@ -168,8 +168,6 @@ class IdeProtocolServer(AbstractIdeProtocolServer): self.onAcceptRejectSuggestion(data["accepted"]) elif msg.message_type == "acceptRejectDiff": self.onAcceptRejectDiff(data["accepted"], data["stepIndex"]) - elif msg.message_type == "mainUserInput": - self.onMainUserInput(data["input"]) elif msg.message_type in [ "highlightedCode", "openFiles", @@ -234,17 +232,6 @@ class IdeProtocolServer(AbstractIdeProtocolServer): "setSuggestionsLocked", {"filepath": filepath, "locked": locked} ) - def onTelemetryEnabledChanged(self, enabled: bool): - if autopilot := self.__get_autopilot(): - - async def change_telemetry(): - await autopilot.set_config_attr( - ["allow_anonymous_telemetry"], "True" if enabled else "False" - ) - await autopilot.sdk.load() - - create_async_task(change_telemetry(), self.on_error) - async def highlightCode(self, range_in_file: RangeInFile, color: str = "#00ff0022"): await self.messenger.send( "highlightCode", {"rangeInFile": range_in_file.dict(), "color": color} @@ -274,13 +261,6 @@ class IdeProtocolServer(AbstractIdeProtocolServer): # Access to Autopilot (so SessionManager) pass - def onCloseGUI(self, session_id: str): - # Access to SessionManager - pass - - def onOpenGUIRequest(self): - pass - def onFileEdits(self, edits: List[FileEditWithFullContents]): pass @@ -300,6 +280,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer): _files_renamed_callbacks = [] _file_saved_callbacks = [] _debug_terminal_callbacks = [] + _telemetry_enabled_callbacks = [] def call_callback(self, callback, *args, **kwargs): if asyncio.iscoroutinefunction(callback): @@ -307,6 +288,9 @@ class IdeProtocolServer(AbstractIdeProtocolServer): else: callback(*args, **kwargs) + def subscribeToTelemetryEnabled(self, callback: Callable[[bool], None]): + self._telemetry_enabled_callbacks.append(callback) + def subscribeToDebugTerminal(self, callback: Callable[[str], None]): self._debug_terminal_callbacks.append(callback) @@ -327,6 +311,10 @@ class IdeProtocolServer(AbstractIdeProtocolServer): def subscribeToFileSaved(self, callback: Callable[[str, str], None]): self._file_saved_callbacks.append(callback) + def onTelemetryEnabledChanged(self, enabled: bool): + for callback in self._telemetry_enabled_callbacks: + self.call_callback(callback, enabled) + def onDebugTerminal(self, content: str): for callback in self._debug_terminal_callbacks: self.call_callback(callback, content) diff --git a/server/continuedev/server/protocols/ide_protocol.py b/server/continuedev/server/protocols/ide_protocol.py index 6a027ec85..26869def4 100644 --- a/server/continuedev/server/protocols/ide_protocol.py +++ b/server/continuedev/server/protocols/ide_protocol.py @@ -46,14 +46,6 @@ class AbstractIdeProtocolServer(ABC): def onFileSystemUpdate(self, update: FileSystemEdit): """Called when a file system update is received""" - @abstractmethod - def onCloseGUI(self, session_id: str): - """Called when a GUI is closed""" - - @abstractmethod - def onOpenGUIRequest(self): - """Called when a GUI is requested to be opened""" - @abstractmethod async def getOpenFiles(self) -> List[str]: """Get a list of open files""" diff --git a/server/continuedev/server/window_manager.py b/server/continuedev/server/window_manager.py index 104353173..6414e7567 100644 --- a/server/continuedev/server/window_manager.py +++ b/server/continuedev/server/window_manager.py @@ -135,6 +135,12 @@ class Window: self.ide.subscribeToDebugTerminal(onDebugCallback) + def onTelemetryChangeCallback(enabled: bool): + self.config.allow_anonymous_telemetry = enabled + ContinueConfig.set_telemetry_enabled(enabled) + + self.ide.subscribeToTelemetryEnabled(onTelemetryChangeCallback) + # # Subscribe to highlighted code, pass to the context manager # def onHighlightedCodeCallback( # range_in_files: List[RangeInFileWithContents], edit: bool