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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ui): switch the quick switcher off or change its chord
rubenluetke10-beep056119b70b0d
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsxindex d887bd2a7a..c00e51e101 100644--- a/jarvis/ui/web/frontend/src/App.tsx+++ b/jarvis/ui/web/frontend/src/App.tsx@@ -46,7 +46,8 @@ import { shouldOpenShortcutOverlay } from "@/lib/shortcutOverlayTrigger";const QuickSwitcher = lazy(() =>import("@/components/QuickSwitcher").then((m) => ({ default: m.QuickSwitcher })),);-import { isQuickSwitchChord } from "@/lib/quickSwitchChord";+import { eventMatchesChord } from "@/lib/quickSwitchChord";+import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";import { JarvisDock } from "@/components/JarvisDock";import { CliConnectPoller } from "@/components/CliConnectPoller";import { OnboardingGate } from "@/components/onboarding/OnboardingGate";@@ -115,23 +116,33 @@ export default function App() {}, []);/*- Ctrl+Space opens the quick switcher — the Spotlight-style "type a section,- press Enter" launcher. Listened for in the CAPTURE phase so it also works- while a terminal pane has focus: xterm handles keys on its own textarea and- would otherwise swallow the chord as a NUL byte for the agent. Pressing it- again closes the switcher, the way Spotlight's own chord toggles.+ The quick switcher's chord (Ctrl+Space; ⌥+Space on a Mac — both can be+ changed or switched off under Settings → Keyboard shortcuts) opens the+ Spotlight-style "type a section, press Enter" launcher. Listened for in the+ CAPTURE phase so it also works while a terminal pane has focus: xterm+ handles keys on its own textarea and would otherwise send the chord to the+ agent. Pressing it again closes the switcher, the way Spotlight's own+ chord toggles. While the Settings recorder is capturing, the chord must+ reach the recorder instead, so a recording session is skipped.*/const [switcherOpen, setSwitcherOpen] = useState(false);+ const switcherEnabled = useQuickSwitchSettings((s) => s.enabled);+ const switcherCombo = useQuickSwitchSettings((s) => s.combo);useEffect(() => {+ if (!switcherEnabled || !switcherCombo) {+ setSwitcherOpen(false);+ return;+ }const onKeyDown = (event: KeyboardEvent) => {- if (event.repeat || !isQuickSwitchChord(event)) return;+ if (event.repeat || !eventMatchesChord(event, switcherCombo)) return;+ if (document.querySelector('[data-keybind-recording="true"]')) return;event.preventDefault();event.stopPropagation();setSwitcherOpen((open) => !open);};window.addEventListener("keydown", onKeyDown, true);return () => window.removeEventListener("keydown", onKeyDown, true);- }, []);+ }, [switcherEnabled, switcherCombo]);useWebSocket();useBrainStatus();@@ -411,7 +422,7 @@ export default function App() {<CliConnectPoller />{/* Blocking onboarding gate — overlays everything until first-run setup is complete. */}<OnboardingGate activeSection={activeSection} />- {/* Ctrl+Space anywhere; the chunk loads on first use. Main window only:+ {/* The switcher chord anywhere; the chunk loads on first use. Main window only:a detached solo window IS one section, there is nowhere to switch. */}{switcherOpen && (<Suspense fallback={null}>diff --git a/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsxindex fa43cc1d30..259b74f091 100644--- a/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx+++ b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx@@ -14,6 +14,7 @@import * as Dialog from "@radix-ui/react-dialog";import { Keyboard, X } from "lucide-react";import { useKeybinds } from "@/hooks/useHotkey";+import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";import { detectKeyboardPlatform } from "@/views/settings/keyboardLayout";import {SHORTCUT_AREAS,@@ -70,6 +71,7 @@ function comboTokens(combo: string): string[] {function ShortcutRow({ shortcut, isMac }: { shortcut: Shortcut; isMac: boolean }) {const t = useT();const { config } = useKeybinds();+ const quickSwitch = useQuickSwitchSettings();let chord: React.ReactNode;if (shortcut.kind === "fixed") {@@ -86,6 +88,15 @@ function ShortcutRow({ shortcut, isMac }: { shortcut: Shortcut; isMac: boolean }))}</div>);+ } else if (shortcut.kind === "app") {+ // A per-device setting: show what this machine uses, or that it is off.+ chord = quickSwitch.enabled && quickSwitch.combo ? (+ <Chord keys={comboTokens(quickSwitch.combo)} isMac={isMac} />+ ) : (+ <span className="text-xs italic text-muted-foreground">+ {t(quickSwitch.enabled ? "shortcut_overlay.unassigned" : "shortcut_overlay.off")}+ </span>+ );} else {// The live value, never the default — the whole point of resolving these// at render time. An unset action says so instead of showing a shippeddiff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex b508b5725f..f3ce0aaaf9 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1568,6 +1568,7 @@"close": "Schließen","or": "oder","unassigned": "nicht belegt",+ "off": "aus","footer": "Sprachtasten änderst du unter Einstellungen → Tastatur.","area": {"voice": "Sprache",@@ -2566,6 +2567,18 @@"reset_done": "Auf den Standard-System-Prompt zurückgesetzt","applies_next_turn": "Wirkt ab der nächsten Antwort deines Assistenten — kein Neustart nötig."},+ "quick_switch": {+ "title": "Schnellsuche",+ "description": "Eine Suche über allem: Tippe den Namen eines Bereichs und drücke Enter, um dorthin zu springen. Funktioniert, solange das Jarvis-Fenster vorne ist.",+ "shortcut_label": "Schnellsuche öffnen",+ "keys_only": "Die Schnellsuche öffnet sich nur mit Tasten, nicht mit Maustasten.",+ "mac_note": "Auf dem Mac gehört Command+Leertaste zu Spotlight und Control+Leertaste zum Wechsel der Eingabequelle — macOS fängt beide ab, bevor Jarvis sie sieht. Deshalb ist hier Option+Leertaste voreingestellt.",+ "problem_one_key": "Nimm genau eine Taste plus Zusatztasten, zum Beispiel Strg+Leertaste. Nur Zusatztasten, Tastenpaare und Maustasten können die Schnellsuche nicht öffnen.",+ "problem_typing_key": "Diese Taste würde die Schnellsuche bei jedem Tippen öffnen. Nimm Strg, Alt oder Command dazu — oder eine Funktionstaste wie F6.",+ "problem_os_reserved": "Dein Betriebssystem behält diese Kombination für sich, sie kommt nie bei Jarvis an. Wähle eine andere.",+ "problem_app_reserved": "Jarvis nutzt diese Kombination schon (Kopieren, Einfügen, Rückgängig oder die Wiki- und Docs-Suche). Wähle eine andere.",+ "problem_voice_taken": "Ein Sprach-Kürzel nutzt genau diese Kombination schon und reagiert vor der Schnellsuche. Wähle eine andere."+ },"keybinds": {"title": "Sprach-Tastenkürzel","description": "Lege die Tasten für Anruf und Auflegen fest. Klick auf Aufnehmen und drücke deine Kombination — oder klick die Tasten auf der Bildschirm-Tastatur an. Die Tastenkürzel fürs Diktat findest du im Sprachbereich unter Tastenkürzel. Änderungen greifen sofort.",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex f04ab915f3..61ecf17509 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1601,6 +1601,7 @@"close": "Close","or": "or","unassigned": "not assigned",+ "off": "off","footer": "Rebind the voice keys under Settings → Keyboard.","area": {"voice": "Voice",@@ -2599,6 +2600,18 @@"reset_done": "Reset to the default system prompt","applies_next_turn": "Applies on your assistant's next message — no restart needed."},+ "quick_switch": {+ "title": "Quick switcher",+ "description": "A search that opens over everything: type a section's name and press Enter to go there. Works while the Jarvis window is in front.",+ "shortcut_label": "Open the quick switcher",+ "keys_only": "The quick switcher opens with keys only, not mouse buttons.",+ "mac_note": "On a Mac, Command+Space belongs to Spotlight and Control+Space to the input source switch — macOS keeps both before Jarvis sees them. That is why Option+Space is the default here.",+ "problem_one_key": "Use exactly one key plus modifiers, for example Ctrl+Space. Modifier-only chords, key pairs and mouse buttons cannot open the quick switcher.",+ "problem_typing_key": "This key would open the quick switcher every time you type it. Add Ctrl, Alt or Command — or use a function key such as F6.",+ "problem_os_reserved": "Your operating system keeps this combination for itself, so it never reaches Jarvis. Pick another one.",+ "problem_app_reserved": "Jarvis already uses this combination (copy, paste, undo or the Wiki and Docs search). Pick another one.",+ "problem_voice_taken": "A voice shortcut already uses exactly this combination, and it fires before the quick switcher can. Pick another one."+ },"keybinds": {"title": "Voice Keybinds","description": "Set the keys for starting a call and for hanging up. Click Record and press your combination — or click keys on the on-screen keyboard. The dictation shortcuts live in the voice section, under Shortcuts. Changes apply instantly.",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex a8c93f1f1f..51f4e157fa 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1568,6 +1568,7 @@"close": "Cerrar","or": "o","unassigned": "sin asignar",+ "off": "desactivado","footer": "Cambia las teclas de voz en Ajustes → Teclado.","area": {"voice": "Voz",@@ -2566,6 +2567,18 @@"reset_done": "Restablecido al prompt del sistema predeterminado","applies_next_turn": "Se aplica en el próximo mensaje de tu asistente — sin reiniciar."},+ "quick_switch": {+ "title": "Cambio rápido",+ "description": "Una búsqueda sobre todo: escribe el nombre de una sección y pulsa Enter para ir allí. Funciona mientras la ventana de Jarvis está delante.",+ "shortcut_label": "Abrir el cambio rápido",+ "keys_only": "El cambio rápido solo se abre con teclas, no con botones del ratón.",+ "mac_note": "En un Mac, Comando+Espacio pertenece a Spotlight y Control+Espacio al cambio de fuente de entrada: macOS se queda con ambos antes de que Jarvis los vea. Por eso aquí el predeterminado es Opción+Espacio.",+ "problem_one_key": "Usa exactamente una tecla más modificadores, por ejemplo Ctrl+Espacio. Solo modificadores, pares de teclas y botones del ratón no pueden abrir el cambio rápido.",+ "problem_typing_key": "Esta tecla abriría el cambio rápido cada vez que escribes. Añade Ctrl, Alt o Comando, o usa una tecla de función como F6.",+ "problem_os_reserved": "Tu sistema operativo se reserva esta combinación, así que nunca llega a Jarvis. Elige otra.",+ "problem_app_reserved": "Jarvis ya usa esta combinación (copiar, pegar, deshacer o la búsqueda de Wiki y Docs). Elige otra.",+ "problem_voice_taken": "Un atajo de voz ya usa exactamente esta combinación y se activa antes que el cambio rápido. Elige otra."+ },"keybinds": {"title": "Atajos de voz","description": "Configura las teclas para llamar y colgar. Pulsa Grabar y presiona tu combinación — o haz clic en las teclas del teclado en pantalla. Los atajos de dictado están en la sección de voz, en Atajos. Los cambios se aplican al instante.",diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitchChord.test.ts b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.test.tsnew file mode 100644index 0000000000..5516c0b464--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.test.ts@@ -0,0 +1,106 @@+/**+ * The quick switcher chord: the matcher, the per-platform default, and the+ * combos refused because the OS or the app would never let them through.+ */+import { describe, expect, it } from "vitest";+import { codeToKeyToken } from "@/hooks/useHotkey";+import {+ chordKeyToken,+ defaultQuickSwitchCombo,+ eventMatchesChord,+ quickSwitchComboProblem,+} from "./quickSwitchChord";++const press = (code: string, mods: Partial<Record<"ctrlKey" | "altKey" | "shiftKey" | "metaKey", boolean>> = {}) => ({+ code,+ ctrlKey: false,+ altKey: false,+ shiftKey: false,+ metaKey: false,+ ...mods,+});++describe("chordKeyToken agrees with the recorder", () => {+ // The startup chunk cannot import the recorder, so its key names are restated+ // here; this pins them to the recorder's so a recorded chord always matches.+ const codes = [+ "KeyA", "KeyK", "KeyZ", "Digit0", "Digit7", "F1", "F6", "F12", "F24",+ "Space", "ArrowUp", "ArrowLeft", "Home", "End", "PageUp", "PageDown",+ "Insert", "Delete", "Enter", "NumpadEnter", "Tab", "Backspace", "Numpad3",+ ];+ it.each(codes)("%s", (code) => {+ expect(chordKeyToken(code)).toBe(codeToKeyToken(code));+ });+});++describe("eventMatchesChord", () => {+ it("matches the exact chord and nothing wider", () => {+ expect(eventMatchesChord(press("Space", { ctrlKey: true }), "ctrl+space")).toBe(true);+ expect(eventMatchesChord(press("Space", { ctrlKey: true, shiftKey: true }), "ctrl+space")).toBe(false);+ expect(eventMatchesChord(press("Space"), "ctrl+space")).toBe(false);+ expect(eventMatchesChord(press("KeyK", { ctrlKey: true }), "ctrl+space")).toBe(false);+ });++ it("reads every spelling of a modifier the recorder may store", () => {+ expect(eventMatchesChord(press("KeyP", { metaKey: true, shiftKey: true }), "cmd+shift+p")).toBe(true);+ expect(eventMatchesChord(press("KeyP", { metaKey: true, shiftKey: true }), "shift+win+p")).toBe(true);+ expect(eventMatchesChord(press("Space", { altKey: true }), "right_alt+space")).toBe(true);+ });++ it("treats AltGr's phantom Ctrl as Alt, like the recorder", () => {+ const altGr = { ...press("Space", { ctrlKey: true, altKey: true }), getModifierState: (k: string) => k === "AltGraph" };+ expect(eventMatchesChord(altGr, "alt+space")).toBe(true);+ expect(eventMatchesChord(altGr, "ctrl+alt+space")).toBe(false);+ });++ it("never fires for an empty or multi-key chord", () => {+ expect(eventMatchesChord(press("Space", { ctrlKey: true }), "")).toBe(false);+ expect(eventMatchesChord(press("F3"), "f3+f4")).toBe(false);+ });+});++describe("defaults", () => {+ it("avoids the keys macOS keeps for itself", () => {+ expect(defaultQuickSwitchCombo("pc")).toBe("ctrl+space");+ expect(defaultQuickSwitchCombo("mac")).toBe("alt+space");+ expect(quickSwitchComboProblem(defaultQuickSwitchCombo("mac"), "mac")).toBeNull();+ expect(quickSwitchComboProblem(defaultQuickSwitchCombo("pc"), "pc")).toBeNull();+ });+});++describe("quickSwitchComboProblem", () => {+ it.each([+ ["cmd+space", "mac", "os_reserved"], // Spotlight+ ["command+space", "mac", "os_reserved"],+ ["cmd+alt+space", "mac", "os_reserved"],+ ["ctrl+space", "mac", "os_reserved"], // input source switch+ ["cmd+tab", "mac", "os_reserved"],+ ["alt+space", "pc", "os_reserved"], // window system menu+ ["win+space", "pc", "os_reserved"],+ ["alt+f4", "pc", "os_reserved"],+ ["ctrl+k", "pc", "app_reserved"], // Wiki / Docs search+ ["cmd+k", "mac", "app_reserved"],+ ["ctrl+c", "pc", "app_reserved"],+ ["cmd+v", "mac", "app_reserved"],+ ["space", "pc", "typing_key"],+ ["shift+j", "pc", "typing_key"],+ ["ctrl", "pc", "one_key"],+ ["ctrl+f3+f4", "pc", "one_key"],+ ["ctrl+mouse_middle", "pc", "one_key"],+ ] as const)("refuses %s on %s (%s)", (combo, platform, problem) => {+ expect(quickSwitchComboProblem(combo, platform)).toBe(problem);+ });++ it.each([+ ["ctrl+space", "pc"],+ ["ctrl+shift+space", "pc"],+ ["ctrl+shift+k", "pc"],+ ["f6", "pc"],+ ["alt+space", "mac"],+ ["cmd+shift+space", "mac"],+ ["cmd+shift+k", "mac"],+ ["ctrl+alt+k", "mac"],+ ] as const)("accepts %s on %s", (combo, platform) => {+ expect(quickSwitchComboProblem(combo, platform)).toBeNull();+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.tsindex b10cc4b45e..d0a516ea7f 100644--- a/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts+++ b/jarvis/ui/web/frontend/src/lib/quickSwitchChord.ts@@ -1,31 +1,188 @@/**- * The quick switcher's chord, kept apart from `./quickSwitch` on purpose: the- * app shell checks every keystroke against it, so it ships in the startup- * chunk — and `./quickSwitch` carries all three locale dictionaries, which- * must stay in the switcher's own lazy chunk.+ * The quick switcher's chord: which keys open it, and which keys never could.+ *+ * Kept apart from `./quickSwitch` on purpose: the app shell checks every+ * keystroke against it, so it ships in the startup chunk — and `./quickSwitch`+ * carries all three locale dictionaries, which must stay in the switcher's own+ * lazy chunk. For the same reason it does not import `@/hooks/useHotkey` (the+ * recorder and the keyboard layout table): the few token rules it needs are+ * restated here and pinned to the recorder's by `quickSwitchChord.test.ts`.+ *+ * Combos use the recorder's spelling ("ctrl+space", "alt+space", "cmd+shift+k"),+ * because the Settings row that edits this chord IS the voice keybind recorder.+ *+ * ## Why the default differs on a Mac+ *+ * The switcher only ever sees keys the operating system lets through to the+ * window. On a Mac, ⌘+Space is Spotlight and ⌃+Space switches the input source,+ * so neither would ever arrive — the switcher would simply look broken. ⌥+Space+ * is what Mac launchers (Alfred, Raycast) settled on for the same reason. Every+ * other system gets Ctrl+Space. The keys an OS is known to swallow are refused+ * outright when someone records them (`quickSwitchComboProblem`), with a reason.*/-export interface QuickSwitchKeyEvent {- key: string;++export type ChordPlatform = "mac" | "pc";++export function hostChordPlatform(): ChordPlatform {+ if (typeof navigator === "undefined") return "pc";+ const hint = `${navigator.platform ?? ""} ${navigator.userAgent ?? ""}`;+ return /mac|iphone|ipad/i.test(hint) ? "mac" : "pc";+}++export function defaultQuickSwitchCombo(platform: ChordPlatform = hostChordPlatform()): string {+ return platform === "mac" ? "alt+space" : "ctrl+space";+}++/** Every spelling the recorder (or a hand edit) may use, folded to four names. */+const MODIFIER_FOLD: Record<string, "ctrl" | "alt" | "shift" | "meta"> = {+ ctrl: "ctrl",+ control: "ctrl",+ right_ctrl: "ctrl",+ right_control: "ctrl",+ alt: "alt",+ right_alt: "alt",+ left_alt: "alt",+ altgr: "alt",+ shift: "shift",+ win: "meta",+ window: "meta",+ super: "meta",+ meta: "meta",+ cmd: "meta",+ command: "meta",+};++/** The recorder's names for keys whose `event.code` is not a letter, digit or F-key. */+const NAMED_CODES: Record<string, string> = {+ Space: "space",+ ArrowUp: "up",+ ArrowDown: "down",+ ArrowLeft: "left",+ ArrowRight: "right",+ Insert: "insert",+ Delete: "delete",+ Home: "home",+ End: "end",+ PageUp: "page_up",+ PageDown: "page_down",+ Enter: "enter",+ NumpadEnter: "enter",+ Tab: "tab",+ Backspace: "backspace",+};++/** The recorder's token for a physical key, or null for modifiers and the rest. */+export function chordKeyToken(code: string): string | null {+ 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();+ if (/^Numpad[0-9]$/.test(code)) return `numpad_${code.slice(6)}`;+ return NAMED_CODES[code] ?? null;+}++export interface ParsedChord {+ mods: Set<"ctrl" | "alt" | "shift" | "meta">;+ keys: string[];+}++export function parseChord(combo: string): ParsedChord {+ const mods = new Set<"ctrl" | "alt" | "shift" | "meta">();+ const keys: string[] = [];+ for (const raw of (combo ?? "").split("+")) {+ const token = raw.trim().toLowerCase();+ if (!token) continue;+ const mod = MODIFIER_FOLD[token];+ if (mod) mods.add(mod);+ else keys.push(token);+ }+ return { mods, keys };+}++export interface ChordKeyEvent {code: string;ctrlKey: boolean;metaKey: boolean;altKey: boolean;shiftKey: boolean;+ getModifierState?(key: string): boolean;}/**- * Ctrl+Space, on every platform.- *- * The closest chord to the Mac's ⌘+Space that the app can actually receive:- * ⌘+Space itself belongs to the OS launcher and never reaches the window, and- * Ctrl/⌘+K is already the Wiki's and the Docs' own search. Ctrl+Space means- * nothing to a coding agent's TUI (it would send a NUL byte) and is not one of- * the voice defaults — those all carry Alt, which disqualifies here.- *- * `code` is checked as well as `key` because some layouts and IMEs report the- * space bar's `key` as something other than " " while a modifier is held.+ * Does this keydown press exactly `combo`? Exactly: Ctrl+Shift+Space does not+ * fire a Ctrl+Space binding, so a chord can be kept free for something else.+ * AltGr reports a phantom Ctrl on Windows; like the recorder, it counts as Alt.*/-export function isQuickSwitchChord(event: QuickSwitchKeyEvent): boolean {- if (!event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return false;- return event.code === "Space" || event.key === " ";+export function eventMatchesChord(event: ChordKeyEvent, combo: string): boolean {+ const { mods, keys } = parseChord(combo);+ if (keys.length !== 1) return false;+ if (chordKeyToken(event.code) !== keys[0]) return false;+ const altGr = event.getModifierState?.("AltGraph") === true;+ const held = {+ ctrl: event.ctrlKey && !altGr,+ alt: event.altKey || altGr,+ shift: event.shiftKey,+ meta: event.metaKey,+ };+ return (Object.keys(held) as (keyof typeof held)[]).every((m) => held[m] === mods.has(m));+}++/** Why a chord cannot open the switcher; null when it can. */+export type ChordProblem =+ /** Not exactly one real key (modifiers only, a mouse button, a key pair). */+ | "one_key"+ /** A typing key with no Ctrl/Alt/⌘ — it would fire on every keystroke. */+ | "typing_key"+ /** The operating system takes it before the window ever sees it. */+ | "os_reserved"+ /** Already means something inside the app (copy, paste, Wiki search …). */+ | "app_reserved";++/** Combos each OS keeps for itself, in folded spelling ("meta+space"). */+const OS_RESERVED: Record<ChordPlatform, readonly string[]> = {+ mac: [+ "meta+space", // Spotlight+ "alt+meta+space", // Finder search+ "ctrl+space", // previous input source+ "alt+ctrl+space", // next input source+ "meta+tab",+ "meta+q",+ "meta+h",+ "meta+m",+ "meta+w",+ ],+ pc: [+ "alt+space", // the window's system menu+ "alt+tab",+ "alt+f4",+ "alt+ctrl+delete",+ "ctrl+shift+escape",+ ],+};++/** Chords the app already gives a meaning to, on every platform. */+const APP_RESERVED = ["k", "c", "v", "x", "a", "z", "y", "0"];++function foldedChord({ mods, keys }: ParsedChord): string {+ return [...[...mods].sort(), ...keys].join("+");+}++export function quickSwitchComboProblem(+ combo: string,+ platform: ChordPlatform = hostChordPlatform(),+): ChordProblem | null {+ const parsed = parseChord(combo);+ const { mods, keys } = parsed;+ if (keys.length !== 1 || keys[0].startsWith("mouse_")) return "one_key";+ const key = keys[0];+ // The Windows key and Super belong to the desktop shell on a PC; the shell+ // swallows most of those chords before any window sees them.+ if (platform === "pc" && mods.has("meta")) return "os_reserved";+ if (OS_RESERVED[platform].includes(foldedChord(parsed))) return "os_reserved";+ const realModifier = mods.has("ctrl") || mods.has("alt") || mods.has("meta");+ if (!realModifier && !/^f[0-9]{1,2}$/.test(key)) return "typing_key";+ // Ctrl/⌘ + a letter the editors, terminals or the Wiki/Docs search use.+ const primaryOnly =+ mods.size === 1 && (mods.has("ctrl") || mods.has("meta")) && APP_RESERVED.includes(key);+ if (primaryOnly) return "app_reserved";+ return null;}diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.tsindex d06cba1183..784acdd092 100644--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts@@ -17,7 +17,7 @@ import {type FixedShortcut,} from "./shortcutRegistry";import { shouldOpenShortcutOverlay } from "./shortcutOverlayTrigger";-import { isQuickSwitchChord } from "./quickSwitchChord";+import { eventMatchesChord, defaultQuickSwitchCombo } from "./quickSwitchChord";/** Turn a declared chord into the event the matcher would see. */function eventFor(keys: string[], isMac: boolean) {@@ -103,27 +103,29 @@ describe("fixed chords agree with the matcher that implements them", () => {});});-describe("the quick switcher chord", () => {- it("declares the chord its matcher accepts", () => {+describe("the quick switcher entry", () => {+ it("is read from the live setting, never spelled out", () => {const entry = shortcutsForArea("workspace").find((s) => s.labelKey === "shortcut_overlay.workspace.quick_switch",- ) as FixedShortcut;- expect(entry.keys).toEqual(["Ctrl", "Space"]);- const chord = { key: " ", code: "Space", ctrlKey: true, metaKey: false, altKey: false, shiftKey: false };- expect(isQuickSwitchChord(chord)).toBe(true);+ );+ expect(entry?.kind).toBe("app");+ expect(entry).not.toHaveProperty("keys");});- it("leaves the voice toggle's Ctrl+Alt+Space and plain typing alone", () => {- const base = { key: " ", code: "Space", ctrlKey: true, metaKey: false, altKey: false, shiftKey: false };- expect(isQuickSwitchChord({ ...base, altKey: true })).toBe(false);- expect(isQuickSwitchChord({ ...base, shiftKey: true })).toBe(false);- expect(isQuickSwitchChord({ ...base, metaKey: true })).toBe(false);- expect(isQuickSwitchChord({ ...base, ctrlKey: false })).toBe(false);- expect(isQuickSwitchChord({ ...base, key: "k", code: "KeyK" })).toBe(false);+ it("defaults to a chord the matcher accepts on both platforms", () => {+ const base = { code: "Space", ctrlKey: false, metaKey: false, altKey: false, shiftKey: false };+ expect(eventMatchesChord({ ...base, ctrlKey: true }, defaultQuickSwitchCombo("pc"))).toBe(true);+ expect(eventMatchesChord({ ...base, altKey: true }, defaultQuickSwitchCombo("mac"))).toBe(true);});});describe("keyLabel", () => {+ it("prints Mac glyphs for saved modifier names", () => {+ expect(keyLabel("Alt", true)).toBe("⌥");+ expect(keyLabel("Ctrl", true)).toBe("⌃");+ expect(keyLabel("Cmd", true)).toBe("⌘");+ });+it("draws the platform modifier the way each keyboard prints it", () => {expect(keyLabel("Mod", true)).toBe("⌘");expect(keyLabel("Mod", false)).toBe("Ctrl");@@ -131,6 +133,7 @@ describe("keyLabel", () => {it("passes every other token through untouched", () => {expect(keyLabel("F9", true)).toBe("F9");+ expect(keyLabel("Alt", false)).toBe("Alt");expect(keyLabel("+", false)).toBe("+");});});diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.tsindex 494757544c..65bc5ad717 100644--- a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts@@ -56,7 +56,17 @@ export interface FixedShortcut extends ShortcutBase {alternateKeys?: string[][];}-export type Shortcut = RebindableShortcut | FixedShortcut;+/**+ * An in-app shortcut whose chord is a per-device preference (the quick+ * switcher). 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";+}++export type Shortcut = RebindableShortcut | FixedShortcut | AppSettingShortcut;export const SHORTCUTS: readonly Shortcut[] = [// ── Voice — every one of these is rebindable in Settings ───────────────@@ -104,9 +114,9 @@ export const SHORTCUTS: readonly Shortcut[] = [labelKey: "shortcut_overlay.workspace.open_overlay",},{- kind: "fixed",+ kind: "app",area: "workspace",- keys: ["Ctrl", "Space"],+ setting: "quick_switch",labelKey: "shortcut_overlay.workspace.quick_switch",},] as const;@@ -126,5 +136,21 @@ export function shortcutsForArea(area: ShortcutArea): Shortcut[] {*/export function keyLabel(token: string, isMac: boolean): string {if (token === "Mod") return isMac ? "⌘" : "Ctrl";+ // A saved combo spells modifiers the PC way; a Mac keycap prints a glyph.+ if (isMac) {+ const glyph = MAC_GLYPHS[token.toLowerCase()];+ if (glyph) return glyph;+ }return token;}++const MAC_GLYPHS: Record<string, string> = {+ ctrl: "⌃",+ alt: "⌥",+ right_alt: "⌥",+ cmd: "⌘",+ command: "⌘",+ meta: "⌘",+ win: "⌘",+ super: "⌘",+};diff --git a/jarvis/ui/web/frontend/src/store/quickSwitchSettings.ts b/jarvis/ui/web/frontend/src/store/quickSwitchSettings.tsnew file mode 100644index 0000000000..ae3a4f8826--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/quickSwitchSettings.ts@@ -0,0 +1,77 @@+/**+ * The quick switcher's two settings: whether it is on, and which chord opens it.+ *+ * Stored in the browser's own storage rather than in `jarvis.toml`: the+ * switcher lives entirely inside the window and the backend never needs to know+ * about it — the voice keybinds are a different thing, global OS hotkeys the+ * backend registers. Every window of the app shares one origin, so they all+ * read the same value, and a change made in one window reaches the others+ * through the `storage` event.+ *+ * An unreadable or missing value falls back to "on, platform default" — a+ * broken preference must never leave someone without the switcher and without+ * a clue why.+ */+import { create } from "zustand";+import { defaultQuickSwitchCombo } from "@/lib/quickSwitchChord";++export const QUICK_SWITCH_STORAGE_KEY = "jarvis.quickSwitch.v1";++interface StoredQuickSwitch {+ enabled: boolean;+ /** "" means deliberately unassigned (the row's clear button). */+ combo: string;+}++function defaults(): StoredQuickSwitch {+ return { enabled: true, combo: defaultQuickSwitchCombo() };+}++export function readQuickSwitchSettings(): StoredQuickSwitch {+ try {+ const raw = window.localStorage.getItem(QUICK_SWITCH_STORAGE_KEY);+ if (!raw) return defaults();+ const parsed = JSON.parse(raw) as Partial<StoredQuickSwitch>;+ return {+ enabled: typeof parsed.enabled === "boolean" ? parsed.enabled : true,+ combo: typeof parsed.combo === "string" ? parsed.combo : defaultQuickSwitchCombo(),+ };+ } catch {+ return defaults();+ }+}++function write(value: StoredQuickSwitch): void {+ try {+ window.localStorage.setItem(QUICK_SWITCH_STORAGE_KEY, JSON.stringify(value));+ } catch {+ /* storage unavailable — the choice holds for this session only */+ }+}++interface QuickSwitchSettingsState extends StoredQuickSwitch {+ setEnabled: (enabled: boolean) => void;+ setCombo: (combo: string) => void;+}++export const useQuickSwitchSettings = create<QuickSwitchSettingsState>((set, get) => ({+ ...readQuickSwitchSettings(),+ setEnabled: (enabled) => {+ write({ enabled, combo: get().combo });+ set({ enabled });+ },+ setCombo: (combo) => {+ const next = combo.trim().toLowerCase();+ write({ enabled: get().enabled, combo: next });+ set({ combo: next });+ },+}));++// Another window changed it: take the new value over.+if (typeof window !== "undefined") {+ window.addEventListener("storage", (event) => {+ if (event.key === QUICK_SWITCH_STORAGE_KEY) {+ useQuickSwitchSettings.setState(readQuickSwitchSettings());+ }+ });+}diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsxindex 86c41c6054..277812de19 100644--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx@@ -30,6 +30,7 @@ import {} from "@/hooks/useWakeWord";import { useKeybinds, type KeybindAction } from "@/hooks/useHotkey";import { KeybindRow } from "@/views/settings/KeybindRow";+import { QuickSwitchKeybind } from "@/views/settings/QuickSwitchKeybind";import { deriveAssistantName } from "@/lib/deriveAssistantName";import { WAKE_ENGINES, WAKE_ENGINE_I18N_KEY } from "@/constants/wakeEngines";import { useEventStore } from "@/store/events";@@ -871,6 +872,7 @@ export function KeybindsPanel() {/>))}</div>+ <QuickSwitchKeybind voiceConfig={config} /></div></div></div>diff --git a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsxindex 22768b01c5..530dcbe52f 100644--- a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx+++ b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx@@ -862,6 +862,9 @@ export function KeybindRow({<buttontype="button"data-testid={`combo-field-${action}`}+ // App-level chords (the quick switcher) stand down while this is set, so+ // the keys being recorded reach the recorder instead of opening something.+ data-keybind-recording={capturing ? "true" : undefined}onClick={() => setCapturing((c) => !c)}disabled={loading}className={`flex min-h-[34px] flex-wrap items-center gap-1 rounded-md border px-3 py-1.5 text-left text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-border-strong disabled:opacity-50 ${diff --git a/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.test.tsx b/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.test.tsxnew file mode 100644index 0000000000..431225c6dd--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.test.tsx@@ -0,0 +1,58 @@+/**+ * Settings → Keyboard shortcuts: the quick switcher can be switched off, and+ * its chord is stored per device.+ */+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { QuickSwitchKeybind } from "./QuickSwitchKeybind";+import {+ QUICK_SWITCH_STORAGE_KEY,+ readQuickSwitchSettings,+ useQuickSwitchSettings,+} from "@/store/quickSwitchSettings";+import { defaultQuickSwitchCombo } from "@/lib/quickSwitchChord";++describe("QuickSwitchKeybind", () => {+ beforeEach(() => {+ window.localStorage.removeItem(QUICK_SWITCH_STORAGE_KEY);+ useQuickSwitchSettings.setState(readQuickSwitchSettings());+ });+ afterEach(cleanup);++ it("starts on, with the platform default", () => {+ render(<QuickSwitchKeybind voiceConfig={null} />);+ expect(useQuickSwitchSettings.getState().enabled).toBe(true);+ expect(useQuickSwitchSettings.getState().combo).toBe(defaultQuickSwitchCombo());+ expect(screen.getByTestId("combo-field-quick_switch")).toBeTruthy();+ });++ it("switches off, hides the recorder and remembers it", () => {+ render(<QuickSwitchKeybind voiceConfig={null} />);+ fireEvent.click(screen.getByTestId("quick-switch-enabled"));+ expect(useQuickSwitchSettings.getState().enabled).toBe(false);+ expect(screen.queryByTestId("combo-field-quick_switch")).toBeNull();+ expect(readQuickSwitchSettings().enabled).toBe(false);+ });++ it("keeps a stored chord across a reload", () => {+ useQuickSwitchSettings.getState().setCombo("Ctrl+Shift+K");+ expect(readQuickSwitchSettings().combo).toBe("ctrl+shift+k");+ });++ it("shows no overlap warning for a voice chord it merely contains", () => {+ const voice = {+ keybinds: { dictate_toggle: "ctrl+right_alt+space" },+ defaults: {},+ suggestions: [],+ restart_required: false,+ };+ useQuickSwitchSettings.getState().setCombo("ctrl+space");+ render(<QuickSwitchKeybind voiceConfig={voice} />);+ expect(screen.queryByTestId("keybind-validation-quick_switch")).toBeNull();+ });++ it("falls back to the defaults when storage holds garbage", () => {+ window.localStorage.setItem(QUICK_SWITCH_STORAGE_KEY, "{not json");+ expect(readQuickSwitchSettings()).toEqual({ enabled: true, combo: defaultQuickSwitchCombo() });+ });+});diff --git a/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsx b/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsxnew file mode 100644index 0000000000..1d4317a715--- /dev/null+++ b/jarvis/ui/web/frontend/src/views/settings/QuickSwitchKeybind.tsx@@ -0,0 +1,117 @@+/**+ * Settings → Keyboard shortcuts: the quick switcher's on/off switch and chord.+ *+ * The chord is edited with the SAME recorder the voice keybinds use, so+ * recording, the on-screen keyboard and the "already used by" marks behave+ * identically. What differs is where the value goes: into the browser's storage+ * (see store/quickSwitchSettings) instead of the backend, because the switcher+ * is an in-window shortcut, not a global OS hotkey.+ *+ * The voice keybinds are passed in so a chord EQUAL to one of them is refused —+ * a global hotkey fires before the window sees the key, so the switcher would+ * 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.+ */+import { Search } from "lucide-react";+import { Switch } from "@/components/ui/switch";+import { useT } from "@/i18n";+import type { KeybindAction, KeybindSaveResult, KeybindsConfig } from "@/hooks/useHotkey";+import { KeybindRow } from "@/views/settings/KeybindRow";+import { useQuickSwitchSettings } from "@/store/quickSwitchSettings";+import {+ defaultQuickSwitchCombo,+ hostChordPlatform,+ parseChord,+ quickSwitchComboProblem,+ type ChordProblem,+} from "@/lib/quickSwitchChord";++/** The recorder keys rows by action id; this one is not a backend action. */+const ACTION = "quick_switch" as unknown as KeybindAction;++const PROBLEM_KEY: Record<ChordProblem, string> = {+ one_key: "settings_view.quick_switch.problem_one_key",+ typing_key: "settings_view.quick_switch.problem_typing_key",+ os_reserved: "settings_view.quick_switch.problem_os_reserved",+ app_reserved: "settings_view.quick_switch.problem_app_reserved",+};++/** One spelling per chord, so "cmd+space" and "win+space" compare equal. */+function chordKey(combo: string): string {+ const { mods, keys } = parseChord(combo);+ return [...[...mods].sort(), ...[...keys].sort()].join("+");+}++export function QuickSwitchKeybind({ voiceConfig }: { voiceConfig: KeybindsConfig | null }) {+ const t = useT();+ const enabled = useQuickSwitchSettings((s) => s.enabled);+ const combo = useQuickSwitchSettings((s) => s.combo);+ const setEnabled = useQuickSwitchSettings((s) => s.setEnabled);+ const setCombo = useQuickSwitchSettings((s) => s.setCombo);+ const mac = hostChordPlatform() === "mac";+ const label = t("settings_view.quick_switch.title");++ const config: KeybindsConfig = {+ keybinds: { [ACTION]: combo },+ defaults: { [ACTION]: defaultQuickSwitchCombo() },+ suggestions: [],+ restart_required: false,+ mouse_buttons: { supported: false, reason: t("settings_view.quick_switch.keys_only") },+ };++ const save = async (_action: KeybindAction, hotkey: string): Promise<KeybindSaveResult> => {+ if (hotkey) {+ const problem = quickSwitchComboProblem(hotkey);+ // Thrown, so the recorder shows it as its error toast and keeps the old chord.+ if (problem) throw new Error(t(PROBLEM_KEY[problem]));+ const taken = Object.entries(voiceConfig?.keybinds ?? {}).find(+ ([, other]) => other && chordKey(other) === chordKey(hotkey),+ );+ if (taken) throw new Error(t("settings_view.quick_switch.problem_voice_taken"));+ }+ setCombo(hotkey);+ return { ok: true, action: ACTION, hotkey, persisted: true, restart_required: false };+ };++ return (+ <div className="mt-block border-t border-border pt-block" data-testid="quick-switch-settings">+ <div className="flex items-start gap-3">+ <Search className="mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" aria-hidden />+ <div className="min-w-0 flex-1">+ <div className="flex items-start justify-between gap-4">+ <div className="min-w-0">+ <h4 className="text-title font-semibold text-foreground-strong">{label}</h4>+ <p className="mt-1 text-meta 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>+ {enabled && (+ <div className="mt-block space-y-stack">+ <KeybindRow+ action={ACTION}+ label={t("settings_view.quick_switch.shortcut_label")}+ config={config}+ loading={false}+ onSave={save}+ actionLabel={(action) => (action === (ACTION as string) ? label : undefined)}+ />+ {mac && (+ <p className="text-meta text-muted-foreground" data-testid="quick-switch-mac-note">+ {t("settings_view.quick_switch.mac_note")}+ </p>+ )}+ </div>+ )}+ </div>+ </div>+ </div>+ );+}