From 069997de3e66b552a3e2f28f90e4a687aa073fcf Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 5 Dec 2023 14:46:50 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20JetBrains=20up=20to=20date,=20many?= =?UTF-8?q?=20bug=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changes/extensions/intellij/v0.0.21.md | 5 ++ extensions/intellij/CHANGELOG.md | 6 ++ extensions/intellij/gradle.properties | 5 +- .../actions/ContinuePluginActions.kt | 14 ++++ .../continue/IdeProtocolClient.kt | 2 +- .../ContinuePluginToolWindowFactory.kt | 26 ++++--- .../src/main/resources/META-INF/plugin.xml | 14 +++- extensions/vscode/config_schema.json | 3 +- extensions/vscode/src/debugPanel.ts | 16 +++-- gui/src/components/Layout.tsx | 2 +- gui/src/components/mainInput/ComboBox.tsx | 4 ++ gui/src/pages/gui.tsx | 68 ------------------- server/continuedev/core/autopilot.py | 4 +- server/continuedev/core/main.py | 29 ++++++++ server/continuedev/libs/llm/ggml.py | 9 +-- server/continuedev/libs/llm/hf_tgi.py | 4 +- server/continuedev/libs/llm/llamacpp.py | 4 +- server/continuedev/libs/llm/lmstudio.py | 2 +- server/continuedev/libs/llm/ollama.py | 4 +- server/continuedev/libs/llm/text_gen_webui.py | 4 +- server/continuedev/libs/util/count_tokens.py | 2 +- .../continuedev/server/meilisearch_server.py | 2 +- server/continuedev/server/protocols/gui.py | 22 ++++-- server/continuedev/server/window_manager.py | 7 +- 24 files changed, 144 insertions(+), 114 deletions(-) create mode 100644 .changes/extensions/intellij/v0.0.21.md diff --git a/.changes/extensions/intellij/v0.0.21.md b/.changes/extensions/intellij/v0.0.21.md new file mode 100644 index 000000000..7933cd1b4 --- /dev/null +++ b/.changes/extensions/intellij/v0.0.21.md @@ -0,0 +1,5 @@ +## v0.0.21 - 2023-12-05 + +### Added + +- updated to match latest VS Code updates diff --git a/extensions/intellij/CHANGELOG.md b/extensions/intellij/CHANGELOG.md index 320b9c9db..7770cbd07 100644 --- a/extensions/intellij/CHANGELOG.md +++ b/extensions/intellij/CHANGELOG.md @@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v0.0.21 - 2023-12-05 + +### Added + +- updated to match latest VS Code updates + ## v0.0.19 - 2023-11-19 ### Changed diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 2a93d2ade..553d49447 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -4,15 +4,16 @@ pluginGroup = com.github.continuedev.continueintellijextension pluginName = continue-intellij-extension pluginRepositoryUrl = https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion = 0.0.20 +pluginVersion = 0.0.21 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 223 -pluginUntilBuild = 232.* +#pluginUntilBuild = 232.* # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension platformType = IC platformVersion = 2022.3.3 +#platformVersion = LATEST-EAP-SNAPSHOT # Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html # Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index a61e108c4..8e095ea2d 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -226,4 +226,18 @@ class NewContinueSessionAction : AnAction() { continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus() continuePluginService.dispatchCustomEvent("message", mutableMapOf("type" to "focusContinueInputWithNewSession")) } +} + +class ViewHistoryAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + val project = e.project + if (project != null) { + val toolWindowManager = ToolWindowManager.getInstance(project) + val toolWindow = toolWindowManager.getToolWindow("Continue") + } + + val continuePluginService = pluginServiceFromActionEvent(e) ?: return + + continuePluginService.dispatchCustomEvent("message", mutableMapOf("type" to "viewHistory")) + } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 0ee9e6bec..399e09014 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -285,7 +285,7 @@ class IdeProtocolClient ( version = ideVersion, remote_name = remoteName ?: "" ), - "server_url": getContinueServerUrl() + "server_url" to getContinueServerUrl() ) val requestUrl = "${getContinueServerUrl()}/?window_info=${ diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt index cc253cf4d..3c1596de1 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinuePluginToolWindowFactory.kt @@ -1,10 +1,5 @@ package com.github.continuedev.continueintellijextension.toolWindow -import com.intellij.openapi.diagnostic.thisLogger -import com.intellij.ui.components.JBPanel -import com.intellij.ui.content.ContentFactory -import com.intellij.ui.jcef.JBCefJSQuery -import javax.swing.* import com.github.continuedev.continueintellijextension.activities.getContinueServerUrl import com.github.continuedev.continueintellijextension.`continue`.Position import com.github.continuedev.continueintellijextension.`continue`.Range @@ -12,10 +7,13 @@ import com.github.continuedev.continueintellijextension.`continue`.RangeInFile import com.github.continuedev.continueintellijextension.`continue`.getMachineUniqueID import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory import com.github.continuedev.continueintellijextension.services.ContinuePluginService -import com.github.continuedev.continueintellijextension.utils.runJsInWebview import com.google.gson.Gson import com.google.gson.JsonObject import com.google.gson.JsonParser +import com.intellij.openapi.actionSystem.ActionGroup +import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.ActionToolbar +import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.project.DumbAware @@ -23,17 +21,19 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer import com.intellij.openapi.wm.ToolWindow import com.intellij.openapi.wm.ToolWindowFactory +import com.intellij.ui.content.ContentFactory import com.intellij.ui.jcef.* import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import org.cef.CefApp import org.cef.browser.CefBrowser import org.cef.handler.CefLoadHandlerAdapter -import javax.swing.JComponent +import java.awt.BorderLayout +import javax.swing.* import kotlin.math.max import kotlin.math.min + const val JS_QUERY_POOL_SIZE = "200" class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware { @@ -41,6 +41,16 @@ class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware { val continueToolWindow = ContinuePluginWindow(toolWindow, project) val content = ContentFactory.getInstance().createContent(continueToolWindow.content, null, false) toolWindow.contentManager.addContent(content) + val titleActions = mutableListOf() + createTitleActions(titleActions) + toolWindow.setTitleActions(titleActions) + } + + private fun createTitleActions(titleActions: MutableList) { + val action = ActionManager.getInstance().getAction("ContinueSidebarActionsGroup") + if (action != null) { + titleActions.add(action) + } } override fun shouldBeAvailable(project: Project) = true diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index ba8da55af..872fefd57 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -4,7 +4,7 @@ Continue continue-dev com.intellij.modules.platform - + @@ -87,6 +88,12 @@ first-keystroke="alt meta N"/> + + + + + + + diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 50efe8964..90c454fd6 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -640,7 +640,8 @@ "CommentCodeStep", "ClearHistoryStep", "StackOverflowStep", - "OpenConfigStep" + "OpenConfigStep", + "DraftIssueStep" ], "type": "string" }, diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/debugPanel.ts index daa87e4bf..3d7370667 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/debugPanel.ts @@ -14,24 +14,26 @@ export function getSidebarContent( edits: FileEdit[] | undefined = undefined, isFullScreen: boolean = false ): string { - debugPanelWebview = panel.webview; - panel.onDidDispose(() => { - debugPanelWebview = undefined; - }); + if (!isFullScreen) { + debugPanelWebview = panel.webview; + panel.onDidDispose(() => { + debugPanelWebview = undefined; + }); + } let extensionUri = getExtensionUri(); let scriptUri: string; let styleMainUri: string; - let vscMediaUrl: string = debugPanelWebview + let vscMediaUrl: string = panel.webview .asWebviewUri(vscode.Uri.joinPath(extensionUri, "gui")) .toString(); const isProduction = true; // context?.extensionMode === vscode.ExtensionMode.Development; if (isProduction) { - scriptUri = debugPanelWebview + scriptUri = panel.webview .asWebviewUri(vscode.Uri.joinPath(extensionUri, "gui/assets/index.js")) .toString(); - styleMainUri = debugPanelWebview + styleMainUri = panel.webview .asWebviewUri(vscode.Uri.joinPath(extensionUri, "gui/assets/index.css")) .toString(); } else { diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 4cdb784ba..317ffead8 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -177,7 +177,7 @@ const Layout = () => { return () => { window.removeEventListener("message", handler); }; - }, []); + }, [location, navigate]); return ( diff --git a/gui/src/components/mainInput/ComboBox.tsx b/gui/src/components/mainInput/ComboBox.tsx index fe21ddb98..7c5bf02db 100644 --- a/gui/src/components/mainInput/ComboBox.tsx +++ b/gui/src/components/mainInput/ComboBox.tsx @@ -1080,6 +1080,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { setShowContextItemsIfNotMain(true); } }} + id="snippets-selected-div" style={{ color: lightGray, backgroundColor: vscBackground, @@ -1206,6 +1207,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { topRef.current?.contains(e.relatedTarget as Node) || document .getElementById("toggle-context-div") + ?.contains(e.relatedTarget as Node) || + document + .getElementById("snippets-selected-div") ?.contains(e.relatedTarget as Node) ) { return; diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index 3822cd1dd..102004394 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -591,74 +591,6 @@ function GUI(props: GUIProps) { } }} > - {localStorage.getItem("ide") === "jetbrains" && ( - - { - // Select all text - (e.target as any).setSelectionRange( - 0, - (e.target as any).value.length - ); - }} - value={sessionTitleInput} - onChange={(e) => setSessionTitleInput(e.target.value)} - onBlur={(e) => { - if ( - e.target.value === sessionTitle || - (typeof sessionTitle === "undefined" && - e.target.value === "New Session") - ) - return; - dispatch(setTitle(e.target.value)); - }} - onKeyDown={(e) => { - if (e.key === "Enter") { - e.preventDefault(); - (e.target as any).blur(); - } else if (e.key === "Escape") { - setSessionTitleInput(sessionTitle || "New Session"); - (e.target as any).blur(); - } - }} - /> -
- {localStorage.getItem("ide") === "vscode" && ( - { - postToIde("toggleFullScreen", {}); - }} - text={`Toggle Full Screen (${getMetaKeyLabel()}K ${getMetaKeyLabel()}M)`} - > - {(window as any).isFullScreen ? ( - - ) : ( - - )} - - )} - { - client?.stopSession(); - client?.persistSession(sessionState, workspacePaths[0] || ""); - dispatch(newSession()); - }} - text={`New Session (⌥${getMetaKeyLabel()}N)`} - > - - - - { - navigate("/history"); - }} - text="History" - > - - -
-
- )} {takenAction && showLoading && typeof client === "undefined" && ( <> diff --git a/server/continuedev/core/autopilot.py b/server/continuedev/core/autopilot.py index 2f88684b6..447e9c9d7 100644 --- a/server/continuedev/core/autopilot.py +++ b/server/continuedev/core/autopilot.py @@ -248,8 +248,8 @@ class Autopilot: index=index, update=SetStep( error=ContinueError( - title=continue_custom_exception.title, - message=continue_custom_exception.message, + title=continue_custom_exception.title or "Error", + message=continue_custom_exception.message or "Error", ), hide=False, ), diff --git a/server/continuedev/core/main.py b/server/continuedev/core/main.py index 0bbcdc5f3..ecfaa9b19 100644 --- a/server/continuedev/core/main.py +++ b/server/continuedev/core/main.py @@ -163,6 +163,20 @@ class StepDescription(BaseModel): for key, value in update.dict(exclude_none=True).items(): setattr(self, key, value) + @staticmethod + def from_empty() -> "StepDescription": + return StepDescription( + step_type="EmptyStep", + name="", + description="", + params={}, + hide=True, + depth=0, + error=None, + observations=[], + logs=[], + ) + class SessionUpdate(BaseModel): index: int @@ -296,6 +310,21 @@ class SessionState(ContinueBaseModel): def from_empty(): return SessionState(history=[], context_items=[]) + @classmethod + def parse_obj(cls, obj: Any): + # Safety net against the client sending malformed data + valid_steps = [] + for step in obj["history"]: + try: + StepDescription.parse_obj(step) + valid_steps.append(step) + except Exception: + valid_steps.append(StepDescription.from_empty()) + + obj["history"] = valid_steps + + return super().parse_obj(obj) + class ContinueSDK: async def run_step(self, step: "Step"): diff --git a/server/continuedev/libs/llm/ggml.py b/server/continuedev/libs/llm/ggml.py index b8343d550..bc8cbddc3 100644 --- a/server/continuedev/libs/llm/ggml.py +++ b/server/continuedev/libs/llm/ggml.py @@ -30,13 +30,13 @@ class GGML(LLM): """ api_base: Optional[str] = Field( - "http://localhost:8000", + "http://127.0.0.1:8000", description="URL of the OpenAI-compatible server where the model is being served", ) @validator("api_base", pre=True, always=True) def set_api_base(cls, api_base): - return api_base or "http://localhost:8000" + return api_base or "http://127.0.0.1:8000" model: str = Field( "ggml", description="The name of the model to use (optional for the GGML class)" @@ -56,9 +56,10 @@ class GGML(LLM): ) chat_endpoint: str = Field( - default="chat/completions", description="The endpoint to call for chat completions" + default="chat/completions", + description="The endpoint to call for chat completions", ) - + completions_endpoint: str = Field( default="completions", description="The endpoint to call for chat completions" ) diff --git a/server/continuedev/libs/llm/hf_tgi.py b/server/continuedev/libs/llm/hf_tgi.py index 2a08c856f..f8faec895 100644 --- a/server/continuedev/libs/llm/hf_tgi.py +++ b/server/continuedev/libs/llm/hf_tgi.py @@ -10,12 +10,12 @@ from .base import LLM, CompletionOptions class HuggingFaceTGI(LLM): model: str = "huggingface-tgi" api_base: Optional[str] = Field( - "http://localhost:8080", description="URL of your TGI server" + "http://127.0.0.1:8080", description="URL of your TGI server" ) @validator("api_base", pre=True, always=True) def set_api_base(cls, api_base): - return api_base or "http://localhost:8080" + return api_base or "http://127.0.0.1:8080" class Config: arbitrary_types_allowed = True diff --git a/server/continuedev/libs/llm/llamacpp.py b/server/continuedev/libs/llm/llamacpp.py index 366d1c88b..891d87a61 100644 --- a/server/continuedev/libs/llm/llamacpp.py +++ b/server/continuedev/libs/llm/llamacpp.py @@ -30,12 +30,12 @@ class LlamaCpp(LLM): model: str = "llamacpp" api_base: Optional[str] = Field( - "http://localhost:8080", description="URL of the server" + "http://127.0.0.1:8080", description="URL of the server" ) @validator("api_base", pre=True, always=True) def set_api_base(cls, api_base): - return api_base or "http://localhost:8080" + return api_base or "http://127.0.0.1:8080" llama_cpp_args: Dict[str, Any] = Field( {"stop": ["[INST]"]}, diff --git a/server/continuedev/libs/llm/lmstudio.py b/server/continuedev/libs/llm/lmstudio.py index a2bcfde3e..46ec43e71 100644 --- a/server/continuedev/libs/llm/lmstudio.py +++ b/server/continuedev/libs/llm/lmstudio.py @@ -4,4 +4,4 @@ from .ggml import GGML class LMStudio(GGML): """LMStudio provides a professional and well-designed GUI for exploring, configuring, and serving LLMs. It is available on both Mac and Windows. To get started:\n1. Download from [lmstudio.ai](https://lmstudio.ai/) and open the application\n2. Search for and download the desired model from the home screen of LMStudio.\n3. In the left-bar, click the '<->' icon to open the Local Inference Server and press 'Start Server'.\n4. Once your model is loaded and the server has started, you can begin using Continue.""" - api_base: str = "http://localhost:1234" + api_base: str = "http://127.0.0.1:1234" diff --git a/server/continuedev/libs/llm/ollama.py b/server/continuedev/libs/llm/ollama.py index 886783126..5d9fa16b6 100644 --- a/server/continuedev/libs/llm/ollama.py +++ b/server/continuedev/libs/llm/ollama.py @@ -26,12 +26,12 @@ class Ollama(LLM): model: str = "llama2" api_base: Optional[str] = Field( - "http://localhost:11434", description="URL of the Ollama server" + "http://127.0.0.1:11434", description="URL of the Ollama server" ) @validator("api_base", pre=True, always=True) def set_api_base(cls, api_base): - return api_base or "http://localhost:11434" + return api_base or "http://127.0.0.1:11434" class Config: arbitrary_types_allowed = True diff --git a/server/continuedev/libs/llm/text_gen_webui.py b/server/continuedev/libs/llm/text_gen_webui.py index b60c4e034..21c1e03d4 100644 --- a/server/continuedev/libs/llm/text_gen_webui.py +++ b/server/continuedev/libs/llm/text_gen_webui.py @@ -25,10 +25,10 @@ class TextGenWebUI(LLM): model: str = "text-gen-webui" api_base: Optional[str] = Field( - "http://localhost:5000", description="URL of your TextGenWebUI server" + "http://127.0.0.1:5000", description="URL of your TextGenWebUI server" ) streaming_url: Optional[str] = Field( - "http://localhost:5005", + "http://127.0.0.1:5005", description="URL of your TextGenWebUI streaming server (separate from main server URL)", ) diff --git a/server/continuedev/libs/util/count_tokens.py b/server/continuedev/libs/util/count_tokens.py index 2306e24d1..c3f75cf53 100644 --- a/server/continuedev/libs/util/count_tokens.py +++ b/server/continuedev/libs/util/count_tokens.py @@ -203,7 +203,7 @@ def prune_chat_history( # In case we've missed weird edge cases -TOKEN_BUFFER_FOR_SAFETY = 100 +TOKEN_BUFFER_FOR_SAFETY = 350 def flatten_messages(msgs: List[ChatMessage]) -> List[ChatMessage]: diff --git a/server/continuedev/server/meilisearch_server.py b/server/continuedev/server/meilisearch_server.py index 2d4fcac10..77d1ef7eb 100644 --- a/server/continuedev/server/meilisearch_server.py +++ b/server/continuedev/server/meilisearch_server.py @@ -190,7 +190,7 @@ def kill_proc(port): try: for conns in proc.connections(kind="inet"): if conns.laddr.port == port: - proc.send_signal(signal.SIGKILL) + proc.send_signal(signal.SIGTERM) except psutil.AccessDenied: logger.warning(f"Failed to kill process on port {port} (access denied)") return diff --git a/server/continuedev/server/protocols/gui.py b/server/continuedev/server/protocols/gui.py index 3187c9737..061d8a7de 100644 --- a/server/continuedev/server/protocols/gui.py +++ b/server/continuedev/server/protocols/gui.py @@ -27,7 +27,7 @@ class GUIProtocolServer(AbstractGUIProtocolServer): window_id: str messenger: SocketIOMessenger - get_autopilot: Callable[[SessionState], Optional[Autopilot]] + get_autopilot: Callable[[SessionState, "GUIProtocolServer"], Optional[Autopilot]] get_context_item: Callable[[str, str], Awaitable[Optional[ContextItem]]] get_config: Callable[[], Optional[ContinueConfig]] reload_config: AsyncFunc @@ -38,7 +38,9 @@ class GUIProtocolServer(AbstractGUIProtocolServer): window_id: str, sio: socketio.AsyncServer, sid: str, - get_autopilot: Callable[[SessionState], Optional[Autopilot]], + get_autopilot: Callable[ + [SessionState, "GUIProtocolServer"], Optional[Autopilot] + ], get_context_item: Callable[[str, str], Awaitable[Optional[ContextItem]]], get_config: Callable[[], Optional[ContinueConfig]], reload_config: Callable, @@ -63,9 +65,15 @@ class GUIProtocolServer(AbstractGUIProtocolServer): return ctx_item.dict() return None elif msg.message_type == "get_session_title": - return await self.get_session_title( - [StepDescription(**step) for step in data["history"]] - ) + # guard against malformed data from the client + valid_steps = [] + for step in data["history"]: + try: + valid_steps.append(StepDescription(**step)) + except Exception: + valid_steps.append(StepDescription.from_empty()) + + return await self.get_session_title(valid_steps) elif msg.message_type == "get_config": if config := self.get_config(): return config.dict() @@ -116,7 +124,7 @@ class GUIProtocolServer(AbstractGUIProtocolServer): _running_autopilots: Dict[str, Autopilot] = {} async def run_from_state(self, state: SessionState, step: Optional[Step] = None): - if autopilot := self.get_autopilot(state): + if autopilot := self.get_autopilot(state, self): if step is not None or len(state.history) > 0: step_to_log = step or state.history[-1] posthog_logger.capture_event( @@ -170,7 +178,7 @@ class GUIProtocolServer(AbstractGUIProtocolServer): async def get_session_title(self, history: List[StepDescription]) -> str: if autopilot := self.get_autopilot( - SessionState(history=history, context_items=[]) + SessionState(history=history, context_items=[]), self ): return await autopilot.get_session_title() else: diff --git a/server/continuedev/server/window_manager.py b/server/continuedev/server/window_manager.py index 2cba8d238..75e3d957d 100644 --- a/server/continuedev/server/window_manager.py +++ b/server/continuedev/server/window_manager.py @@ -52,7 +52,12 @@ class Window: def __init__(self, config: Optional[ContinueConfig] = None) -> None: self.reload_config() - def get_autopilot(self, session_state: SessionState) -> Optional[Autopilot]: + def get_autopilot( + self, session_state: SessionState, gui: GUIProtocolServer + ) -> Optional[Autopilot]: + if self.gui is None: + self.gui = gui + if self.ide is None or self.gui is None or self.config is None: return None