diff --git a/extension/react-app/src/components/Layout.tsx b/extension/react-app/src/components/Layout.tsx index a54c0ed48..e0733a549 100644 --- a/extension/react-app/src/components/Layout.tsx +++ b/extension/react-app/src/components/Layout.tsx @@ -131,6 +131,20 @@ const Layout = () => { }; }, [client, timeline]); + useEffect(() => { + const handler = (event: any) => { + if (event.data.type === "addModel") { + navigate("/models"); + } else if (event.data.type === "openSettings") { + navigate("/settings"); + } + }; + window.addEventListener("message", handler); + return () => { + window.removeEventListener("message", handler); + }; + }, []); + return (
any } = { vscode.commands.executeCommand("continue.continueGUIView.focus"); await ideProtocolClient.debugTerminal(); }, + + // Commands without keyboard shortcuts + "continue.addModel": () => { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + debugPanelWebview?.postMessage({ + type: "addModel", + }); + }, + "continue.openSettingsUI": () => { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + debugPanelWebview?.postMessage({ + type: "openSettings", + }); + }, }; export function registerAllCommands(context: vscode.ExtensionContext) { diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts index ec03f73e8..6cd9f38cb 100644 --- a/extension/src/lang-server/codeLens.ts +++ b/extension/src/lang-server/codeLens.ts @@ -4,6 +4,7 @@ import * as path from "path"; import * as os from "os"; import { DIFF_DIRECTORY, diffManager } from "../diffs"; import { getMetaKeyLabel } from "../util/util"; +import { debugPanelWebview } from "../debugPanel"; class SuggestionsCodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses( document: vscode.TextDocument, @@ -82,8 +83,61 @@ class DiffViewerCodeLensProvider implements vscode.CodeLensProvider { } } +class ConfigPyCodeLensProvider implements vscode.CodeLensProvider { + public provideCodeLenses( + document: vscode.TextDocument, + _: vscode.CancellationToken + ): vscode.CodeLens[] | Thenable { + const codeLenses: vscode.CodeLens[] = []; + + if ( + !document.uri.fsPath.endsWith(".continue/config.py") && + !document.uri.fsPath.endsWith(".continue\\config.py") + ) { + return codeLenses; + } + + const lines = document.getText().split(os.EOL); + const lineOfModels = lines.findIndex((line) => + line.includes("models=Models(") + ); + + if (lineOfModels >= 0) { + const range = new vscode.Range(lineOfModels, 0, lineOfModels + 1, 0); + codeLenses.push( + new vscode.CodeLens(range, { + title: `+ Add a Model`, + command: "continue.addModel", + }) + ); + } + + const lineOfSystemMessage = lines.findIndex((line) => + line.includes("system_message=") + ); + + if (lineOfSystemMessage >= 0) { + const range = new vscode.Range( + lineOfSystemMessage, + 0, + lineOfSystemMessage + 1, + 0 + ); + codeLenses.push( + new vscode.CodeLens(range, { + title: `✏️ Edit in UI`, + command: "continue.openSettingsUI", + }) + ); + } + + return codeLenses; + } +} + let diffsCodeLensDisposable: vscode.Disposable | undefined = undefined; let suggestionsCodeLensDisposable: vscode.Disposable | undefined = undefined; +let configPyCodeLensDisposable: vscode.Disposable | undefined = undefined; export function registerAllCodeLensProviders(context: vscode.ExtensionContext) { if (suggestionsCodeLensDisposable) { @@ -92,6 +146,9 @@ export function registerAllCodeLensProviders(context: vscode.ExtensionContext) { if (diffsCodeLensDisposable) { diffsCodeLensDisposable.dispose(); } + if (configPyCodeLensDisposable) { + configPyCodeLensDisposable.dispose(); + } suggestionsCodeLensDisposable = vscode.languages.registerCodeLensProvider( "*", new SuggestionsCodeLensProvider() @@ -100,6 +157,11 @@ export function registerAllCodeLensProviders(context: vscode.ExtensionContext) { "*", new DiffViewerCodeLensProvider() ); + configPyCodeLensDisposable = vscode.languages.registerCodeLensProvider( + "*", + new ConfigPyCodeLensProvider() + ); context.subscriptions.push(suggestionsCodeLensDisposable); context.subscriptions.push(diffsCodeLensDisposable); + context.subscriptions.push(configPyCodeLensDisposable); } diff --git a/server/continuedev/server/meilisearch_server.py b/server/continuedev/server/meilisearch_server.py index 6ce4d61c5..93761ce1e 100644 --- a/server/continuedev/server/meilisearch_server.py +++ b/server/continuedev/server/meilisearch_server.py @@ -28,9 +28,9 @@ async def download_meilisearch(): """ serverPath = getServerFolderPath() - logger.debug("Downloading MeiliSearch...") if os.name == "nt": + logger.debug("Downloading MeiliSearch for Windows...") download_url = "https://github.com/meilisearch/meilisearch/releases/download/v1.3.2/meilisearch-windows-amd64.exe" download_path = getMeilisearchExePath() if not os.path.exists(download_path): @@ -42,6 +42,7 @@ async def download_meilisearch(): # cwd=serverPath, # ) else: + logger.debug("Downloading MeiliSearch with curl...") subprocess.run( "curl -L https://install.meilisearch.com | sh", shell=True,