feat: add settings keyboard shortcut

This commit is contained in:
Shakker
2026-07-09 20:50:31 +01:00
parent ef9a94ecba
commit 64ed3dfde8
3 changed files with 61 additions and 8 deletions
+52
View File
@@ -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();
});
});
+7 -7
View File
@@ -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();
+2 -1
View File
@@ -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" : ""}"