Merge pull request #2481 from continuedev/tomasz/shortcut-to-help-center

Add a help center shortcut
This commit is contained in:
Nate Sesti 2024-10-06 10:33:18 -07:00 • committed by GitHub
commit d964b4e9f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 24 deletions

View file

@ -58,8 +58,13 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
},
void,
];
navigateTo: [{ path: string; toggle?: boolean }, void];
addModel: [undefined, void];
openSettings: [undefined, void];
/**
* @deprecated Use navigateTo with a path instead.
*/
viewHistory: [undefined, void];
newSession: [undefined, void];
setTheme: [{ theme: any }, void];

View file

@ -221,6 +221,12 @@
"icon": "$(history)",
"group": "Continue"
},
{
"command": "continue.navigateTo",
"category": "Continue",
"title": "Navigate to a path",
"group": "Continue"
},
{
"command": "continue.writeCommentsForCode",
"category": "Continue",

View file

@ -165,6 +165,17 @@ async function addEntireFileToContext(
});
}
function focusGUI() {
const fullScreenTab = getFullScreenTab();
if (!fullScreenTab) {
// focus sidebar
vscode.commands.executeCommand("continue.continueGUIView.focus");
} else {
// focus fullscreen
fullScreenPanel?.reveal();
}
}
// Copy everything over from extension.ts
const commandsMap: (
ide: IDE,
@ -315,14 +326,7 @@ const commandsMap: (
core.invoke("context/indexDocs", { reIndex: true });
},
"continue.focusContinueInput": async () => {
const fullScreenTab = getFullScreenTab();
if (!fullScreenTab) {
// focus sidebar
vscode.commands.executeCommand("continue.continueGUIView.focus");
} else {
// focus fullscreen
fullScreenPanel?.reveal();
}
focusGUI();
sidebar.webviewProtocol?.request("focusContinueInput", undefined);
await addHighlightedCodeToContext(sidebar.webviewProtocol);
},
@ -631,8 +635,8 @@ const commandsMap: (
currentStatus === StatusBarStatus.Paused
? StatusBarStatus.Enabled
: currentStatus === StatusBarStatus.Disabled
? StatusBarStatus.Paused
: StatusBarStatus.Disabled;
? StatusBarStatus.Paused
: StatusBarStatus.Disabled;
} else {
// Toggle between Disabled and Enabled
targetStatus =
@ -641,6 +645,9 @@ const commandsMap: (
: StatusBarStatus.Disabled;
}
quickPick.items = [
{
label: "$(question) Open help center",
},
{
label: "$(comment) Open chat (Cmd+L)",
},
@ -698,6 +705,9 @@ const commandsMap: (
"$(screen-full) Open full screen chat (Cmd+K Cmd+M)"
) {
vscode.commands.executeCommand("continue.toggleFullScreen");
} else if (selectedOption === "$(question) Open help center") {
focusGUI();
vscode.commands.executeCommand("continue.navigateTo", "/more");
}
quickPick.dispose();
});
@ -717,6 +727,10 @@ const commandsMap: (
client.sendFeedback(feedback, lastLines);
}
},
"continue.navigateTo": (path: string) => {
sidebar.webviewProtocol?.request("navigateTo", { path });
focusGUI();
},
};
};

View file

@ -115,6 +115,18 @@ const Layout = () => {
[location, navigate],
);
useWebviewListener(
"navigateTo",
async (data) => {
if (data.toggle && location.pathname === data.path) {
navigate("/");
} else {
navigate(data.path);
}
},
[location, navigate],
);
useWebviewListener(
"incrementFtc",
async () => {

View file

@ -13,7 +13,6 @@ const openGUITypes: (keyof ToWebviewProtocol)[] = [
export const useNavigationListener = () => {
const navigate = useNavigate();
const location = useLocation();
for (const messageType of openGUITypes) {
useWebviewListener(
@ -34,17 +33,4 @@ export const useNavigationListener = () => {
[navigate],
);
}
useWebviewListener(
"viewHistory",
async () => {
// Toggle the history page / main page
if (location.pathname === "/history") {
navigate("/");
} else {
navigate("/history");
}
},
[location, navigate],
);
};