Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(settings): list every keyboard shortcut in one list

rubenluetke10-beepd73d7d672c8d
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index f1be04787f..5bae868f8c 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1656,16 +1656,20 @@
"tester_hint": "Drück beliebige Tasten — sie erscheinen hier, zusammen mit dem, was sie in Jarvis tun.",
"tester_modifiers": "Halten und eine Taste dazunehmen.",
"tester_free": "Frei — nichts in Jarvis nutzt diese Kombination.",
- "section_app": "In der App",
- "section_app_hint": "Funktioniert, solange das Jarvis-Fenster vorne ist.",
- "section_calls": "Anrufe",
- "section_calls_hint": "Sprachanruf starten und beenden — aus jedem Programm auf diesem Computer.",
- "section_dictation": "Diktat",
- "section_dictation_hint": "In das Fenster sprechen, das gerade vorne ist. Geändert wird es im Sprachbereich.",
- "edit_in_voice": "Ändern",
- "section_workspace": "Terminals und Arbeitsbereich",
- "section_workspace_hint": "Feste Tasten für die Agenten-Terminals und diese App.",
- "footer": "Anruf-, Auflege- und Diktat-Tasten funktionieren überall auf diesem Computer. Die Schnellsuche und die Arbeitsbereich-Tasten nur im Jarvis-Fenster."
+ "list_title": "Alle Tastenkürzel",
+ "list_count": "{count} Kürzel",
+ "scope_global": "Überall auf diesem Computer",
+ "scope_window": "Im Jarvis-Fenster",
+ "scope_terminal": "In einem Agenten-Terminal",
+ "edit": "Ändern",
+ "new_keys": "Neue Tasten",
+ "edit_in_voice": "Im Sprachbereich ändern",
+ "edit_in_appshots": "In Appshots ändern",
+ "appshot_window": "Appshot vom Fenster vorne",
+ "appshot_region": "Appshot von einem Bereich",
+ "appshot_recording": "Bildschirmaufnahme starten oder stoppen",
+ "open_overlay": "Kürzel-Übersicht zeigen",
+ "options_title": "Ein- und ausschalten"
},
"shortcut_overlay": {
"title": "Tastenkürzel",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 04268fe7b1..4fc46264ef 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1689,16 +1689,20 @@
"tester_hint": "Press any keys — they show up here with what they do in Jarvis.",
"tester_modifiers": "Keep holding and add a key.",
"tester_free": "Free — nothing in Jarvis uses this combination.",
- "section_app": "In the app",
- "section_app_hint": "Works while the Jarvis window is in front.",
- "section_calls": "Calls",
- "section_calls_hint": "Start and end a voice call — from any app on this computer.",
- "section_dictation": "Dictation",
- "section_dictation_hint": "Speak into whatever window is in front. Changed in the voice section.",
- "edit_in_voice": "Change",
- "section_workspace": "Terminals and workspace",
- "section_workspace_hint": "Fixed keys for the agent terminals and this app.",
- "footer": "Call, hang-up and dictation keys work everywhere on this computer. The quick switcher and the workspace keys only work inside the Jarvis window."
+ "list_title": "All shortcuts",
+ "list_count": "{count} shortcuts",
+ "scope_global": "Anywhere on this computer",
+ "scope_window": "In the Jarvis window",
+ "scope_terminal": "In an agent terminal",
+ "edit": "Change",
+ "new_keys": "New keys",
+ "edit_in_voice": "Change in the voice section",
+ "edit_in_appshots": "Change in Appshots",
+ "appshot_window": "Appshot of the window in front",
+ "appshot_region": "Appshot of an area",
+ "appshot_recording": "Start or stop a screen recording",
+ "open_overlay": "Show the shortcut overview",
+ "options_title": "Switch on or off"
},
"shortcut_overlay": {
"title": "Keyboard shortcuts",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 6a112c697e..1ed517e115 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1656,16 +1656,20 @@
"tester_hint": "Pulsa cualquier tecla: aparece aquí junto con lo que hace en Jarvis.",
"tester_modifiers": "Mantén pulsado y añade una tecla.",
"tester_free": "Libre: nada en Jarvis usa esta combinación.",
- "section_app": "En la app",
- "section_app_hint": "Funciona mientras la ventana de Jarvis está delante.",
- "section_calls": "Llamadas",
- "section_calls_hint": "Empieza y termina una llamada de voz desde cualquier app de este ordenador.",
- "section_dictation": "Dictado",
- "section_dictation_hint": "Habla en la ventana que esté delante. Se cambia en la sección de voz.",
- "edit_in_voice": "Cambiar",
- "section_workspace": "Terminales y espacio de trabajo",
- "section_workspace_hint": "Teclas fijas para los terminales de agentes y esta app.",
- "footer": "Las teclas de llamada, colgar y dictado funcionan en todo este ordenador. El cambio rápido y las teclas del espacio de trabajo solo dentro de la ventana de Jarvis."
+ "list_title": "Todos los atajos",
+ "list_count": "{count} atajos",
+ "scope_global": "En cualquier lugar de este ordenador",
+ "scope_window": "En la ventana de Jarvis",
+ "scope_terminal": "En un terminal de agente",
+ "edit": "Cambiar",
+ "new_keys": "Teclas nuevas",
+ "edit_in_voice": "Cambiar en la sección de voz",
+ "edit_in_appshots": "Cambiar en Appshots",
+ "appshot_window": "Appshot de la ventana de delante",
+ "appshot_region": "Appshot de una zona",
+ "appshot_recording": "Iniciar o detener una grabación de pantalla",
+ "open_overlay": "Mostrar el resumen de atajos",
+ "options_title": "Activar o desactivar"
},
"shortcut_overlay": {
"title": "Atajos de teclado",
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
index 663dd3fe28..6776b28663 100644
--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
@@ -27,10 +27,17 @@ import type { KeybindAction } from "@/hooks/useHotkey";
export type ShortcutArea = "voice" | "workspace";
+/**
+ * Where a shortcut fires: anywhere on the computer (a global OS hotkey), only
+ * while the Jarvis window is in front, or only inside an agent terminal.
+ */
+export type ShortcutScope = "global" | "window" | "terminal";
+
interface ShortcutBase {
/** i18n key for the one-line description. */
labelKey: string;
area: ShortcutArea;
+ scope: ShortcutScope;
}
export interface RebindableShortcut extends ShortcutBase {
@@ -71,18 +78,20 @@ export type Shortcut = RebindableShortcut | FixedShortcut | AppSettingShortcut;
export const SHORTCUTS: readonly Shortcut[] = [
// ── Voice — every one of these is rebindable in Settings ───────────────
- { kind: "rebindable", area: "voice", action: "dictate", labelKey: "shortcut_overlay.voice.dictate" },
+ { kind: "rebindable", area: "voice", scope: "global", action: "dictate", labelKey: "shortcut_overlay.voice.dictate" },
{
kind: "rebindable",
area: "voice",
+ scope: "global",
action: "dictate_toggle",
labelKey: "shortcut_overlay.voice.dictate_toggle",
},
- { kind: "rebindable", area: "voice", action: "call", labelKey: "shortcut_overlay.voice.call" },
- { kind: "rebindable", area: "voice", action: "hangup", labelKey: "shortcut_overlay.voice.hangup" },
+ { kind: "rebindable", area: "voice", scope: "global", action: "call", labelKey: "shortcut_overlay.voice.call" },
+ { kind: "rebindable", area: "voice", scope: "global", action: "hangup", labelKey: "shortcut_overlay.voice.hangup" },
{
kind: "rebindable",
area: "voice",
+ scope: "global",
action: "paste_last",
labelKey: "shortcut_overlay.voice.paste_last",
},
@@ -91,6 +100,7 @@ export const SHORTCUTS: readonly Shortcut[] = [
{
kind: "fixed",
area: "workspace",
+ scope: "terminal",
keys: ["Mod", "+"],
alternateKeys: [["Mod", "="]],
labelKey: "shortcut_overlay.workspace.zoom_in",
@@ -98,6 +108,7 @@ export const SHORTCUTS: readonly Shortcut[] = [
{
kind: "fixed",
area: "workspace",
+ scope: "terminal",
keys: ["Mod", "-"],
alternateKeys: [["Mod", "_"]],
labelKey: "shortcut_overlay.workspace.zoom_out",
@@ -105,42 +116,49 @@ export const SHORTCUTS: readonly Shortcut[] = [
{
kind: "fixed",
area: "workspace",
+ scope: "terminal",
keys: ["Mod", "0"],
labelKey: "shortcut_overlay.workspace.zoom_reset",
},
{
kind: "fixed",
area: "workspace",
+ scope: "window",
keys: ["?"],
labelKey: "shortcut_overlay.workspace.open_overlay",
},
{
kind: "fixed",
area: "workspace",
+ scope: "terminal",
keys: ["Ctrl", "B"],
labelKey: "shortcut_overlay.workspace.ide_menu",
},
{
kind: "app",
area: "workspace",
+ scope: "window",
setting: "quick_switch",
labelKey: "shortcut_overlay.workspace.quick_switch",
},
{
kind: "app",
area: "workspace",
+ scope: "window",
setting: "app_zoom_in",
labelKey: "shortcut_overlay.workspace.app_zoom_in",
},
{
kind: "app",
area: "workspace",
+ scope: "window",
setting: "app_zoom_out",
labelKey: "shortcut_overlay.workspace.app_zoom_out",
},
{
kind: "app",
area: "workspace",
+ scope: "window",
setting: "app_zoom_reset",
labelKey: "shortcut_overlay.workspace.app_zoom_reset",
},
diff --git a/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx b/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx
index 257caa2c0e..2089fe4694 100644
--- a/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx
@@ -1,6 +1,6 @@
/**
- * The Keyboard shortcuts page: its four sections, and the key tester telling
- * what a pressed combination does — through the real matchers.
+ * The Keyboard shortcuts page: one list of every shortcut, and the key tester
+ * telling what a pressed combination does — through the real matchers.
*/
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
@@ -45,14 +45,37 @@ describe("ShortcutsView", () => {
vi.unstubAllGlobals();
});
- it("shows the four sections", async () => {
+ it("lists every shortcut in one list, global keys first", async () => {
render(<ShortcutsView />);
- for (const id of ["app", "calls", "dictation", "workspace"]) {
- expect(screen.getByTestId(`shortcuts-section-${id}`)).toBeTruthy();
+ const list = screen.getByTestId("shortcuts-list");
+ const rows = list.querySelectorAll("li");
+ // 14 registry entries + the three appshot keys.
+ expect(rows.length).toBe(17);
+ expect(screen.getByTestId("shortcuts-count").textContent).toContain("17");
+ expect(rows[0].textContent).toContain("Anywhere on this computer");
+ expect(rows[rows.length - 1].textContent).toContain("In an agent terminal");
+ for (const id of ["call", "hangup", "dictate", "quick_switch", "appshot-hotkey"]) {
+ expect(screen.getByTestId(`shortcut-row-${id}`)).toBeTruthy();
}
expect(await screen.findAllByText("Ctrl")).toBeTruthy();
});
+ it("opens the recorder under a voice key row", async () => {
+ render(<ShortcutsView />);
+ await act(async () => {});
+ expect(screen.queryByTestId("combo-field-call")).toBeNull();
+ fireEvent.click(screen.getByTestId("shortcuts-edit-call"));
+ expect(screen.getByTestId("combo-field-call")).toBeTruthy();
+ });
+
+ it("shows the quick switcher as off once it is switched off", () => {
+ render(<ShortcutsView />);
+ fireEvent.click(screen.getByTestId("quick-switch-enabled"));
+ const row = screen.getByTestId("shortcut-row-quick_switch");
+ expect(row.textContent).toMatch(/off/i);
+ expect(screen.getByTestId("shortcuts-edit-quick_switch").hasAttribute("disabled")).toBe(true);
+ });
+
it("names what the quick switcher chord does", () => {
render(<ShortcutsView />);
press({ key: " ", code: "Space", ctrlKey: true });
@@ -61,7 +84,7 @@ describe("ShortcutsView", () => {
it("names a voice keybind and calls a free chord free", async () => {
render(<ShortcutsView />);
- await screen.findByTestId("shortcuts-section-dictation");
+ await screen.findByTestId("shortcut-row-dictate");
// Let the keybinds fetch settle before pressing.
await act(async () => {});
press({ key: "v", code: "KeyV", ctrlKey: true, altKey: true });
@@ -88,7 +111,13 @@ describe("ShortcutsView", () => {
it("sends the dictation edit to the voice section", () => {
render(<ShortcutsView />);
- fireEvent.click(screen.getByTestId("shortcuts-edit-dictation"));
+ fireEvent.click(screen.getByTestId("shortcuts-edit-dictate"));
expect(useEventStore.getState().activeSection).toBe("voice-shortcuts");
});
+
+ it("sends the appshot keys to the Appshots section", () => {
+ render(<ShortcutsView />);
+ fireEvent.click(screen.getByTestId("shortcuts-edit-appshot-region_hotkey"));
+ expect(useEventStore.getState().activeSection).toBe("appshots");
+ });
});
diff --git a/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx b/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx
index 4eda48a420..9824403f6c 100644
--- a/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx
@@ -1,19 +1,23 @@
/**
* Keyboard shortcuts — a Settings-hub page of its own.
*
- * Every shortcut Jarvis answers to, on one page: the ones edited here (the
- * quick switcher, Call and Hang up), the dictation keys that are edited in the
- * voice section and only listed here with a way there, and the fixed chords of
- * the workspace. On top sits a key tester: press anything and it shows the
- * keys big, plus what — if anything — they do in Jarvis. It answers "is this
- * combination free?" before someone records it.
+ * Every shortcut Jarvis answers to, in ONE list: the voice keys, the appshot
+ * keys, the quick switcher, the zoom steps and the fixed chords of the
+ * workspace. Each row says what the shortcut does and where it works, and
+ * shows its keys in one column; the rows that can be changed carry their
+ * editor (or, for keys owned by another section, a way there). The on/off
+ * switches live under the list. On top sits a key tester: press anything and
+ * it shows the keys big, plus what — if anything — they do in Jarvis. It
+ * answers "is this combination free?" before someone records it.
*
- * The tester resolves through the REAL matchers (the quick switcher's chord
- * matcher, the terminal zoom matcher, the voice keybind normalisation), never
- * through a copied list, so it cannot tell a different story than the app.
+ * The list is built from `lib/shortcutRegistry` — the source the `?` overlay
+ * renders from — plus the appshot settings. The tester resolves through the
+ * REAL matchers (the quick switcher's chord matcher, the terminal zoom matcher,
+ * the voice keybind normalisation), never through a copied list, so it cannot
+ * tell a different story than the app.
*/
-import { useEffect, useMemo, useState, type ReactNode } from "react";
-import { ArrowUpRight, AppWindow, Keyboard, Mic, Phone, Sparkles, SquareTerminal } from "lucide-react";
+import { useEffect, useState, type ReactNode } from "react";
+import { ArrowUpRight, Keyboard, Pencil } from "lucide-react";
import { PageHeader } from "@/components/layout/PageHeader";
import { Button } from "@/components/ui/button";
import { useT } from "@/i18n";
@@ -28,19 +32,33 @@ import {
type KeybindsConfig,
} from "@/hooks/useHotkey";
import { detectKeyboardPlatform } from "@/views/settings/keyboardLayout";
-import { ACTION_LABEL_KEY, ComboChips, formatCombo } from "@/views/settings/KeybindRow";
-import { KeybindsPanel } from "@/views/settings/KeybindsPanel";
+import { ACTION_LABEL_KEY, ComboChips, KeybindRow, formatCombo } from "@/views/settings/KeybindRow";
import { QuickSwitchKeybind } from "@/views/settings/QuickSwitchKeybind";
-import { AppZoomKeybinds } from "@/views/settings/AppZoomKeybinds";
-import { appZoomIntentFor } from "@/lib/appZoom";
+import { AppZoomChordRow, AppZoomKeybinds } from "@/views/settings/AppZoomKeybinds";
+import { KeyCaps, NoKeys, ShortcutListRow } from "@/views/settings/ShortcutListRow";
+import { appZoomIntentFor, type AppZoomIntent } from "@/lib/appZoom";
import { useAppZoomSettings } from "@/store/appZoomSettings";
import { eventMatchesChord } from "@/lib/quickSwitchChord";
import { isTextEntryTarget } from "@/lib/shortcutOverlayTrigger";
-import { keyLabel, shortcutsForArea, type FixedShortcut } from "@/lib/shortcutRegistry";
+import {
+ SHORTCUTS,
+ keyLabel,
+ type AppSettingShortcut,
+ type FixedShortcut,
+ type RebindableShortcut,
+ type Shortcut,
+ type ShortcutScope,
+} from "@/lib/shortcutRegistry";
+import { fetchAppshotSettings, formatAppshotHotkey, type AppshotSettings } from "@/lib/appshotApi";
import { zoomIntentFor } from "@/components/agentic/terminalZoom";
import { cn } from "@/lib/utils";
-const DICTATION_ACTIONS: readonly KeybindAction[] = ["dictate", "dictate_toggle", "paste_last"];
+/** Voice keys that are edited in the voice section; this page links there. */
+const VOICE_SECTION_ACTIONS: ReadonlySet<KeybindAction> = new Set<KeybindAction>([
+ "dictate",
+ "dictate_toggle",
+ "paste_last",
+]);
const APP_ZOOM_LABEL = {
in: "settings_view.app_zoom.in_label",
@@ -48,12 +66,57 @@ const APP_ZOOM_LABEL = {
reset: "settings_view.app_zoom.reset_label",
} as const;
+const APP_ZOOM_SETTING: Record<Exclude<AppSettingShortcut["setting"], "quick_switch">, AppZoomIntent> = {
+ app_zoom_in: "in",
+ app_zoom_out: "out",
+ app_zoom_reset: "reset",
+};
+
const ZOOM_LABEL = {
in: "shortcut_overlay.workspace.zoom_in",
out: "shortcut_overlay.workspace.zoom_out",
reset: "shortcut_overlay.workspace.zoom_reset",
} as const;
+/** The overlay calls itself "this list"; on this page that would mean the page. */
+const LABEL_OVERRIDE: Record<string, string> = {
+ "shortcut_overlay.workspace.open_overlay": "shortcuts_view.open_overlay",
+};
+
+type AppshotField = "hotkey" | "region_hotkey" | "recording_hotkey";
+
+const APPSHOT_ROWS: readonly { field: AppshotField; labelKey: string }[] = [
+ { field: "hotkey", labelKey: "shortcuts_view.appshot_window" },
+ { field: "region_hotkey", labelKey: "shortcuts_view.appshot_region" },
+ { field: "recording_hotkey", labelKey: "shortcuts_view.appshot_recording" },
+];
+
+const SCOPE_ORDER: Record<ShortcutScope, number> = { global: 0, window: 1, terminal: 2 };
+
+/** One row of the list: a registry entry or an appshot key. */
+type ListEntry =
+ | { kind: "registry"; shortcut: Shortcut }
+ | { kind: "appshot"; field: AppshotField; labelKey: string };
+
+/** Where it works first (everywhere → window → terminal), then changeable before fixed keys. */
+function entryRank(entry: ListEntry): [number, number] {
+ if (entry.kind === "appshot") return [SCOPE_ORDER.global, 1];
+ const { scope, kind } = entry.shortcut;
+ return [SCOPE_ORDER[scope], kind === "fixed" ? 2 : 0];
+}
+
+const LIST_ENTRIES: readonly ListEntry[] = [
+ ...SHORTCUTS.map((shortcut): ListEntry => ({ kind: "registry", shortcut })),
+ ...APPSHOT_ROWS.map((row): ListEntry => ({ kind: "appshot", ...row })),
+]
+ .map((entry, index) => ({ entry, index }))
+ .sort((a, b) => {
+ const [scopeA, rankA] = entryRank(a.entry);
+ const [scopeB, rankB] = entryRank(b.entry);
+ return scopeA - scopeB || rankA - rankB || a.index - b.index;
+ })
+ .map(({ entry }) => entry);
+
// ── Keycaps ────────────────────────────────────────────────────────────────
/** One big keycap. Theme tokens only, so it reads in light and dark. */
@@ -74,22 +137,6 @@ function BigCap({ children, ghost = false }: { children: ReactNode; ghost?: bool
);
}
-/** A small keycap for a fixed chord ("Mod" drawn as ⌘ or Ctrl). */
-function SmallCaps({ keys, isMac }: { keys: string[]; isMac: boolean }) {
- return (
- <span className="inline-flex items-center gap-1">
- {keys.map((token, i) => (
- <span key={i} className="inline-flex items-center gap-1">
- {i > 0 && <span className="text-muted-foreground/50">+</span>}
- <kbd className="rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-micro text-foreground shadow-[inset_0_-1px_0_rgba(0,0,0,0.35)]">
- {keyLabel(token, isMac)}
- </kbd>
- </span>
- ))}
- </span>
- );
-}
-
// ── The key tester ──────────────────────────────────────────────────────────
interface Pressed {
@@ -209,97 +256,305 @@ function KeyTester({ config }: { config: KeybindsConfig | null }) {
);
}
-// ── Sections ────────────────────────────────────────────────────────────────
+// ── The list ────────────────────────────────────────────────────────────────
+
+type Keybinds = ReturnType<typeof useKeybinds>;
-function SectionCard({
- icon,
- title,
- hint,
- action,
- children,
+function Chips({ combo }: { combo: string }) {
+ return (
+ <span className="inline-flex flex-wrap items-center justify-end gap-1">
+ <ComboChips combo={combo} />
+ </span>
+ );
+}
+
+/** The pencil that opens or closes a row's editor. */
+function EditToggle({
+ open,
+ disabled = false,
+ onToggle,
testId,
}: {
- icon: ReactNode;
- title: string;
- hint: string;
- action?: ReactNode;
- children: ReactNode;
+ open: boolean;
+ disabled?: boolean;
+ onToggle: () => void;
testId: string;
}) {
+ const t = useT();
return (
- <section data-testid={testId} className="flex flex-col rounded-xl border border-border bg-card">
- <header className="flex items-start gap-3 border-b border-border px-5 py-4">
- <span className="grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-secondary text-foreground [&>svg]:h-[18px] [&>svg]:w-[18px]">
- {icon}
- </span>
- <div className="min-w-0 flex-1">
- <h2 className="text-base font-semibold text-foreground">{title}</h2>
- <p className="mt-0.5 text-sm text-muted-foreground">{hint}</p>
- </div>
- {action}
- </header>
- <div className="flex-1 px-5 py-4">{children}</div>
- </section>
+ <Button
+ type="button"
+ size="icon"
+ variant={open ? "secondary" : "ghost"}
+ className="h-8 w-8"
+ data-testid={testId}
+ aria-expanded={open}
+ aria-label={t("shortcuts_view.edit")}
+ title={t("shortcuts_view.edit")}
+ disabled={disabled}
+ onClick={onToggle}
+ >
+ <Pencil />
+ </Button>
);
}
-function ListRow({ label, chord }: { label: string; chord: ReactNode }) {
+/** The arrow to the section that owns a key, for rows not edited here. */
+function EditElsewhere({ label, testId, onClick }: { label: string; testId: string; onClick: () => void }) {
return (
- <li className="flex items-center justify-between gap-4 py-2.5">
- <span className="min-w-0 text-sm text-foreground">{label}</span>
- <span className="flex shrink-0 flex-wrap items-center justify-end gap-1">{chord}</span>
- </li>
+ <Button
+ type="button"
+ size="icon"
+ variant="ghost"
+ className="h-8 w-8"
+ data-testid={testId}
+ aria-label={label}
+ title={label}
+ onClick={onClick}
+ >
+ <ArrowUpRight />
+ </Button>
);
}
-function DictationList({ config }: { config: KeybindsConfig | null }) {
+function VoiceKeyRow({ shortcut, keybinds }: { shortcut: RebindableShortcut; keybinds: Keybinds }) {
const t = useT();
+ const setActiveSection = useEventStore((s) => s.setActiveSection);
+ const [open, setOpen] = useState(false);
+ const { config, loading, saveKeybind } = keybinds;
+ const combo = config?.keybinds?.[shortcut.action] ?? "";
+ const elsewhere = VOICE_SECTION_ACTIONS.has(shortcut.action);
+
return (
- <ul className="divide-y divide-border">
- {DICTATION_ACTIONS.map((action) => {
- const combo = config?.keybinds?.[action];
- return (
- <ListRow
- key={action}
- label={t(ACTION_LABEL_KEY[action])}
- chord={
- combo ? (
- <ComboChips combo={combo} />
- ) : (
- <span className="text-sm italic text-muted-foreground">
- {t("shortcut_overlay.unassigned")}
- </span>
- )
- }
+ <ShortcutListRow
+ testId={`shortcut-row-${shortcut.action}`}
+ title={t(shortcut.labelKey)}
+ scope={shortcut.scope}
+ chord={
+ !config ? (
+ <NoKeys>—</NoKeys>
+ ) : combo ? (
+ <Chips combo={combo} />
+ ) : (
+ <NoKeys>{t("shortcut_overlay.unassigned")}</NoKeys>
+ )
+ }
+ actions={
+ elsewhere ? (
+ <EditElsewhere
+ label={t("shortcuts_view.edit_in_voice")}
+ testId={`shortcuts-edit-${shortcut.action}`}
+ onClick={() => setActiveSection("voice-shortcuts")}
/>
- );
- })}
- </ul>
+ ) : (
+ <EditToggle open={open} onToggle={() => setOpen((o) => !o)} testId={`shortcuts-edit-${shortcut.action}`} />
+ )
+ }
+ >
+ {open && !elsewhere && (
+ <div className="mt-3">
+ <KeybindRow
+ action={shortcut.action}
+ label={t("shortcuts_view.new_keys")}
+ config={config}
+ loading={loading}
+ onSave={saveKeybind}
+ />
+ </div>
+ )}
+ </ShortcutListRow>
);
}
-function WorkspaceList() {
+function QuickSwitchRow({
+ shortcut,
+ voiceConfig,
+}: {
+ shortcut: AppSettingShortcut;
+ voiceConfig: KeybindsConfig | null;
+}) {
+ const t = useT();
+ const enabled = useQuickSwitchSettings((s) => s.enabled);
+ const combo = useQuickSwitchSettings((s) => s.combo);
+ const [open, setOpen] = useState(false);
+ const editing = open && enabled;
+
+ return (
+ <ShortcutListRow
+ testId="shortcut-row-quick_switch"
+ title={t(shortcut.labelKey)}
+ scope={shortcut.scope}
+ chord={
+ !enabled ? (
+ <NoKeys>{t("shortcut_overlay.off")}</NoKeys>
+ ) : combo ? (
+ <KeyCaps caps={formatCombo(combo).split(" + ")} />
+ ) : (
+ <NoKeys>{t("shortcut_overlay.unassigned")}</NoKeys>
+ )
+ }
+ actions={
+ <EditToggle
+ open={editing}
+ disabled={!enabled}
+ onToggle={() => setOpen((o) => !o)}
+ testId="shortcuts-edit-quick_switch"
+ />
+ }
+ >
+ {editing && (
+ <div className="mt-3">
+ <QuickSwitchKeybind voiceConfig={voiceConfig} part="editor" />
+ </div>
+ )}
+ </ShortcutListRow>
+ );
+}
+
+function FixedRow({ shortcut, isMac }: { shortcut: FixedShortcut; isMac: boolean }) {
+ const t = useT();
+ return (
+ <ShortcutListRow
+ title={t(LABEL_OVERRIDE[shortcut.labelKey] ?? shortcut.labelKey)}
+ scope={shortcut.scope}
+ chord={<KeyCaps caps={shortcut.keys.map((key) => keyLabel(key, isMac))} />}
+ />
+ );
+}
+
+function AppshotRow({
+ field,
+ labelKey,
+ settings,
+ isMac,
+}: {
+ field: AppshotField;
+ labelKey: string;
+ /** undefined while loading, null when the settings could not be read. */
+ settings: AppshotSettings | null | undefined;
+ isMac: boolean;
+}) {
+ const t = useT();
+ const setActiveSection = useEventStore((s) => s.setActiveSection);
+ const hotkey = settings?.[field] ?? "";
+
+ return (
+ <ShortcutListRow
+ testId={`shortcut-row-appshot-${field}`}
+ title={t(labelKey)}
+ scope="global"
+ chord={
+ !settings ? (
+ <NoKeys>—</NoKeys>
+ ) : !settings.enabled ? (
+ <NoKeys>{t("shortcut_overlay.off")}</NoKeys>
+ ) : hotkey ? (
+ <KeyCaps caps={formatAppshotHotkey(hotkey, isMac).split(" + ")} />
+ ) : (
+ <NoKeys>{t("shortcut_overlay.unassigned")}</NoKeys>
+ )
+ }
+ actions={
+ <EditElsewhere
+ label={t("shortcuts_view.edit_in_appshots")}
+ testId={`shortcuts-edit-appshot-${field}`}
+ onClick={() => setActiveSection("appshots")}
+ />
+ }
+ />
+ );
+}
+
+function ShortcutList({ keybinds }: { keybinds: Keybinds }) {
const t = useT();
const isMac = detectKeyboardPlatform() === "mac";
- const rows = useMemo(
- () => shortcutsForArea("workspace").filter((s): s is FixedShortcut => s.kind === "fixed"),
- [],
+ const [appshots, setAppshots] = useState<AppshotSettings | null | undefined>(undefined);
+
+ useEffect(() => {
+ let alive = true;
+ fetchAppshotSettings()
+ .then((settings) => {
+ if (alive) setAppshots(settings);
+ })
+ .catch((error: unknown) => {
+ // The rows stay readable without it: they show "—" instead of keys.
+ console.warn("[shortcuts] appshot settings unavailable", error);
+ if (alive) setAppshots(null);
+ });
+ return () => {
+ alive = false;
+ };
+ }, []);
+
+ const rows = LIST_ENTRIES.map((entry) => {
+ if (entry.kind === "appshot") {
+ return (
+ <AppshotRow
+ key={`appshot-${entry.field}`}
+ field={entry.field}
+ labelKey={entry.labelKey}
+ settings={appshots}
+ isMac={isMac}
+ />
+ );
+ }
+ const { shortcut } = entry;
+ if (shortcut.kind === "rebindable") {
+ return <VoiceKeyRow key={shortcut.labelKey} shortcut={shortcut} keybinds={keybinds} />;
+ }
+ if (shortcut.kind === "fixed") {
+ return <FixedRow key={shortcut.labelKey} shortcut={shortcut} isMac={isMac} />;
+ }
+ if (shortcut.setting === "quick_switch") {
+ return <QuickSwitchRow key={shortcut.labelKey} shortcut={shortcut} voiceConfig={keybinds.config} />;
+ }
+ return (
+ <AppZoomChordRow
+ key={shortcut.labelKey}
+ intent={APP_ZOOM_SETTING[shortcut.setting]}
+ title={t(shortcut.labelKey)}
+ />
+ );
+ });
+
+ return (
+ <section data-testid="shortcuts-list" className="rounded-xl border border-border bg-card">
+ <header className="flex items-center justify-between gap-4 border-b border-border px-5 py-3">
+ <h2 className="text-sm font-semibold text-foreground">{t("shortcuts_view.list_title")}</h2>
+ <span className="text-micro tabular-nums text-muted-foreground" data-testid="shortcuts-count">
+ {t("shortcuts_view.list_count").replace("{count}", String(rows.length))}
+ </span>
+ </header>
+ {keybinds.error && <p className="px-5 pt-3 text-sm text-destructive">{keybinds.error}</p>}
+ <ul className="divide-y divide-border">{rows}</ul>
+ </section>
);
+}
+
+function OptionsCard({ voiceConfig }: { voiceConfig: KeybindsConfig | null }) {
+ const t = useT();
return (
- <ul className="divide-y divide-border">
- {rows.map((row) => (
- <ListRow key={row.labelKey} label={t(row.labelKey)} chord={<SmallCaps keys={row.keys} isMac={isMac} />} />
- ))}
- </ul>
+ <section data-testid="shortcuts-options" className="rounded-xl border border-border bg-card">
+ <header className="border-b border-border px-5 py-3">
+ <h2 className="text-sm font-semibold text-foreground">{t("shortcuts_view.options_title")}</h2>
+ </header>
+ <div className="divide-y divide-border">
+ <div className="px-5 py-4">
+ <QuickSwitchKeybind voiceConfig={voiceConfig} part="toggle" />
+ </div>
+ <div className="px-5 py-4">
+ <AppZoomKeybinds />
+ </div>
+ </div>
+ </section>
);
}
export function ShortcutsView() {
const t = useT();
- const setActiveSection = useEventStore((s) => s.setActiveSection);
// One read of the voice keybinds for the tester, the list and the quick
// switcher's duplicate check; a save anywhere refetches it.
- const { config } = useKeybinds();
+ const keybinds = useKeybinds();
return (
<div
@@ -313,58 +568,9 @@ export function ShortcutsView() {
description={t("shortcuts_view.description")}
/>
<div className="flex flex-col gap-6">
- <KeyTester config={config} />
- <div className="grid gap-6 xl:grid-cols-2">
- <SectionCard
- testId="shortcuts-section-app"
- icon={<Sparkles />}
- title={t("shortcuts_view.section_app")}
- hint={t("shortcuts_view.section_app_hint")}
- >
- <QuickSwitchKeybind voiceConfig={config} />
- <AppZoomKeybinds />
- </SectionCard>
- <SectionCard
- testId="shortcuts-section-calls"
- icon={<Phone />}
- title={t("shortcuts_view.section_calls")}
- hint={t("shortcuts_view.section_calls_hint")}
- >
- <KeybindsPanel bare />
- </SectionCard>
- <SectionCard
- testId="shortcuts-section-dictation"
- icon={<Mic />}
- title={t("shortcuts_view.section_dictation")}
- hint={t("shortcuts_view.section_dictation_hint")}
- action={
- <Button
- type="button"
- variant="ghost"
- size="sm"
- data-testid="shortcuts-edit-dictation"
- onClick={() => setActiveSection("voice-shortcuts")}
- >
- {t("shortcuts_view.edit_in_voice")}
- <ArrowUpRight aria-hidden />
- </Button>
- }
- >
- <DictationList config={config} />
- </SectionCard>
- <SectionCard
- testId="shortcuts-section-workspace"
- icon={<SquareTerminal />}
- title={t("shortcuts_view.section_workspace")}
- hint={t("shortcuts_view.section_workspace_hint")}
- >
- <WorkspaceList />
- </SectionCard>
- </div>
- <p className="flex items-center gap-2 text-sm text-muted-foreground">
- <AppWindow className="h-4 w-4 shrink-0" aria-hidden />
- {t("shortcuts_view.footer")}
- </p>
+ <KeyTester config={keybinds.config} />
+ <ShortcutList keybinds={keybinds} />
+ <OptionsCard voiceConfig={keybinds.config} />
</div>
</div>
</div>
diff --git a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.test.tsx b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.test.tsx
index fab9d1a05e..57f56a8dab 100644
--- a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.test.tsx
@@ -5,7 +5,7 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
-import { AppZoomKeybinds } from "./AppZoomKeybinds";
+import { AppZoomChordRow, AppZoomKeybinds } from "./AppZoomKeybinds";
import { useAppZoomSupport } from "@/hooks/useAppZoom";
import { defaultAppZoomBindings } from "@/lib/appZoom";
import {
@@ -19,6 +19,20 @@ import {
useQuickSwitchSettings,
} from "@/store/quickSwitchSettings";
+/** The page draws the switch and the three chord rows in two places; render both. */
+function Zoom() {
+ return (
+ <>
+ <AppZoomKeybinds />
+ <ul>
+ <AppZoomChordRow intent="in" title="Zoom in" />
+ <AppZoomChordRow intent="out" title="Zoom out" />
+ <AppZoomChordRow intent="reset" title="Back to 100 %" />
+ </ul>
+ </>
+ );
+}
+
describe("AppZoomKeybinds", () => {
beforeEach(() => {
window.localStorage.removeItem(APP_ZOOM_STORAGE_KEY);
@@ -30,7 +44,7 @@ describe("AppZoomKeybinds", () => {
afterEach(cleanup);
it("records a new zoom-in chord and remembers it", () => {
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
fireEvent.click(screen.getByTestId("app-zoom-record-in"));
expect(screen.getByTestId("app-zoom-row-in").getAttribute("data-keybind-recording")).toBe("true");
@@ -42,14 +56,14 @@ describe("AppZoomKeybinds", () => {
it("records Plus on a German keyboard without the layout's key position", () => {
useAppZoomSettings.getState().setBinding("in", "f9");
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
fireEvent.click(screen.getByTestId("app-zoom-record-in"));
fireEvent.keyDown(window, { key: "+", code: "BracketRight", ctrlKey: true });
expect(useAppZoomSettings.getState().bindings.in).toBe("ctrl+plus");
});
it("refuses a chord another step uses, and keeps the old one", () => {
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
const before = useAppZoomSettings.getState().bindings.in;
fireEvent.click(screen.getByTestId("app-zoom-record-in"));
fireEvent.keyDown(window, { key: "-", code: "Minus", ctrlKey: true });
@@ -58,7 +72,7 @@ describe("AppZoomKeybinds", () => {
});
it("refuses the quick switcher's chord", () => {
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
fireEvent.click(screen.getByTestId("app-zoom-record-reset"));
fireEvent.keyDown(window, { key: " ", code: "Space", ctrlKey: true });
expect(screen.getByRole("alert").textContent).toMatch(/quick switcher/i);
@@ -66,7 +80,7 @@ describe("AppZoomKeybinds", () => {
it("cancels on Escape and resets to the default", () => {
useAppZoomSettings.getState().setBinding("out", "alt+down");
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
fireEvent.click(screen.getByTestId("app-zoom-record-out"));
fireEvent.keyDown(window, { key: "Escape", code: "Escape" });
expect(useAppZoomSettings.getState().bindings.out).toBe("alt+down");
@@ -76,7 +90,7 @@ describe("AppZoomKeybinds", () => {
});
it("steps the size with its buttons and resets on the percentage", () => {
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
fireEvent.click(screen.getByTestId("app-zoom-step-in"));
expect(screen.getByTestId("app-zoom-level").textContent).toBe("110 %");
fireEvent.click(screen.getByTestId("app-zoom-level"));
@@ -85,7 +99,7 @@ describe("AppZoomKeybinds", () => {
it("explains that a browser tab keeps its own zoom", () => {
useAppZoomSupport.setState({ support: "browser" });
- render(<AppZoomKeybinds />);
+ render(<Zoom />);
expect(screen.queryByTestId("app-zoom-level")).toBeNull();
expect(screen.getByTestId("app-zoom-note").textContent).toMatch(/browser/i);
});
diff --git a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx
index 49a495ffe4..2b47235265 100644
--- a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx
@@ -1,6 +1,7 @@
/**
- * The Keyboard shortcuts page's zoom block: on/off, the current size, and the
- * three chords (bigger, smaller, back to 100 %).
+ * The Keyboard shortcuts page's zoom pieces: `AppZoomChordRow` is one of the
+ * three chords (bigger, smaller, back to 100 %) as a row of the shortcut list,
+ * and `AppZoomKeybinds` is the on/off switch with the current size.
*
* It has its own small recorder instead of the shared voice-key recorder, and
* that is deliberate: the shared one records physical key positions and knows
@@ -31,12 +32,7 @@ import {
import { useAppZoomSettings } from "@/store/appZoomSettings";
import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";
import { parseChord } from "@/lib/quickSwitchChord";
-
-const LABEL_KEY: Record<AppZoomIntent, string> = {
- in: "settings_view.app_zoom.in_label",
- out: "settings_view.app_zoom.out_label",
- reset: "settings_view.app_zoom.reset_label",
-};
+import { NoKeys, ShortcutListRow } from "@/views/settings/ShortcutListRow";
const PROBLEM_KEY: Record<AppZoomComboProblem | "quick_switch", string> = {
typing_key: "settings_view.app_zoom.problem_typing_key",
@@ -68,8 +64,10 @@ export function ZoomCaps({ combo }: { combo: string }) {
);
}
-function ZoomChordRow({ intent }: { intent: AppZoomIntent }) {
+/** One zoom step as a row of the shortcut list, with its own recorder. */
+export function AppZoomChordRow({ intent, title }: { intent: AppZoomIntent; title: string }) {
const t = useT();
+ const enabled = useAppZoomSettings((s) => s.enabled);
const bindings = useAppZoomSettings((s) => s.bindings);
const setBinding = useAppZoomSettings((s) => s.setBinding);
const quickSwitch = useQuickSwitchSettings();
@@ -109,32 +107,39 @@ function ZoomChordRow({ intent }: { intent: AppZoomIntent }) {
return () => window.removeEventListener("keydown", onKeyDown, true);
}, [recording, intent, bindings, quickSwitch.enabled, quickSwitch.combo, setBinding, t]);
+ const off = !enabled && !recording;
+ const recordLabel = recording ? t("settings_view.keybinds.stop") : t("settings_view.keybinds.record");
+
return (
- <div
- className="flex flex-col gap-1 py-2.5"
- data-testid={`app-zoom-row-${intent}`}
- data-keybind-recording={recording ? "true" : undefined}
- >
- <div className="flex items-center justify-between gap-3">
- <span className="min-w-0 text-sm text-foreground">{t(LABEL_KEY[intent])}</span>
- <div className="flex shrink-0 items-center gap-1.5">
- {recording ? (
- <span className="text-sm italic text-muted-foreground" aria-live="polite">
- {t("settings_view.keybinds.recording")}
- </span>
- ) : combo ? (
- <ZoomCaps combo={combo} />
- ) : (
- <span className="text-sm italic text-muted-foreground">{t("shortcut_overlay.unassigned")}</span>
- )}
+ <ShortcutListRow
+ testId={`app-zoom-row-${intent}`}
+ recording={recording}
+ title={title}
+ scope="window"
+ chord={
+ recording ? (
+ <span className="text-sm italic text-muted-foreground" aria-live="polite">
+ {t("settings_view.keybinds.recording")}
+ </span>
+ ) : off ? (
+ <NoKeys>{t("shortcut_overlay.off")}</NoKeys>
+ ) : combo ? (
+ <ZoomCaps combo={combo} />
+ ) : (
+ <NoKeys>{t("shortcut_overlay.unassigned")}</NoKeys>
+ )
+ }
+ actions={
+ <>
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8"
data-testid={`app-zoom-record-${intent}`}
- aria-label={recording ? t("settings_view.keybinds.stop") : t("settings_view.keybinds.record")}
- title={recording ? t("settings_view.keybinds.stop") : t("settings_view.keybinds.record")}
+ aria-label={recordLabel}
+ title={recordLabel}
+ disabled={off}
onClick={() => {
setError(null);
setRecording((r) => !r);
@@ -150,31 +155,34 @@ function ZoomChordRow({ intent }: { intent: AppZoomIntent }) {
data-testid={`app-zoom-clear-${intent}`}
aria-label={t("settings_view.keybinds.clear")}
title={t("settings_view.keybinds.clear")}
- disabled={!combo || recording}
+ disabled={off || !combo || recording}
onClick={() => setBinding(intent, "")}
>
<X />
</Button>
- </div>
- </div>
+ </>
+ }
+ >
{error && (
- <p className="text-sm text-destructive" role="alert">
+ <p className="mt-2 text-sm text-destructive" role="alert">
{error}
</p>
)}
- {!recording && combo !== fallback && (
- <button
- type="button"
- className="self-end text-micro text-muted-foreground underline hover:text-foreground"
- onClick={() => {
- setError(null);
- setBinding(intent, fallback);
- }}
- >
- {t("settings_view.keybinds.reset")}
- </button>
+ {!off && !recording && combo !== fallback && (
+ <div className="mt-1 flex justify-end">
+ <button
+ type="button"
+ className="text-micro text-muted-foreground underline hover:text-foreground"
+ onClick={() => {
+ setError(null);
+ setBinding(intent, fallback);
+ }}
+ >
+ {t("settings_view.keybinds.reset")}
+ </button>
+ </div>
)}
- </div>
+ </ShortcutListRow>
);
}
@@ -190,7 +198,7 @@ export function AppZoomKeybinds() {
const stepper = support !== "browser" && support !== "unsupported";
return (
- <div className="mt-4 space-y-stack border-t border-border pt-4" data-testid="app-zoom-settings">
+ <div className="space-y-stack" data-testid="app-zoom-settings">
<div className="flex items-start justify-between gap-4">
<div className="min-w-0">
<p className="text-base font-medium text-foreground">{label}</p>
@@ -238,13 +246,6 @@ export function AppZoomKeybinds() {
</div>
</div>
)}
- {enabled && (
- <div className="divide-y divide-border">
- {APP_ZOOM_INTENTS.map((intent) => (
- <ZoomChordRow key={intent} intent={intent} />
- ))}
- </div>
- )}
<p className="text-sm text-muted-foreground" data-testid="app-zoom-note">
{support === "browser"
? t("settings_view.app_zoom.note_browser")
diff --git a/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsx b/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsx
index 53e1946a3e..a5118cfe3c 100644
--- a/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsx
@@ -12,6 +12,9 @@
* never open on it. They are deliberately NOT handed to the recorder: its
* overlap caution ("pressing the longer one triggers both") is true for global
* hotkeys but false here, because the switcher fires on its exact chord only.
+ *
+ * `part` splits the block for the shortcuts page, which shows the on/off switch
+ * among its options and the recorder under the quick switcher's list row.
*/
import { Switch } from "@/components/ui/switch";
import { useT } from "@/i18n";
@@ -42,7 +45,13 @@ function chordKey(combo: string): string {
return [...[...mods].sort(), ...[...keys].sort()].join("+");
}
-export function QuickSwitchKeybind({ voiceConfig }: { voiceConfig: KeybindsConfig | null }) {
+export function QuickSwitchKeybind({
+ voiceConfig,
+ part = "all",
+}: {
+ voiceConfig: KeybindsConfig | null;
+ part?: "all" | "toggle" | "editor";
+}) {
const t = useT();
const enabled = useQuickSwitchSettings((s) => s.enabled);
const combo = useQuickSwitchSettings((s) => s.combo);
@@ -75,21 +84,23 @@ export function QuickSwitchKeybind({ voiceConfig }: { voiceConfig: KeybindsConfi
return (
<div className="space-y-stack" data-testid="quick-switch-settings">
- <div className="flex items-start justify-between gap-4">
- <div className="min-w-0">
- <p className="text-base font-medium text-foreground">{label}</p>
- <p className="mt-0.5 text-sm text-muted-foreground">
- {t("settings_view.quick_switch.description")}
- </p>
+ {part !== "editor" && (
+ <div className="flex items-start justify-between gap-4">
+ <div className="min-w-0">
+ <p className="text-base font-medium text-foreground">{label}</p>
+ <p className="mt-0.5 text-sm text-muted-foreground">
+ {t("settings_view.quick_switch.description")}
+ </p>
+ </div>
+ <Switch
+ checked={enabled}
+ onCheckedChange={setEnabled}
+ aria-label={label}
+ data-testid="quick-switch-enabled"
+ />
</div>
- <Switch
- checked={enabled}
- onCheckedChange={setEnabled}
- aria-label={label}
- data-testid="quick-switch-enabled"
- />
- </div>
- {enabled && (
+ )}
+ {enabled && part !== "toggle" && (
<KeybindRow
action={ACTION}
label={t("settings_view.quick_switch.shortcut_label")}
@@ -98,7 +109,7 @@ export function QuickSwitchKeybind({ voiceConfig }: { voiceConfig: KeybindsConfi
onSave={save}
/>
)}
- {enabled && mac && (
+ {enabled && mac && part !== "toggle" && (
<p className="text-sm text-muted-foreground" data-testid="quick-switch-mac-note">
{t("settings_view.quick_switch.mac_note")}
</p>
diff --git a/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx b/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx
index ae2831913c..ab3c5b5997 100644
--- a/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx
@@ -1,4 +1,4 @@
-import { render, screen, waitFor } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, describe, expect, it, vi } from "vitest";
import { SettingsView } from "@/views/SettingsView";
@@ -189,6 +189,7 @@ describe("SettingsView against an empty backend", () => {
render(wrap(<ShortcutsView />));
// The keybind field proves the row that used to kill Settings survived.
+ fireEvent.click(await screen.findByTestId("shortcuts-edit-call"));
await waitFor(() => expect(screen.getByTestId("combo-field-call")).toBeTruthy());
expect(screen.getByTestId("shortcut-tester")).toBeTruthy();
});
diff --git a/jarvis/ui/web/frontend/src/views/settings/ShortcutListRow.tsx b/jarvis/ui/web/frontend/src/views/settings/ShortcutListRow.tsx
new file mode 100644
index 0000000000..e28e78b005
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/settings/ShortcutListRow.tsx
@@ -0,0 +1,84 @@
+/**
+ * One row of the Keyboard shortcuts list: what the shortcut does and where it
+ * works on the left, its keys and the controls that change it on the right.
+ *
+ * Every row on that page — fixed chords, voice keys, the quick switcher, the
+ * zoom steps, the appshot keys — is drawn by this component, so the keys line
+ * up in one column however a row is edited. The control column keeps its width
+ * when a row has no controls, for the same reason.
+ */
+import { Fragment, type ReactNode } from "react";
+import { AppWindow, Globe, SquareTerminal } from "lucide-react";
+
+import { useT } from "@/i18n";
+import type { ShortcutScope } from "@/lib/shortcutRegistry";
+
+const SCOPE: Record<ShortcutScope, { icon: typeof Globe; labelKey: string }> = {
+ global: { icon: Globe, labelKey: "shortcuts_view.scope_global" },
+ window: { icon: AppWindow, labelKey: "shortcuts_view.scope_window" },
+ terminal: { icon: SquareTerminal, labelKey: "shortcuts_view.scope_terminal" },
+};
+
+/** Keycaps for labels that are already display text ("Ctrl", "Space", "⌥"). */
+export function KeyCaps({ caps }: { caps: string[] }) {
+ return (
+ <span className="inline-flex flex-wrap items-center justify-end gap-1">
+ {caps.map((cap, i) => (
+ <Fragment key={`${cap}-${i}`}>
+ {i > 0 && <span className="text-muted-foreground/50">+</span>}
+ <kbd className="rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-micro text-foreground shadow-[inset_0_-1px_0_rgba(0,0,0,0.35)]">
+ {cap}
+ </kbd>
+ </Fragment>
+ ))}
+ </span>
+ );
+}
+
+/** The quiet text a row shows instead of keys ("off", "not assigned", "—"). */
+export function NoKeys({ children }: { children: ReactNode }) {
+ return <span className="text-sm italic text-muted-foreground">{children}</span>;
+}
+
+export function ShortcutListRow({
+ title,
+ scope,
+ chord,
+ actions,
+ children,
+ testId,
+ recording = false,
+}: {
+ title: string;
+ scope: ShortcutScope;
+ chord: ReactNode;
+ actions?: ReactNode;
+ /** Shown under the row: an editor, an error, a reset link. */
+ children?: ReactNode;
+ testId?: string;
+ /** Marks the row while it records, so app-level chords stand down. */
+ recording?: boolean;
+}) {
+ const t = useT();
+ const { icon: ScopeIcon, labelKey } = SCOPE[scope];
+ return (
+ <li
+ data-testid={testId}
+ data-keybind-recording={recording ? "true" : undefined}
+ className="px-5 py-3"
+ >
+ <div className="flex items-center gap-4">
+ <div className="min-w-0 flex-1">
+ <p className="text-sm font-medium text-foreground">{title}</p>
+ <p className="mt-1 flex items-center gap-1.5 text-micro text-muted-foreground">
+ <ScopeIcon className="h-3 w-3 shrink-0" aria-hidden />
+ {t(labelKey)}
+ </p>
+ </div>
+ <div className="flex shrink-0 items-center justify-end">{chord}</div>
+ <div className="flex w-[4.5rem] shrink-0 items-center justify-end gap-0.5">{actions}</div>
+ </div>
+ {children}
+ </li>
+ );
+}