From a1de5078505b627d10729605efa720e3292cebf9 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 10 Nov 2023 11:15:08 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Full=20Screen=20Mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package-lock.json | 4 +- extensions/vscode/package.json | 21 +++------- extensions/vscode/src/commands.ts | 60 ++++++++++++++++++++++------- extensions/vscode/src/debugPanel.ts | 10 +++-- gui/src/pages/gui.tsx | 20 +++++++++- 5 files changed, 80 insertions(+), 35 deletions(-) diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5f9d9575f..509669c92 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.5.1", + "version": "0.5.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.5.1", + "version": "0.5.2", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 9740c382f..4daff3f2c 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.5.1", + "version": "0.5.2", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -116,9 +116,9 @@ "title": "Debug Terminal" }, { - "command": "continue.openFullScreen", + "command": "continue.toggleFullScreen", "category": "Continue", - "title": "Open Full Screen" + "title": "Toggle Full Screen" }, { "command": "continue.shareSession", @@ -129,11 +129,6 @@ "command": "continue.selectFilesAsContext", "category": "Continue", "title": "Continue: Select Files as Context" - }, - { - "command": "continue.updateAllReferences", - "category": "Continue", - "title": "Update All References" } ], "keybindings": [ @@ -173,9 +168,9 @@ "key": "ctrl+shift+r" }, { - "command": "continue.openFullScreen", - "mac": "cmd+l", - "key": "ctrl+l" + "command": "continue.toggleFullScreen", + "mac": "cmd+k cmd+m", + "key": "ctrl+k ctrl+m" } ], "submenus": [ @@ -213,10 +208,6 @@ "command": "continue.focusContinueInputWithEdit", "group": "Continue", "when": "editorHasSelection" - }, - { - "command": "continue.updateAllReferences", - "group": "Continue" } ], "explorer/context": [ diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index cb5d144fd..daa42a6d5 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -7,10 +7,7 @@ import { acceptDiffCommand, rejectDiffCommand } from "./diffs"; import { debugPanelWebview, getSidebarContent } from "./debugPanel"; import { ideProtocolClient } from "./activation/activate"; -let focusedOnContinueInput = false; - function addHighlightedCodeToContext(edit: boolean) { - focusedOnContinueInput = !focusedOnContinueInput; const editor = vscode.window.activeTextEditor; if (editor) { const selection = editor.selection; @@ -41,7 +38,17 @@ function addHighlightedCodeToContext(edit: boolean) { } async function addEntireFileToContext(filepath: vscode.Uri, edit: boolean) { - focusedOnContinueInput = !focusedOnContinueInput; + // If a directory, add all files in the directory + const stat = await vscode.workspace.fs.stat(filepath); + if (stat.type === vscode.FileType.Directory) { + const files = await vscode.workspace.fs.readDirectory(filepath); + for (const [filename, type] of files) { + if (type === vscode.FileType.File) { + addEntireFileToContext(vscode.Uri.joinPath(filepath, filename), edit); + } + } + return; + } // Get the contents of the file const contents = (await vscode.workspace.fs.readFile(filepath)).toString(); @@ -67,10 +74,6 @@ async function addEntireFileToContext(filepath: vscode.Uri, edit: boolean) { }); } -export const setFocusedOnContinueInput = (value: boolean) => { - focusedOnContinueInput = value; -}; - // Copy everything over from extension.ts const commandsMap: { [command: string]: (...args: any) => any } = { "continue.acceptDiff": acceptDiffCommand, @@ -98,7 +101,6 @@ const commandsMap: { [command: string]: (...args: any) => any } = { debugPanelWebview?.postMessage({ type: "focusContinueInputWithEdit", }); - focusedOnContinueInput = true; }, "continue.toggleAuxiliaryBar": () => { vscode.commands.executeCommand("workbench.action.toggleAuxiliaryBar"); @@ -185,17 +187,49 @@ const commandsMap: { [command: string]: (...args: any) => any } = { "continue.sendToTerminal": (text: string) => { ideProtocolClient.runCommand(text); }, - "continue.openFullScreen": () => { + "continue.toggleFullScreen": () => { + // Check if full screen is already open by checking open tabs + const tabs = vscode.window.tabGroups.all.flatMap( + (tabGroup) => tabGroup.tabs + ); + + const fullScreenTab = tabs.find( + (tab) => (tab.input as any).viewType?.endsWith("continue.continueGUIView") + ); + + // Check if the active editor is the Continue GUI View + if (fullScreenTab && fullScreenTab.isActive) { + vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + vscode.commands.executeCommand("continue.focusContinueInput"); + return; + } + + if (fullScreenTab) { + // 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; + } + // Close the sidebars - vscode.commands.executeCommand("workbench.action.closeSidebar"); + // vscode.commands.executeCommand("workbench.action.closeSidebar"); vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); - vscode.commands.executeCommand("workbench.action.toggleZenMode"); + // vscode.commands.executeCommand("workbench.action.toggleZenMode"); const panel = vscode.window.createWebviewPanel( "continue.continueGUIView", "Continue", vscode.ViewColumn.One ); - panel.webview.html = getSidebarContent(panel); + panel.webview.html = getSidebarContent(panel, undefined, undefined, true); }, "continue.selectFilesAsContext": ( firstUri: vscode.Uri, diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/debugPanel.ts index 0b72cbe13..a65ef0b81 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/debugPanel.ts @@ -1,7 +1,6 @@ import * as vscode from "vscode"; import { getContinueServerUrl } from "./bridge"; import { getExtensionUri, getNonce, getUniqueId } from "./util/vscode"; -import { setFocusedOnContinueInput } from "./commands"; import { ideProtocolClient, windowId } from "./activation/activate"; import * as io from "socket.io-client"; import { FileEdit } from "../schema/FileEdit"; @@ -12,7 +11,8 @@ export let debugPanelWebview: vscode.Webview | undefined; export function getSidebarContent( panel: vscode.WebviewPanel | vscode.WebviewView, page: string | undefined = undefined, - edits: FileEdit[] | undefined = undefined + edits: FileEdit[] | undefined = undefined, + isFullScreen: boolean = false ): string { debugPanelWebview = panel.webview; panel.onDidDispose(() => { @@ -186,12 +186,15 @@ export function getSidebarContent( break; } case "focusEditor": { - setFocusedOnContinueInput(false); vscode.commands.executeCommand( "workbench.action.focusActiveEditorGroup" ); break; } + case "toggleFullScreen": { + vscode.commands.executeCommand("continue.toggleFullScreen"); + break; + } case "withProgress": { // This message allows withProgress to be used in the webview if (data.done) { @@ -255,6 +258,7 @@ export function getSidebarContent( (folder) => folder.uri.fsPath ) || [] )} + ${edits && ``} ${page && ``} diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index e3e760ea4..620a95e0c 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -23,7 +23,7 @@ import { usePostHog } from "posthog-js/react"; import { useDispatch, useSelector } from "react-redux"; import { RootStore } from "../redux/store"; import { postToIde } from "../vscode"; -import { isMetaEquivalentKeyPressed } from "../util"; +import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../util"; import { setBottomMessage, setDialogEntryOn, @@ -35,6 +35,8 @@ import RingLoader from "../components/RingLoader"; import TimelineItem from "../components/TimelineItem"; import ErrorStepContainer from "../components/ErrorStepContainer"; import { + ArrowsPointingInIcon, + ArrowsPointingOutIcon, ChatBubbleOvalLeftIcon, CodeBracketSquareIcon, ExclamationTriangleIcon, @@ -579,13 +581,27 @@ function GUI(props: GUIProps) { }} />
+ {localStorage.getItem("ide") === "vscode" && ( + { + postToIde("toggleFullScreen", {}); + }} + text={`Toggle Full Screen (${getMetaKeyLabel()}K M)`} + > + {(window as any).isFullScreen ? ( + + ) : ( + + )} + + )} { client?.stopSession(); client?.persistSession(sessionState, workspacePaths[0] || ""); dispatch(newSession()); }} - text="New Session (⌥⌘N)" + text={`New Session (⌥${getMetaKeyLabel()}N)`} >