feat: ✨ codelens in config.py
This commit is contained in:
parent
e2d0baf393
commit
58cd4db253
4 changed files with 92 additions and 1 deletions
|
|
@ -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 (
|
||||
<LayoutTopDiv>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -100,6 +100,20 @@ const commandsMap: { [command: string]: (...args: any) => 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) {
|
||||
|
|
|
|||
|
|
@ -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<vscode.CodeLens[]> {
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue