diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 676292959..f017cd151 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -118,7 +118,8 @@ { "command": "continue.toggleFullScreen", "category": "Continue", - "title": "Toggle Full Screen" + "title": "Toggle Full Screen", + "icon": "$(fullscreen)" }, { "command": "continue.shareSession", @@ -129,6 +130,18 @@ "command": "continue.selectFilesAsContext", "category": "Continue", "title": "Continue: Select Files as Context" + }, + { + "command": "continue.newSession", + "category": "Continue", + "title": "New Session", + "icon": "$(add)" + }, + { + "command": "continue.viewHistory", + "category": "Continue", + "title": "View History", + "icon": "$(history)" } ], "keybindings": [ @@ -210,6 +223,30 @@ "command": "continue.selectFilesAsContext", "group": "1_debug@1" } + ], + "view/title": [ + { + "command": "continue.newSession", + "group": "navigation@1", + "when": "view == continue.continueGUIView" + }, + { + "command": "continue.toggleFullScreen", + "group": "navigation@1", + "when": "view == continue.continueGUIView" + }, + { + "command": "continue.viewHistory", + "group": "navigation@1", + "when": "view == continue.continueGUIView" + } + ], + "editor/title": [ + { + "command": "continue.toggleFullScreen", + "group": "navigation@1", + "when": "activeWebviewPanelId == continue.continueGUIView" + } ] }, "viewsContainers": { diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index daa42a6d5..7957912ef 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -187,6 +187,16 @@ const commandsMap: { [command: string]: (...args: any) => any } = { "continue.sendToTerminal": (text: string) => { ideProtocolClient.runCommand(text); }, + "continue.newSession": () => { + debugPanelWebview?.postMessage({ + type: "newSession", + }); + }, + "continue.viewHistory": () => { + debugPanelWebview?.postMessage({ + type: "viewHistory", + }); + }, "continue.toggleFullScreen": () => { // Check if full screen is already open by checking open tabs const tabs = vscode.window.tabGroups.all.flatMap( diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/debugPanel.ts index a51834b98..daa87e4bf 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/debugPanel.ts @@ -260,8 +260,12 @@ export function getSidebarContent( )} - ${edits ? `` : ''} - ${page ? `` : ''} + ${ + edits + ? `` + : "" + } + ${page ? `` : ""} `; } diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 1b325cfae..4cdb784ba 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -164,6 +164,13 @@ const Layout = () => { navigate("/models"); } else if (event.data.type === "openSettings") { navigate("/settings"); + } else if (event.data.type === "viewHistory") { + // Toggle the history page / main page + if (location.pathname === "/history") { + navigate("/"); + } else { + navigate("/history"); + } } }; window.addEventListener("message", handler); diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index e32750cf5..8e5219402 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -21,6 +21,7 @@ import { Listbox, Transition } from "@headlessui/react"; import ReactDOM from "react-dom"; import HeaderButtonWithText from "../HeaderButtonWithText"; import { defaultModelSelector } from "../../redux/selectors/configSelectors"; +import { getMetaKeyLabel } from "../../util"; const GridDiv = styled.div` display: grid; @@ -226,6 +227,23 @@ function ModelSelect(props: {}) { const topDiv = document.getElementById("model-select-top-div"); + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === "'" && event.metaKey) { + const currentIndex = options.findIndex( + (option) => option.value === defaultModel?.title + ); + const nextIndex = (currentIndex + 1) % options.length; + client?.setModelForRoleFromTitle("default", options[nextIndex].value); + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + }, [options, defaultModel]); + return ( <> @@ -259,6 +277,9 @@ function ModelSelect(props: {}) { {options.map((option, idx) => ( ))} + + {getMetaKeyLabel()}' to toggle + , topDiv diff --git a/gui/src/pages/gui.tsx b/gui/src/pages/gui.tsx index 8396ccb14..3822cd1dd 100644 --- a/gui/src/pages/gui.tsx +++ b/gui/src/pages/gui.tsx @@ -439,6 +439,21 @@ function GUI(props: GUIProps) { }; }, [client, persistSession, mainTextInputRef]); + useEffect(() => { + const handler = (event: any) => { + if (event.data.type === "newSession") { + client?.stopSession(); + persistSession(); + dispatch(newSession()); + mainTextInputRef.current?.focus?.(); + } + }; + window.addEventListener("message", handler); + return () => { + window.removeEventListener("message", handler); + }; + }, []); + useEffect(() => { const eventListener = (event: any) => { if (event.data.type === "userInput") { @@ -576,72 +591,74 @@ function GUI(props: GUIProps) { } }} > - - { - // Select all text - (e.target as any).setSelectionRange( - 0, - (e.target as any).value.length - ); - }} - value={sessionTitleInput} - onChange={(e) => setSessionTitleInput(e.target.value)} - onBlur={(e) => { - if ( - e.target.value === sessionTitle || - (typeof sessionTitle === "undefined" && - e.target.value === "New Session") - ) - return; - dispatch(setTitle(e.target.value)); - }} - onKeyDown={(e) => { - if (e.key === "Enter") { - e.preventDefault(); - (e.target as any).blur(); - } else if (e.key === "Escape") { - setSessionTitleInput(sessionTitle || "New Session"); - (e.target as any).blur(); - } - }} - /> -
- {localStorage.getItem("ide") === "vscode" && ( + {localStorage.getItem("ide") === "jetbrains" && ( + + { + // Select all text + (e.target as any).setSelectionRange( + 0, + (e.target as any).value.length + ); + }} + value={sessionTitleInput} + onChange={(e) => setSessionTitleInput(e.target.value)} + onBlur={(e) => { + if ( + e.target.value === sessionTitle || + (typeof sessionTitle === "undefined" && + e.target.value === "New Session") + ) + return; + dispatch(setTitle(e.target.value)); + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + (e.target as any).blur(); + } else if (e.key === "Escape") { + setSessionTitleInput(sessionTitle || "New Session"); + (e.target as any).blur(); + } + }} + /> +
+ {localStorage.getItem("ide") === "vscode" && ( + { + postToIde("toggleFullScreen", {}); + }} + text={`Toggle Full Screen (${getMetaKeyLabel()}K ${getMetaKeyLabel()}M)`} + > + {(window as any).isFullScreen ? ( + + ) : ( + + )} + + )} { - postToIde("toggleFullScreen", {}); + client?.stopSession(); + client?.persistSession(sessionState, workspacePaths[0] || ""); + dispatch(newSession()); }} - text={`Toggle Full Screen (${getMetaKeyLabel()}K ${getMetaKeyLabel()}M)`} + text={`New Session (⌥${getMetaKeyLabel()}N)`} > - {(window as any).isFullScreen ? ( - - ) : ( - - )} + - )} - { - client?.stopSession(); - client?.persistSession(sessionState, workspacePaths[0] || ""); - dispatch(newSession()); - }} - text={`New Session (⌥${getMetaKeyLabel()}N)`} - > - - - { - navigate("/history"); - }} - text="History" - > - - -
-
+ { + navigate("/history"); + }} + text="History" + > + + +
+
+ )} {takenAction && showLoading && typeof client === "undefined" && ( <> @@ -713,7 +730,6 @@ function GUI(props: GUIProps) { )} -