mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
feat: add settings keyboard shortcut
This commit is contained in:
@@ -30,6 +30,13 @@ type ShellInitializationState = {
|
||||
) => void;
|
||||
};
|
||||
|
||||
type ShellKeyboardState = {
|
||||
runtime: {
|
||||
context: ApplicationContext;
|
||||
};
|
||||
handleDocumentKeydown: (event: KeyboardEvent) => void;
|
||||
};
|
||||
|
||||
type ShellEpochState = {
|
||||
navDrawerOpen: boolean;
|
||||
navDrawerTrigger: HTMLElement | null;
|
||||
@@ -163,3 +170,48 @@ describe("OpenClaw shell source initialization", () => {
|
||||
expect(secondRuntimeConfig.ensureLoaded).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
describe("OpenClaw shell keyboard shortcuts", () => {
|
||||
it("opens Settings with Shift-Command-Comma", () => {
|
||||
const navigate = vi.fn();
|
||||
const shell = document.createElement("openclaw-app-shell") as unknown as ShellKeyboardState;
|
||||
shell.runtime = {
|
||||
context: {
|
||||
navigate,
|
||||
} as unknown as ApplicationContext,
|
||||
};
|
||||
const event = new KeyboardEvent("keydown", {
|
||||
key: "<",
|
||||
code: "Comma",
|
||||
metaKey: true,
|
||||
shiftKey: true,
|
||||
cancelable: true,
|
||||
});
|
||||
|
||||
shell.handleDocumentKeydown(event);
|
||||
|
||||
expect(event.defaultPrevented).toBe(true);
|
||||
expect(navigate).toHaveBeenCalledWith("config", undefined);
|
||||
});
|
||||
|
||||
it("leaves plain Command-Comma to the browser", () => {
|
||||
const navigate = vi.fn();
|
||||
const shell = document.createElement("openclaw-app-shell") as unknown as ShellKeyboardState;
|
||||
shell.runtime = {
|
||||
context: {
|
||||
navigate,
|
||||
} as unknown as ApplicationContext,
|
||||
};
|
||||
const event = new KeyboardEvent("keydown", {
|
||||
key: ",",
|
||||
code: "Comma",
|
||||
metaKey: true,
|
||||
cancelable: true,
|
||||
});
|
||||
|
||||
shell.handleDocumentKeydown(event);
|
||||
|
||||
expect(event.defaultPrevented).toBe(false);
|
||||
expect(navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -633,13 +633,13 @@ class OpenClawShell extends OpenClawLightDomElement {
|
||||
this.exitSettings();
|
||||
return;
|
||||
}
|
||||
if (
|
||||
event.altKey ||
|
||||
event.shiftKey ||
|
||||
!event.metaKey ||
|
||||
event.ctrlKey ||
|
||||
event.key.toLowerCase() !== "b"
|
||||
) {
|
||||
const commandKey = event.metaKey && !event.ctrlKey && !event.altKey;
|
||||
if (commandKey && event.shiftKey && event.code === "Comma") {
|
||||
event.preventDefault();
|
||||
this.navigate("config");
|
||||
return;
|
||||
}
|
||||
if (!commandKey || event.shiftKey || event.key.toLowerCase() !== "b") {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1807,6 +1807,7 @@ class AppSidebar extends OpenClawLightDomContentsElement {
|
||||
});
|
||||
const settingsActive =
|
||||
this.activeRouteId !== undefined && isSettingsNavigationRoute(this.activeRouteId);
|
||||
const settingsTooltip = `${titleForRoute("config")} (⇧⌘,)`;
|
||||
return html`
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-shell">
|
||||
@@ -1841,7 +1842,7 @@ class AppSidebar extends OpenClawLightDomContentsElement {
|
||||
></span>
|
||||
</openclaw-tooltip>
|
||||
<span class="sidebar-footer-bar__spacer"></span>
|
||||
<openclaw-tooltip .content=${titleForRoute("config")}>
|
||||
<openclaw-tooltip .content=${settingsTooltip}>
|
||||
<a
|
||||
href=${pathForRoute("config", this.basePath)}
|
||||
class="sidebar-footer-icon ${settingsActive ? "sidebar-footer-icon--active" : ""}"
|
||||
|
||||
Reference in New Issue
Block a user