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): edit every keyboard shortcut in place

rubenluetke10-beep775de843ea8a
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsx
index e48799febd..b2ee6f0997 100644
--- a/jarvis/ui/web/frontend/src/App.tsx
+++ b/jarvis/ui/web/frontend/src/App.tsx
@@ -37,6 +37,7 @@ const ShortcutOverlay = lazy(() =>
import("@/components/ShortcutOverlay").then((m) => ({ default: m.ShortcutOverlay })),
);
import { shouldOpenShortcutOverlay } from "@/lib/shortcutOverlayTrigger";
+import { appChord } from "@/store/appChordSettings";
/*
Lazy for the same reason: the switcher carries every locale for its
cross-language search, and nobody needs it before the first Ctrl+Space.
@@ -108,7 +109,7 @@ export default function App() {
const [shortcutsOpen, setShortcutsOpen] = useState(false);
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
- if (!shouldOpenShortcutOverlay(event)) return;
+ if (!shouldOpenShortcutOverlay(event, appChord("shortcut_overlay"))) return;
event.preventDefault();
setShortcutsOpen(true);
};
diff --git a/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx
index 03c9e1bf66..70c9b4d9f5 100644
--- a/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx
+++ b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx
@@ -16,6 +16,8 @@ import { Keyboard, X } from "lucide-react";
import { useKeybinds } from "@/hooks/useHotkey";
import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";
import { useAppZoomSettings } from "@/store/appZoomSettings";
+import { useAppChordSettings } from "@/store/appChordSettings";
+import type { AppChordId } from "@/lib/appChords";
import { appZoomCaps, type AppZoomIntent } from "@/lib/appZoom";
import { detectKeyboardPlatform } from "@/views/settings/keyboardLayout";
import {
@@ -81,29 +83,25 @@ function ShortcutRow({ shortcut, isMac }: { shortcut: Shortcut; isMac: boolean }
const { config } = useKeybinds();
const quickSwitch = useQuickSwitchSettings();
const appZoom = useAppZoomSettings();
+ const appChords = useAppChordSettings((s) => s.bindings);
let chord: React.ReactNode;
- if (shortcut.kind === "fixed") {
- chord = (
- <div className="flex flex-col items-end gap-1">
- <Chord keys={shortcut.keys} isMac={isMac} />
- {shortcut.alternateKeys?.map((alt, i) => (
- <div key={i} className="flex items-center gap-1.5 opacity-60">
- <span className="text-micro text-muted-foreground">
- {t("shortcut_overlay.or")}
- </span>
- <Chord keys={alt} isMac={isMac} />
- </div>
- ))}
- </div>
- );
- } else if (shortcut.kind === "app") {
+ if (shortcut.kind === "app") {
// A per-device setting: show what this machine uses, or that it is off.
const zoomIntent = APP_ZOOM_SETTING_INTENT[shortcut.setting];
- const on = zoomIntent ? appZoom.enabled : quickSwitch.enabled;
- const combo = zoomIntent ? appZoom.bindings[zoomIntent] : quickSwitch.combo;
+ const appChordId = shortcut.setting in appChords ? (shortcut.setting as AppChordId) : null;
+ const on = appChordId ? true : zoomIntent ? appZoom.enabled : quickSwitch.enabled;
+ const combo = appChordId
+ ? appChords[appChordId]
+ : zoomIntent
+ ? appZoom.bindings[zoomIntent]
+ : quickSwitch.combo;
chord = on && combo ? (
- zoomIntent ? <Chord keys={appZoomCaps(combo)} isMac={false} /> : <Chord keys={comboTokens(combo)} isMac={isMac} />
+ zoomIntent || appChordId ? (
+ <Chord keys={appZoomCaps(combo)} isMac={false} />
+ ) : (
+ <Chord keys={comboTokens(combo)} isMac={isMac} />
+ )
) : (
<span className="text-xs italic text-muted-foreground">
{t(on ? "shortcut_overlay.unassigned" : "shortcut_overlay.off")}
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
index 3fa500661a..ca895ce579 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticGrid.tsx
@@ -46,6 +46,7 @@ import { AgenticTerminal, type SplitDirection } from "./AgenticTerminal";
import { AgentPickerMenu, offersAgentChoice, type SplitAgentChoice } from "./AgentPicker";
import { TERMINAL_APPEARANCE_KEY, type TerminalAppearance } from "./terminalThemes";
import { installZoomKeyBridge, type ZoomIntent } from "./terminalZoom";
+import { terminalZoomBindings } from "@/store/appChordSettings";
import {
FONT_DEFAULT,
FONT_KEY,
@@ -654,6 +655,8 @@ export function AgenticGrid({
// Hidden rather than unmounted when another section is open, so the
// grid has to be asked whether anyone is looking at it.
enabled: () => zoomStateRef.current.onScreen,
+ // Read per keystroke: a chord changed in Settings applies at once.
+ bindings: () => terminalZoomBindings(),
apply: (intent) => {
const current = zoomStateRef.current.fontSize;
const next = zoomedFontSize(current, intent);
diff --git a/jarvis/ui/web/frontend/src/components/agentic/IdeHotkeyMenu.tsx b/jarvis/ui/web/frontend/src/components/agentic/IdeHotkeyMenu.tsx
index 6692c97865..efc19fb78f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/IdeHotkeyMenu.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/IdeHotkeyMenu.tsx
@@ -1,4 +1,6 @@
import { useEffect, useMemo, useRef, useState } from "react";
+import { appZoomCaps } from "@/lib/appZoom";
+import { appChord, useAppChordSettings } from "@/store/appChordSettings";
import {
STICKY_ACTIONS, assignAgentKeys, hotkeyHints, isLeaderChord, modeBar, resolveHotkey,
type HotkeyAgent, type IdeHotkeyAction, type IdeHotkeyStep,
@@ -38,6 +40,7 @@ function Cap({ children }: { children: React.ReactNode }) {
export function IdeHotkeyMenu({ enabled, agents, pane, onAction, onRenamePane, onPassThrough }: Props) {
const [view, setView] = useState<View | null>(null);
const [draft, setDraft] = useState("");
+ const leader = useAppChordSettings((state) => state.bindings.ide_menu);
const keyed = useMemo(() => assignAgentKeys(agents), [agents]);
const latest = useRef({ view, keyed, pane, onAction, onPassThrough, enabled });
latest.current = { view, keyed, pane, onAction, onPassThrough, enabled };
@@ -50,7 +53,8 @@ export function IdeHotkeyMenu({ enabled, agents, pane, onAction, onRenamePane, o
const onKeyDown = (event: KeyboardEvent) => {
const { view: current, keyed: agentKeys, enabled: on } = latest.current;
if (!on || event.isComposing) return;
- if (isLeaderChord(event)) {
+ // Read per keystroke: a leader changed in Settings applies at once.
+ if (isLeaderChord(event, appChord("ide_menu"))) {
event.preventDefault();
event.stopPropagation();
if (!current) { setView({ menu: "root" }); return; }
@@ -100,8 +104,10 @@ export function IdeHotkeyMenu({ enabled, agents, pane, onAction, onRenamePane, o
if (!view) return null;
+ const leaderCaps = leader ? appZoomCaps(leader) : [];
+
const step: IdeHotkeyStep = view.menu === "rename" ? { menu: "root" } : view;
- const bar = modeBar(step, keyed);
+ const bar = modeBar(step, keyed, leaderCaps);
const submitRename = (event: React.FormEvent) => {
event.preventDefault();
const name = draft.trim();
@@ -117,7 +123,7 @@ export function IdeHotkeyMenu({ enabled, agents, pane, onAction, onRenamePane, o
className="pointer-events-auto w-full max-w-3xl rounded-xl border border-border bg-popover p-4 text-popover-foreground shadow-xl motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-150">
<h2 className="mb-3 text-sm font-semibold">All keys</h2>
<div className="grid gap-x-6 gap-y-3 sm:grid-cols-3">
- {hotkeyHints({ menu: "root" }, keyed).map((group) => <section key={group.title} className="min-w-0">
+ {hotkeyHints({ menu: "root" }, keyed, leaderCaps).map((group) => <section key={group.title} className="min-w-0">
<h3 className="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">{group.title}</h3>
<ul className="space-y-1.5">
{group.hints.map((hint) => <li key={hint.label} className="flex items-center gap-2 text-sm">
diff --git a/jarvis/ui/web/frontend/src/components/agentic/ideHotkeys.ts b/jarvis/ui/web/frontend/src/components/agentic/ideHotkeys.ts
index 0e6b0fe7d2..111d1e357f 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/ideHotkeys.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/ideHotkeys.ts
@@ -21,6 +21,8 @@
* without a DOM.
*/
import type { PaneSplitDirection } from "./WorkspaceTerminalHeader";
+import { appZoomChordMatches } from "@/lib/appZoom";
+import { parseChord } from "@/lib/quickSwitchChord";
export type PaneDirection = "left" | "right" | "up" | "down";
@@ -93,11 +95,18 @@ export const STICKY_ACTIONS: ReadonlySet<IdeHotkeyAction["kind"]> = new Set([
"toggle-voice", "workspace-index", "workspace-step",
]);
+/** The shipped leader chord, as stored under Settings → Keyboard shortcuts. */
+export const DEFAULT_LEADER = "ctrl+b";
+
/**
- * Is this the leader chord? Ctrl+B on every OS — Ctrl, not Cmd, on a Mac too,
- * because that is the terminal key tmux users already have in their hands.
+ * Is this the leader chord? Ctrl+B on every OS by default — Ctrl, not Cmd, on a
+ * Mac too, because that is the terminal key tmux users already have in their
+ * hands. `combo` is the chord the user chose ("" = off); another chord is
+ * matched like every other in-app chord.
*/
-export function isLeaderChord(event: HotkeyEventLike): boolean {
+export function isLeaderChord(event: HotkeyEventLike, combo: string = DEFAULT_LEADER): boolean {
+ if (!combo) return false;
+ if (combo !== DEFAULT_LEADER) return appZoomChordMatches(event, combo);
// `code` first: it names the physical key on every layout. `key` covers a
// host that reports no code (some remote-desktop and test events do).
const isB = event.code === "KeyB" || (!event.code && event.key.toLowerCase() === "b");
@@ -107,6 +116,18 @@ export function isLeaderChord(event: HotkeyEventLike): boolean {
/** What Ctrl+B twice types into the focused pane: the control code Ctrl+B itself sends. */
export const LEADER_PASSTHROUGH = "\x02";
+/**
+ * What the leader pressed twice types into the focused pane: the control code
+ * the chord itself sends (Ctrl+B is `LEADER_PASSTHROUGH`). Only a plain
+ * Ctrl+letter has one; any other leader passes nothing through.
+ */
+export function leaderPassthrough(combo: string = DEFAULT_LEADER): string | null {
+ const { mods, keys } = parseChord(combo);
+ const letter = keys.length === 1 && /^[a-z]$/.test(keys[0]) ? keys[0] : null;
+ if (!letter || !mods.has("ctrl") || mods.size !== 1) return null;
+ return String.fromCharCode(letter.charCodeAt(0) - 96);
+}
+
/** Letters the root menu keeps for its own commands; no agent may take one. */
export const RESERVED_ROOT_KEYS = new Set(["e", "f", "m", "n", "p", "q", "r", "v", "w", "z"]);
@@ -264,7 +285,11 @@ export function resolveHotkey(step: IdeHotkeyStep, event: HotkeyEventLike, agent
export interface ModeBar { badge: string; hints: HotkeyHint[] }
/** What the bar at the bottom says for a step; the full list lives behind `?`. */
-export function modeBar(step: IdeHotkeyStep, agents: readonly AgentKey[]): ModeBar {
+export function modeBar(
+ step: IdeHotkeyStep,
+ agents: readonly AgentKey[],
+ leaderCaps: readonly string[] = ["Ctrl", "B"],
+): ModeBar {
if (step.menu === "direction") {
return {
badge: step.label.toUpperCase(),
@@ -295,7 +320,7 @@ export function modeBar(step: IdeHotkeyStep, agents: readonly AgentKey[]): ModeB
{ keys: ["Q"], label: "close" },
{ keys: ["W"], label: "workspaces" },
{ keys: ["?"], label: "all keys" },
- { keys: ["Ctrl", "B"], label: "send Ctrl+B" },
+ { keys: [...leaderCaps], label: `send ${leaderCaps.join("+")}` },
],
};
}
@@ -305,7 +330,11 @@ export interface HotkeyHint { keys: string[]; label: string }
export interface HotkeyHintGroup { title: string; hints: HotkeyHint[] }
/** The rows the overlay shows for a step — the same table `resolveHotkey` reads. */
-export function hotkeyHints(step: IdeHotkeyStep, agents: readonly AgentKey[]): HotkeyHintGroup[] {
+export function hotkeyHints(
+ step: IdeHotkeyStep,
+ agents: readonly AgentKey[],
+ leaderCaps: readonly string[] = ["Ctrl", "B"],
+): HotkeyHintGroup[] {
if (step.menu === "direction") {
return [{
title: `Open ${step.label}`,
@@ -366,7 +395,7 @@ export function hotkeyHints(step: IdeHotkeyStep, agents: readonly AgentKey[]): H
{ keys: ["Shift", "W"], label: "Rename workspace" },
{ keys: ["Shift", "D"], label: "Close workspace" },
{ keys: ["M"], label: "Voice bubble" },
- { keys: ["Ctrl", "B"], label: "Send Ctrl+B to the pane" },
+ { keys: [...leaderCaps], label: `Send ${leaderCaps.join("+")} to the pane` },
],
},
];
diff --git a/jarvis/ui/web/frontend/src/components/agentic/terminalZoom.ts b/jarvis/ui/web/frontend/src/components/agentic/terminalZoom.ts
index 75ec283b73..af8f0275af 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/terminalZoom.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/terminalZoom.ts
@@ -32,9 +32,16 @@
* identifies it when NumLock is off.
*/
+import { appZoomChordMatches } from "@/lib/appZoom";
+
/** Which way the user asked the terminal text to go. */
export type ZoomIntent = "in" | "out" | "reset";
+/** The chord per step, as stored under Settings → Keyboard shortcuts ("" = removed). */
+export type TerminalZoomBindings = Record<ZoomIntent, string>;
+
+const ZOOM_INTENTS: readonly ZoomIntent[] = ["in", "out", "reset"];
+
export interface ZoomChordOptions {
/** Cmd is the modifier on Apple keyboards, Ctrl everywhere else. */
isMac: boolean;
@@ -65,6 +72,36 @@ export function zoomIntentFor(
return null;
}
+/** The shipped chord per step — the ones `zoomIntentFor` above answers to. */
+export function defaultTerminalZoomBindings(isMac: boolean): TerminalZoomBindings {
+ const mod = isMac ? "cmd" : "ctrl";
+ return { in: `${mod}+plus`, out: `${mod}+minus`, reset: `${mod}+0` };
+}
+
+/**
+ * Like `zoomIntentFor`, but against the chords the user chose. A step still on
+ * its shipped chord keeps the exact rules above (both spellings, the keypad,
+ * AltGr refused); a step the user recorded anew is matched the way the
+ * whole-app zoom matches its chords, by the character the key types.
+ */
+export function zoomIntentForBindings(
+ event: Pick<KeyboardEvent, "key" | "code" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey"> & {
+ getModifierState?(key: string): boolean;
+ },
+ { isMac, bindings }: ZoomChordOptions & { bindings: TerminalZoomBindings },
+): ZoomIntent | null {
+ const shipped = defaultTerminalZoomBindings(isMac);
+ const legacy = zoomIntentFor(event, { isMac });
+ for (const intent of ZOOM_INTENTS) {
+ const combo = bindings[intent];
+ if (!combo) continue;
+ if (combo === shipped[intent] ? legacy === intent : appZoomChordMatches(event, combo)) {
+ return intent;
+ }
+ }
+ return null;
+}
+
/**
* How much accumulated wheel travel counts as one step of text size.
*
@@ -128,6 +165,11 @@ export interface ZoomKeyBridgeOptions
extends ZoomChordOptions, ZoomBridgeOptions {
/** The key bridge is installed once for a whole grid, so it must be asked. */
enabled: () => boolean;
+ /**
+ * The user's chords, read per keystroke so a change in Settings applies at
+ * once. Absent: the shipped chords.
+ */
+ bindings?: () => TerminalZoomBindings;
}
/**
@@ -141,12 +183,14 @@ export interface ZoomKeyBridgeOptions
*/
export function installZoomKeyBridge(
target: Pick<EventTarget, "addEventListener" | "removeEventListener">,
- { isMac, enabled, apply }: ZoomKeyBridgeOptions,
+ { isMac, enabled, apply, bindings }: ZoomKeyBridgeOptions,
): () => void {
const onKeyDown = (event: Event) => {
const key = event as KeyboardEvent;
if (!enabled()) return;
- const intent = zoomIntentFor(key, { isMac });
+ const intent = bindings
+ ? zoomIntentForBindings(key, { isMac, bindings: bindings() })
+ : zoomIntentFor(key, { isMac });
if (intent === null) return;
// Stops the WebView's own page zoom (the reason this is a shortcut the app
// has to claim rather than inherit) and keeps the pane from typing it.
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index c3c4d1dad8..626c04196f 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1663,19 +1663,22 @@
"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"
+ "options_title": "Ein- und ausschalten",
+ "remove": "Kürzel entfernen",
+ "record_hint": "Drück die neuen Tasten. Esc bricht ab.",
+ "appshot_record_hint": "Ins Feld klicken, dann die neuen Tasten drücken.",
+ "problem_typing_key": "Diese Taste allein würde bei jedem Tippen auslösen. Nimm Strg, Alt oder Command dazu — oder eine Funktionstaste wie F9.",
+ "problem_os_reserved": "Die Windows-Taste gehört dem System. Wähl eine Kombination mit Strg oder Alt.",
+ "problem_duplicate": "Ein anderes Kürzel nutzt schon genau diese Kombination."
},
"shortcut_overlay": {
"title": "Tastenkürzel",
"description": "Drücke überall ?, um diese Liste zu öffnen. Die Sprachtasten lassen sich in den Einstellungen ändern.",
"close": "Schließen",
- "or": "oder",
"unassigned": "nicht belegt",
"off": "aus",
"footer": "Ändern kannst du sie unter Einstellungen → Tastenkürzel.",
@@ -1699,7 +1702,7 @@
"app_zoom_reset": "App-Zoom auf 100 % zurücksetzen",
"open_overlay": "Diese Liste öffnen",
"quick_switch": "Schnell zu jedem Bereich springen",
- "ide_menu": "Tastenmenü der Agentic IDE (zweimal: Strg+B an das Fenster)"
+ "ide_menu": "Tastenmenü der Agentic IDE (zweimal drücken: an das Fenster senden)"
}
},
"quick_switch": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 5ff98adf9f..8b7c3e06d2 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1696,19 +1696,22 @@
"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"
+ "options_title": "Switch on or off",
+ "remove": "Remove shortcut",
+ "record_hint": "Press the new keys. Esc cancels.",
+ "appshot_record_hint": "Click the field, then press the new keys.",
+ "problem_typing_key": "This key alone would fire every time you type it. Add Ctrl, Alt or Command — or use a function key such as F9.",
+ "problem_os_reserved": "The Windows key belongs to the system. Pick a combination with Ctrl or Alt.",
+ "problem_duplicate": "Another shortcut already uses exactly this combination."
},
"shortcut_overlay": {
"title": "Keyboard shortcuts",
"description": "Press ? anywhere to open this list. Voice keys are configurable in Settings.",
"close": "Close",
- "or": "or",
"unassigned": "not assigned",
"off": "off",
"footer": "Change them under Settings → Keyboard shortcuts.",
@@ -1732,7 +1735,7 @@
"app_zoom_reset": "Reset the app zoom to 100 %",
"open_overlay": "Open this list",
"quick_switch": "Quick switch to any section",
- "ide_menu": "Agentic IDE key menu (twice: Ctrl+B to the pane)"
+ "ide_menu": "Agentic IDE key menu (press twice to send it to the pane)"
}
},
"quick_switch": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index e7edf4bfd3..9afd58ff7f 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1663,19 +1663,22 @@
"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"
+ "options_title": "Activar o desactivar",
+ "remove": "Quitar atajo",
+ "record_hint": "Pulsa las teclas nuevas. Esc cancela.",
+ "appshot_record_hint": "Haz clic en el campo y pulsa las teclas nuevas.",
+ "problem_typing_key": "Esta tecla sola se activaría cada vez que escribes. Añade Ctrl, Alt o Command — o usa una tecla de función como F9.",
+ "problem_os_reserved": "La tecla de Windows pertenece al sistema. Elige una combinación con Ctrl o Alt.",
+ "problem_duplicate": "Otro atajo ya usa exactamente esta combinación."
},
"shortcut_overlay": {
"title": "Atajos de teclado",
"description": "Pulsa ? en cualquier lugar para abrir esta lista. Las teclas de voz se configuran en Ajustes.",
"close": "Cerrar",
- "or": "o",
"unassigned": "sin asignar",
"off": "desactivado",
"footer": "Cámbialos en Ajustes → Atajos de teclado.",
@@ -1699,7 +1702,7 @@
"app_zoom_reset": "Restablecer el zoom de la aplicación al 100 %",
"open_overlay": "Abrir esta lista",
"quick_switch": "Saltar rápido a cualquier sección",
- "ide_menu": "Menú de teclas del IDE agéntico (dos veces: Ctrl+B al panel)"
+ "ide_menu": "Menú de teclas del IDE agéntico (pulsa dos veces para enviarlo al panel)"
}
},
"quick_switch": {
diff --git a/jarvis/ui/web/frontend/src/lib/appChords.ts b/jarvis/ui/web/frontend/src/lib/appChords.ts
new file mode 100644
index 0000000000..0f045d7618
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/appChords.ts
@@ -0,0 +1,73 @@
+/**
+ * The in-app chords that used to be compiled in: the terminal text size steps,
+ * the `?` shortcut overview and the Agentic IDE key menu. Each one now has a
+ * default and can be recorded anew under Settings → Keyboard shortcuts.
+ *
+ * They are matched and recorded by CHARACTER exactly like the whole-app zoom
+ * (see ./appZoom): `+`, `-` and `?` sit on different keys on a German and a US
+ * keyboard, so a chord saved as a key position would mean another key on the
+ * next keyboard.
+ *
+ * Kept free of React: the app shell and the terminal grid check keystrokes
+ * against these on every press.
+ */
+import { appZoomComboProblem, type AppZoomComboProblem } from "@/lib/appZoom";
+import { hostChordPlatform, parseChord, type ChordPlatform } from "@/lib/quickSwitchChord";
+
+export type AppChordId =
+ | "terminal_zoom_in"
+ | "terminal_zoom_out"
+ | "terminal_zoom_reset"
+ | "shortcut_overlay"
+ | "ide_menu";
+
+export const APP_CHORD_IDS: readonly AppChordId[] = [
+ "terminal_zoom_in",
+ "terminal_zoom_out",
+ "terminal_zoom_reset",
+ "shortcut_overlay",
+ "ide_menu",
+];
+
+export type AppChordBindings = Record<AppChordId, string>;
+
+/**
+ * The shipped chords. The terminal steps use the platform modifier (⌘ on a
+ * Mac, Ctrl elsewhere); the IDE key menu is Ctrl+B on every OS, the terminal
+ * key tmux users already have in their hands.
+ */
+export function defaultAppChords(platform: ChordPlatform = hostChordPlatform()): AppChordBindings {
+ const mod = platform === "mac" ? "cmd" : "ctrl";
+ return {
+ terminal_zoom_in: `${mod}+plus`,
+ terminal_zoom_out: `${mod}+minus`,
+ terminal_zoom_reset: `${mod}+0`,
+ shortcut_overlay: "question",
+ ide_menu: "ctrl+b",
+ };
+}
+
+/**
+ * Chords that may be a single key without Ctrl, Alt or ⌘. Only the overview:
+ * its listener ignores keys typed into a text field, so a bare `?` never eats
+ * a question mark out of a message.
+ */
+export const BARE_KEY_CHORDS: ReadonlySet<AppChordId> = new Set(["shortcut_overlay"]);
+
+/** True when the chord holds no Ctrl, Alt or ⌘ — it must stay out of text fields. */
+export function isBareChord(combo: string): boolean {
+ const { mods } = parseChord(combo);
+ return !mods.has("ctrl") && !mods.has("alt") && !mods.has("meta");
+}
+
+/** Why a recorded chord cannot be used for `id`; null when it can. */
+export function appChordProblem(
+ id: AppChordId,
+ combo: string,
+ others: readonly string[],
+ platform: ChordPlatform = hostChordPlatform(),
+): AppZoomComboProblem | null {
+ const problem = appZoomComboProblem(combo, others, platform);
+ if (problem === "typing_key" && BARE_KEY_CHORDS.has(id)) return null;
+ return problem;
+}
diff --git a/jarvis/ui/web/frontend/src/lib/appZoom.ts b/jarvis/ui/web/frontend/src/lib/appZoom.ts
index 77726ed7db..60d6aa7692 100644
--- a/jarvis/ui/web/frontend/src/lib/appZoom.ts
+++ b/jarvis/ui/web/frontend/src/lib/appZoom.ts
@@ -62,8 +62,12 @@ export function nextAppZoom(level: number, intent: AppZoomIntent): number {
return APP_ZOOM_LEVELS[Math.min(APP_ZOOM_LEVELS.length - 1, Math.max(0, next))];
}
-/** Keys whose identity is the character they type, not their position. */
-const CHARACTER_KEYS = new Set(["plus", "minus"]);
+/**
+ * Keys whose identity is the character they type, not their position. `?` is
+ * one too: Shift+`/` on a US keyboard, Shift+`ß` on a German one — the other
+ * in-app chords (the shortcut overview) record it through this module.
+ */
+const CHARACTER_KEYS = new Set(["plus", "minus", "question"]);
const NAMED_CODES: Record<string, string> = {
Space: "space",
@@ -106,6 +110,7 @@ export function appZoomKeyToken(event: Pick<AppZoomKeyEvent, "key" | "code">): s
if (code === "NumpadInsert") return "0"; // keypad 0 with NumLock off
if (key === "+" || (key === "=" && code === "Equal")) return "plus";
if (key === "-" || (key === "_" && code === "Minus")) return "minus";
+ if (key === "?") return "question";
if (/^Key[A-Z]$/.test(code)) return code.slice(3).toLowerCase();
if (/^Digit[0-9]$/.test(code)) return code.slice(5);
if (/^F[0-9]{1,2}$/.test(code)) return code.toLowerCase();
@@ -202,6 +207,7 @@ export function appZoomComboProblem(
const KEY_LABEL: Record<string, string> = {
plus: "+",
minus: "-",
+ question: "?",
space: "Space",
up: "↑",
down: "↓",
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts b/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts
index 1dffecc6b3..2311698013 100644
--- a/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts
+++ b/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts
@@ -12,6 +12,9 @@
* rules are testable without mounting anything.
*/
+import { appZoomChordMatches } from "@/lib/appZoom";
+import { isBareChord } from "@/lib/appChords";
+
/** Elements that are text entry by their tag alone. */
const TEXT_TAGS = new Set(["INPUT", "TEXTAREA", "SELECT"]);
@@ -59,6 +62,9 @@ export function isTextEntryTarget(target: EventTarget | null): boolean {
export interface OverlayTriggerEvent {
key: string;
+ /** Needed only for a chord the user recorded anew (letters match by position). */
+ code?: string;
+ shiftKey?: boolean;
ctrlKey: boolean;
metaKey: boolean;
altKey: boolean;
@@ -67,15 +73,29 @@ export interface OverlayTriggerEvent {
}
/**
- * True when this keystroke is a bare `?` typed outside any text entry.
+ * True when this keystroke is the overview's chord — by default a bare `?`
+ * typed outside any text entry.
*
* Shift is allowed and expected: `?` is Shift plus `/` on a US layout, and Shift
* plus the key right of `0` on a German one. Reading `event.key` rather than a
* physical code is what makes both work without a per-layout table.
* Ctrl/Cmd/Alt disqualify: those chords belong to whatever else claims them.
+ *
+ * `combo` is the chord chosen under Settings → Keyboard shortcuts ("" = off).
+ * A chord without Ctrl, Alt or ⌘ keeps the text-entry guard; one with them
+ * works inside a field too, like every other app chord.
*/
-export function shouldOpenShortcutOverlay(event: OverlayTriggerEvent): boolean {
+export function shouldOpenShortcutOverlay(event: OverlayTriggerEvent, combo = "question"): boolean {
if (event.defaultPrevented) return false;
+ if (!combo) return false;
+ if (combo !== "question") {
+ const matches = appZoomChordMatches(
+ { ...event, code: event.code ?? "", shiftKey: event.shiftKey ?? false },
+ combo,
+ );
+ if (!matches) return false;
+ return !isBareChord(combo) || !isTextEntryTarget(event.target);
+ }
if (event.key !== "?") return false;
if (event.ctrlKey || event.metaKey || event.altKey) return false;
return !isTextEntryTarget(event.target);
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts
index 784acdd092..895518b47a 100644
--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts
@@ -1,43 +1,31 @@
/**
* The registry must not drift from the code that implements the chords.
*
- * The fixed entries are the risky half: they spell out keys that a matcher
- * elsewhere decides on. So every fixed chord declared for the workspace area is
- * replayed here through `zoomIntentFor` — the real matcher — and must produce
- * the intent its label claims. Change the matcher without changing the registry
- * and this fails, which is the whole reason the duplication is acceptable.
+ * Every chord is now read from a live setting, so the risky half is the
+ * DEFAULTS: the shipped bindings must still mean what the matchers answer to.
+ * They are replayed here through the real matchers — the terminal zoom, the
+ * overview trigger and the IDE leader — on both platforms.
*/
import { describe, expect, it } from "vitest";
-import { zoomIntentFor } from "@/components/agentic/terminalZoom";
-import {
- SHORTCUTS,
- SHORTCUT_AREAS,
- keyLabel,
- shortcutsForArea,
- type FixedShortcut,
-} from "./shortcutRegistry";
+import { defaultTerminalZoomBindings, zoomIntentForBindings } from "@/components/agentic/terminalZoom";
+import { isLeaderChord, leaderPassthrough } from "@/components/agentic/ideHotkeys";
+import { APP_CHORD_IDS, defaultAppChords } from "./appChords";
+import { SHORTCUTS, SHORTCUT_AREAS, keyLabel, shortcutsForArea } from "./shortcutRegistry";
import { shouldOpenShortcutOverlay } from "./shortcutOverlayTrigger";
import { eventMatchesChord, defaultQuickSwitchCombo } from "./quickSwitchChord";
-/** Turn a declared chord into the event the matcher would see. */
-function eventFor(keys: string[], isMac: boolean) {
- const mod = keys.includes("Mod");
- const key = keys[keys.length - 1];
+/** A keydown as the matchers see it. */
+function keyEvent(key: string, code: string, mods: { ctrl?: boolean; meta?: boolean; shift?: boolean } = {}) {
return {
key,
- code: "",
- ctrlKey: mod && !isMac,
- metaKey: mod && isMac,
+ code,
+ ctrlKey: Boolean(mods.ctrl),
+ metaKey: Boolean(mods.meta),
altKey: false,
+ shiftKey: Boolean(mods.shift),
};
}
-const ZOOM_EXPECTATIONS: Record<string, "in" | "out" | "reset"> = {
- "shortcut_overlay.workspace.zoom_in": "in",
- "shortcut_overlay.workspace.zoom_out": "out",
- "shortcut_overlay.workspace.zoom_reset": "reset",
-};
-
describe("registry integrity", () => {
it("declares every area it groups by, and groups nothing else", () => {
const declared = new Set(SHORTCUTS.map((s) => s.area));
@@ -61,45 +49,51 @@ describe("registry integrity", () => {
});
});
-describe("fixed chords agree with the matcher that implements them", () => {
- const zoomEntries = shortcutsForArea("workspace").filter(
- (s): s is FixedShortcut =>
- s.kind === "fixed" && s.labelKey in ZOOM_EXPECTATIONS,
- );
-
- it("covers all three zoom steps", () => {
- expect(zoomEntries).toHaveLength(3);
+describe("the default chords agree with the matchers that implement them", () => {
+ it("lists every in-app chord in the registry, read from its setting", () => {
+ const settings = SHORTCUTS.filter((s) => s.kind === "app").map((s) => s.setting);
+ for (const id of APP_CHORD_IDS) expect(settings).toContain(id);
+ for (const shortcut of SHORTCUTS) expect(shortcut).not.toHaveProperty("keys");
});
for (const isMac of [true, false]) {
- it(`resolves on ${isMac ? "macOS" : "PC"} exactly as declared`, () => {
- for (const entry of zoomEntries) {
- const expected = ZOOM_EXPECTATIONS[entry.labelKey];
- expect(zoomIntentFor(eventFor(entry.keys, isMac), { isMac })).toBe(
- expected,
- );
- for (const alt of entry.alternateKeys ?? []) {
- expect(zoomIntentFor(eventFor(alt, isMac), { isMac })).toBe(expected);
- }
- }
+ it(`zooms the terminal text on ${isMac ? "macOS" : "PC"} with both spellings`, () => {
+ const mod = isMac ? { meta: true } : { ctrl: true };
+ const bindings = defaultTerminalZoomBindings(isMac);
+ const intent = (key: string, code: string, shift = false) =>
+ zoomIntentForBindings(keyEvent(key, code, { ...mod, shift }), { isMac, bindings });
+ expect(intent("+", "BracketRight")).toBe("in");
+ expect(intent("=", "Equal")).toBe("in");
+ expect(intent("-", "Minus")).toBe("out");
+ expect(intent("_", "Minus", true)).toBe("out");
+ expect(intent("0", "Digit0")).toBe("reset");
});
}
- it("declares the `?` chord that actually opens the overlay", () => {
- const entry = shortcutsForArea("workspace").find(
- (s) => s.labelKey === "shortcut_overlay.workspace.open_overlay",
- ) as FixedShortcut;
- expect(entry.keys).toEqual(["?"]);
- expect(
- shouldOpenShortcutOverlay({
- key: entry.keys[0],
- ctrlKey: false,
- metaKey: false,
- altKey: false,
- defaultPrevented: false,
- target: null,
- }),
- ).toBe(true);
+ it("answers a recorded terminal chord and drops a removed one", () => {
+ const bindings = { in: "alt+up", out: "", reset: "ctrl+0" };
+ const altUp = { ...keyEvent("ArrowUp", "ArrowUp"), altKey: true };
+ expect(zoomIntentForBindings(altUp, { isMac: false, bindings })).toBe("in");
+ expect(zoomIntentForBindings(keyEvent("-", "Minus", { ctrl: true }), { isMac: false, bindings })).toBeNull();
+ });
+
+ it("opens the overview on a bare `?` by default, and on a recorded chord", () => {
+ const base = { ctrlKey: false, metaKey: false, altKey: false, defaultPrevented: false, target: null };
+ expect(shouldOpenShortcutOverlay({ ...base, key: "?" }, defaultAppChords().shortcut_overlay)).toBe(true);
+ const f1 = { ...base, key: "F1", code: "F1" };
+ expect(shouldOpenShortcutOverlay(f1, "f1")).toBe(true);
+ expect(shouldOpenShortcutOverlay({ ...base, key: "?" }, "f1")).toBe(false);
+ expect(shouldOpenShortcutOverlay({ ...base, key: "?" }, "")).toBe(false);
+ });
+
+ it("opens the IDE key menu on Ctrl+B by default, and passes its control code through", () => {
+ const leader = defaultAppChords().ide_menu;
+ expect(isLeaderChord(keyEvent("b", "KeyB", { ctrl: true }), leader)).toBe(true);
+ expect(leaderPassthrough(leader)).toBe("\x02");
+ expect(isLeaderChord(keyEvent("b", "KeyB", { ctrl: true }), "ctrl+g")).toBe(false);
+ expect(isLeaderChord(keyEvent("g", "KeyG", { ctrl: true }), "ctrl+g")).toBe(true);
+ expect(leaderPassthrough("ctrl+g")).toBe("\x07");
+ expect(leaderPassthrough("alt+b")).toBeNull();
});
});
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
index 6776b28663..9611ca978b 100644
--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
@@ -12,18 +12,15 @@
* these through `useKeybinds()`, which reads the live configuration, so what
* the overlay shows is by construction what the backend has registered.
*
- * A **fixed** entry carries its chord, because the chord is compiled into the
- * frontend and cannot be rebound. Those chords ARE duplicated from the modules
- * that implement them — there is no way to run a matcher backwards to recover
- * the keys it accepts. `shortcutRegistry.test.ts` closes that gap instead: it
- * feeds every chord declared here to the real matcher and asserts the real
- * matcher agrees. Change the implementation without changing this file and the
- * test fails, which is the drift protection the copy would otherwise lack.
+ * An **app** entry is an in-window chord stored per device (the quick
+ * switcher, the zoom steps, the overview, the IDE key menu). It carries no keys
+ * either: the renderer reads the live setting, including whether it is off.
*
* Entries are grouped by area so the overlay can render sections without a
* second ordering table.
*/
import type { KeybindAction } from "@/hooks/useHotkey";
+import type { AppChordId } from "@/lib/appChords";
export type ShortcutArea = "voice" | "workspace";
@@ -46,35 +43,18 @@ export interface RebindableShortcut extends ShortcutBase {
action: KeybindAction;
}
-export interface FixedShortcut extends ShortcutBase {
- kind: "fixed";
- /**
- * Key tokens, in press order, as the overlay should draw them. `Mod` renders
- * as ⌘ on Apple keyboards and Ctrl everywhere else — the platform split the
- * implementing modules already make.
- */
- keys: string[];
- /**
- * Alternative spellings of the same chord on other layouts, drawn as a
- * secondary line. `+` is its own key on a German board but Shift+`=` on a US
- * one, and an overlay that names only one of them is wrong for half its
- * readers.
- */
- alternateKeys?: string[][];
-}
-
/**
- * An in-app shortcut whose chord is a per-device preference (the quick
- * switcher, the whole-app zoom). Like a rebindable entry it carries no keys —
- * the overlay reads the live setting, including whether the shortcut is
- * switched off.
+ * An in-app shortcut whose chord is a per-device preference: the quick
+ * switcher, the whole-app zoom, and the chords of ./appChords. Like a
+ * rebindable entry it carries no keys — the overlay reads the live setting,
+ * including whether the shortcut is switched off.
*/
export interface AppSettingShortcut extends ShortcutBase {
kind: "app";
- setting: "quick_switch" | "app_zoom_in" | "app_zoom_out" | "app_zoom_reset";
+ setting: "quick_switch" | "app_zoom_in" | "app_zoom_out" | "app_zoom_reset" | AppChordId;
}
-export type Shortcut = RebindableShortcut | FixedShortcut | AppSettingShortcut;
+export type Shortcut = RebindableShortcut | AppSettingShortcut;
export const SHORTCUTS: readonly Shortcut[] = [
// ── Voice — every one of these is rebindable in Settings ───────────────
@@ -96,71 +76,69 @@ export const SHORTCUTS: readonly Shortcut[] = [
labelKey: "shortcut_overlay.voice.paste_last",
},
- // ── Workspace — fixed chords, verified against their matcher by the test ──
+ // ── Workspace — per-device chords, changed under Settings ───────────────
{
- kind: "fixed",
+ kind: "app",
area: "workspace",
- scope: "terminal",
- keys: ["Mod", "+"],
- alternateKeys: [["Mod", "="]],
- labelKey: "shortcut_overlay.workspace.zoom_in",
+ scope: "window",
+ setting: "quick_switch",
+ labelKey: "shortcut_overlay.workspace.quick_switch",
},
{
- kind: "fixed",
+ kind: "app",
area: "workspace",
- scope: "terminal",
- keys: ["Mod", "-"],
- alternateKeys: [["Mod", "_"]],
- labelKey: "shortcut_overlay.workspace.zoom_out",
+ scope: "window",
+ setting: "app_zoom_in",
+ labelKey: "shortcut_overlay.workspace.app_zoom_in",
},
{
- kind: "fixed",
+ kind: "app",
area: "workspace",
- scope: "terminal",
- keys: ["Mod", "0"],
- labelKey: "shortcut_overlay.workspace.zoom_reset",
+ scope: "window",
+ setting: "app_zoom_out",
+ labelKey: "shortcut_overlay.workspace.app_zoom_out",
},
{
- kind: "fixed",
+ kind: "app",
area: "workspace",
scope: "window",
- keys: ["?"],
- labelKey: "shortcut_overlay.workspace.open_overlay",
+ setting: "app_zoom_reset",
+ labelKey: "shortcut_overlay.workspace.app_zoom_reset",
},
{
- kind: "fixed",
+ kind: "app",
area: "workspace",
- scope: "terminal",
- keys: ["Ctrl", "B"],
- labelKey: "shortcut_overlay.workspace.ide_menu",
+ scope: "window",
+ setting: "shortcut_overlay",
+ labelKey: "shortcut_overlay.workspace.open_overlay",
},
{
kind: "app",
area: "workspace",
- scope: "window",
- setting: "quick_switch",
- labelKey: "shortcut_overlay.workspace.quick_switch",
+ scope: "terminal",
+ setting: "terminal_zoom_in",
+ labelKey: "shortcut_overlay.workspace.zoom_in",
},
{
kind: "app",
area: "workspace",
- scope: "window",
- setting: "app_zoom_in",
- labelKey: "shortcut_overlay.workspace.app_zoom_in",
+ scope: "terminal",
+ setting: "terminal_zoom_out",
+ labelKey: "shortcut_overlay.workspace.zoom_out",
},
{
kind: "app",
area: "workspace",
- scope: "window",
- setting: "app_zoom_out",
- labelKey: "shortcut_overlay.workspace.app_zoom_out",
+ scope: "terminal",
+ setting: "terminal_zoom_reset",
+ labelKey: "shortcut_overlay.workspace.zoom_reset",
},
{
kind: "app",
area: "workspace",
- scope: "window",
- setting: "app_zoom_reset",
- labelKey: "shortcut_overlay.workspace.app_zoom_reset",
+ scope: "terminal",
+ setting: "ide_menu",
+ labelKey: "shortcut_overlay.workspace.ide_menu",
},
] as const;
diff --git a/jarvis/ui/web/frontend/src/store/appChordSettings.ts b/jarvis/ui/web/frontend/src/store/appChordSettings.ts
new file mode 100644
index 0000000000..0c68967376
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/store/appChordSettings.ts
@@ -0,0 +1,74 @@
+/**
+ * The in-app chords of ../lib/appChords: which keys the terminal text size
+ * steps, the shortcut overview and the Agentic IDE key menu use on this device.
+ *
+ * Stored in the browser's own storage, like the quick switcher and the app
+ * zoom: these keys live entirely inside the window and the backend never needs
+ * them. Every window shares one origin, so a chord changed in one window
+ * reaches the others through the `storage` event.
+ *
+ * An unreadable value falls back to the platform defaults.
+ */
+import { create } from "zustand";
+import {
+ APP_CHORD_IDS,
+ defaultAppChords,
+ type AppChordBindings,
+ type AppChordId,
+} from "@/lib/appChords";
+
+export const APP_CHORD_STORAGE_KEY = "jarvis.appChords.v1";
+
+export function readAppChordSettings(): { bindings: AppChordBindings } {
+ const bindings = defaultAppChords();
+ try {
+ const raw = window.localStorage.getItem(APP_CHORD_STORAGE_KEY);
+ if (!raw) return { bindings };
+ const parsed = JSON.parse(raw) as { bindings?: Partial<Record<AppChordId, unknown>> };
+ for (const id of APP_CHORD_IDS) {
+ const value = parsed.bindings?.[id];
+ // "" is kept: it means the user removed the shortcut on purpose.
+ if (typeof value === "string") bindings[id] = value;
+ }
+ } catch {
+ /* unreadable — the defaults above stand */
+ }
+ return { bindings };
+}
+
+interface AppChordSettingsState {
+ bindings: AppChordBindings;
+ setBinding: (id: AppChordId, combo: string) => void;
+}
+
+export const useAppChordSettings = create<AppChordSettingsState>((set, get) => ({
+ ...readAppChordSettings(),
+ setBinding: (id, combo) => {
+ const bindings = { ...get().bindings, [id]: combo.trim().toLowerCase() };
+ try {
+ window.localStorage.setItem(APP_CHORD_STORAGE_KEY, JSON.stringify({ bindings }));
+ } catch {
+ /* storage unavailable — the choice holds for this session only */
+ }
+ set({ bindings });
+ },
+}));
+
+/** The terminal text size steps, shaped for ../components/agentic/terminalZoom. */
+export function terminalZoomBindings(bindings: AppChordBindings = useAppChordSettings.getState().bindings) {
+ return { in: bindings.terminal_zoom_in, out: bindings.terminal_zoom_out, reset: bindings.terminal_zoom_reset };
+}
+
+/** The current chord for `id`, for listeners outside React. "" when removed. */
+export function appChord(id: AppChordId): string {
+ return useAppChordSettings.getState().bindings[id];
+}
+
+// Another window changed it: take the new value over.
+if (typeof window !== "undefined") {
+ window.addEventListener("storage", (event) => {
+ if (event.key === APP_CHORD_STORAGE_KEY) {
+ useAppChordSettings.setState(readAppChordSettings());
+ }
+ });
+}
diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
index f9480c86a1..9e21163a07 100644
--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx
@@ -13,7 +13,8 @@ import { isBalancedWorkspace } from "@/components/agentic/workspaceDocking";
import { AgentMark } from "@/components/agentic/AgentMark";
import { CloseAgentDialog, type CloseTarget } from "@/components/agentic/CloseAgentDialog";
import { IdeHotkeyMenu } from "@/components/agentic/IdeHotkeyMenu";
-import { LEADER_PASSTHROUGH, PANE_COMMAND_EVENT, PANE_INPUT_EVENT, type IdeHotkeyAction, type PaneCommand, type PaneCommandDetail, type PaneInputDetail } from "@/components/agentic/ideHotkeys";
+import { leaderPassthrough, PANE_COMMAND_EVENT, PANE_INPUT_EVENT, type IdeHotkeyAction, type PaneCommand, type PaneCommandDetail, type PaneInputDetail } from "@/components/agentic/ideHotkeys";
+import { appChord } from "@/store/appChordSettings";
import { GitCheckoutPicker } from "@/components/agentic/git/GitCheckoutPicker";
import { GitPanelDialog } from "@/components/agentic/git/GitPanelDialog";
import { KEEP_CHECKOUT, prepareGit, type GitPlan } from "@/lib/gitApi";
@@ -577,7 +578,11 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {
onRenamePane={(name) => sendPaneCommand({ kind: "rename", name })}
onPassThrough={() => {
if (!session || !selected) return;
- const detail: PaneInputDetail = { workspaceId: session.id, pane: selected, data: LEADER_PASSTHROUGH };
+ // The control code of the user's leader chord; a leader that is not
+ // Ctrl+letter has none to pass through.
+ const data = leaderPassthrough(appChord("ide_menu"));
+ if (data === null) return;
+ const detail: PaneInputDetail = { workspaceId: session.id, pane: selected, data };
window.dispatchEvent(new CustomEvent(PANE_INPUT_EVENT, { detail }));
}} />
<VoiceBubble open={voiceOpen} onClose={closeVoice} onScreen={onScreen} onJumpToPane={jumpToPane} promptTarget={selected} />
diff --git a/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx b/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx
index 2089fe4694..f4b0a8971e 100644
--- a/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ShortcutsView.test.tsx
@@ -11,6 +11,7 @@ import {
readQuickSwitchSettings,
useQuickSwitchSettings,
} from "@/store/quickSwitchSettings";
+import { APP_CHORD_STORAGE_KEY, readAppChordSettings, useAppChordSettings } from "@/store/appChordSettings";
const KEYBINDS = {
keybinds: {
@@ -34,6 +35,9 @@ function press(init: KeyboardEventInit) {
describe("ShortcutsView", () => {
beforeEach(() => {
window.localStorage.removeItem(QUICK_SWITCH_STORAGE_KEY);
+ window.localStorage.removeItem(APP_CHORD_STORAGE_KEY);
+ useAppChordSettings.setState(readAppChordSettings());
+ useEventStore.getState().setActiveSection("shortcuts");
useQuickSwitchSettings.setState({ ...readQuickSwitchSettings(), combo: "ctrl+space" });
vi.stubGlobal(
"fetch",
@@ -109,15 +113,42 @@ describe("ShortcutsView", () => {
expect(screen.getByTestId("shortcut-tester-meaning").textContent).toMatch(/free/i);
});
- it("sends the dictation edit to the voice section", () => {
+ it("edits a dictation key in place, without leaving the page", async () => {
render(<ShortcutsView />);
+ await act(async () => {});
fireEvent.click(screen.getByTestId("shortcuts-edit-dictate"));
- expect(useEventStore.getState().activeSection).toBe("voice-shortcuts");
+ expect(screen.getByTestId("combo-field-dictate")).toBeTruthy();
+ expect(useEventStore.getState().activeSection).not.toBe("voice-shortcuts");
});
- it("sends the appshot keys to the Appshots section", () => {
+ it("edits an appshot key in place", async () => {
render(<ShortcutsView />);
+ await act(async () => {});
fireEvent.click(screen.getByTestId("shortcuts-edit-appshot-region_hotkey"));
- expect(useEventStore.getState().activeSection).toBe("appshots");
+ expect(screen.getByTestId("shortcuts-appshot-field-region_hotkey")).toBeTruthy();
+ });
+
+ it("gives every row the same one pencil", async () => {
+ render(<ShortcutsView />);
+ await act(async () => {});
+ for (const row of screen.getByTestId("shortcuts-list").querySelectorAll("li")) {
+ expect(row.querySelectorAll("button").length).toBe(1);
+ }
+ });
+
+ it("records a new chord for the shortcut overview", () => {
+ render(<ShortcutsView />);
+ fireEvent.click(screen.getByTestId("chord-record-shortcut_overlay"));
+ press({ key: "F1", code: "F1" });
+ expect(useAppChordSettings.getState().bindings.shortcut_overlay).toBe("f1");
+ expect(screen.getByTestId("shortcut-row-shortcut_overlay").textContent).toContain("F1");
+ });
+
+ it("refuses a bare letter for the IDE key menu", () => {
+ render(<ShortcutsView />);
+ fireEvent.click(screen.getByTestId("chord-record-ide_menu"));
+ press({ key: "g", code: "KeyG" });
+ expect(useAppChordSettings.getState().bindings.ide_menu).toBe("ctrl+b");
+ expect(screen.getByRole("alert").textContent).toMatch(/every time you type/i);
});
});
diff --git a/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx b/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx
index 9824403f6c..7955861034 100644
--- a/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ShortcutsView.tsx
@@ -2,13 +2,13 @@
* Keyboard shortcuts — a Settings-hub page of its own.
*
* 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.
+ * keys, the quick switcher, the zoom steps, the terminal text size, the
+ * shortcut overview and the Agentic IDE key menu. Each row says what the
+ * shortcut does and where it works, shows its keys in one column, and carries
+ * one pencil that changes it right here — no row sends the user elsewhere.
+ * 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 list is built from `lib/shortcutRegistry` — the source the `?` overlay
* renders from — plus the appshot settings. The tester resolves through the
@@ -16,8 +16,8 @@
* the voice keybind normalisation), never through a copied list, so it cannot
* tell a different story than the app.
*/
-import { useEffect, useState, type ReactNode } from "react";
-import { ArrowUpRight, Keyboard, Pencil } from "lucide-react";
+import { useCallback, useEffect, useState, type ReactNode } from "react";
+import { Keyboard, Pencil } from "lucide-react";
import { PageHeader } from "@/components/layout/PageHeader";
import { Button } from "@/components/ui/button";
import { useT } from "@/i18n";
@@ -34,39 +34,41 @@ import {
import { detectKeyboardPlatform } from "@/views/settings/keyboardLayout";
import { ACTION_LABEL_KEY, ComboChips, KeybindRow, formatCombo } from "@/views/settings/KeybindRow";
import { QuickSwitchKeybind } from "@/views/settings/QuickSwitchKeybind";
-import { AppZoomChordRow, AppZoomKeybinds } from "@/views/settings/AppZoomKeybinds";
+import { AppZoomChordRow, AppZoomKeybinds, sameChord } from "@/views/settings/AppZoomKeybinds";
+import { CharacterChordRow } from "@/views/settings/CharacterChordRow";
import { KeyCaps, NoKeys, ShortcutListRow } from "@/views/settings/ShortcutListRow";
-import { appZoomIntentFor, type AppZoomIntent } from "@/lib/appZoom";
+import { AppshotShortcutField } from "@/views/AppshotShortcutField";
+import { appZoomIntentFor, type AppZoomComboProblem, type AppZoomIntent } from "@/lib/appZoom";
+import { APP_CHORD_IDS, appChordProblem, defaultAppChords, type AppChordId } from "@/lib/appChords";
import { useAppZoomSettings } from "@/store/appZoomSettings";
+import { terminalZoomBindings, useAppChordSettings } from "@/store/appChordSettings";
import { eventMatchesChord } from "@/lib/quickSwitchChord";
-import { isTextEntryTarget } from "@/lib/shortcutOverlayTrigger";
+import { isTextEntryTarget, shouldOpenShortcutOverlay } from "@/lib/shortcutOverlayTrigger";
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 {
+ fetchAppshotSettings,
+ formatAppshotHotkey,
+ saveAppshotSettings,
+ type AppshotSettings,
+ type AppshotSettingsPatch,
+} from "@/lib/appshotApi";
+import { zoomIntentForBindings } from "@/components/agentic/terminalZoom";
+import { isLeaderChord } from "@/components/agentic/ideHotkeys";
import { cn } from "@/lib/utils";
-/** 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",
out: "settings_view.app_zoom.out_label",
reset: "settings_view.app_zoom.reset_label",
} as const;
-const APP_ZOOM_SETTING: Record<Exclude<AppSettingShortcut["setting"], "quick_switch">, AppZoomIntent> = {
+const APP_ZOOM_SETTING: Partial<Record<AppSettingShortcut["setting"], AppZoomIntent>> = {
app_zoom_in: "in",
app_zoom_out: "out",
app_zoom_reset: "reset",
@@ -83,6 +85,12 @@ const LABEL_OVERRIDE: Record<string, string> = {
"shortcut_overlay.workspace.open_overlay": "shortcuts_view.open_overlay",
};
+const CHORD_PROBLEM_KEY: Record<AppZoomComboProblem, string> = {
+ typing_key: "shortcuts_view.problem_typing_key",
+ os_reserved: "shortcuts_view.problem_os_reserved",
+ duplicate: "shortcuts_view.problem_duplicate",
+};
+
type AppshotField = "hotkey" | "region_hotkey" | "recording_hotkey";
const APPSHOT_ROWS: readonly { field: AppshotField; labelKey: string }[] = [
@@ -98,11 +106,10 @@ type ListEntry =
| { kind: "registry"; shortcut: Shortcut }
| { kind: "appshot"; field: AppshotField; labelKey: string };
-/** Where it works first (everywhere → window → terminal), then changeable before fixed keys. */
+/** Where it works first (everywhere → window → terminal); the appshot keys after the voice 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];
+ return [SCOPE_ORDER[entry.shortcut.scope], 0];
}
const LIST_ENTRIES: readonly ListEntry[] = [
@@ -152,6 +159,7 @@ function KeyTester({ config }: { config: KeybindsConfig | null }) {
const isMac = detectKeyboardPlatform() === "mac";
const quickSwitch = useQuickSwitchSettings();
const appZoom = useAppZoomSettings();
+ const appChords = useAppChordSettings((s) => s.bindings);
const [pressed, setPressed] = useState<Pressed | null>(null);
useEffect(() => {
@@ -178,16 +186,33 @@ function KeyTester({ config }: { config: KeybindsConfig | null }) {
if (caps.length === 0) return;
let meaningKey: string | null = "";
- const zoom = zoomIntentFor(event, { isMac });
+ const zoom = zoomIntentForBindings(event, { isMac, bindings: terminalZoomBindings(appChords) });
const appZoomIntent = appZoom.enabled ? appZoomIntentFor(event, appZoom.bindings) : null;
+ // The tester's own listener never marks a field, so the overview is
+ // asked as if the key were pressed outside one.
+ const overview = shouldOpenShortcutOverlay(
+ {
+ key: event.key,
+ code: event.code,
+ shiftKey: event.shiftKey,
+ ctrlKey: event.ctrlKey,
+ metaKey: event.metaKey,
+ altKey: event.altKey,
+ defaultPrevented: false,
+ target: null,
+ },
+ appChords.shortcut_overlay,
+ );
if (quickSwitch.enabled && quickSwitch.combo && eventMatchesChord(event, quickSwitch.combo)) {
meaningKey = "settings_view.quick_switch.title";
} else if (appZoomIntent) {
meaningKey = APP_ZOOM_LABEL[appZoomIntent];
} else if (zoom) {
meaningKey = ZOOM_LABEL[zoom];
- } else if (event.key === "?" && !event.ctrlKey && !event.metaKey && !event.altKey) {
+ } else if (overview) {
meaningKey = "shortcut_overlay.workspace.open_overlay";
+ } else if (isLeaderChord(event, appChords.ide_menu)) {
+ meaningKey = "shortcut_overlay.workspace.ide_menu";
} else if (combo) {
const mine = [...normalizedComboTokens(combo)].sort().join("+");
const hit = Object.entries(config?.keybinds ?? {}).find(
@@ -202,7 +227,7 @@ function KeyTester({ config }: { config: KeybindsConfig | null }) {
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
- }, [config, quickSwitch.enabled, quickSwitch.combo, appZoom.enabled, appZoom.bindings, isMac]);
+ }, [config, quickSwitch.enabled, quickSwitch.combo, appZoom.enabled, appZoom.bindings, appChords, isMac]);
const ghost = quickSwitch.combo ? formatCombo(quickSwitch.combo).split(" + ") : ["Ctrl", "Space"];
@@ -268,7 +293,7 @@ function Chips({ combo }: { combo: string }) {
);
}
-/** The pencil that opens or closes a row's editor. */
+/** The pencil that opens or closes a row's editor — the one control every row has. */
function EditToggle({
open,
disabled = false,
@@ -299,31 +324,28 @@ function EditToggle({
);
}
-/** 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 (
- <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 VoiceKeyRow({ shortcut, keybinds }: { shortcut: RebindableShortcut; keybinds: Keybinds }) {
const t = useT();
- const setActiveSection = useEventStore((s) => s.setActiveSection);
+ const pushToast = useEventStore((s) => s.pushToast);
const [open, setOpen] = useState(false);
const { config, loading, saveKeybind } = keybinds;
const combo = config?.keybinds?.[shortcut.action] ?? "";
- const elsewhere = VOICE_SECTION_ACTIONS.has(shortcut.action);
+
+ // A push-to-talk key only works while dictation listens in "hold" mode, so
+ // saving one pins that mode — the same side effect the voice section has.
+ const pinHoldMode = useCallback(async () => {
+ try {
+ const res = await fetch("/api/dictation/settings", {
+ method: "PUT",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ mode: "hold", persist: true }),
+ });
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ } catch (e) {
+ // The keybind itself is already saved — report the missing side effect.
+ pushToast("warning", (e as Error).message);
+ }
+ }, [pushToast]);
return (
<ShortcutListRow
@@ -340,18 +362,10 @@ function VoiceKeyRow({ shortcut, keybinds }: { shortcut: RebindableShortcut; key
)
}
actions={
- elsewhere ? (
- <EditElsewhere
- label={t("shortcuts_view.edit_in_voice")}
- testId={`shortcuts-edit-${shortcut.action}`}
- onClick={() => setActiveSection("voice-shortcuts")}
- />
- ) : (
- <EditToggle open={open} onToggle={() => setOpen((o) => !o)} testId={`shortcuts-edit-${shortcut.action}`} />
- )
+ <EditToggle open={open} onToggle={() => setOpen((o) => !o)} testId={`shortcuts-edit-${shortcut.action}`} />
}
>
- {open && !elsewhere && (
+ {open && (
<div className="mt-3">
<KeybindRow
action={shortcut.action}
@@ -359,6 +373,7 @@ function VoiceKeyRow({ shortcut, keybinds }: { shortcut: RebindableShortcut; key
config={config}
loading={loading}
onSave={saveKeybind}
+ onSaved={shortcut.action === "dictate" ? pinHoldMode : undefined}
/>
</div>
)}
@@ -411,13 +426,45 @@ function QuickSwitchRow({
);
}
-function FixedRow({ shortcut, isMac }: { shortcut: FixedShortcut; isMac: boolean }) {
+/**
+ * One of the in-app chords of lib/appChords (terminal text size, overview,
+ * IDE key menu), recorded by character.
+ */
+function AppChordRow({ shortcut, id }: { shortcut: AppSettingShortcut; id: AppChordId }) {
const t = useT();
+ const bindings = useAppChordSettings((s) => s.bindings);
+ const setBinding = useAppChordSettings((s) => s.setBinding);
+ const appZoom = useAppZoomSettings((s) => s.bindings);
+ const quickSwitch = useQuickSwitchSettings();
+
+ const problemFor = useCallback(
+ (next: string) => {
+ // The terminal steps may share a chord with the whole-app zoom on
+ // purpose: inside a terminal the terminal wins. Everything else must be
+ // unique among the in-window chords.
+ const others = APP_CHORD_IDS.filter((other) => other !== id).map((other) => bindings[other]);
+ if (id === "shortcut_overlay" || id === "ide_menu") others.push(...Object.values(appZoom));
+ const problem = appChordProblem(id, next, others);
+ if (problem) return t(CHORD_PROBLEM_KEY[problem]);
+ if (quickSwitch.enabled && sameChord(next, quickSwitch.combo)) {
+ return t("settings_view.app_zoom.problem_quick_switch");
+ }
+ return null;
+ },
+ [id, bindings, appZoom, quickSwitch.enabled, quickSwitch.combo, t],
+ );
+ const onChange = useCallback((combo: string) => setBinding(id, combo), [id, setBinding]);
+
return (
- <ShortcutListRow
+ <CharacterChordRow
+ rowTestId={`shortcut-row-${id}`}
+ testIdSuffix={id}
title={t(LABEL_OVERRIDE[shortcut.labelKey] ?? shortcut.labelKey)}
scope={shortcut.scope}
- chord={<KeyCaps caps={shortcut.keys.map((key) => keyLabel(key, isMac))} />}
+ combo={bindings[id]}
+ fallback={defaultAppChords()[id]}
+ problemFor={problemFor}
+ onChange={onChange}
/>
);
}
@@ -426,18 +473,30 @@ function AppshotRow({
field,
labelKey,
settings,
+ onSaved,
isMac,
}: {
field: AppshotField;
labelKey: string;
/** undefined while loading, null when the settings could not be read. */
settings: AppshotSettings | null | undefined;
+ onSaved: (settings: AppshotSettings) => void;
isMac: boolean;
}) {
const t = useT();
- const setActiveSection = useEventStore((s) => s.setActiveSection);
+ const pushToast = useEventStore((s) => s.pushToast);
+ const [open, setOpen] = useState(false);
+ const [status, setStatus] = useState<string | null>(null);
const hotkey = settings?.[field] ?? "";
+ const save = async (next: string) => {
+ try {
+ onSaved(await saveAppshotSettings({ [field]: next } as AppshotSettingsPatch));
+ } catch (error) {
+ pushToast("error", t("appshots.save_error").replace("{0}", (error as Error).message));
+ }
+ };
+
return (
<ShortcutListRow
testId={`shortcut-row-appshot-${field}`}
@@ -455,13 +514,32 @@ function AppshotRow({
)
}
actions={
- <EditElsewhere
- label={t("shortcuts_view.edit_in_appshots")}
+ <EditToggle
+ open={open}
+ disabled={!settings}
+ onToggle={() => setOpen((o) => !o)}
testId={`shortcuts-edit-appshot-${field}`}
- onClick={() => setActiveSection("appshots")}
/>
}
- />
+ >
+ {open && settings && (
+ <div className="mt-3 flex flex-wrap items-center gap-3 rounded-md border border-border bg-background p-3">
+ <AppshotShortcutField
+ value={hotkey}
+ isMac={isMac}
+ disabled={false}
+ testId={`shortcuts-appshot-field-${field}`}
+ label={t(labelKey)}
+ className="w-44"
+ onSave={save}
+ onStatus={setStatus}
+ />
+ <p className="min-w-0 flex-1 text-micro text-muted-foreground">
+ {status ?? t("shortcuts_view.appshot_record_hint")}
+ </p>
+ </div>
+ )}
+ </ShortcutListRow>
);
}
@@ -494,6 +572,7 @@ function ShortcutList({ keybinds }: { keybinds: Keybinds }) {
field={entry.field}
labelKey={entry.labelKey}
settings={appshots}
+ onSaved={setAppshots}
isMac={isMac}
/>
);
@@ -502,19 +581,14 @@ function ShortcutList({ keybinds }: { keybinds: Keybinds }) {
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)}
- />
- );
+ const zoomIntent = APP_ZOOM_SETTING[shortcut.setting];
+ if (zoomIntent) {
+ return <AppZoomChordRow key={shortcut.labelKey} intent={zoomIntent} title={t(shortcut.labelKey)} />;
+ }
+ return <AppChordRow key={shortcut.labelKey} shortcut={shortcut} id={shortcut.setting as AppChordId} />;
});
return (
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 57f56a8dab..5994effc96 100644
--- a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.test.tsx
@@ -45,7 +45,7 @@ describe("AppZoomKeybinds", () => {
it("records a new zoom-in chord and remembers it", () => {
render(<Zoom />);
- fireEvent.click(screen.getByTestId("app-zoom-record-in"));
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-in"));
expect(screen.getByTestId("app-zoom-row-in").getAttribute("data-keybind-recording")).toBe("true");
fireEvent.keyDown(window, { key: "ArrowUp", code: "ArrowUp", altKey: true });
@@ -57,7 +57,7 @@ describe("AppZoomKeybinds", () => {
it("records Plus on a German keyboard without the layout's key position", () => {
useAppZoomSettings.getState().setBinding("in", "f9");
render(<Zoom />);
- fireEvent.click(screen.getByTestId("app-zoom-record-in"));
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-in"));
fireEvent.keyDown(window, { key: "+", code: "BracketRight", ctrlKey: true });
expect(useAppZoomSettings.getState().bindings.in).toBe("ctrl+plus");
});
@@ -65,7 +65,7 @@ describe("AppZoomKeybinds", () => {
it("refuses a chord another step uses, and keeps the old one", () => {
render(<Zoom />);
const before = useAppZoomSettings.getState().bindings.in;
- fireEvent.click(screen.getByTestId("app-zoom-record-in"));
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-in"));
fireEvent.keyDown(window, { key: "-", code: "Minus", ctrlKey: true });
expect(useAppZoomSettings.getState().bindings.in).toBe(before);
expect(screen.getByRole("alert").textContent).toMatch(/zoom step/i);
@@ -73,7 +73,7 @@ describe("AppZoomKeybinds", () => {
it("refuses the quick switcher's chord", () => {
render(<Zoom />);
- fireEvent.click(screen.getByTestId("app-zoom-record-reset"));
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-reset"));
fireEvent.keyDown(window, { key: " ", code: "Space", ctrlKey: true });
expect(screen.getByRole("alert").textContent).toMatch(/quick switcher/i);
});
@@ -81,14 +81,23 @@ describe("AppZoomKeybinds", () => {
it("cancels on Escape and resets to the default", () => {
useAppZoomSettings.getState().setBinding("out", "alt+down");
render(<Zoom />);
- fireEvent.click(screen.getByTestId("app-zoom-record-out"));
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-out"));
fireEvent.keyDown(window, { key: "Escape", code: "Escape" });
expect(useAppZoomSettings.getState().bindings.out).toBe("alt+down");
+ // Remove and Reset live under the row while it records.
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-out"));
fireEvent.click(screen.getByText("Reset to default"));
expect(useAppZoomSettings.getState().bindings.out).toBe(defaultAppZoomBindings().out);
});
+ it("removes a chord from the open recorder", () => {
+ render(<Zoom />);
+ fireEvent.click(screen.getByTestId("chord-record-app-zoom-in"));
+ fireEvent.click(screen.getByTestId("chord-clear-app-zoom-in"));
+ expect(useAppZoomSettings.getState().bindings.in).toBe("");
+ });
+
it("steps the size with its buttons and resets on the percentage", () => {
render(<Zoom />);
fireEvent.click(screen.getByTestId("app-zoom-step-in"));
diff --git a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx
index 2b47235265..75aa71bb23 100644
--- a/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/AppZoomKeybinds.tsx
@@ -3,17 +3,12 @@
* 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
- * no punctuation, because a global OS hotkey cannot use it. Zoom needs `+` and
- * `-`, which sit on different keys on a German and a US keyboard, so this
- * recorder reads the character the key types (see lib/appZoom).
- *
- * The value goes into the browser's storage (store/appZoomSettings), like the
- * quick switcher's chord: zoom is an in-window shortcut, not a global hotkey.
+ * The chords are recorded by character (see ./CharacterChordRow) and go into
+ * the browser's storage (store/appZoomSettings), like the quick switcher's
+ * chord: zoom is an in-window shortcut, not a global hotkey.
*/
-import { Fragment, useEffect, useState } from "react";
-import { Minus, Pencil, Plus, X } from "lucide-react";
+import { useCallback } from "react";
+import { Minus, Plus } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
@@ -21,8 +16,6 @@ import { useAppZoomSupport } from "@/hooks/useAppZoom";
import { useT } from "@/i18n";
import {
APP_ZOOM_INTENTS,
- appZoomCaps,
- appZoomComboFromEvent,
appZoomComboProblem,
defaultAppZoomBindings,
nextAppZoom,
@@ -32,7 +25,7 @@ import {
import { useAppZoomSettings } from "@/store/appZoomSettings";
import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";
import { parseChord } from "@/lib/quickSwitchChord";
-import { NoKeys, ShortcutListRow } from "@/views/settings/ShortcutListRow";
+import { CharacterChordRow } from "@/views/settings/CharacterChordRow";
const PROBLEM_KEY: Record<AppZoomComboProblem | "quick_switch", string> = {
typing_key: "settings_view.app_zoom.problem_typing_key",
@@ -41,7 +34,8 @@ const PROBLEM_KEY: Record<AppZoomComboProblem | "quick_switch", string> = {
quick_switch: "settings_view.app_zoom.problem_quick_switch",
};
-function sameChord(a: string, b: string): boolean {
+/** Same chord, whatever order the modifiers were written in. */
+export function sameChord(a: string, b: string): boolean {
const fold = (combo: string) => {
const { mods, keys } = parseChord(combo);
return [...[...mods].sort(), ...keys].join("+");
@@ -49,140 +43,38 @@ function sameChord(a: string, b: string): boolean {
return Boolean(a && b) && fold(a) === fold(b);
}
-export function ZoomCaps({ combo }: { combo: string }) {
- return (
- <span className="inline-flex items-center gap-1">
- {appZoomCaps(combo).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>
- );
-}
-
-/** One zoom step as a row of the shortcut list, with its own recorder. */
+/** One zoom step as a row of the shortcut list. */
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();
- const [recording, setRecording] = useState(false);
- const [error, setError] = useState<string | null>(null);
- const combo = bindings[intent];
- const fallback = defaultAppZoomBindings()[intent];
- useEffect(() => {
- if (!recording) return;
- const onKeyDown = (event: KeyboardEvent) => {
- event.preventDefault();
- event.stopPropagation();
- if (event.key === "Escape") {
- setRecording(false);
- return;
- }
- const next = appZoomComboFromEvent(event);
- if (next === null) return; // only modifiers so far
+ const problemFor = useCallback(
+ (next: string) => {
const others = APP_ZOOM_INTENTS.filter((other) => other !== intent).map((other) => bindings[other]);
const problem = appZoomComboProblem(next, others);
- if (problem) {
- setError(t(PROBLEM_KEY[problem]));
- return;
- }
- if (quickSwitch.enabled && sameChord(next, quickSwitch.combo)) {
- setError(t(PROBLEM_KEY.quick_switch));
- return;
- }
- setError(null);
- setBinding(intent, next);
- setRecording(false);
- };
- // Capture on window: ahead of the zoom itself, the quick switcher and any
- // terminal pane, so the keys land here while recording.
- window.addEventListener("keydown", onKeyDown, true);
- 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");
+ if (problem) return t(PROBLEM_KEY[problem]);
+ if (quickSwitch.enabled && sameChord(next, quickSwitch.combo)) return t(PROBLEM_KEY.quick_switch);
+ return null;
+ },
+ [intent, bindings, quickSwitch.enabled, quickSwitch.combo, t],
+ );
+ const onChange = useCallback((combo: string) => setBinding(intent, combo), [intent, setBinding]);
return (
- <ShortcutListRow
- testId={`app-zoom-row-${intent}`}
- recording={recording}
+ <CharacterChordRow
+ rowTestId={`app-zoom-row-${intent}`}
+ testIdSuffix={`app-zoom-${intent}`}
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={recordLabel}
- title={recordLabel}
- disabled={off}
- onClick={() => {
- setError(null);
- setRecording((r) => !r);
- }}
- >
- {recording ? <X /> : <Pencil />}
- </Button>
- <Button
- type="button"
- size="icon"
- variant="ghost"
- className="h-8 w-8"
- data-testid={`app-zoom-clear-${intent}`}
- aria-label={t("settings_view.keybinds.clear")}
- title={t("settings_view.keybinds.clear")}
- disabled={off || !combo || recording}
- onClick={() => setBinding(intent, "")}
- >
- <X />
- </Button>
- </>
- }
- >
- {error && (
- <p className="mt-2 text-sm text-destructive" role="alert">
- {error}
- </p>
- )}
- {!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>
- )}
- </ShortcutListRow>
+ combo={bindings[intent]}
+ fallback={defaultAppZoomBindings()[intent]}
+ off={!enabled}
+ problemFor={problemFor}
+ onChange={onChange}
+ />
);
}
diff --git a/jarvis/ui/web/frontend/src/views/settings/CharacterChordRow.tsx b/jarvis/ui/web/frontend/src/views/settings/CharacterChordRow.tsx
new file mode 100644
index 0000000000..aa63fa159e
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/settings/CharacterChordRow.tsx
@@ -0,0 +1,160 @@
+/**
+ * A row of the shortcut list for an in-window chord recorded by CHARACTER: the
+ * whole-app zoom steps, the terminal text size steps, the shortcut overview and
+ * the Agentic IDE key menu.
+ *
+ * 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
+ * no punctuation, because a global OS hotkey cannot use it. These chords need
+ * `+`, `-` and `?`, which sit on different keys on a German and a US keyboard,
+ * so this recorder reads the character the key types (see lib/appZoom).
+ *
+ * The pencil starts recording; while it records, the same button cancels and
+ * the line under the row offers "Remove" and "Reset to default". The owner
+ * decides where the chord is stored and which chords it refuses.
+ */
+import { useEffect, useState } from "react";
+import { Pencil, X } from "lucide-react";
+
+import { Button } from "@/components/ui/button";
+import { useT } from "@/i18n";
+import { appZoomCaps, appZoomComboFromEvent } from "@/lib/appZoom";
+import type { ShortcutScope } from "@/lib/shortcutRegistry";
+import { KeyCaps, NoKeys, ShortcutListRow } from "@/views/settings/ShortcutListRow";
+
+export function CharacterChordRow({
+ title,
+ scope,
+ combo,
+ fallback,
+ off = false,
+ rowTestId,
+ testIdSuffix,
+ problemFor,
+ onChange,
+}: {
+ title: string;
+ scope: ShortcutScope;
+ /** The stored chord; "" when the user removed it. */
+ combo: string;
+ /** The shipped chord "Reset to default" goes back to. */
+ fallback: string;
+ /** The feature is switched off: the row says so and cannot be edited. */
+ off?: boolean;
+ rowTestId: string;
+ /** Names the controls: `chord-record-<suffix>`, `chord-clear-<suffix>`. */
+ testIdSuffix: string;
+ /** The message that refuses this chord, or null when it may be saved. */
+ problemFor: (next: string) => string | null;
+ onChange: (combo: string) => void;
+}) {
+ const t = useT();
+ const [recording, setRecording] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ useEffect(() => {
+ if (!recording) return;
+ const onKeyDown = (event: KeyboardEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+ if (event.key === "Escape") {
+ setError(null);
+ setRecording(false);
+ return;
+ }
+ const next = appZoomComboFromEvent(event);
+ if (next === null) return; // only modifiers so far
+ const problem = problemFor(next);
+ if (problem) {
+ setError(problem);
+ return;
+ }
+ setError(null);
+ onChange(next);
+ setRecording(false);
+ };
+ // Capture on window: ahead of the zoom itself, the quick switcher and any
+ // terminal pane, so the keys land here while recording.
+ window.addEventListener("keydown", onKeyDown, true);
+ return () => window.removeEventListener("keydown", onKeyDown, true);
+ }, [recording, problemFor, onChange]);
+
+ const finish = (next: string) => {
+ setError(null);
+ onChange(next);
+ setRecording(false);
+ };
+ const buttonLabel = recording ? t("settings_view.keybinds.stop") : t("shortcuts_view.edit");
+
+ return (
+ <ShortcutListRow
+ testId={rowTestId}
+ recording={recording}
+ title={title}
+ scope={scope}
+ 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 ? (
+ <KeyCaps caps={appZoomCaps(combo)} />
+ ) : (
+ <NoKeys>{t("shortcut_overlay.unassigned")}</NoKeys>
+ )
+ }
+ actions={
+ <Button
+ type="button"
+ size="icon"
+ variant={recording ? "secondary" : "ghost"}
+ className="h-8 w-8"
+ data-testid={`chord-record-${testIdSuffix}`}
+ aria-label={buttonLabel}
+ title={buttonLabel}
+ disabled={off}
+ onClick={() => {
+ setError(null);
+ setRecording((r) => !r);
+ }}
+ >
+ {recording ? <X /> : <Pencil />}
+ </Button>
+ }
+ >
+ {recording && (
+ <div className="mt-2 flex flex-wrap items-center justify-between gap-x-4 gap-y-1">
+ <p className="text-micro text-muted-foreground">{t("shortcuts_view.record_hint")}</p>
+ <div className="flex items-center gap-3">
+ {combo && (
+ <button
+ type="button"
+ data-testid={`chord-clear-${testIdSuffix}`}
+ className="text-micro text-muted-foreground underline hover:text-foreground"
+ onClick={() => finish("")}
+ >
+ {t("shortcuts_view.remove")}
+ </button>
+ )}
+ {combo !== fallback && (
+ <button
+ type="button"
+ className="text-micro text-muted-foreground underline hover:text-foreground"
+ onClick={() => finish(fallback)}
+ >
+ {t("settings_view.keybinds.reset")}
+ </button>
+ )}
+ </div>
+ </div>
+ )}
+ {error && (
+ <p className="mt-2 text-sm text-destructive" role="alert">
+ {error}
+ </p>
+ )}
+ </ShortcutListRow>
+ );
+}