💄 move top bar to VS Code toolbar
This commit is contained in:
parent
827b941624
commit
cc6373cc67
6 changed files with 159 additions and 64 deletions
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -260,8 +260,12 @@ export function getSidebarContent(
|
|||
)}</script>
|
||||
<script>window.isFullScreen = ${isFullScreen}</script>
|
||||
|
||||
${edits ? `<script>window.edits = ${JSON.stringify(edits)}</script>` : ''}
|
||||
${page ? `<script>window.location.pathname = "${page}"</script>` : ''}
|
||||
${
|
||||
edits
|
||||
? `<script>window.edits = ${JSON.stringify(edits)}</script>`
|
||||
: ""
|
||||
}
|
||||
${page ? `<script>window.location.pathname = "${page}"</script>` : ""}
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<>
|
||||
<GridDiv>
|
||||
|
|
@ -259,6 +277,9 @@ function ModelSelect(props: {}) {
|
|||
{options.map((option, idx) => (
|
||||
<ListBoxOption option={option} idx={idx} />
|
||||
))}
|
||||
<i className="text-xs ml-2" style={{ color: lightGray }}>
|
||||
{getMetaKeyLabel()}' to toggle
|
||||
</i>
|
||||
</StyledListboxOptions>
|
||||
</Transition>,
|
||||
topDiv
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
}
|
||||
}}
|
||||
>
|
||||
<GUIHeaderDiv>
|
||||
<TitleTextInput
|
||||
onClick={(e) => {
|
||||
// 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();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
{localStorage.getItem("ide") === "vscode" && (
|
||||
{localStorage.getItem("ide") === "jetbrains" && (
|
||||
<GUIHeaderDiv>
|
||||
<TitleTextInput
|
||||
onClick={(e) => {
|
||||
// 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();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
{localStorage.getItem("ide") === "vscode" && (
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
postToIde("toggleFullScreen", {});
|
||||
}}
|
||||
text={`Toggle Full Screen (${getMetaKeyLabel()}K ${getMetaKeyLabel()}M)`}
|
||||
>
|
||||
{(window as any).isFullScreen ? (
|
||||
<ArrowsPointingInIcon width="1.4em" height="1.4em" />
|
||||
) : (
|
||||
<ArrowsPointingOutIcon width="1.4em" height="1.4em" />
|
||||
)}
|
||||
</HeaderButtonWithText>
|
||||
)}
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
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 ? (
|
||||
<ArrowsPointingInIcon width="1.4em" height="1.4em" />
|
||||
) : (
|
||||
<ArrowsPointingOutIcon width="1.4em" height="1.4em" />
|
||||
)}
|
||||
<PlusIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
)}
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
client?.stopSession();
|
||||
client?.persistSession(sessionState, workspacePaths[0] || "");
|
||||
dispatch(newSession());
|
||||
}}
|
||||
text={`New Session (⌥${getMetaKeyLabel()}N)`}
|
||||
>
|
||||
<PlusIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
navigate("/history");
|
||||
}}
|
||||
text="History"
|
||||
>
|
||||
<FolderIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
</div>
|
||||
</GUIHeaderDiv>
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
navigate("/history");
|
||||
}}
|
||||
text="History"
|
||||
>
|
||||
<FolderIcon width="1.4em" height="1.4em" />
|
||||
</HeaderButtonWithText>
|
||||
</div>
|
||||
</GUIHeaderDiv>
|
||||
)}
|
||||
{takenAction && showLoading && typeof client === "undefined" && (
|
||||
<>
|
||||
<RingLoader size={32} />
|
||||
|
|
@ -713,7 +730,6 @@ function GUI(props: GUIProps) {
|
|||
</div>
|
||||
</>
|
||||
)}
|
||||
<br />
|
||||
|
||||
<div className="max-w-3xl m-auto">
|
||||
<StepsDiv>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue