left panel

This commit is contained in:
Nate Sesti 2023-06-15 08:57:55 -07:00
parent 0eb6d13e2c
commit 0c33de59e4
4 changed files with 66 additions and 79 deletions

View file

@ -20,7 +20,19 @@
"vscode": "^1.74.0"
},
"categories": [
"Other"
"Other",
"Education",
"Machine Learning"
],
"keywords": [
"openai",
"chatbot",
"chatgpt",
"autocomplete",
"llm",
"ai",
"assistant",
"chat"
],
"activationEvents": [
"onStartupFinished",
@ -68,20 +80,24 @@
}
],
"menus": {
"view/title": [
"view/title": []
},
"viewsContainers": {
"activitybar": [
{
"command": "continue.openContinueGUI",
"group": "navigation",
"when": "view == continue.continueGUIView"
"id": "continue",
"title": "Continue",
"icon": "media/continue-gradient.png"
}
]
},
"views": {
"explorer": [
"continue": [
{
"type": "webview",
"id": "continue.continueGUIView",
"name": "Continue GUI"
"name": "Continue GUI",
"visibility": "visible"
}
]
}

View file

@ -7,7 +7,7 @@ import * as path from "path";
// import { openCapturedTerminal } from "../terminal/terminalEmulator";
import IdeProtocolClient from "../continueIdeClient";
import { getContinueServerUrl } from "../bridge";
import { setupDebugPanel } from "../debugPanel";
import { setupDebugPanel, ContinueGUIWebviewViewProvider } from "../debugPanel";
export let extensionContext: vscode.ExtensionContext | undefined = undefined;
@ -31,44 +31,21 @@ export function activateExtension(
context
);
if (showTutorial && false) {
Promise.all([
vscode.workspace
.openTextDocument(
path.join(getExtensionUri().fsPath, "examples/python/sum.py")
)
.then((document) =>
vscode.window.showTextDocument(document, {
preview: false,
viewColumn: vscode.ViewColumn.One,
})
),
// Setup the left panel
(async () => {
const sessionId = await ideProtocolClient.getSessionId();
const provider = new ContinueGUIWebviewViewProvider(sessionId);
vscode.workspace
.openTextDocument(
path.join(getExtensionUri().fsPath, "examples/python/main.py")
)
.then((document) =>
vscode.window
.showTextDocument(document, {
preview: false,
viewColumn: vscode.ViewColumn.One,
})
.then((editor) => {
editor.revealRange(
new vscode.Range(0, 0, 0, 0),
vscode.TextEditorRevealType.InCenter
);
})
),
]).then(() => {
ideProtocolClient?.openGUI();
});
} else {
ideProtocolClient.openGUI().then(() => {
// openCapturedTerminal();
});
}
context.subscriptions.push(
vscode.window.registerWebviewViewProvider(
"continue.continueGUIView",
provider,
{
webviewOptions: { retainContextWhenHidden: true },
}
)
);
})();
extensionContext = context;
}

View file

@ -17,7 +17,6 @@ import { decorationManager } from "./decorations";
class IdeProtocolClient {
private messenger: WebsocketMessenger | null = null;
private panels: Map<string, vscode.WebviewPanel> = new Map();
private readonly context: vscode.ExtensionContext;
private _makingEdit = 0;
@ -214,35 +213,18 @@ class IdeProtocolClient {
// ------------------------------------ //
// Initiate Request
closeGUI(sessionId: string) {
this.panels.get(sessionId)?.dispose();
this.panels.delete(sessionId);
async openGUI(asRightWebviewPanel: boolean = false) {
// Open the webview panel
}
async openGUI() {
console.log("OPENING GUI");
async getSessionId(): Promise<string> {
if (this.messenger === null) {
console.log("MESSENGER IS NULL");
}
const resp = await this.messenger?.sendAndReceive("openGUI", {});
const sessionId = resp.sessionId;
console.log("SESSION ID", sessionId);
const column = getRightViewColumn();
const panel = vscode.window.createWebviewPanel(
"continue.debugPanelView",
"Continue",
column,
{
enableScripts: true,
retainContextWhenHidden: true,
}
);
// And set its HTML content
panel.webview.html = setupDebugPanel(panel, this.context, sessionId);
this.panels.set(sessionId, panel);
console.log("New Continue session with ID: ", sessionId);
return sessionId;
}
acceptRejectSuggestion(accept: boolean, key: SuggestionRanges) {

View file

@ -136,7 +136,6 @@ let streamManager = new StreamManager();
export let debugPanelWebview: vscode.Webview | undefined;
export function setupDebugPanel(
panel: vscode.WebviewPanel | vscode.WebviewView,
context: vscode.ExtensionContext | undefined,
sessionId: string
): string {
debugPanelWebview = panel.webview;
@ -165,6 +164,11 @@ export function setupDebugPanel(
.toString();
}
panel.webview.options = {
enableScripts: true,
localResourceRoots: [vscode.Uri.joinPath(extensionUri, "react-app/dist")],
};
const nonce = getNonce();
vscode.window.onDidChangeTextEditorSelection((e) => {
@ -488,13 +492,21 @@ export function setupDebugPanel(
</html>`;
}
// class ContinueGUIWebviewViewProvider implements vscode.WebviewViewProvider {
// public static readonly viewType = "continue.continueGUIView";
// resolveWebviewView(
// webviewView: vscode.WebviewView,
// context: vscode.WebviewViewResolveContext<unknown>,
// token: vscode.CancellationToken
// ): void | Thenable<void> {
// setupDebugPanel(webviewView, context, sessionId);
// }
// }
export class ContinueGUIWebviewViewProvider
implements vscode.WebviewViewProvider
{
public static readonly viewType = "continue.continueGUIView";
private readonly sessionId: string;
constructor(sessionId: string) {
this.sessionId = sessionId;
}
resolveWebviewView(
webviewView: vscode.WebviewView,
_context: vscode.WebviewViewResolveContext,
_token: vscode.CancellationToken
): void | Thenable<void> {
webviewView.webview.html = setupDebugPanel(webviewView, this.sessionId);
}
}