From 721ce6c7992de326f2a4e6bfb9c092247244ce6d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 27 Apr 2024 23:10:09 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20model=20role=20for=20inlineEdit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/index.d.ts | 6 + docs/static/schemas/config.json | 8 + .../src/main/resources/config_schema.json | 8 + extensions/vscode/config_schema.json | 8 + extensions/vscode/continue_rc_schema.json | 8 + extensions/vscode/src/commands.ts | 740 +++++++++--------- 6 files changed, 411 insertions(+), 367 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 456b1dee7..2579b7a06 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -702,8 +702,14 @@ interface ContextMenuConfig { optimize?: string; fixGrammar?: string; } + +interface ModelRoles { + inlineEdit?: string; +} + interface ExperimantalConfig { contextMenuPrompts?: ContextMenuConfig; + modelRoles?: ModelRoles; } export interface SerializedContinueConfig { diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index c5f011a5c..b3042dd49 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1960,6 +1960,14 @@ "title": "Experimental", "description": "Experimental properties are subject to change.", "properties": { + "modelRoles": { + "type": "object", + "properties": { + "inlineEdit": { + "type": "string" + } + } + }, "contextMenuPrompts": { "type": "object", "properties": { diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index c5f011a5c..b3042dd49 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1960,6 +1960,14 @@ "title": "Experimental", "description": "Experimental properties are subject to change.", "properties": { + "modelRoles": { + "type": "object", + "properties": { + "inlineEdit": { + "type": "string" + } + } + }, "contextMenuPrompts": { "type": "object", "properties": { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index c5f011a5c..b3042dd49 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1960,6 +1960,14 @@ "title": "Experimental", "description": "Experimental properties are subject to change.", "properties": { + "modelRoles": { + "type": "object", + "properties": { + "inlineEdit": { + "type": "string" + } + } + }, "contextMenuPrompts": { "type": "object", "properties": { diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index f0e53cad3..0c799523b 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -2199,6 +2199,14 @@ "title": "Experimental", "description": "Experimental properties are subject to change.", "properties": { + "modelRoles": { + "type": "object", + "properties": { + "inlineEdit": { + "type": "string" + } + } + }, "contextMenuPrompts": { "type": "object", "properties": { diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 57e01d9e7..88e786656 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -3,7 +3,7 @@ import * as os from "os"; import * as path from "path"; import * as vscode from "vscode"; -import { IDE } from "core"; +import { ContextMenuConfig, IDE } from "core"; import { AutocompleteOutcome } from "core/autocomplete/completionProvider"; import { ConfigHandler } from "core/config/handler"; import { logDevData } from "core/util/devdata"; @@ -147,389 +147,395 @@ const commandsMap: ( configHandler, diffManager, verticalDiffManager, -) => ({ - "continue.acceptDiff": async (newFilepath?: string | vscode.Uri) => { - if (newFilepath instanceof vscode.Uri) { - newFilepath = newFilepath.fsPath; - } - verticalDiffManager.clearForFilepath(newFilepath, true); - await diffManager.acceptDiff(newFilepath); - }, - "continue.rejectDiff": async (newFilepath?: string | vscode.Uri) => { - if (newFilepath instanceof vscode.Uri) { - newFilepath = newFilepath.fsPath; - } - verticalDiffManager.clearForFilepath(newFilepath, false); - await diffManager.rejectDiff(newFilepath); - }, - "continue.acceptVerticalDiffBlock": (filepath?: string, index?: number) => { - verticalDiffManager.acceptRejectVerticalDiffBlock(true, filepath, index); - }, - "continue.rejectVerticalDiffBlock": (filepath?: string, index?: number) => { - verticalDiffManager.acceptRejectVerticalDiffBlock(false, filepath, index); - }, - "continue.quickFix": async (message: string, code: string, edit: boolean) => { - sidebar.webviewProtocol?.request("newSessionWithPrompt", { - prompt: `${ - edit ? "/edit " : "" - }${code}\n\nHow do I fix this problem in the above code?: ${message}`, - }); - - if (!edit) { - vscode.commands.executeCommand("continue.continueGUIView.focus"); - } - }, - "continue.focusContinueInput": async () => { - if (!getFullScreenTab()) { - vscode.commands.executeCommand("continue.continueGUIView.focus"); - } - sidebar.webviewProtocol?.request("focusContinueInput", undefined); - await addHighlightedCodeToContext(false, sidebar.webviewProtocol); - }, - "continue.focusContinueInputWithoutClear": async () => { - if (!getFullScreenTab()) { - vscode.commands.executeCommand("continue.continueGUIView.focus"); - } - sidebar.webviewProtocol?.request( - "focusContinueInputWithoutClear", - undefined, - ); - await addHighlightedCodeToContext(true, sidebar.webviewProtocol); - }, - "continue.toggleAuxiliaryBar": () => { - vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar"); - }, - "continue.quickEdit": async (prompt?: string) => { - const selectionEmpty = vscode.window.activeTextEditor?.selection.isEmpty; - - const editor = vscode.window.activeTextEditor; - const existingHandler = verticalDiffManager.getHandlerForFile( - editor?.document.uri.fsPath ?? "", - ); - const previousInput = existingHandler?.input; - - let defaultModelTitle = await sidebar.webviewProtocol.request( - "getDefaultModelTitle", - undefined, - ); +) => { + async function streamInlineEdit( + promptName: keyof ContextMenuConfig, + fallbackPrompt: string, + ) { const config = await configHandler.loadConfig(); - if (!defaultModelTitle) { - defaultModelTitle = config.models[0]?.title!; - } - const quickPickItems = - config.contextProviders - ?.filter((provider) => provider.description.type === "normal") - .map((provider) => { - return { - label: provider.description.displayTitle, - description: provider.description.title, - detail: provider.description.description, - }; - }) || []; - - const addContextMsg = quickPickItems.length - ? " (or press enter to add context first)" - : ""; - const textInputOptions: vscode.InputBoxOptions = { - placeHolder: selectionEmpty - ? `Type instructions to generate code${addContextMsg}` - : `Describe how to edit the highlighted code${addContextMsg}`, - title: `${getPlatform() === "mac" ? "Cmd" : "Ctrl"}+I`, - prompt: `[${defaultModelTitle}]`, - value: prompt, - }; - if (previousInput) { - textInputOptions.value = previousInput + ", "; - textInputOptions.valueSelection = [ - textInputOptions.value.length, - textInputOptions.value.length, - ]; - } - - let text = await vscode.window.showInputBox(textInputOptions); - - if (text === undefined) { - return; - } - - if (text.length > 0 || quickPickItems.length === 0) { - const modelName = await sidebar.webviewProtocol.request( + const modelTitle = + config.experimental?.modelRoles?.inlineEdit ?? + (await sidebar.webviewProtocol.request( "getDefaultModelTitle", undefined, + )); + await verticalDiffManager.streamEdit( + config.experimental?.contextMenuPrompts?.[promptName] ?? fallbackPrompt, + modelTitle, + ); + } + return { + "continue.acceptDiff": async (newFilepath?: string | vscode.Uri) => { + if (newFilepath instanceof vscode.Uri) { + newFilepath = newFilepath.fsPath; + } + verticalDiffManager.clearForFilepath(newFilepath, true); + await diffManager.acceptDiff(newFilepath); + }, + "continue.rejectDiff": async (newFilepath?: string | vscode.Uri) => { + if (newFilepath instanceof vscode.Uri) { + newFilepath = newFilepath.fsPath; + } + verticalDiffManager.clearForFilepath(newFilepath, false); + await diffManager.rejectDiff(newFilepath); + }, + "continue.acceptVerticalDiffBlock": (filepath?: string, index?: number) => { + verticalDiffManager.acceptRejectVerticalDiffBlock(true, filepath, index); + }, + "continue.rejectVerticalDiffBlock": (filepath?: string, index?: number) => { + verticalDiffManager.acceptRejectVerticalDiffBlock(false, filepath, index); + }, + "continue.quickFix": async ( + message: string, + code: string, + edit: boolean, + ) => { + sidebar.webviewProtocol?.request("newSessionWithPrompt", { + prompt: `${ + edit ? "/edit " : "" + }${code}\n\nHow do I fix this problem in the above code?: ${message}`, + }); + + if (!edit) { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + } + }, + "continue.focusContinueInput": async () => { + if (!getFullScreenTab()) { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + } + sidebar.webviewProtocol?.request("focusContinueInput", undefined); + await addHighlightedCodeToContext(false, sidebar.webviewProtocol); + }, + "continue.focusContinueInputWithoutClear": async () => { + if (!getFullScreenTab()) { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + } + sidebar.webviewProtocol?.request( + "focusContinueInputWithoutClear", + undefined, ); - await verticalDiffManager.streamEdit(text, modelName); - } else { - // Pick context first - const selectedProviders = await vscode.window.showQuickPick( - quickPickItems, - { - title: "Add Context", - canPickMany: true, - }, + await addHighlightedCodeToContext(true, sidebar.webviewProtocol); + }, + "continue.toggleAuxiliaryBar": () => { + vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar"); + }, + "continue.quickEdit": async (prompt?: string) => { + const selectionEmpty = vscode.window.activeTextEditor?.selection.isEmpty; + + const editor = vscode.window.activeTextEditor; + const existingHandler = verticalDiffManager.getHandlerForFile( + editor?.document.uri.fsPath ?? "", ); + const previousInput = existingHandler?.input; + + const config = await configHandler.loadConfig(); + let defaultModelTitle = + config.experimental?.modelRoles?.inlineEdit ?? + (await sidebar.webviewProtocol.request( + "getDefaultModelTitle", + undefined, + )); + if (!defaultModelTitle) { + defaultModelTitle = config.models[0]?.title!; + } + const quickPickItems = + config.contextProviders + ?.filter((provider) => provider.description.type === "normal") + .map((provider) => { + return { + label: provider.description.displayTitle, + description: provider.description.title, + detail: provider.description.description, + }; + }) || []; + + const addContextMsg = quickPickItems.length + ? " (or press enter to add context first)" + : ""; + const textInputOptions: vscode.InputBoxOptions = { + placeHolder: selectionEmpty + ? `Type instructions to generate code${addContextMsg}` + : `Describe how to edit the highlighted code${addContextMsg}`, + title: `${getPlatform() === "mac" ? "Cmd" : "Ctrl"}+I`, + prompt: `[${defaultModelTitle}]`, + value: prompt, + }; + if (previousInput) { + textInputOptions.value = previousInput + ", "; + textInputOptions.valueSelection = [ + textInputOptions.value.length, + textInputOptions.value.length, + ]; + } let text = await vscode.window.showInputBox(textInputOptions); - if (text) { - const llm = await configHandler.llmFromTitle(); - const config = await configHandler.loadConfig(); - const context = ( - await Promise.all( - selectedProviders?.map((providerTitle) => { - const provider = config.contextProviders?.find( - (provider) => - provider.description.title === providerTitle.description, - ); - if (!provider) { - return []; - } - return provider.getContextItems("", { - embeddingsProvider: config.embeddingsProvider, - reranker: config.reranker, - ide, - llm, - fullInput: text || "", - selectedCode: [], - fetch: (url, init) => - fetchwithRequestOptions(url, init, config.requestOptions), - }); - }) || [], - ) - ).flat(); - - text = - context.map((item) => item.content).join("\n\n") + - "\n\n---\n\n" + - text; - - await verticalDiffManager.streamEdit(text, defaultModelTitle); + if (text === undefined) { + return; } - } - }, - "continue.writeCommentsForCode": async () => { - await verticalDiffManager.streamEdit( - (await configHandler.loadConfig()).experimental?.contextMenuPrompts - ?.comment || + + if (text.length > 0 || quickPickItems.length === 0) { + await verticalDiffManager.streamEdit(text, defaultModelTitle); + } else { + // Pick context first + const selectedProviders = await vscode.window.showQuickPick( + quickPickItems, + { + title: "Add Context", + canPickMany: true, + }, + ); + + let text = await vscode.window.showInputBox(textInputOptions); + if (text) { + const llm = await configHandler.llmFromTitle(); + const config = await configHandler.loadConfig(); + const context = ( + await Promise.all( + selectedProviders?.map((providerTitle) => { + const provider = config.contextProviders?.find( + (provider) => + provider.description.title === providerTitle.description, + ); + if (!provider) { + return []; + } + + return provider.getContextItems("", { + embeddingsProvider: config.embeddingsProvider, + reranker: config.reranker, + ide, + llm, + fullInput: text || "", + selectedCode: [], + fetch: (url, init) => + fetchwithRequestOptions(url, init, config.requestOptions), + }); + }) || [], + ) + ).flat(); + + text = + context.map((item) => item.content).join("\n\n") + + "\n\n---\n\n" + + text; + + await verticalDiffManager.streamEdit(text, defaultModelTitle); + } + } + }, + "continue.writeCommentsForCode": async () => { + streamInlineEdit( + "comment", "Write comments for this code. Do not change anything about the code itself.", - await sidebar.webviewProtocol.request("getDefaultModelTitle", undefined), - ); - }, - "continue.writeDocstringForCode": async () => { - await verticalDiffManager.streamEdit( - (await configHandler.loadConfig()).experimental?.contextMenuPrompts - ?.docstring || - "Write a docstring for this code. Do not change anything about the code itself.", - await sidebar.webviewProtocol.request("getDefaultModelTitle", undefined), - ); - }, - "continue.fixCode": async () => { - await verticalDiffManager.streamEdit( - (await configHandler.loadConfig()).experimental?.contextMenuPrompts - ?.fix || "Fix this code", - await sidebar.webviewProtocol.request("getDefaultModelTitle", undefined), - ); - }, - "continue.optimizeCode": async () => { - await verticalDiffManager.streamEdit( - (await configHandler.loadConfig()).experimental?.contextMenuPrompts - ?.optimize || "Optimize this code", - await sidebar.webviewProtocol.request("getDefaultModelTitle", undefined), - ); - }, - "continue.fixGrammar": async () => { - await verticalDiffManager.streamEdit( - (await configHandler.loadConfig()).experimental?.contextMenuPrompts - ?.fixGrammar || - "If there are any grammar or spelling mistakes in this writing, fix them. Do not make other large changes to the writing.", - await sidebar.webviewProtocol.request("getDefaultModelTitle", undefined), - ); - }, - "continue.viewLogs": async () => { - // Open ~/.continue/continue.log - const logFile = path.join(os.homedir(), ".continue", "continue.log"); - // Make sure the file/directory exist - if (!fs.existsSync(logFile)) { - fs.mkdirSync(path.dirname(logFile), { recursive: true }); - fs.writeFileSync(logFile, ""); - } - - const uri = vscode.Uri.file(logFile); - await vscode.window.showTextDocument(uri); - }, - "continue.debugTerminal": async () => { - const terminalContents = await ide.getTerminalContents(); - vscode.commands.executeCommand("continue.continueGUIView.focus"); - sidebar.webviewProtocol?.request("userInput", { - input: `I got the following error, can you please help explain how to fix it?\n\n${terminalContents.trim()}`, - }); - }, - "continue.hideInlineTip": () => { - vscode.workspace - .getConfiguration("continue") - .update("showInlineTip", false, vscode.ConfigurationTarget.Global); - }, - - // Commands without keyboard shortcuts - "continue.addModel": () => { - vscode.commands.executeCommand("continue.continueGUIView.focus"); - sidebar.webviewProtocol?.request("addModel", undefined); - }, - "continue.openSettingsUI": () => { - vscode.commands.executeCommand("continue.continueGUIView.focus"); - sidebar.webviewProtocol?.request("openSettings", undefined); - }, - "continue.sendMainUserInput": (text: string) => { - sidebar.webviewProtocol?.request("userInput", { - input: text, - }); - }, - "continue.shareSession": () => { - sidebar.sendMainUserInput("/share"); - }, - "continue.selectRange": (startLine: number, endLine: number) => { - if (!vscode.window.activeTextEditor) { - return; - } - vscode.window.activeTextEditor.selection = new vscode.Selection( - startLine, - 0, - endLine, - 0, - ); - }, - "continue.foldAndUnfold": ( - foldSelectionLines: number[], - unfoldSelectionLines: number[], - ) => { - vscode.commands.executeCommand("editor.unfold", { - selectionLines: unfoldSelectionLines, - }); - vscode.commands.executeCommand("editor.fold", { - selectionLines: foldSelectionLines, - }); - }, - "continue.sendToTerminal": (text: string) => { - ide.runCommand(text); - }, - "continue.newSession": () => { - sidebar.webviewProtocol?.request("newSession", undefined); - }, - "continue.viewHistory": () => { - sidebar.webviewProtocol?.request("viewHistory", undefined); - }, - "continue.toggleFullScreen": () => { - // Check if full screen is already open by checking open tabs - const fullScreenTab = getFullScreenTab(); - - // Check if the active editor is the Continue GUI View - if (fullScreenTab && fullScreenTab.isActive) { - //Full screen open and focused - close it - vscode.commands.executeCommand("workbench.action.closeActiveEditor"); //this will trigger the onDidDispose listener below - return; - } - - if (fullScreenTab) { - //Full screen open, but not focused - focus it - // Focus the tab - const openOptions = { - preserveFocus: true, - preview: fullScreenTab.isPreview, - viewColumn: fullScreenTab.group.viewColumn, - }; - - vscode.commands.executeCommand( - "vscode.open", - (fullScreenTab.input as any).uri, - openOptions, ); - return; - } + }, + "continue.writeDocstringForCode": async () => { + streamInlineEdit( + "docstring", + "Write a docstring for this code. Do not change anything about the code itself.", + ); + }, + "continue.fixCode": async () => { + streamInlineEdit("fix", "Fix this code"); + }, + "continue.optimizeCode": async () => { + streamInlineEdit("optimize", "Optimize this code"); + }, + "continue.fixGrammar": async () => { + streamInlineEdit( + "fixGrammar", + "If there are any grammar or spelling mistakes in this writing, fix them. Do not make other large changes to the writing.", + ); + }, + "continue.viewLogs": async () => { + // Open ~/.continue/continue.log + const logFile = path.join(os.homedir(), ".continue", "continue.log"); + // Make sure the file/directory exist + if (!fs.existsSync(logFile)) { + fs.mkdirSync(path.dirname(logFile), { recursive: true }); + fs.writeFileSync(logFile, ""); + } - //Full screen not open - open it + const uri = vscode.Uri.file(logFile); + await vscode.window.showTextDocument(uri); + }, + "continue.debugTerminal": async () => { + const terminalContents = await ide.getTerminalContents(); + vscode.commands.executeCommand("continue.continueGUIView.focus"); + sidebar.webviewProtocol?.request("userInput", { + input: `I got the following error, can you please help explain how to fix it?\n\n${terminalContents.trim()}`, + }); + }, + "continue.hideInlineTip": () => { + vscode.workspace + .getConfiguration("continue") + .update("showInlineTip", false, vscode.ConfigurationTarget.Global); + }, - // Close the sidebar.webviews - // vscode.commands.executeCommand("workbench.action.closeSidebar"); - vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); - // vscode.commands.executeCommand("workbench.action.toggleZenMode"); + // Commands without keyboard shortcuts + "continue.addModel": () => { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + sidebar.webviewProtocol?.request("addModel", undefined); + }, + "continue.openSettingsUI": () => { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + sidebar.webviewProtocol?.request("openSettings", undefined); + }, + "continue.sendMainUserInput": (text: string) => { + sidebar.webviewProtocol?.request("userInput", { + input: text, + }); + }, + "continue.shareSession": () => { + sidebar.sendMainUserInput("/share"); + }, + "continue.selectRange": (startLine: number, endLine: number) => { + if (!vscode.window.activeTextEditor) { + return; + } + vscode.window.activeTextEditor.selection = new vscode.Selection( + startLine, + 0, + endLine, + 0, + ); + }, + "continue.foldAndUnfold": ( + foldSelectionLines: number[], + unfoldSelectionLines: number[], + ) => { + vscode.commands.executeCommand("editor.unfold", { + selectionLines: unfoldSelectionLines, + }); + vscode.commands.executeCommand("editor.fold", { + selectionLines: foldSelectionLines, + }); + }, + "continue.sendToTerminal": (text: string) => { + ide.runCommand(text); + }, + "continue.newSession": () => { + sidebar.webviewProtocol?.request("newSession", undefined); + }, + "continue.viewHistory": () => { + sidebar.webviewProtocol?.request("viewHistory", undefined); + }, + "continue.toggleFullScreen": () => { + // Check if full screen is already open by checking open tabs + const fullScreenTab = getFullScreenTab(); - //create the full screen panel - let panel = vscode.window.createWebviewPanel( - "continue.continueGUIView", - "Continue", - vscode.ViewColumn.One, - ); + // Check if the active editor is the Continue GUI View + if (fullScreenTab && fullScreenTab.isActive) { + //Full screen open and focused - close it + vscode.commands.executeCommand("workbench.action.closeActiveEditor"); //this will trigger the onDidDispose listener below + return; + } - //Add content to the panel - panel.webview.html = sidebar.getSidebarContent( - extensionContext, - panel, - ide, - configHandler, - verticalDiffManager, - undefined, - undefined, - true, - ); + if (fullScreenTab) { + //Full screen open, but not focused - focus it + // Focus the tab + const openOptions = { + preserveFocus: true, + preview: fullScreenTab.isPreview, + viewColumn: fullScreenTab.group.viewColumn, + }; - //When panel closes, reset the webview and focus - panel.onDidDispose( - () => { - sidebar.resetWebviewProtocolWebview(); - vscode.commands.executeCommand("continue.focusContinueInput"); - }, - null, - extensionContext.subscriptions, - ); - }, - "continue.openConfigJson": () => { - ide.openFile(getConfigJsonPath()); - }, - "continue.selectFilesAsContext": ( - firstUri: vscode.Uri, - uris: vscode.Uri[], - ) => { - vscode.commands.executeCommand("continue.continueGUIView.focus"); + vscode.commands.executeCommand( + "vscode.open", + (fullScreenTab.input as any).uri, + openOptions, + ); + return; + } - for (const uri of uris) { - addEntireFileToContext(uri, false, sidebar.webviewProtocol); - } - }, - "continue.updateAllReferences": (filepath: vscode.Uri) => { - // Get the cursor position in the editor - const editor = vscode.window.activeTextEditor; - if (!editor) { - return; - } - const position = editor.selection.active; - sidebar.sendMainUserInput( - `/references ${filepath.fsPath} ${position.line} ${position.character}`, - ); - }, - "continue.logAutocompleteOutcome": ( - outcome: AutocompleteOutcome, - logRejectionTimeout: NodeJS.Timeout, - ) => { - clearTimeout(logRejectionTimeout); - outcome.accepted = true; - logDevData("autocomplete", outcome); - Telemetry.capture("autocomplete", { - accepted: outcome.accepted, - modelName: outcome.modelName, - modelProvider: outcome.modelProvider, - time: outcome.time, - cacheHit: outcome.cacheHit, - }); - }, - "continue.toggleTabAutocompleteEnabled": () => { - const config = vscode.workspace.getConfiguration("continue"); - const enabled = config.get("enableTabAutocomplete"); - config.update( - "enableTabAutocomplete", - !enabled, - vscode.ConfigurationTarget.Global, - ); - }, -}); + //Full screen not open - open it + + // Close the sidebar.webviews + // vscode.commands.executeCommand("workbench.action.closeSidebar"); + vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); + // vscode.commands.executeCommand("workbench.action.toggleZenMode"); + + //create the full screen panel + let panel = vscode.window.createWebviewPanel( + "continue.continueGUIView", + "Continue", + vscode.ViewColumn.One, + ); + + //Add content to the panel + panel.webview.html = sidebar.getSidebarContent( + extensionContext, + panel, + ide, + configHandler, + verticalDiffManager, + undefined, + undefined, + true, + ); + + //When panel closes, reset the webview and focus + panel.onDidDispose( + () => { + sidebar.resetWebviewProtocolWebview(); + vscode.commands.executeCommand("continue.focusContinueInput"); + }, + null, + extensionContext.subscriptions, + ); + }, + "continue.openConfigJson": () => { + ide.openFile(getConfigJsonPath()); + }, + "continue.selectFilesAsContext": ( + firstUri: vscode.Uri, + uris: vscode.Uri[], + ) => { + vscode.commands.executeCommand("continue.continueGUIView.focus"); + + for (const uri of uris) { + addEntireFileToContext(uri, false, sidebar.webviewProtocol); + } + }, + "continue.updateAllReferences": (filepath: vscode.Uri) => { + // Get the cursor position in the editor + const editor = vscode.window.activeTextEditor; + if (!editor) { + return; + } + const position = editor.selection.active; + sidebar.sendMainUserInput( + `/references ${filepath.fsPath} ${position.line} ${position.character}`, + ); + }, + "continue.logAutocompleteOutcome": ( + outcome: AutocompleteOutcome, + logRejectionTimeout: NodeJS.Timeout, + ) => { + clearTimeout(logRejectionTimeout); + outcome.accepted = true; + logDevData("autocomplete", outcome); + Telemetry.capture("autocomplete", { + accepted: outcome.accepted, + modelName: outcome.modelName, + modelProvider: outcome.modelProvider, + time: outcome.time, + cacheHit: outcome.cacheHit, + }); + }, + "continue.toggleTabAutocompleteEnabled": () => { + const config = vscode.workspace.getConfiguration("continue"); + const enabled = config.get("enableTabAutocomplete"); + config.update( + "enableTabAutocomplete", + !enabled, + vscode.ConfigurationTarget.Global, + ); + }, + }; +}; export function registerAllCommands( context: vscode.ExtensionContext,