Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: add a keyboard shortcuts page and make the existing chords rebindable (#8948)

Michael Han334db4875feb
diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsx
index 2c65c1ae3e7..eed0c8db7a2 100644
--- a/studio/frontend/src/app/routes/__root.tsx
+++ b/studio/frontend/src/app/routes/__root.tsx
@@ -24,7 +24,11 @@ import { bootstrapPersistedCredentials } from "@/features/credentials/bootstrap"
import { backfillModelOverrides } from "@/features/model-picker/api/migrate-model-overrides";
import { usePersonalizationSync } from "@/features/profile";
import { RemoteCodeConsentDialog } from "@/features/security";
-import { SettingsDialog, useSettingsDialogStore } from "@/features/settings";
+import {
+ SettingsDialog,
+ useSettingsDialogStore,
+ useShortcut,
+} from "@/features/settings";
import { useTrainingUnloadGuard } from "@/features/training";
import { TransformersUpgradeDialog } from "@/features/transformers-upgrade";
import { useSidebarPin } from "@/hooks/use-sidebar-pin";
@@ -324,31 +328,32 @@ function RootLayout() {
if (isAuthFlowRoute) {
useSettingsDialogStore.getState().closeDialog();
}
- const handler = (e: KeyboardEvent) => {
- if (e.defaultPrevented) return;
- if ((e.metaKey || e.ctrlKey) && e.key === ",") {
- if (isAuthFlowRoute) return;
- e.preventDefault();
- useSettingsDialogStore.getState().openDialog();
- return;
- }
- // Cmd/Ctrl+Shift+O opens a new chat.
- if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.code === "KeyO") {
- e.preventDefault();
- clearNewChatDraft(); // fresh chat starts empty, no bleed from the last one
- const chatRuntime = useChatRuntimeStore.getState();
- chatRuntime.setActiveThreadId(null);
- chatRuntime.setActiveProjectId(null);
- chatRuntime.setIncognito(false);
- void navigate({
- to: "/chat",
- search: { new: crypto.randomUUID() },
- });
- }
- };
- window.addEventListener("keydown", handler);
- return () => window.removeEventListener("keydown", handler);
- }, [isAuthFlowRoute, navigate]);
+ }, [isAuthFlowRoute]);
+
+ // Chords come from the shortcuts store (Settings -> Shortcuts), so a rebind
+ // applies without a reload. The auth flow has no shell to act on.
+ useShortcut(
+ "openSettings",
+ () => useSettingsDialogStore.getState().openDialog(),
+ { enabled: !isAuthFlowRoute },
+ );
+ useShortcut(
+ "openKeyboardShortcuts",
+ () =>
+ useSettingsDialogStore.getState().openDialog("keyboard-shortcuts"),
+ { enabled: !isAuthFlowRoute },
+ );
+ useShortcut("newChat", () => {
+ clearNewChatDraft(); // fresh chat starts empty, no bleed from the last one
+ const chatRuntime = useChatRuntimeStore.getState();
+ chatRuntime.setActiveThreadId(null);
+ chatRuntime.setActiveProjectId(null);
+ chatRuntime.setIncognito(false);
+ void navigate({
+ to: "/chat",
+ search: { new: crypto.randomUUID() },
+ });
+ });
useEffect(() => {
if (isChatRoute) return;
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 9f0625bc0a8..5c5aa4977d7 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -57,7 +57,6 @@ import { Switch } from "@/components/ui/switch";
import { useAnimatedThemeToggle } from "@/components/ui/animated-theme-toggler";
import {
DesktopTitlebarNavigation,
- getClientPlatform,
shouldUseCustomWindowTitlebar,
shouldUseNativeMacWindowTitlebar,
} from "@/components/tauri/window-titlebar";
@@ -180,6 +179,7 @@ import { NewProjectDialog } from "@/features/chat/components/new-project-dialog"
import {
useAppearanceCustomStore,
useSettingsDialogStore,
+ useShortcutLabel,
} from "@/features/settings";
import type { SidebarNavItemId } from "@/features/settings";
import { useEffectiveProfile, UserAvatar } from "@/features/profile";
@@ -723,8 +723,11 @@ export function AppSidebar() {
);
const [usesCustomTitlebar] = useState(shouldUseCustomWindowTitlebar);
const [usesNativeMacTitlebar] = useState(shouldUseNativeMacWindowTitlebar);
- // Mac uses Cmd, others use Ctrl. Not Tauri-gated, so it's right on web too.
- const [isMacPlatform] = useState(() => getClientPlatform().includes("mac"));
+ // Read from the shortcuts store, not the shipped default: a rebound or
+ // cleared action must not leave the hint advertising a dead chord. Both
+ // already render in the platform's own notation.
+ const searchShortcutLabel = useShortcutLabel("searchChats");
+ const settingsShortcutLabel = useShortcutLabel("openSettings");
const { pathname, search } = useRouterState({
select: (s) => ({
pathname: s.location.pathname,
@@ -2915,9 +2918,11 @@ export function AppSidebar() {
hidden={isMobile}
>
{t("shell.navigation.search")}
- <kbd className="rounded bg-black/10 px-1 py-px text-ui-10 font-medium leading-none dark:bg-white/15">
- {isMacPlatform ? "⌘K" : "Ctrl+K"}
- </kbd>
+ {searchShortcutLabel && (
+ <kbd className="rounded bg-black/10 px-1 py-px text-ui-10 font-medium leading-none dark:bg-white/15">
+ {searchShortcutLabel}
+ </kbd>
+ )}
</TooltipContent>
</Tooltip>
{!isMobile && !usesDesktopTitlebar && (
@@ -3806,7 +3811,11 @@ export function AppSidebar() {
>
<HugeiconsIcon icon={Settings02Icon} strokeWidth={1.75} className="size-icon" />
<span>{t("shell.navigation.settings")}</span>
- <DropdownMenuShortcut>⌘,</DropdownMenuShortcut>
+ {settingsShortcutLabel && (
+ <DropdownMenuShortcut>
+ {settingsShortcutLabel}
+ </DropdownMenuShortcut>
+ )}
</DropdownMenuItem>
{/* Optional items follow the order and visibility set in
Appearance settings; Settings above and the block after
diff --git a/studio/frontend/src/components/ui/sidebar.tsx b/studio/frontend/src/components/ui/sidebar.tsx
index 7de2c62564f..1e25cc2f2bd 100644
--- a/studio/frontend/src/components/ui/sidebar.tsx
+++ b/studio/frontend/src/components/ui/sidebar.tsx
@@ -8,6 +8,9 @@ import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"
import { cn } from "@/lib/utils"
+// Deep import, not the feature barrel: the barrel pulls in SettingsDialog,
+// which renders sidebar-aware panels and would close an import cycle.
+import { useShortcut } from "@/features/settings/hooks/use-shortcut"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Separator } from "@/components/ui/separator"
@@ -40,7 +43,6 @@ const noop = () => {}
const SIDEBAR_WIDTH = `${SIDEBAR_WIDTH_DEFAULT}px`
const SIDEBAR_WIDTH_ICON = "3rem"
-const SIDEBAR_KEYBOARD_SHORTCUT = "b"
type SidebarContextProps = {
state: "expanded" | "collapsed"
@@ -146,21 +148,9 @@ function SidebarProvider({
return setOpen((open) => !open)
}, [isMobile, setOpen, setOpenMobile, hasPinMode, togglePinnedProp])
- // Adds a keyboard shortcut to toggle the sidebar.
- React.useEffect(() => {
- const handleKeyDown = (event: KeyboardEvent) => {
- if (
- event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
- (event.metaKey || event.ctrlKey)
- ) {
- event.preventDefault()
- toggleSidebar()
- }
- }
-
- window.addEventListener("keydown", handleKeyDown)
- return () => window.removeEventListener("keydown", handleKeyDown)
- }, [toggleSidebar])
+ // Chord comes from the shortcuts store, so Settings -> Shortcuts can rebind
+ // or clear it.
+ useShortcut("toggleSidebar", toggleSidebar)
// We add a state so that we can do data-state="expanded" or "collapsed".
// This makes it easier to style the sidebar with Tailwind classes.
diff --git a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
index 12466e7638c..d7631a2f3c1 100644
--- a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
+++ b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
@@ -8,6 +8,7 @@ import {
CommandGroup,
CommandList,
} from "@/components/ui/command";
+import { useShortcut } from "@/features/settings/hooks/use-shortcut";
import { Cancel01Icon, Message01Icon, Search01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { useNavigate } from "@tanstack/react-router";
@@ -66,18 +67,11 @@ export function ChatSearchDialog() {
if (!isOpen) setQuery("");
}, [isOpen]);
- useEffect(() => {
- const handler = (e: KeyboardEvent) => {
- if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== "k") return;
- const el = document.activeElement as HTMLElement | null;
- const tag = el?.tagName;
- if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
- e.preventDefault();
- useChatSearchStore.getState().open();
- };
- window.addEventListener("keydown", handler);
- return () => window.removeEventListener("keydown", handler);
- }, []);
+ // skipInTextFields keeps the composer's own ⌘K (and any browser find) intact
+ // while the user is typing, as the hand-rolled handler did.
+ useShortcut("searchChats", () => useChatSearchStore.getState().open(), {
+ skipInTextFields: true,
+ });
return (
<CommandDialog
diff --git a/studio/frontend/src/features/settings/hooks/use-shortcut.ts b/studio/frontend/src/features/settings/hooks/use-shortcut.ts
new file mode 100644
index 00000000000..7e7afbae064
--- /dev/null
+++ b/studio/frontend/src/features/settings/hooks/use-shortcut.ts
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { useEffect, useMemo, useRef } from "react";
+import {
+ type ShortcutId,
+ formatBindingLabel,
+ matchesBinding,
+ parseBinding,
+} from "../lib/keyboard-shortcuts";
+import {
+ resolveBinding,
+ shortcutOwningBinding,
+ useKeyboardShortcutsStore,
+} from "../stores/keyboard-shortcuts-store";
+
+function isTextEntryFocused(): boolean {
+ if (typeof document === "undefined") return false;
+ const el = document.activeElement as HTMLElement | null;
+ const tag = el?.tagName;
+ return (
+ tag === "INPUT" || tag === "TEXTAREA" || Boolean(el?.isContentEditable)
+ );
+}
+
+export interface UseShortcutOptions {
+ /** Skip registration entirely (route gating, dialogs). Defaults to true. */
+ enabled?: boolean;
+ /**
+ * Ignore the chord while a text field has focus. For chords that would
+ * otherwise steal a keystroke the composer wants.
+ */
+ skipInTextFields?: boolean;
+}
+
+/**
+ * Run `handler` when the user presses whatever chord `id` is currently bound
+ * to. The binding is read from the shortcuts store, so an edit in Settings
+ * takes effect without a reload; an unassigned action registers nothing.
+ */
+export function useShortcut(
+ id: ShortcutId,
+ handler: (event: KeyboardEvent) => void,
+ options: UseShortcutOptions = {},
+): void {
+ const { enabled = true, skipInTextFields = false } = options;
+ const value = useKeyboardShortcutsStore((s) =>
+ resolveBinding(s.overrides, id),
+ );
+ // A chord claimed by two actions is consumed by whichever listener runs
+ // first, so only its owner registers. Otherwise the winner would follow mount
+ // order and change from route to route.
+ const owned = useKeyboardShortcutsStore(
+ (s) =>
+ shortcutOwningBinding(s.overrides, resolveBinding(s.overrides, id)) ===
+ id,
+ );
+ const binding = useMemo(() => parseBinding(value), [value]);
+ // The handler usually closes over fresh props, so keep it in a ref rather
+ // than tearing down and re-adding the listener on every render.
+ const handlerRef = useRef(handler);
+ handlerRef.current = handler;
+
+ useEffect(() => {
+ if (!binding || !enabled || !owned) return;
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (event.defaultPrevented) return;
+ if (!matchesBinding(binding, event)) return;
+ if (skipInTextFields && isTextEntryFocused()) return;
+ event.preventDefault();
+ handlerRef.current(event);
+ };
+ window.addEventListener("keydown", onKeyDown);
+ return () => window.removeEventListener("keydown", onKeyDown);
+ }, [binding, enabled, owned, skipInTextFields]);
+}
+
+/**
+ * Label for the chord `id` is bound to right now, in the platform's own
+ * notation, or null when the action is unassigned. Hints that render the
+ * shipped default instead would tell the user to press a chord that stopped
+ * working the moment they rebound or cleared the action in Settings.
+ */
+export function useShortcutLabel(id: ShortcutId): string | null {
+ const value = useKeyboardShortcutsStore((s) =>
+ resolveBinding(s.overrides, id),
+ );
+ return useMemo(() => {
+ const binding = parseBinding(value);
+ return binding ? formatBindingLabel(binding) : null;
+ }, [value]);
+}
diff --git a/studio/frontend/src/features/settings/index.ts b/studio/frontend/src/features/settings/index.ts
index a6d908733fc..c5f69da235c 100644
--- a/studio/frontend/src/features/settings/index.ts
+++ b/studio/frontend/src/features/settings/index.ts
@@ -58,6 +58,12 @@ export type {
PersonalizationAppearance,
PersonalizationProfile,
} from "./api/personalization";
+export { useShortcut, useShortcutLabel } from "./hooks/use-shortcut";
+export {
+ currentBinding,
+ useKeyboardShortcutsStore,
+} from "./stores/keyboard-shortcuts-store";
+export type { ShortcutId } from "./lib/keyboard-shortcuts";
export { useSettingsDialogStore } from "./stores/settings-dialog-store";
export type { SettingsTab } from "./stores/settings-dialog-store";
export type { Palette, ResolvedTheme, Theme } from "./stores/theme-store";
diff --git a/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
new file mode 100644
index 00000000000..880c027f06d
--- /dev/null
+++ b/studio/frontend/src/features/settings/lib/keyboard-shortcuts.ts
@@ -0,0 +1,326 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import type { TranslationKey } from "@/i18n";
+
+/**
+ * Every rebindable action. To add one: an entry in SHORTCUT_DEFS, its two i18n
+ * keys, and a `useShortcut(id, ...)` where the action runs.
+ */
+export type ShortcutId =
+ | "openSettings"
+ | "openKeyboardShortcuts"
+ | "newChat"
+ | "searchChats"
+ | "toggleSidebar";
+
+export type ShortcutGroup = "general" | "chat";
+
+export interface ShortcutDef {
+ id: ShortcutId;
+ labelKey: TranslationKey;
+ descriptionKey: TranslationKey;
+ group: ShortcutGroup;
+ /** Serialized binding, or null for an action that ships unassigned. */
+ defaultBinding: string | null;
+}
+
+/**
+ * `code` is KeyboardEvent.code, not `key`: the physical key, so a binding
+ * survives a layout change and does not shift under Shift/Option. `mod` is Cmd
+ * on macOS and Ctrl elsewhere, as every handler here already treated it.
+ */
+export interface ShortcutBinding {
+ code: string;
+ mod: boolean;
+ ctrl: boolean;
+ shift: boolean;
+ alt: boolean;
+}
+
+export const SHORTCUT_GROUPS: ShortcutGroup[] = ["general", "chat"];
+
+export const SHORTCUT_DEFS: ShortcutDef[] = [
+ {
+ id: "newChat",
+ labelKey: "settings.keyboardShortcuts.actions.newChat.label",
+ descriptionKey: "settings.keyboardShortcuts.actions.newChat.description",
+ group: "chat",
+ defaultBinding: "Mod+Shift+KeyO",
+ },
+ {
+ id: "searchChats",
+ labelKey: "settings.keyboardShortcuts.actions.searchChats.label",
+ descriptionKey:
+ "settings.keyboardShortcuts.actions.searchChats.description",
+ group: "chat",
+ defaultBinding: "Mod+KeyK",
+ },
+ {
+ id: "toggleSidebar",
+ labelKey: "settings.keyboardShortcuts.actions.toggleSidebar.label",
+ descriptionKey:
+ "settings.keyboardShortcuts.actions.toggleSidebar.description",
+ group: "general",
+ defaultBinding: "Mod+KeyB",
+ },
+ {
+ id: "openSettings",
+ labelKey: "settings.keyboardShortcuts.actions.openSettings.label",
+ descriptionKey:
+ "settings.keyboardShortcuts.actions.openSettings.description",
+ group: "general",
+ defaultBinding: "Mod+Comma",
+ },
+ {
+ id: "openKeyboardShortcuts",
+ labelKey: "settings.keyboardShortcuts.actions.openKeyboardShortcuts.label",
+ descriptionKey:
+ "settings.keyboardShortcuts.actions.openKeyboardShortcuts.description",
+ group: "general",
+ defaultBinding: "Mod+Slash",
+ },
+];
+
+export const SHORTCUT_DEF_BY_ID: Record<ShortcutId, ShortcutDef> =
+ Object.fromEntries(SHORTCUT_DEFS.map((def) => [def.id, def])) as Record<
+ ShortcutId,
+ ShortcutDef
+ >;
+
+const SHORTCUT_IDS = new Set<string>(SHORTCUT_DEFS.map((def) => def.id));
+
+export function isShortcutId(value: unknown): value is ShortcutId {
+ return typeof value === "string" && SHORTCUT_IDS.has(value);
+}
+
+/** Modifier codes are never a binding's key on their own. */
+const MODIFIER_CODES = new Set([
+ "MetaLeft",
+ "MetaRight",
+ "ControlLeft",
+ "ControlRight",
+ "ShiftLeft",
+ "ShiftRight",
+ "AltLeft",
+ "AltRight",
+ "CapsLock",
+]);
+
+export function isModifierCode(code: string): boolean {
+ return MODIFIER_CODES.has(code);
+}
+
+// Resolved once: matchesBinding runs on every keydown, and the platform cannot
+// change under a live document.
+let macPlatform: boolean | null = null;
+
+export function isMacPlatform(): boolean {
+ if (macPlatform !== null) return macPlatform;
+ if (typeof navigator === "undefined") return false;
+ // `platform` is deprecated but still the only synchronous signal in Safari,
+ // which is the browser most likely to be rendering ⌘ here.
+ const source = `${navigator.platform ?? ""} ${navigator.userAgent ?? ""}`;
+ macPlatform = /mac|iphone|ipad|ipod/i.test(source);
+ return macPlatform;
+}
+
+/** Serialize to the stored form, e.g. "Mod+Shift+KeyO". */
+export function formatBindingValue(binding: ShortcutBinding): string {
+ const parts: string[] = [];
+ if (binding.mod) parts.push("Mod");
+ if (binding.ctrl) parts.push("Ctrl");
+ if (binding.alt) parts.push("Alt");
+ if (binding.shift) parts.push("Shift");
+ parts.push(binding.code);
+ return parts.join("+");
+}
+
+/** Parse the stored form. Returns null for anything unrecognised. */
+export function parseBinding(
+ value: string | null | undefined,
+): ShortcutBinding | null {
+ if (!value) return null;
+ const parts = value.split("+").filter(Boolean);
+ if (parts.length === 0) return null;
+ const code = parts[parts.length - 1];
+ if (!code || isModifierCode(code)) return null;
+ const binding: ShortcutBinding = {
+ code,
+ mod: false,
+ ctrl: false,
+ shift: false,
+ alt: false,
+ };
+ for (const part of parts.slice(0, -1)) {
+ switch (part) {
+ case "Mod":
+ binding.mod = true;
+ break;
+ case "Ctrl":
+ binding.ctrl = true;
+ break;
+ case "Shift":
+ binding.shift = true;
+ break;
+ case "Alt":
+ binding.alt = true;
+ break;
+ default:
+ return null;
+ }
+ }
+ return binding;
+}
+
+/** Build a binding from a keydown. Returns null while only modifiers are held. */
+export function bindingFromEvent(
+ event: {
+ code: string;
+ key?: string;
+ metaKey: boolean;
+ ctrlKey: boolean;
+ shiftKey: boolean;
+ altKey: boolean;
+ },
+ mac = isMacPlatform(),
+): ShortcutBinding | null {
+ const code = event.code || keyToCode(event.key ?? "");
+ if (!code || isModifierCode(code)) return null;
+ // Off macOS there is nowhere to put Meta: matchesBinding rejects an event
+ // carrying it, so recording Super+Alt+K would drop the Super and persist plain
+ // Alt+K -- a chord the user did not choose, which then fires on Alt+K alone
+ // while the one they pressed never matches. Record nothing instead, the same
+ // answer the recorder already gets while only modifiers are held.
+ if (!mac && event.metaKey) return null;
+ // Cmd on macOS and Ctrl elsewhere both record as Mod, so one binding reads
+ // naturally on either platform. A macOS user pressing Ctrl means Ctrl.
+ return {
+ code,
+ mod: mac ? event.metaKey : event.ctrlKey,
+ ctrl: mac ? event.ctrlKey : false,
+ shift: event.shiftKey,
+ alt: event.altKey,
+ };
+}
+
+/** Last-resort code for engines that report an empty `code` (some IMEs). */
+function keyToCode(key: string): string {
+ if (!key) return "";
+ if (/^[a-z]$/i.test(key)) return `Key${key.toUpperCase()}`;
+ if (/^[0-9]$/.test(key)) return `Digit${key}`;
+ const punctuation: Record<string, string> = {
+ ",": "Comma",
+ ".": "Period",
+ "/": "Slash",
+ ";": "Semicolon",
+ "'": "Quote",
+ "[": "BracketLeft",
+ "]": "BracketRight",
+ "\\": "Backslash",
+ "-": "Minus",
+ "=": "Equal",
+ "`": "Backquote",
+ };
+ return punctuation[key] ?? key;
+}
+
+export function matchesBinding(
+ binding: ShortcutBinding,
+ event: {
+ code: string;
+ key?: string;
+ metaKey: boolean;
+ ctrlKey: boolean;
+ shiftKey: boolean;
+ altKey: boolean;
+ },
+ mac = isMacPlatform(),
+): boolean {
+ const code = event.code || keyToCode(event.key ?? "");
+ if (code !== binding.code) return false;
+ const modHeld = mac ? event.metaKey : event.ctrlKey;
+ // Off-platform modifier: on macOS a bare Ctrl must not satisfy a Mod binding,
+ // and on Windows/Linux the Meta (Windows) key must not either.
+ const otherModHeld = mac ? event.ctrlKey : event.metaKey;
+ if (modHeld !== binding.mod) return false;
+ if (mac) {
+ if (event.ctrlKey !== binding.ctrl) return false;
+ } else if (otherModHeld) {
+ return false;
+ }
+ return event.shiftKey === binding.shift && event.altKey === binding.alt;
+}
+
+/** Human label for a code: "KeyO" -> "O", "Comma" -> ",", "ArrowUp" -> "↑". */
+export function formatCode(code: string): string {
+ if (code.startsWith("Key") && code.length === 4) return code.slice(3);
+ if (code.startsWith("Digit") && code.length === 6) return code.slice(5);
+ const named: Record<string, string> = {
+ Comma: ",",
+ Period: ".",
+ Slash: "/",
+ Semicolon: ";",
+ Quote: "'",
+ BracketLeft: "[",
+ BracketRight: "]",
+ Backslash: "\\",
+ Minus: "-",
+ Equal: "=",
+ Backquote: "`",
+ Space: "Space",
+ Enter: "Enter",
+ Escape: "Esc",
+ Backspace: "⌫",
+ Delete: "Del",
+ Tab: "Tab",
+ ArrowUp: "↑",
+ ArrowDown: "↓",
+ ArrowLeft: "←",
+ ArrowRight: "→",
+ };
+ return named[code] ?? code;
+}
+
+/**
+ * Display string, in the platform's own modifier order: macOS renders
+ * ⌃⌥⇧⌘ then the key, everything else spells the modifiers out.
+ */
+export function formatBindingLabel(
+ binding: ShortcutBinding,
+ mac = isMacPlatform(),
+): string {
+ const key = formatCode(binding.code);
+ if (mac) {
+ let out = "";
+ if (binding.ctrl) out += "⌃";
+ if (binding.alt) out += "⌥";
+ if (binding.shift) out += "⇧";
+ if (binding.mod) out += "⌘";
+ return `${out}${key}`;
+ }
+ const parts: string[] = [];
+ if (binding.mod || binding.ctrl) parts.push("Ctrl");
+ if (binding.alt) parts.push("Alt");
+ if (binding.shift) parts.push("Shift");
+ parts.push(key);
+ return parts.join("+");
+}
+
+/** Convenience for rendering a stored value straight to a chip. */
+export function formatBindingValueLabel(
+ value: string | null,
+ mac = isMacPlatform(),
+): string | null {
+ const parsed = parseBinding(value);
+ return parsed ? formatBindingLabel(parsed, mac) : null;
+}
+
+/**
+ * A binding with no modifier at all would swallow plain typing, so the
+ * recorder refuses it. Function keys and Escape are self-contained.
+ */
+export function isAcceptableBinding(binding: ShortcutBinding): boolean {
+ if (binding.mod || binding.ctrl || binding.alt) return true;
+ return /^F\d{1,2}$/.test(binding.code) || binding.code === "Escape";
+}
diff --git a/studio/frontend/src/features/settings/settings-dialog.tsx b/studio/frontend/src/features/settings/settings-dialog.tsx
index dedd4568712..f6477b5b6ec 100644
--- a/studio/frontend/src/features/settings/settings-dialog.tsx
+++ b/studio/frontend/src/features/settings/settings-dialog.tsx
@@ -24,6 +24,7 @@ import {
DatabaseSettingIcon,
Globe02Icon,
HelpCircleIcon,
+ KeyboardIcon,
Message01Icon,
PaintBrush02Icon,
Search01Icon,
@@ -67,6 +68,10 @@ const TAB_LOADERS = {
connections: () =>
import("./tabs/connections-tab").then((m) => ({ default: m.ConnectionsTab })),
data: () => import("./tabs/data-tab").then((m) => ({ default: m.DataTab })),
+ "keyboard-shortcuts": () =>
+ import("./tabs/keyboard-shortcuts-tab").then((m) => ({
+ default: m.KeyboardShortcutsTab,
+ })),
"api-keys": () => import("./tabs/api-keys-tab").then((m) => ({ default: m.ApiKeysTab })),
agents: () => import("./tabs/agents-tab").then((m) => ({ default: m.AgentsTab })),
debugging: () =>
@@ -204,6 +209,11 @@ const TABS: TabDef[] = [
icon: DatabaseSettingIcon,
badgeKey: "common.new",
},
+ {
+ id: "keyboard-shortcuts",
+ labelKey: "settings.tabs.keyboardShortcuts",
+ icon: KeyboardIcon,
+ },
{
id: "debugging",
labelKey: "settings.tabs.debugging",
@@ -344,6 +354,7 @@ export function SettingsDialog() {
chat: null,
voice: null,
connections: null,
+ "keyboard-shortcuts": null,
data: null,
"api-keys": null,
agents: null,
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index 5c13a0e4fa3..fb963ec1d19 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -150,6 +150,18 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"settings.voice.readAloud.volumeLabel",
"settings.voice.readAloud.previewLabel",
],
+ "keyboard-shortcuts": [
+ // Both the section titles and each action label, so searching "sidebar" or
+ // "new chat" from the settings search lands on the row itself.
+ "settings.keyboardShortcuts.title",
+ "settings.keyboardShortcuts.groups.general",
+ "settings.keyboardShortcuts.groups.chat",
+ "settings.keyboardShortcuts.actions.newChat.label",
+ "settings.keyboardShortcuts.actions.searchChats.label",
+ "settings.keyboardShortcuts.actions.toggleSidebar.label",
+ "settings.keyboardShortcuts.actions.openSettings.label",
+ "settings.keyboardShortcuts.actions.openKeyboardShortcuts.label",
+ ],
debugging: [
"settings.debugging.logSection",
"settings.debugging.source",
diff --git a/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts b/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
new file mode 100644
index 00000000000..291a06e9bcd
--- /dev/null
+++ b/studio/frontend/src/features/settings/stores/keyboard-shortcuts-store.ts
@@ -0,0 +1,160 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { create } from "zustand";
+import {
+ SHORTCUT_DEFS,
+ SHORTCUT_DEF_BY_ID,
+ type ShortcutId,
+ isShortcutId,
+ // Explicit extension: this module is imported directly by the node test
+ // runner, which does not do bundler-style resolution.
+} from "../lib/keyboard-shortcuts.ts";
+
+/**
+ * Exported so "Reset all local preferences" in General can clear it by
+ * reference rather than by a second copy of the literal.
+ */
+export const KEYBOARD_SHORTCUTS_STORAGE_KEY = "unsloth_keyboard_shortcuts";
+const STORAGE_KEY = KEYBOARD_SHORTCUTS_STORAGE_KEY;
+
+/**
+ * Deltas only, so a changed default still reaches rows the user never touched.
+ * `null` means "unassigned"; an absent key means "use the default".
+ */
+export type ShortcutOverrides = Partial<Record<ShortcutId, string | null>>;
+
+function loadOverrides(): ShortcutOverrides {
+ if (typeof window === "undefined") return {};
+ try {
+ const raw = window.localStorage.getItem(STORAGE_KEY);
+ if (!raw) return {};
+ const parsed = JSON.parse(raw) as unknown;
+ if (!parsed || typeof parsed !== "object") return {};
+ const out: ShortcutOverrides = {};
+ for (const [id, value] of Object.entries(
+ parsed as Record<string, unknown>,
+ )) {
+ // Drop ids from an older build so a removed action cannot resurrect.
+ if (!isShortcutId(id)) continue;
+ if (value === null || typeof value === "string") out[id] = value;
+ }
+ return out;
+ } catch {
+ return {};
+ }
+}
+
+function persist(overrides: ShortcutOverrides): void {
+ if (typeof window === "undefined") return;
+ try {
+ if (Object.keys(overrides).length === 0) {
+ window.localStorage.removeItem(STORAGE_KEY);
+ return;
+ }
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify(overrides));
+ } catch {
+ // Private mode / quota: customization is a preference, not worth failing on.
+ }
+}
+
+/** The binding actually in force for `id`, given a set of overrides. */
+export function resolveBinding(
+ overrides: ShortcutOverrides,
+ id: ShortcutId,
+): string | null {
+ return Object.hasOwn(overrides, id)
+ ? (overrides[id] ?? null)
+ : SHORTCUT_DEF_BY_ID[id].defaultBinding;
+}
+
+export function resolveAllBindings(
+ overrides: ShortcutOverrides,
+): Record<ShortcutId, string | null> {
+ return Object.fromEntries(
+ SHORTCUT_DEFS.map((def) => [def.id, resolveBinding(overrides, def.id)]),
+ ) as Record<ShortcutId, string | null>;
+}
+
+/**
+ * Which action a chord runs when more than one claims it. The first window
+ * listener consumes the event, so without a rule the winner would be whichever
+ * component mounted first, and that varies by route. Registry order decides.
+ */
+export function shortcutOwningBinding(
+ overrides: ShortcutOverrides,
+ value: string | null,
+): ShortcutId | null {
+ if (!value) return null;
+ for (const def of SHORTCUT_DEFS) {
+ if (resolveBinding(overrides, def.id) === value) return def.id;
+ }
+ return null;
+}
+
+/**
+ * Ids sharing a binding with at least one other action. Only the owner above
+ * runs, so the tab flags the clash rather than silently refusing the edit.
+ */
+export function findConflicts(overrides: ShortcutOverrides): Set<ShortcutId> {
+ const byValue = new Map<string, ShortcutId[]>();
+ for (const def of SHORTCUT_DEFS) {
+ const value = resolveBinding(overrides, def.id);
+ if (!value) continue;
+ const ids = byValue.get(value);
+ if (ids) ids.push(def.id);
+ else byValue.set(value, [def.id]);
+ }
+ const out = new Set<ShortcutId>();
+ for (const ids of byValue.values()) {
+ if (ids.length > 1) for (const id of ids) out.add(id);
+ }
+ return out;
+}
+
+interface KeyboardShortcutsState {
+ overrides: ShortcutOverrides;
+ /** Assign a serialized binding, e.g. "Mod+Shift+KeyO". */
+ setBinding: (id: ShortcutId, value: string) => void;
+ /** Leave the action with no binding at all. */
+ clearBinding: (id: ShortcutId) => void;
+ /** Drop the override so the shipped default applies again. */
+ resetBinding: (id: ShortcutId) => void;
+ resetAll: () => void;
+}
+
+export const useKeyboardShortcutsStore = create<KeyboardShortcutsState>(
+ (set) => ({
+ overrides: loadOverrides(),
+ setBinding: (id, value) =>
+ set((state) => {
+ const overrides = { ...state.overrides, [id]: value };
+ persist(overrides);
+ return { overrides };
+ }),
+ clearBinding: (id) =>
+ set((state) => {
+ const overrides = { ...state.overrides, [id]: null };
+ persist(overrides);
+ return { overrides };
+ }),
+ resetBinding: (id) =>
+ set((state) => {
+ if (!Object.hasOwn(state.overrides, id)) return state;
+ const overrides = { ...state.overrides };
+ delete overrides[id];
+ persist(overrides);
+ return { overrides };
+ }),
+ resetAll: () =>
+ set(() => {
+ persist({});
+ return { overrides: {} };
+ }),
+ }),
+);
+
+/** Binding in force right now, for non-React callers (keydown handlers). */
+export function currentBinding(id: ShortcutId): string | null {
+ return resolveBinding(useKeyboardShortcutsStore.getState().overrides, id);
+}
diff --git a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts b/studio/frontend/src/features/settings/stores/settings-dialog-store.ts
index 7a383cad7e6..c2569137d98 100644
--- a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts
+++ b/studio/frontend/src/features/settings/stores/settings-dialog-store.ts
@@ -3,19 +3,27 @@
import { create } from "zustand";
-export type SettingsTab =
- | "general"
- | "profile"
- | "appearance"
- | "resources"
- | "chat"
- | "voice"
- | "connections"
- | "data"
- | "api-keys"
- | "agents"
- | "debugging"
- | "about";
+/**
+ * One list, so the type and the persisted-tab check cannot drift: a tab added
+ * to the union alone used to be rejected on reload and fall back to General.
+ */
+export const SETTINGS_TABS = [
+ "general",
+ "profile",
+ "appearance",
+ "resources",
+ "chat",
+ "voice",
+ "connections",
+ "data",
+ "api-keys",
+ "agents",
+ "keyboard-shortcuts",
+ "debugging",
+ "about",
+] as const;
+
+export type SettingsTab = (typeof SETTINGS_TABS)[number];
export type SettingsScrollTarget = "about-updates" | "appearance-sidebar-nav";
@@ -66,21 +74,7 @@ function loadInitialTab(): SettingsTab {
} catch {
return "general";
}
- const valid: SettingsTab[] = [
- "general",
- "profile",
- "appearance",
- "resources",
- "chat",
- "voice",
- "connections",
- "data",
- "api-keys",
- "agents",
- "debugging",
- "about",
- ];
- return valid.includes(stored as SettingsTab)
+ return (SETTINGS_TABS as readonly string[]).includes(stored ?? "")
? (stored as SettingsTab)
: "general";
}
diff --git a/studio/frontend/src/features/settings/tabs/general-tab.tsx b/studio/frontend/src/features/settings/tabs/general-tab.tsx
index 6134ded04ab..5ffbfa1a449 100644
--- a/studio/frontend/src/features/settings/tabs/general-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/general-tab.tsx
@@ -77,6 +77,7 @@ import { SettingsRow } from "../components/settings-row";
import { SettingsSection } from "../components/settings-section";
import { StudioVersionSection } from "../components/studio-version-section";
import { useDesktopBooleanSetting } from "../hooks/use-desktop-boolean-setting";
+import { KEYBOARD_SHORTCUTS_STORAGE_KEY } from "../stores/keyboard-shortcuts-store";
import { SETTINGS_PANEL_PREFS_STORAGE_KEY } from "../stores/settings-panel-prefs-store";
import { CHAT_PROJECT_ATTACHMENT_TARGET_KEY } from "@/features/chat/utils/project-attachment-target";
@@ -98,6 +99,10 @@ const PREFS_KEYS: string[] = [
SIDEBAR_ORGANIZATION_STORAGE_KEY,
"unsloth_settings_active_tab",
SETTINGS_PANEL_PREFS_STORAGE_KEY,
+ // Rebound chords. Without this a reset leaves the user on shortcuts they
+ // asked to throw away, and a chord bound to something unusable has no
+ // escape hatch from this button.
+ KEYBOARD_SHORTCUTS_STORAGE_KEY,
// Chat runtime prefs
CHAT_PROJECT_ATTACHMENT_TARGET_KEY,
"unsloth_chat_auto_title",
diff --git a/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
new file mode 100644
index 00000000000..3f287453900
--- /dev/null
+++ b/studio/frontend/src/features/settings/tabs/keyboard-shortcuts-tab.tsx
@@ -0,0 +1,302 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+import {
+ Alert01Icon,
+ ArrowTurnBackwardIcon,
+ Delete02Icon,
+ PencilEdit02Icon,
+ Search01Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { useEffect, useMemo, useState } from "react";
+import { SettingsRow } from "../components/settings-row";
+import { SettingsSection } from "../components/settings-section";
+import {
+ SHORTCUT_DEFS,
+ SHORTCUT_GROUPS,
+ type ShortcutDef,
+ type ShortcutGroup,
+ type ShortcutId,
+ bindingFromEvent,
+ formatBindingLabel,
+ formatBindingValue,
+ isAcceptableBinding,
+ isMacPlatform,
+ parseBinding,
+} from "../lib/keyboard-shortcuts";
+import {
+ findConflicts,
+ resolveBinding,
+ shortcutOwningBinding,
+ useKeyboardShortcutsStore,
+} from "../stores/keyboard-shortcuts-store";
+
+const GROUP_LABEL_KEYS = {
+ general: "settings.keyboardShortcuts.groups.general",
+ chat: "settings.keyboardShortcuts.groups.chat",
+} as const satisfies Record<ShortcutGroup, string>;
+
+/** The ⌘⇧O chip. Renders the placeholder text when nothing is bound. */
+function BindingChip({
+ label,
+ tone,
+}: {
+ label: string;
+ tone: "assigned" | "unassigned" | "recording";
+}) {
+ return (
+ <span
+ className={cn(
+ "inline-flex min-w-16 items-center justify-center rounded-md px-2 py-1 text-xs font-medium tabular-nums",
+ tone === "assigned" && "bg-muted text-foreground",
+ tone === "unassigned" && "text-muted-foreground",
+ tone === "recording" &&
+ "bg-primary/10 text-primary ring-1 ring-primary/40",
+ )}
+ >
+ {label}
+ </span>
+ );
+}
+
+function IconButton({
+ icon,
+ label,
+ onClick,
+ disabled,
+}: {
+ icon: typeof PencilEdit02Icon;
+ label: string;
+ onClick: () => void;
+ disabled?: boolean;
+}) {
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild={true}>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon"
+ className="size-8 text-muted-foreground hover:text-foreground"
+ aria-label={label}
+ disabled={disabled}
+ onClick={onClick}
+ >
+ <HugeiconsIcon icon={icon} strokeWidth={1.75} className="size-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>{label}</TooltipContent>
+ </Tooltip>
+ );
+}
+
+export function KeyboardShortcutsTab() {
+ const t = useT();
+ const overrides = useKeyboardShortcutsStore((s) => s.overrides);
+ const setBinding = useKeyboardShortcutsStore((s) => s.setBinding);
+ const clearBinding = useKeyboardShortcutsStore((s) => s.clearBinding);
+ const resetBinding = useKeyboardShortcutsStore((s) => s.resetBinding);
+ const resetAll = useKeyboardShortcutsStore((s) => s.resetAll);
+
+ const [query, setQuery] = useState("");
+ const [recordingId, setRecordingId] = useState<ShortcutId | null>(null);
+ // Shown under the row being recorded when the pressed chord is rejected.
+ const [recordingError, setRecordingError] = useState<string | null>(null);
+
+ const mac = isMacPlatform();
+ const conflicts = useMemo(() => findConflicts(overrides), [overrides]);
+
+ // Capture phase, so the chord being recorded reaches this listener before the
+ // shortcut it is replacing fires and before Radix's Escape-to-close.
+ useEffect(() => {
+ if (!recordingId) return;
+ const onKeyDown = (event: KeyboardEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+ if (
+ event.code === "Escape" &&
+ !event.metaKey &&
+ !event.ctrlKey &&
+ !event.altKey &&
+ !event.shiftKey
+ ) {
+ setRecordingId(null);
+ setRecordingError(null);
+ return;
+ }
+ const binding = bindingFromEvent(event);
+ // Modifier held on its own: the user is still assembling the chord.
+ if (!binding) return;
+ if (!isAcceptableBinding(binding)) {
+ setRecordingError(t("settings.keyboardShortcuts.needsModifier"));
+ return;
+ }
+ setBinding(recordingId, formatBindingValue(binding));
+ setRecordingId(null);
+ setRecordingError(null);
+ };
+ window.addEventListener("keydown", onKeyDown, { capture: true });
+ return () =>
+ window.removeEventListener("keydown", onKeyDown, { capture: true });
+ }, [recordingId, setBinding, t]);
+
+ const matches = useMemo(() => {
+ const q = query.trim().toLowerCase();
+ if (!q) return null;
+ return new Set(
+ SHORTCUT_DEFS.filter((def) => {
+ const haystack = `${t(def.labelKey)} ${t(def.descriptionKey)}`;
+ if (haystack.toLowerCase().includes(q)) return true;
+ const value = resolveBinding(overrides, def.id);
+ const parsed = parseBinding(value);
+ return parsed
+ ? formatBindingLabel(parsed, mac).toLowerCase().includes(q)
+ : false;
+ }).map((def) => def.id),
+ );
+ }, [query, t, overrides, mac]);
+
+ const groups = SHORTCUT_GROUPS.map((group) => ({
+ group,
+ defs: SHORTCUT_DEFS.filter(
+ (def) => def.group === group && (!matches || matches.has(def.id)),
+ ),
+ })).filter((entry) => entry.defs.length > 0);
+
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Chip, hint, badge and buttons all read one resolved binding; splitting only passes it around.
+ const renderRow = (def: ShortcutDef) => {
+ const value = resolveBinding(overrides, def.id);
+ const parsed = parseBinding(value);
+ const recording = recordingId === def.id;
+ const conflicted = conflicts.has(def.id) && !recording;
+ // Say which side of a clash this row is on, since only the owner runs.
+ const shadowed =
+ conflicted && shortcutOwningBinding(overrides, value) !== def.id;
+ const label = recording
+ ? t("settings.keyboardShortcuts.recording")
+ : parsed
+ ? formatBindingLabel(parsed, mac)
+ : t("settings.keyboardShortcuts.unassigned");
+ const overridden = Object.hasOwn(overrides, def.id);
+
+ return (
+ <SettingsRow
+ key={def.id}
+ label={t(def.labelKey)}
+ description={
+ <span className="flex flex-col gap-0.5">
+ <span>{t(def.descriptionKey)}</span>
+ {recording ? (
+ <span className="text-xs text-primary">
+ {recordingError ??
+ t("settings.keyboardShortcuts.recordingHint")}
+ </span>
+ ) : null}
+ {conflicted ? (
+ <span className="flex items-center gap-1 text-xs text-amber-500">
+ <HugeiconsIcon
+ icon={Alert01Icon}
+ strokeWidth={1.75}
+ className="size-3.5 shrink-0"
+ />
+ {shadowed
+ ? t("settings.keyboardShortcuts.conflictShadowed")
+ : t("settings.keyboardShortcuts.conflict")}
+ </span>
+ ) : null}
+ </span>
+ }
+ >
+ <div className="flex items-center gap-1">
+ <BindingChip
+ label={label}
+ tone={recording ? "recording" : parsed ? "assigned" : "unassigned"}
+ />
+ <IconButton
+ icon={PencilEdit02Icon}
+ label={t("settings.keyboardShortcuts.edit")}
+ onClick={() => {
+ setRecordingError(null);
+ setRecordingId(recording ? null : def.id);
+ }}
+ />
+ {overridden ? (
+ <IconButton
+ icon={ArrowTurnBackwardIcon}
+ label={t("settings.keyboardShortcuts.reset")}
+ onClick={() => resetBinding(def.id)}
+ />
+ ) : null}
+ <IconButton
+ icon={Delete02Icon}
+ label={t("settings.keyboardShortcuts.clear")}
+ disabled={!parsed}
+ onClick={() => clearBinding(def.id)}
+ />
+ </div>
+ </SettingsRow>
+ );
+ };
+
+ return (
+ <div className="flex flex-col gap-6">
+ <SettingsSection
+ title={t("settings.keyboardShortcuts.title")}
+ description={t("settings.keyboardShortcuts.description")}
+ >
+ <div className="relative py-3">
+ <HugeiconsIcon
+ icon={Search01Icon}
+ strokeWidth={2}
+ className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"
+ />
+ <Input
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder={t("settings.keyboardShortcuts.searchPlaceholder")}
+ className="pl-9"
+ aria-label={t("settings.keyboardShortcuts.searchPlaceholder")}
+ />
+ </div>
+ </SettingsSection>
+
+ {groups.length === 0 ? (
+ <p className="text-sm text-muted-foreground">
+ {t("settings.keyboardShortcuts.noResults")}
+ </p>
+ ) : (
+ groups.map(({ group, defs }) => (
+ <SettingsSection key={group} title={t(GROUP_LABEL_KEYS[group])}>
+ {defs.map(renderRow)}
+ </SettingsSection>
+ ))
+ )}
+
+ <div className="flex justify-start border-t border-border/60 pt-4">
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={Object.keys(overrides).length === 0}
+ onClick={() => {
+ setRecordingId(null);
+ setRecordingError(null);
+ resetAll();
+ }}
+ >
+ {t("settings.keyboardShortcuts.resetAll")}
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index a34183b6655..10a9f6ebfc1 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -198,6 +198,50 @@ export const ar = {
agents: "الوكلاء",
debugging: "السجلات",
voice: "الصوت",
+ keyboardShortcuts: "الاختصارات",
+ },
+ keyboardShortcuts: {
+ title: "اختصارات لوحة المفاتيح",
+ description:
+ "غيّر أي اختصار، أو امسحه لتحرير التركيبة لمتصفحك أو نظام التشغيل.",
+ searchPlaceholder: "بحث في الاختصارات…",
+ noResults: "لا توجد اختصارات مطابقة لهذا البحث.",
+ unassigned: "غير معيّن",
+ recording: "اضغط المفاتيح…",
+ recordingHint: "اضغط التركيبة الجديدة، أو Esc للإلغاء.",
+ needsModifier: "أضف ⌘ أو Ctrl أو Alt. المفتاح المجرد سيبتلع الكتابة.",
+ conflict: "مستخدم أيضاً في اختصار آخر",
+ conflictShadowed: "اختصار آخر يملك هذه التركيبة ويعمل بدلاً منه",
+ edit: "تغيير الاختصار",
+ clear: "إزالة الاختصار",
+ reset: "استعادة الافتراضي",
+ resetAll: "إعادة تعيين الكل إلى الافتراضي",
+ groups: {
+ general: "عام",
+ chat: "المحادثة",
+ },
+ actions: {
+ newChat: {
+ label: "محادثة جديدة",
+ description: "بدء محادثة جديدة",
+ },
+ searchChats: {
+ label: "بحث في المحادثات",
+ description: "فتح مربع حوار بحث المحادثات",
+ },
+ toggleSidebar: {
+ label: "تبديل الشريط الجانبي",
+ description: "إظهار الشريط الجانبي أو إخفاؤه",
+ },
+ openSettings: {
+ label: "فتح الإعدادات",
+ description: "فتح مربع حوار الإعدادات",
+ },
+ openKeyboardShortcuts: {
+ label: "اختصارات لوحة المفاتيح",
+ description: "فتح قائمة الاختصارات هذه",
+ },
+ },
},
debugging: {
logSection: "ملف السجل",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 2c5b3cd5cd5..513dca9852e 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -202,6 +202,50 @@ export const de = {
agents: "Agenten",
debugging: "Protokolle",
voice: "Sprachfunktionen",
+ keyboardShortcuts: "Kürzel",
+ },
+ keyboardShortcuts: {
+ title: "Tastenkürzel",
+ description:
+ "Ändere ein Kürzel oder lösche es, um die Tastenkombination für Browser oder Betriebssystem freizugeben.",
+ searchPlaceholder: "Kürzel suchen…",
+ noResults: "Keine Kürzel passen zu dieser Suche.",
+ unassigned: "Nicht zugewiesen",
+ recording: "Tasten drücken…",
+ recordingHint: "Neue Tastenkombination drücken oder Esc zum Abbrechen.",
+ needsModifier: "⌘, Strg oder Alt hinzufügen. Eine einzelne Taste würde die Eingabe verschlucken.",
+ conflict: "Wird auch von einem anderen Kürzel verwendet",
+ conflictShadowed: "Ein anderes Kürzel belegt diese Kombination und läuft stattdessen",
+ edit: "Kürzel ändern",
+ clear: "Kürzel entfernen",
+ reset: "Standard wiederherstellen",
+ resetAll: "Alle auf Standard zurücksetzen",
+ groups: {
+ general: "Allgemein",
+ chat: "Chat",
+ },
+ actions: {
+ newChat: {
+ label: "Neuer Chat",
+ description: "Einen neuen Chat starten",
+ },
+ searchChats: {
+ label: "Chats durchsuchen",
+ description: "Die Chat-Suche öffnen",
+ },
+ toggleSidebar: {
+ label: "Seitenleiste umschalten",
+ description: "Seitenleiste ein- oder ausblenden",
+ },
+ openSettings: {
+ label: "Einstellungen öffnen",
+ description: "Den Einstellungsdialog öffnen",
+ },
+ openKeyboardShortcuts: {
+ label: "Tastenkürzel",
+ description: "Diese Kürzelliste öffnen",
+ },
+ },
},
debugging: {
logSection: "Protokolldatei",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index a7104afe193..27299c61d92 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -196,9 +196,53 @@ export const en = {
data: "Data",
apiKeys: "API",
agents: "Agents",
+ keyboardShortcuts: "Shortcuts",
debugging: "Logs",
about: "About",
},
+ keyboardShortcuts: {
+ title: "Keyboard shortcuts",
+ description:
+ "Change any shortcut, or clear one to free the chord for your browser or OS.",
+ searchPlaceholder: "Search shortcuts…",
+ noResults: "No shortcuts match that search.",
+ unassigned: "Unassigned",
+ recording: "Press keys…",
+ recordingHint: "Press the new chord, or Esc to cancel.",
+ needsModifier: "Add ⌘, Ctrl or Alt. A bare key would swallow typing.",
+ conflict: "Also used by another shortcut",
+ conflictShadowed: "Another shortcut has this chord and runs instead",
+ edit: "Change shortcut",
+ clear: "Remove shortcut",
+ reset: "Restore default",
+ resetAll: "Reset all to defaults",
+ groups: {
+ general: "General",
+ chat: "Chat",
+ },
+ actions: {
+ newChat: {
+ label: "New chat",
+ description: "Start a new chat",
+ },
+ searchChats: {
+ label: "Search chats",
+ description: "Open the chat search dialog",
+ },
+ toggleSidebar: {
+ label: "Toggle sidebar",
+ description: "Show or hide the sidebar",
+ },
+ openSettings: {
+ label: "Open settings",
+ description: "Open the settings dialog",
+ },
+ openKeyboardShortcuts: {
+ label: "Keyboard shortcuts",
+ description: "Open this shortcuts list",
+ },
+ },
+ },
debugging: {
logSection: "Log file",
source: "Log file",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index aa4f1701e8f..ce335aa6a2e 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -201,6 +201,50 @@ export const es = {
agents: "Agentes",
debugging: "Registros",
voice: "Voz",
+ keyboardShortcuts: "Atajos",
+ },
+ keyboardShortcuts: {
+ title: "Atajos de teclado",
+ description:
+ "Cambia cualquier atajo, o bórralo para liberar la combinación para el navegador o el sistema.",
+ searchPlaceholder: "Buscar atajos…",
+ noResults: "Ningún atajo coincide con esa búsqueda.",
+ unassigned: "Sin asignar",
+ recording: "Pulsa las teclas…",
+ recordingHint: "Pulsa la nueva combinación, o Esc para cancelar.",
+ needsModifier: "Añade ⌘, Ctrl o Alt. Una tecla suelta se tragaría lo que escribes.",
+ conflict: "También lo usa otro atajo",
+ conflictShadowed: "Otro atajo tiene esta combinación y se ejecuta en lugar de este",
+ edit: "Cambiar atajo",
+ clear: "Quitar atajo",
+ reset: "Restaurar el valor predeterminado",
+ resetAll: "Restablecer todo",
+ groups: {
+ general: "General",
+ chat: "Chat",
+ },
+ actions: {
+ newChat: {
+ label: "Nuevo chat",
+ description: "Iniciar un chat nuevo",
+ },
+ searchChats: {
+ label: "Buscar chats",
+ description: "Abrir el diálogo de búsqueda de chats",
+ },
+ toggleSidebar: {
+ label: "Alternar barra lateral",
+ description: "Mostrar u ocultar la barra lateral",
+ },
+ openSettings: {
+ label: "Abrir ajustes",
+ description: "Abrir el diálogo de ajustes",
+ },
+ openKeyboardShortcuts: {
+ label: "Atajos de teclado",
+ description: "Abrir esta lista de atajos",
+ },
+ },
},
debugging: {
logSection: "Archivo de registro",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index 956ceaac266..90f6718868c 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -202,6 +202,50 @@ export const fr = {
agents: "Agents",
debugging: "Journaux",
voice: "Voix",
+ keyboardShortcuts: "Raccourcis",
+ },
+ keyboardShortcuts: {
+ title: "Raccourcis clavier",
+ description:
+ "Modifiez un raccourci, ou effacez-le pour libérer la combinaison pour le navigateur ou le système.",
+ searchPlaceholder: "Rechercher des raccourcis…",
+ noResults: "Aucun raccourci ne correspond à cette recherche.",
+ unassigned: "Non attribué",
+ recording: "Appuyez sur les touches…",
+ recordingHint: "Appuyez sur la nouvelle combinaison, ou Échap pour annuler.",
+ needsModifier: "Ajoutez ⌘, Ctrl ou Alt. Une touche seule avalerait la saisie.",
+ conflict: "Également utilisé par un autre raccourci",
+ conflictShadowed: "Un autre raccourci utilise cette combinaison et s'exécute à sa place",
+ edit: "Modifier le raccourci",
+ clear: "Supprimer le raccourci",
+ reset: "Rétablir la valeur par défaut",
+ resetAll: "Tout réinitialiser",
+ groups: {
+ general: "Général",
+ chat: "Discussion",
+ },
+ actions: {
+ newChat: {
+ label: "Nouvelle discussion",
+ description: "Démarrer une nouvelle discussion",
+ },
+ searchChats: {
+ label: "Rechercher dans les discussions",
+ description: "Ouvrir la recherche de discussions",
+ },
+ toggleSidebar: {
+ label: "Afficher/masquer la barre latérale",
+ description: "Afficher ou masquer la barre latérale",
+ },
+ openSettings: {
+ label: "Ouvrir les paramètres",
+ description: "Ouvrir la fenêtre des paramètres",
+ },
+ openKeyboardShortcuts: {
+ label: "Raccourcis clavier",
+ description: "Ouvrir cette liste de raccourcis",
+ },
+ },
},
debugging: {
logSection: "Fichier journal",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index 4b0aca87f9b..28e740a270d 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -201,6 +201,50 @@ export const hi = {
agents: "एजेंट",
debugging: "लॉग",
voice: "आवाज़",
+ keyboardShortcuts: "शॉर्टकट",
+ },
+ keyboardShortcuts: {
+ title: "कीबोर्ड शॉर्टकट",
+ description:
+ "कोई भी शॉर्टकट बदलें, या उसे हटाकर वह कुंजी-संयोजन अपने ब्राउज़र या OS के लिए खाली करें।",
+ searchPlaceholder: "शॉर्टकट खोजें…",
+ noResults: "इस खोज से कोई शॉर्टकट मेल नहीं खाता।",
+ unassigned: "असाइन नहीं",
+ recording: "कुंजियाँ दबाएँ…",
+ recordingHint: "नया संयोजन दबाएँ, या रद्द करने के लिए Esc।",
+ needsModifier: "⌘, Ctrl या Alt जोड़ें। अकेली कुंजी टाइपिंग निगल लेगी।",
+ conflict: "यह किसी और शॉर्टकट में भी इस्तेमाल हो रहा है",
+ conflictShadowed: "यह संयोजन किसी और शॉर्टकट के पास है और उसके बदले वही चलता है",
+ edit: "शॉर्टकट बदलें",
+ clear: "शॉर्टकट हटाएँ",
+ reset: "डिफ़ॉल्ट पर लौटाएँ",
+ resetAll: "सभी को डिफ़ॉल्ट पर रीसेट करें",
+ groups: {
+ general: "सामान्य",
+ chat: "चैट",
+ },
+ actions: {
+ newChat: {
+ label: "नई चैट",
+ description: "नई चैट शुरू करें",
+ },
+ searchChats: {
+ label: "चैट खोजें",
+ description: "चैट खोज संवाद खोलें",
+ },
+ toggleSidebar: {
+ label: "साइडबार टॉगल करें",
+ description: "साइडबार दिखाएँ या छिपाएँ",
+ },
+ openSettings: {
+ label: "सेटिंग्स खोलें",
+ description: "सेटिंग्स संवाद खोलें",
+ },
+ openKeyboardShortcuts: {
+ label: "कीबोर्ड शॉर्टकट",
+ description: "यह शॉर्टकट सूची खोलें",
+ },
+ },
},
debugging: {
logSection: "लॉग फ़ाइल",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index cb5f645a8ba..c5550908758 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -166,6 +166,50 @@ export const it = {
agents: "Agenti",
debugging: "Log",
about: "Informazioni",
+ keyboardShortcuts: "Scorciatoie",
+ },
+ keyboardShortcuts: {
+ title: "Scorciatoie da tastiera",
+ description:
+ "Modifica una scorciatoia, oppure cancellala per liberare la combinazione per il browser o il sistema.",
+ searchPlaceholder: "Cerca scorciatoie…",
+ noResults: "Nessuna scorciatoia corrisponde alla ricerca.",
+ unassigned: "Non assegnata",
+ recording: "Premi i tasti…",
+ recordingHint: "Premi la nuova combinazione, o Esc per annullare.",
+ needsModifier: "Aggiungi ⌘, Ctrl o Alt. Un tasto singolo intercetterebbe la digitazione.",
+ conflict: "Usata anche da un'altra scorciatoia",
+ conflictShadowed: "Un'altra scorciatoia usa questa combinazione e viene eseguita al suo posto",
+ edit: "Cambia scorciatoia",
+ clear: "Rimuovi scorciatoia",
+ reset: "Ripristina il valore predefinito",
+ resetAll: "Ripristina tutto",
+ groups: {
+ general: "Generali",
+ chat: "Chat",
+ },
+ actions: {
+ newChat: {
+ label: "Nuova chat",
+ description: "Avvia una nuova chat",
+ },
+ searchChats: {
+ label: "Cerca nelle chat",
+ description: "Apri la ricerca delle chat",
+ },
+ toggleSidebar: {
+ label: "Mostra/nascondi barra laterale",
+ description: "Mostra o nascondi la barra laterale",
+ },
+ openSettings: {
+ label: "Apri le impostazioni",
+ description: "Apri la finestra delle impostazioni",
+ },
+ openKeyboardShortcuts: {
+ label: "Scorciatoie da tastiera",
+ description: "Apri questo elenco di scorciatoie",
+ },
+ },
},
debugging: {
logSection: "File di log",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index 1528c9aa227..151a57250ac 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -200,6 +200,50 @@ export const ja = {
data: "データ",
agents: "エージェント",
debugging: "ログ",
+ keyboardShortcuts: "ショートカット",
+ },
+ keyboardShortcuts: {
+ title: "キーボードショートカット",
+ description:
+ "ショートカットを変更したり、消してブラウザや OS にそのキーを譲ったりできます。",
+ searchPlaceholder: "ショートカットを検索…",
+ noResults: "該当するショートカットはありません。",
+ unassigned: "未割り当て",
+ recording: "キーを押してください…",
+ recordingHint: "新しいキーの組み合わせを押すか、Esc でキャンセルします。",
+ needsModifier: "⌘、Ctrl、Alt のいずれかを加えてください。単独のキーでは入力を奪ってしまいます。",
+ conflict: "別のショートカットでも使われています",
+ conflictShadowed: "この組み合わせは別のショートカットのもので、そちらが実行されます",
+ edit: "ショートカットを変更",
+ clear: "ショートカットを削除",
+ reset: "既定値に戻す",
+ resetAll: "すべて既定値に戻す",
+ groups: {
+ general: "一般",
+ chat: "チャット",
+ },
+ actions: {
+ newChat: {
+ label: "新しいチャット",
+ description: "新しいチャットを開始します",
+ },
+ searchChats: {
+ label: "チャットを検索",
+ description: "チャット検索ダイアログを開きます",
+ },
+ toggleSidebar: {
+ label: "サイドバーの表示切り替え",
+ description: "サイドバーを表示または非表示にします",
+ },
+ openSettings: {
+ label: "設定を開く",
+ description: "設定ダイアログを開きます",
+ },
+ openKeyboardShortcuts: {
+ label: "キーボードショートカット",
+ description: "このショートカット一覧を開きます",
+ },
+ },
},
debugging: {
logSection: "ログファイル",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 86c6c651af9..3da7a963be9 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -198,6 +198,50 @@ export const ko = {
agents: "에이전트",
debugging: "로그",
voice: "음성",
+ keyboardShortcuts: "단축키",
+ },
+ keyboardShortcuts: {
+ title: "키보드 단축키",
+ description:
+ "단축키를 바꾸거나, 지워서 해당 조합을 브라우저나 운영체제에 넘길 수 있습니다.",
+ searchPlaceholder: "단축키 검색…",
+ noResults: "검색과 일치하는 단축키가 없습니다.",
+ unassigned: "지정 안 됨",
+ recording: "키를 누르세요…",
+ recordingHint: "새 조합을 누르거나 Esc로 취소하세요.",
+ needsModifier: "⌘, Ctrl 또는 Alt를 추가하세요. 단독 키는 입력을 가로챕니다.",
+ conflict: "다른 단축키도 이 조합을 사용합니다",
+ conflictShadowed: "다른 단축키가 이 조합을 차지하고 있어 그쪽이 실행됩니다",
+ edit: "단축키 변경",
+ clear: "단축키 제거",
+ reset: "기본값 복원",
+ resetAll: "모두 기본값으로 초기화",
+ groups: {
+ general: "일반",
+ chat: "채팅",
+ },
+ actions: {
+ newChat: {
+ label: "새 채팅",
+ description: "새 채팅을 시작합니다",
+ },
+ searchChats: {
+ label: "채팅 검색",
+ description: "채팅 검색 창을 엽니다",
+ },
+ toggleSidebar: {
+ label: "사이드바 토글",
+ description: "사이드바를 표시하거나 숨깁니다",
+ },
+ openSettings: {
+ label: "설정 열기",
+ description: "설정 창을 엽니다",
+ },
+ openKeyboardShortcuts: {
+ label: "키보드 단축키",
+ description: "이 단축키 목록을 엽니다",
+ },
+ },
},
debugging: {
logSection: "로그 파일",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 29b99693b48..d2abee95a48 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -200,6 +200,50 @@ export const ptBR = {
data: "Dados",
agents: "Agentes",
debugging: "Registros",
+ keyboardShortcuts: "Atalhos",
+ },
+ keyboardShortcuts: {
+ title: "Atalhos de teclado",
+ description:
+ "Altere qualquer atalho, ou apague um para liberar a combinação para o navegador ou o sistema.",
+ searchPlaceholder: "Pesquisar atalhos…",
+ noResults: "Nenhum atalho corresponde a essa pesquisa.",
+ unassigned: "Não atribuído",
+ recording: "Pressione as teclas…",
+ recordingHint: "Pressione a nova combinação, ou Esc para cancelar.",
+ needsModifier: "Adicione ⌘, Ctrl ou Alt. Uma tecla sozinha engoliria a digitação.",
+ conflict: "Também usado por outro atalho",
+ conflictShadowed: "Outro atalho tem essa combinação e é executado no lugar dele",
+ edit: "Alterar atalho",
+ clear: "Remover atalho",
+ reset: "Restaurar o padrão",
+ resetAll: "Redefinir tudo para o padrão",
+ groups: {
+ general: "Geral",
+ chat: "Chat",
+ },
+ actions: {
+ newChat: {
+ label: "Novo chat",
+ description: "Iniciar um novo chat",
+ },
+ searchChats: {
+ label: "Pesquisar chats",
+ description: "Abrir a busca de chats",
+ },
+ toggleSidebar: {
+ label: "Alternar barra lateral",
+ description: "Mostrar ou ocultar a barra lateral",
+ },
+ openSettings: {
+ label: "Abrir configurações",
+ description: "Abrir a janela de configurações",
+ },
+ openKeyboardShortcuts: {
+ label: "Atalhos de teclado",
+ description: "Abrir esta lista de atalhos",
+ },
+ },
},
debugging: {
logSection: "Arquivo de log",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 45449fb0246..d3d6c1bb407 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -200,6 +200,50 @@ export const ru = {
agents: "Агенты",
debugging: "Журналы",
voice: "Голос",
+ keyboardShortcuts: "Сочетания",
+ },
+ keyboardShortcuts: {
+ title: "Сочетания клавиш",
+ description:
+ "Измените любое сочетание или очистите его, чтобы освободить комбинацию для браузера или ОС.",
+ searchPlaceholder: "Поиск сочетаний…",
+ noResults: "Ни одно сочетание не соответствует запросу.",
+ unassigned: "Не назначено",
+ recording: "Нажмите клавиши…",
+ recordingHint: "Нажмите новую комбинацию или Esc для отмены.",
+ needsModifier: "Добавьте ⌘, Ctrl или Alt. Одиночная клавиша перехватит ввод текста.",
+ conflict: "Используется также другим сочетанием",
+ conflictShadowed: "Эта комбинация занята другим сочетанием, и выполняется оно",
+ edit: "Изменить сочетание",
+ clear: "Удалить сочетание",
+ reset: "Вернуть значение по умолчанию",
+ resetAll: "Сбросить всё до значений по умолчанию",
+ groups: {
+ general: "Общие",
+ chat: "Чат",
+ },
+ actions: {
+ newChat: {
+ label: "Новый чат",
+ description: "Начать новый чат",
+ },
+ searchChats: {
+ label: "Поиск по чатам",
+ description: "Открыть окно поиска по чатам",
+ },
+ toggleSidebar: {
+ label: "Показать/скрыть боковую панель",
+ description: "Показать или скрыть боковую панель",
+ },
+ openSettings: {
+ label: "Открыть настройки",
+ description: "Открыть окно настроек",
+ },
+ openKeyboardShortcuts: {
+ label: "Сочетания клавиш",
+ description: "Открыть этот список сочетаний",
+ },
+ },
},
debugging: {
logSection: "Файл журнала",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index afa7fb21fbe..190fadab78b 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -196,6 +196,50 @@ export const zhCN = {
data: "数据",
agents: "智能体",
debugging: "日志",
+ keyboardShortcuts: "快捷键",
+ },
+ keyboardShortcuts: {
+ title: "键盘快捷键",
+ description:
+ "可以更改任意快捷键,或将其清除,把该组合让给浏览器或操作系统。",
+ searchPlaceholder: "搜索快捷键…",
+ noResults: "没有匹配的快捷键。",
+ unassigned: "未分配",
+ recording: "请按下按键…",
+ recordingHint: "按下新的组合键,或按 Esc 取消。",
+ needsModifier: "请加上 ⌘、Ctrl 或 Alt。单独一个按键会吞掉正常输入。",
+ conflict: "另一个快捷键也在使用该组合",
+ conflictShadowed: "该组合已被另一个快捷键占用,执行的是那一个",
+ edit: "更改快捷键",
+ clear: "移除快捷键",
+ reset: "恢复默认",
+ resetAll: "全部恢复默认",
+ groups: {
+ general: "通用",
+ chat: "聊天",
+ },
+ actions: {
+ newChat: {
+ label: "新建聊天",
+ description: "开始一个新的聊天",
+ },
+ searchChats: {
+ label: "搜索聊天",
+ description: "打开聊天搜索对话框",
+ },
+ toggleSidebar: {
+ label: "切换侧边栏",
+ description: "显示或隐藏侧边栏",
+ },
+ openSettings: {
+ label: "打开设置",
+ description: "打开设置对话框",
+ },
+ openKeyboardShortcuts: {
+ label: "键盘快捷键",
+ description: "打开该快捷键列表",
+ },
+ },
},
debugging: {
logSection: "日志文件",
diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.ts
new file mode 100644
index 00000000000..df00e15b91c
--- /dev/null
+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts
@@ -0,0 +1,361 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+import {
+ SHORTCUT_DEFS,
+ bindingFromEvent,
+ formatBindingLabel,
+ formatBindingValue,
+ isAcceptableBinding,
+ isShortcutId,
+ matchesBinding,
+ parseBinding,
+} from "../src/features/settings/lib/keyboard-shortcuts.ts";
+import {
+ KEYBOARD_SHORTCUTS_STORAGE_KEY,
+ findConflicts,
+ resolveAllBindings,
+ resolveBinding,
+ shortcutOwningBinding,
+} from "../src/features/settings/stores/keyboard-shortcuts-store.ts";
+import { SETTINGS_TABS } from "../src/features/settings/stores/settings-dialog-store.ts";
+
+function keyEvent(
+ code: string,
+ mods: Partial<{
+ metaKey: boolean;
+ ctrlKey: boolean;
+ shiftKey: boolean;
+ altKey: boolean;
+ }> = {},
+) {
+ return {
+ code,
+ metaKey: false,
+ ctrlKey: false,
+ shiftKey: false,
+ altKey: false,
+ ...mods,
+ };
+}
+
+test("a binding round-trips through serialize and parse", () => {
+ const binding = {
+ code: "KeyO",
+ mod: true,
+ ctrl: false,
+ shift: true,
+ alt: false,
+ };
+ const value = formatBindingValue(binding);
+ assert.equal(value, "Mod+Shift+KeyO");
+ assert.deepEqual(parseBinding(value), binding);
+});
+
+test("parse rejects junk, empties and modifier-only values", () => {
+ assert.equal(parseBinding(null), null);
+ assert.equal(parseBinding(""), null);
+ assert.equal(parseBinding("Mod+ShiftLeft"), null);
+ assert.equal(parseBinding("Hyper+KeyO"), null);
+});
+
+test("every shipped default parses", () => {
+ for (const def of SHORTCUT_DEFS) {
+ if (def.defaultBinding === null) continue;
+ assert.ok(
+ parseBinding(def.defaultBinding),
+ `${def.id} has an unparseable default: ${def.defaultBinding}`,
+ );
+ }
+});
+
+test("matching is exact about modifiers", () => {
+ const binding = parseBinding("Mod+Shift+KeyO");
+ assert.ok(binding);
+ // Non-mac, so Mod is Ctrl.
+ assert.ok(
+ matchesBinding(
+ binding,
+ keyEvent("KeyO", { ctrlKey: true, shiftKey: true }),
+ false,
+ ),
+ );
+ // Missing Shift, extra Alt, and wrong key must all miss.
+ assert.equal(
+ matchesBinding(binding, keyEvent("KeyO", { ctrlKey: true }), false),
+ false,
+ );
+ assert.equal(
+ matchesBinding(
+ binding,
+ keyEvent("KeyO", { ctrlKey: true, shiftKey: true, altKey: true }),
+ false,
+ ),
+ false,
+ );
+ assert.equal(
+ matchesBinding(
+ binding,
+ keyEvent("KeyP", { ctrlKey: true, shiftKey: true }),
+ false,
+ ),
+ false,
+ );
+});
+
+test("off-platform Meta does not satisfy a Mod binding", () => {
+ const binding = parseBinding("Mod+KeyB");
+ assert.ok(binding);
+ // Windows key held instead of Ctrl, on a non-mac platform.
+ assert.equal(
+ matchesBinding(binding, keyEvent("KeyB", { metaKey: true }), false),
+ false,
+ );
+});
+
+test("on macOS Mod is Cmd, and a bare Ctrl is not a substitute", () => {
+ const binding = parseBinding("Mod+KeyB");
+ assert.ok(binding);
+ assert.ok(matchesBinding(binding, keyEvent("KeyB", { metaKey: true }), true));
+ assert.equal(
+ matchesBinding(binding, keyEvent("KeyB", { ctrlKey: true }), true),
+ false,
+ );
+ // Ctrl is bindable in its own right on macOS.
+ const ctrlBinding = parseBinding("Ctrl+KeyB");
+ assert.ok(ctrlBinding);
+ assert.ok(
+ matchesBinding(ctrlBinding, keyEvent("KeyB", { ctrlKey: true }), true),
+ );
+});
+
+test("recording a chord ignores a lone modifier", () => {
+ assert.equal(
+ bindingFromEvent(keyEvent("ShiftLeft", { shiftKey: true }), false),
+ null,
+ );
+ const binding = bindingFromEvent(keyEvent("KeyK", { ctrlKey: true }), false);
+ assert.ok(binding);
+ assert.equal(formatBindingValue(binding), "Mod+KeyK");
+ // The same physical chord on macOS is Cmd, not Ctrl.
+ const macBinding = bindingFromEvent(
+ keyEvent("KeyK", { metaKey: true }),
+ true,
+ );
+ assert.ok(macBinding);
+ assert.equal(formatBindingValue(macBinding), "Mod+KeyK");
+});
+
+test("a bare letter is refused but function keys stand alone", () => {
+ assert.equal(
+ isAcceptableBinding({
+ code: "KeyK",
+ mod: false,
+ ctrl: false,
+ shift: false,
+ alt: false,
+ }),
+ false,
+ );
+ assert.ok(
+ isAcceptableBinding({
+ code: "F5",
+ mod: false,
+ ctrl: false,
+ shift: false,
+ alt: false,
+ }),
+ );
+});
+
+test("labels use each platform's own modifier notation", () => {
+ const binding = parseBinding("Mod+Shift+KeyO");
+ assert.ok(binding);
+ assert.equal(formatBindingLabel(binding, true), "⇧⌘O");
+ assert.equal(formatBindingLabel(binding, false), "Ctrl+Shift+O");
+ const comma = parseBinding("Mod+Comma");
+ assert.ok(comma);
+ assert.equal(formatBindingLabel(comma, true), "⌘,");
+});
+
+test("an override wins, and null means unassigned", () => {
+ assert.equal(resolveBinding({}, "toggleSidebar"), "Mod+KeyB");
+ assert.equal(
+ resolveBinding({ toggleSidebar: "Mod+Alt+KeyB" }, "toggleSidebar"),
+ "Mod+Alt+KeyB",
+ );
+ // Present-but-null is a deliberate clear, not a fallback to the default.
+ assert.equal(resolveBinding({ toggleSidebar: null }, "toggleSidebar"), null);
+});
+
+test("defaults ship without conflicts", () => {
+ assert.equal(findConflicts({}).size, 0);
+ const all = resolveAllBindings({});
+ assert.equal(all.newChat, "Mod+Shift+KeyO");
+});
+
+test("two actions on one chord are both flagged", () => {
+ const conflicts = findConflicts({ toggleSidebar: "Mod+KeyK" });
+ assert.deepEqual(
+ [...conflicts].sort(),
+ ["searchChats", "toggleSidebar"].sort(),
+ );
+});
+
+test("cleared actions never count as conflicting", () => {
+ const conflicts = findConflicts({ toggleSidebar: null, searchChats: null });
+ assert.equal(conflicts.size, 0);
+});
+
+test("ids from an older build are rejected", () => {
+ assert.ok(isShortcutId("newChat"));
+ assert.equal(isShortcutId("someRemovedAction"), false);
+});
+
+test("a contested chord is owned by the earlier action in registry order", () => {
+ // searchChats is declared before toggleSidebar, so it keeps Mod+K.
+ const overrides = { toggleSidebar: "Mod+KeyK" };
+ assert.equal(shortcutOwningBinding(overrides, "Mod+KeyK"), "searchChats");
+ // The loser keeps its own binding elsewhere, so ownership is per chord.
+ assert.equal(shortcutOwningBinding(overrides, "Mod+Comma"), "openSettings");
+});
+
+test("exactly one owner exists per contested chord", () => {
+ const overrides = { toggleSidebar: "Mod+KeyK", newChat: "Mod+KeyK" };
+ const contested = [...findConflicts(overrides)];
+ assert.equal(contested.length, 3);
+ const owners = new Set(
+ contested.map(() => shortcutOwningBinding(overrides, "Mod+KeyK")),
+ );
+ assert.equal(owners.size, 1);
+ // newChat is declared first, so it wins over searchChats and toggleSidebar.
+ assert.equal(shortcutOwningBinding(overrides, "Mod+KeyK"), "newChat");
+});
+
+test("an unbound or unclaimed chord has no owner", () => {
+ assert.equal(shortcutOwningBinding({}, null), null);
+ assert.equal(shortcutOwningBinding({}, "Mod+Alt+KeyZ"), null);
+ // A cleared action does not own the chord it used to have.
+ assert.equal(shortcutOwningBinding({ searchChats: null }, "Mod+KeyK"), null);
+});
+
+// Reset-all is the documented escape hatch. A chord bound to something the
+// browser eats leaves the Shortcuts tab itself hard to reach, so the General
+// reset has to cover this key or the user is stuck with it.
+test("Reset all local preferences clears the rebound chords", async () => {
+ const source = await readFile(
+ new URL("../src/features/settings/tabs/general-tab.tsx", import.meta.url),
+ "utf8",
+ );
+ const keys = source.slice(
+ source.indexOf("const PREFS_KEYS"),
+ source.indexOf("];", source.indexOf("const PREFS_KEYS")),
+ );
+ assert.ok(keys, "PREFS_KEYS moved; this contract needs updating");
+ assert.ok(
+ keys.includes("KEYBOARD_SHORTCUTS_STORAGE_KEY") ||
+ keys.includes(`"${KEYBOARD_SHORTCUTS_STORAGE_KEY}"`),
+ `${KEYBOARD_SHORTCUTS_STORAGE_KEY} missing from PREFS_KEYS`,
+ );
+});
+
+// Every overlay carries the tab label and every row, or a non-English install
+// shows an English word in the middle of a translated settings dialog.
+test("every locale overlay carries the shortcut strings", async () => {
+ const locales = [
+ "ar", "de", "es", "fr", "hi", "it", "ja", "ko", "pt-br", "ru", "zh-CN",
+ ];
+ for (const locale of locales) {
+ const source = await readFile(
+ new URL(`../src/i18n/locales/${locale}.ts`, import.meta.url),
+ "utf8",
+ );
+ const at = source.indexOf("keyboardShortcuts: {");
+ assert.notEqual(
+ at,
+ -1,
+ `${locale} is missing the settings.keyboardShortcuts subtree`,
+ );
+ const subtree = source.slice(at, source.indexOf("\n },", at));
+ for (const key of ["title", "resetAll", "conflictShadowed", "groups"]) {
+ assert.ok(
+ subtree.includes(`${key}:`),
+ `${locale} is missing settings.keyboardShortcuts.${key}`,
+ );
+ }
+ for (const def of SHORTCUT_DEFS) {
+ assert.ok(
+ subtree.includes(`${def.id}: {`),
+ `${locale} is missing settings.keyboardShortcuts.actions.${def.id}`,
+ );
+ }
+ }
+});
+
+test("every settings tab survives a reload", () => {
+ // The persisted-tab check reads this same list, so a tab added to the union
+ // alone can no longer be rejected back to General.
+ assert.ok(SETTINGS_TABS.includes("keyboard-shortcuts"));
+ assert.equal(new Set(SETTINGS_TABS).size, SETTINGS_TABS.length);
+});
+
+test("a Super chord off macOS records nothing rather than a different chord", () => {
+ // matchesBinding rejects a non-mac event carrying Meta, so there is nowhere to
+ // put it. Persisting Alt+K for a user who pressed Super+Alt+K would assign an
+ // action to a chord they did not choose, and fire it on Alt+K alone.
+ assert.equal(
+ bindingFromEvent(keyEvent("KeyK", { metaKey: true, altKey: true }), false),
+ null,
+ );
+ assert.equal(
+ bindingFromEvent(keyEvent("KeyK", { metaKey: true }), false),
+ null,
+ );
+ // Ctrl+Meta is likewise not a Mod chord with the Meta quietly dropped.
+ assert.equal(
+ bindingFromEvent(keyEvent("KeyK", { metaKey: true, ctrlKey: true }), false),
+ null,
+ );
+ // The same chords on macOS are ordinary Cmd bindings and still record.
+ const mac = bindingFromEvent(
+ keyEvent("KeyK", { metaKey: true, altKey: true }),
+ true,
+ );
+ assert.ok(mac);
+ assert.equal(formatBindingValue(mac), "Mod+Alt+KeyK");
+});
+
+// The sidebar search tooltip and the Settings menu row are the two hints a
+// user sees outside the shortcuts tab. Hard-coded, they keep advertising the
+// shipped chord after a rebind, and a dead one after a clear.
+test("the sidebar hints render the bound chord, not the shipped default", async () => {
+ const source = await readFile(
+ new URL("../src/components/app-sidebar.tsx", import.meta.url),
+ "utf8",
+ );
+ for (const literal of ['"⌘K"', '"Ctrl+K"', "<DropdownMenuShortcut>⌘,"]) {
+ assert.ok(
+ !source.includes(literal),
+ `app-sidebar still hard-codes ${literal}`,
+ );
+ }
+ assert.ok(source.includes('useShortcutLabel("searchChats")'));
+ assert.ok(source.includes('useShortcutLabel("openSettings")'));
+ // Unassigned actions must drop the hint rather than render an empty key cap.
+ assert.ok(source.includes("{searchShortcutLabel && ("));
+ assert.ok(source.includes("{settingsShortcutLabel && ("));
+});
+
+test("a hint label follows the override and disappears when cleared", () => {
+ const label = (overrides: Parameters<typeof resolveBinding>[0], id: "searchChats" | "openSettings") => {
+ const binding = parseBinding(resolveBinding(overrides, id));
+ return binding ? formatBindingLabel(binding, false) : null;
+ };
+ assert.equal(label({}, "searchChats"), "Ctrl+K");
+ assert.equal(label({ searchChats: "Mod+Shift+KeyF" }, "searchChats"), "Ctrl+Shift+F");
+ assert.equal(label({ searchChats: null }, "searchChats"), null);
+ assert.equal(label({}, "openSettings"), "Ctrl+,");
+});
diff --git a/tests/studio/test_auth_form_input_count.py b/tests/studio/test_auth_form_input_count.py
index 31cbca85637..cf7ef351e74 100644
--- a/tests/studio/test_auth_form_input_count.py
+++ b/tests/studio/test_auth_form_input_count.py
@@ -172,7 +172,11 @@ def test_auth_flow_routes_do_not_mount_global_settings():
root = (FRONTEND / "app/routes/__root.tsx").read_text(encoding = "utf-8")
assert "{!isAuthFlowRoute && <SettingsDialog />}" in root
assert "useSettingsDialogStore.getState().closeDialog();" in root
- assert "if (isAuthFlowRoute) return;" in root
+ # The settings chord must stay inert on the auth routes. That used to be an
+ # early return inside a hand-rolled keydown handler; once the chords became
+ # rebindable it moved into useShortcut's `enabled` option. Lock the
+ # behaviour, not one spelling of it, so either form passes.
+ assert "if (isAuthFlowRoute) return;" in root or "{ enabled: !isAuthFlowRoute }" in root
for route in ("login", "change-password"):
assert "isAuthFlow: true" in (FRONTEND / f"app/routes/{route}.tsx").read_text(
encoding = "utf-8"