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(ui): press ? for a keyboard shortcut overlay

rubenluetke10-beep081c5abdfc53
diff --git a/jarvis/ui/web/frontend/src/App.tsx b/jarvis/ui/web/frontend/src/App.tsx
index 696fbcb3a5..14d59c2e6e 100644
--- a/jarvis/ui/web/frontend/src/App.tsx
+++ b/jarvis/ui/web/frontend/src/App.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useState } from "react";
+import { Suspense, lazy, useCallback, useEffect, useState } from "react";
import { isSectionId, useEventStore } from "@/store/events";
import { useDeckStore } from "@/store/deck";
@@ -23,6 +23,17 @@ import { MainView } from "@/components/layout/MainView";
import { ToastLayer } from "@/components/ToastLayer";
import { CommandActivityLayer } from "@/components/CommandActivityLayer";
import { EditContextMenu } from "@/components/EditContextMenu";
+/*
+ Lazy on purpose. The overlay pulls in the dialog primitives, the keyboard
+ layout table and the keybind hook — none of which anything needs before
+ someone presses `?`. Imported statically it put the startup chunk over the
+ bundle budget, and every byte there is parsed before the UI paints. Only the
+ key guard below stays eager, and it is a pure function over the event.
+*/
+const ShortcutOverlay = lazy(() =>
+ import("@/components/ShortcutOverlay").then((m) => ({ default: m.ShortcutOverlay })),
+);
+import { shouldOpenShortcutOverlay } from "@/lib/shortcutOverlayTrigger";
import { JarvisDock } from "@/components/JarvisDock";
import { CliConnectPoller } from "@/components/CliConnectPoller";
import { OnboardingGate } from "@/components/onboarding/OnboardingGate";
@@ -116,6 +127,23 @@ export function SectionStage({
}
export default function App() {
+ /*
+ `?` opens the shortcut overlay. Registered here rather than per view so it
+ works everywhere, and guarded by shouldOpenShortcutOverlay so it never eats
+ a question mark typed into a message, a search box or a terminal pane.
+ Escape and focus restoration are the dialog's own.
+ */
+ const [shortcutsOpen, setShortcutsOpen] = useState(false);
+ useEffect(() => {
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (!shouldOpenShortcutOverlay(event)) return;
+ event.preventDefault();
+ setShortcutsOpen(true);
+ };
+ window.addEventListener("keydown", onKeyDown);
+ return () => window.removeEventListener("keydown", onKeyDown);
+ }, []);
+
useWebSocket();
useBrainStatus();
useVoiceStatus();
@@ -307,6 +335,11 @@ export default function App() {
<ToastLayer />
<CommandActivityLayer />
<EditContextMenu />
+ {shortcutsOpen && (
+ <Suspense fallback={null}>
+ <ShortcutOverlay open onOpenChange={setShortcutsOpen} />
+ </Suspense>
+ )}
</div>
);
}
@@ -381,6 +414,12 @@ export default function App() {
<CliConnectPoller />
{/* Blocking onboarding gate — overlays everything until first-run setup is complete. */}
<OnboardingGate />
+ {/* `?` anywhere in the app opens this; the chunk loads on first use. */}
+ {shortcutsOpen && (
+ <Suspense fallback={null}>
+ <ShortcutOverlay open onOpenChange={setShortcutsOpen} />
+ </Suspense>
+ )}
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/ShortcutOverlay.test.tsx b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.test.tsx
new file mode 100644
index 0000000000..e6a695655c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.test.tsx
@@ -0,0 +1,103 @@
+/**
+ * The overlay must show the binding the machine has, not the one it shipped
+ * with. That is the difference between a useful list and a misleading one, so
+ * the rebind case is the test that matters most here.
+ */
+import { describe, expect, it, vi, beforeEach } from "vitest";
+import { render, screen } from "@testing-library/react";
+import { ShortcutOverlay } from "./ShortcutOverlay";
+
+const keybindsState = {
+ config: null as null | {
+ keybinds: Record<string, string>;
+ defaults: Record<string, string>;
+ suggestions: string[];
+ restart_required: boolean;
+ },
+ loading: false,
+ error: null,
+ refetch: vi.fn(),
+ saveKeybind: vi.fn(),
+};
+
+vi.mock("@/hooks/useHotkey", () => ({
+ useKeybinds: () => keybindsState,
+}));
+
+vi.mock("@/views/settings/keyboardLayout", () => ({
+ detectKeyboardPlatform: () => "pc",
+}));
+
+vi.mock("@/i18n", () => ({
+ // Render the key itself so assertions read against a stable string.
+ useT: () => (key: string) => key,
+}));
+
+beforeEach(() => {
+ keybindsState.config = {
+ keybinds: {},
+ defaults: {},
+ suggestions: [],
+ restart_required: false,
+ };
+});
+
+function open() {
+ return render(<ShortcutOverlay open onOpenChange={() => {}} />);
+}
+
+/** The caps rendered on one shortcut's row, found by its label. */
+function capsForRow(labelKey: string): string[] {
+ const row = screen.getByText(labelKey).closest("li");
+ if (!row) throw new Error(`no row for ${labelKey}`);
+ return [...row.querySelectorAll("kbd")].map((k) => k.textContent ?? "");
+}
+
+describe("ShortcutOverlay", () => {
+ it("renders both areas with their entries", () => {
+ open();
+ expect(screen.getByTestId("shortcut-overlay")).toBeTruthy();
+ expect(screen.getByText("shortcut_overlay.area.voice")).toBeTruthy();
+ expect(screen.getByText("shortcut_overlay.area.workspace")).toBeTruthy();
+ expect(screen.getByText("shortcut_overlay.voice.dictate")).toBeTruthy();
+ });
+
+ it("shows the CURRENT binding after a rebind, not the shipped default", () => {
+ keybindsState.config = {
+ keybinds: { dictate: "ctrl+shift+j" },
+ // The default is deliberately different: if the overlay ever read this
+ // field, the assertion below would catch it.
+ defaults: { dictate: "f9" },
+ suggestions: [],
+ restart_required: false,
+ };
+ open();
+ expect(capsForRow("shortcut_overlay.voice.dictate")).toEqual([
+ "Ctrl",
+ "Shift",
+ "J",
+ ]);
+ expect(screen.queryByText("F9")).toBeNull();
+ });
+
+ it("says a voice key is unassigned rather than showing a chord it does not have", () => {
+ open();
+ expect(screen.getAllByText("shortcut_overlay.unassigned").length).toBeGreaterThan(0);
+ expect(capsForRow("shortcut_overlay.voice.call")).toEqual([]);
+ });
+
+ it("draws the platform modifier for this keyboard", () => {
+ open();
+ // detectKeyboardPlatform is mocked to "pc", so Mod must render as Ctrl.
+ expect(capsForRow("shortcut_overlay.workspace.zoom_reset")).toEqual([
+ "Ctrl",
+ "0",
+ ]);
+ expect(screen.queryByText("⌘")).toBeNull();
+ });
+
+ it("renders nothing while closed", () => {
+ render(<ShortcutOverlay open={false} onOpenChange={() => {}} />);
+ expect(screen.queryByTestId("shortcut-overlay")).toBeNull();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx
new file mode 100644
index 0000000000..35b7dc8cd4
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/ShortcutOverlay.tsx
@@ -0,0 +1,188 @@
+/**
+ * The `?` overlay: every keyboard shortcut the app is willing to teach.
+ *
+ * The app had shortcuts and no way to find them. This renders them from
+ * `@/lib/shortcutRegistry` — the single list — and resolves the rebindable ones
+ * through `useKeybinds()`, so what a reader sees is the combo their machine has
+ * registered right now, not the shipped default. That is the difference between
+ * a useful overlay and a misleading one.
+ *
+ * Escape and focus restoration are Radix Dialog's, not ours: it returns focus
+ * to whatever was focused before the dialog opened, which is exactly the
+ * behaviour required and is easy to get subtly wrong by hand.
+ */
+import * as Dialog from "@radix-ui/react-dialog";
+import { Keyboard, X } from "lucide-react";
+import { useKeybinds } from "@/hooks/useHotkey";
+import { detectKeyboardPlatform } from "@/views/settings/keyboardLayout";
+import {
+ SHORTCUT_AREAS,
+ keyLabel,
+ shortcutsForArea,
+ type Shortcut,
+ type ShortcutArea,
+} from "@/lib/shortcutRegistry";
+import { cn } from "@/lib/utils";
+import { useT } from "@/i18n";
+
+/** One keycap. Colours come from theme tokens, so it reads in both modes. */
+function Cap({ children }: { children: React.ReactNode }) {
+ return (
+ <kbd
+ className={cn(
+ "inline-flex min-w-[1.75rem] items-center justify-center rounded-md border border-border",
+ "bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",
+ "shadow-[inset_0_-1px_0_rgba(0,0,0,0.12)]",
+ )}
+ >
+ {children}
+ </kbd>
+ );
+}
+
+function Chord({ keys, isMac }: { keys: string[]; isMac: boolean }) {
+ return (
+ <span className="inline-flex items-center gap-1">
+ {keys.map((token, i) => (
+ <span key={i} className="inline-flex items-center gap-1">
+ {i > 0 && <span className="text-[10px] text-muted-foreground">+</span>}
+ <Cap>{keyLabel(token, isMac)}</Cap>
+ </span>
+ ))}
+ </span>
+ );
+}
+
+/**
+ * Split a saved combo ("ctrl+shift+j") into caps.
+ *
+ * The backend stores combos lowercase and `+`-joined; capitalising each token
+ * for display is presentation only and never written back.
+ */
+function comboTokens(combo: string): string[] {
+ return combo
+ .split("+")
+ .map((t) => t.trim())
+ .filter(Boolean)
+ .map((t) => (t.length === 1 ? t.toUpperCase() : t[0].toUpperCase() + t.slice(1)));
+}
+
+function ShortcutRow({ shortcut, isMac }: { shortcut: Shortcut; isMac: boolean }) {
+ const t = useT();
+ const { config } = useKeybinds();
+
+ 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-[10px] text-muted-foreground">
+ {t("shortcut_overlay.or")}
+ </span>
+ <Chord keys={alt} isMac={isMac} />
+ </div>
+ ))}
+ </div>
+ );
+ } 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 shipped
+ // chord the machine has not registered.
+ const combo = config?.keybinds?.[shortcut.action];
+ chord = combo ? (
+ <Chord keys={comboTokens(combo)} isMac={isMac} />
+ ) : (
+ <span className="text-[11px] italic text-muted-foreground">
+ {t("shortcut_overlay.unassigned")}
+ </span>
+ );
+ }
+
+ return (
+ <li className="flex items-center justify-between gap-4 py-2">
+ <span className="min-w-0 text-xs text-foreground">{t(shortcut.labelKey)}</span>
+ {chord}
+ </li>
+ );
+}
+
+function Section({ area, isMac }: { area: ShortcutArea; isMac: boolean }) {
+ const t = useT();
+ const rows = shortcutsForArea(area);
+ if (rows.length === 0) return null;
+ return (
+ <section>
+ <h3 className="mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground">
+ {t(`shortcut_overlay.area.${area}`)}
+ </h3>
+ <ul className="divide-y divide-border/60">
+ {rows.map((shortcut, i) => (
+ <ShortcutRow key={i} shortcut={shortcut} isMac={isMac} />
+ ))}
+ </ul>
+ </section>
+ );
+}
+
+export function ShortcutOverlay({
+ open,
+ onOpenChange,
+}: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) {
+ const t = useT();
+ const isMac = detectKeyboardPlatform() === "mac";
+
+ return (
+ <Dialog.Root open={open} onOpenChange={onOpenChange}>
+ <Dialog.Portal>
+ <Dialog.Overlay className="fixed inset-0 z-[80] bg-[#090909]/75 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:animate-none" />
+ <Dialog.Content
+ data-testid="shortcut-overlay"
+ className={cn(
+ "fixed left-1/2 top-1/2 z-[90] flex max-h-[min(88dvh,40rem)] w-[min(520px,calc(100vw-2rem))]",
+ "-translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-border",
+ "bg-card shadow-[0_28px_90px_-24px_rgba(0,0,0,0.75)] outline-none",
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none",
+ )}
+ >
+ <header className="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
+ <div className="min-w-0">
+ <div className="mb-1 flex items-center gap-2">
+ <Keyboard className="h-4 w-4 text-primary" aria-hidden="true" />
+ <Dialog.Title className="font-display text-base font-semibold tracking-tight text-foreground">
+ {t("shortcut_overlay.title")}
+ </Dialog.Title>
+ </div>
+ <Dialog.Description className="text-xs leading-relaxed text-muted-foreground">
+ {t("shortcut_overlay.description")}
+ </Dialog.Description>
+ </div>
+ <Dialog.Close asChild>
+ <button
+ type="button"
+ aria-label={t("shortcut_overlay.close")}
+ className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ >
+ <X className="h-4 w-4" aria-hidden="true" />
+ </button>
+ </Dialog.Close>
+ </header>
+
+ <div className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 py-5 scrollbar-jarvis">
+ {SHORTCUT_AREAS.map((area) => (
+ <Section key={area} area={area} isMac={isMac} />
+ ))}
+ </div>
+
+ <footer className="border-t border-border px-5 py-3 text-[11px] text-muted-foreground">
+ {t("shortcut_overlay.footer")}
+ </footer>
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 4046a68592..c0013f355c 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -864,6 +864,31 @@
"error": "fehler"
}
},
+ "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",
+ "footer": "Sprachtasten änderst du unter Einstellungen → Tastatur.",
+ "area": {
+ "voice": "Sprache",
+ "workspace": "Arbeitsbereich"
+ },
+ "voice": {
+ "dictate": "Zum Sprechen halten (Push-to-Talk)",
+ "dictate_toggle": "Freihändiges Diktat an/aus",
+ "call": "Gespräch mit Jarvis starten",
+ "hangup": "Gespräch beenden",
+ "paste_last": "Letzte Transkription einfügen"
+ },
+ "workspace": {
+ "zoom_in": "Terminaltext größer",
+ "zoom_out": "Terminaltext kleiner",
+ "zoom_reset": "Terminaltextgröße zurücksetzen",
+ "open_overlay": "Diese Liste öffnen"
+ }
+ },
"board_view": {
"title": "Board",
"subtitle": "Alles, was du und {name} zusammen gemacht habt — komplett lokal.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index b821774af6..4968b01084 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -864,6 +864,31 @@
"error": "error"
}
},
+ "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",
+ "footer": "Rebind the voice keys under Settings → Keyboard.",
+ "area": {
+ "voice": "Voice",
+ "workspace": "Workspace"
+ },
+ "voice": {
+ "dictate": "Hold to talk (push-to-talk)",
+ "dictate_toggle": "Hands-free dictation on/off",
+ "call": "Start a call with Jarvis",
+ "hangup": "End the call",
+ "paste_last": "Paste the last transcription"
+ },
+ "workspace": {
+ "zoom_in": "Larger terminal text",
+ "zoom_out": "Smaller terminal text",
+ "zoom_reset": "Reset terminal text size",
+ "open_overlay": "Open this list"
+ }
+ },
"board_view": {
"title": "Board",
"subtitle": "Everything you and {name} have done together — fully local.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 127a320e32..8fcf57dcee 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -864,6 +864,31 @@
"error": "error"
}
},
+ "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",
+ "footer": "Cambia las teclas de voz en Ajustes → Teclado.",
+ "area": {
+ "voice": "Voz",
+ "workspace": "Espacio de trabajo"
+ },
+ "voice": {
+ "dictate": "Mantén pulsado para hablar (push-to-talk)",
+ "dictate_toggle": "Dictado manos libres on/off",
+ "call": "Iniciar una llamada con Jarvis",
+ "hangup": "Colgar",
+ "paste_last": "Pegar la última transcripción"
+ },
+ "workspace": {
+ "zoom_in": "Texto del terminal más grande",
+ "zoom_out": "Texto del terminal más pequeño",
+ "zoom_reset": "Restablecer el tamaño del texto",
+ "open_overlay": "Abrir esta lista"
+ }
+ },
"board_view": {
"title": "Tablero",
"subtitle": "Todo lo que tú y {name} habéis hecho juntos — totalmente local.",
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.test.ts b/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.test.ts
new file mode 100644
index 0000000000..d495d67b7e
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.test.ts
@@ -0,0 +1,82 @@
+/**
+ * `?` is a character people type. These tests are the guard that it keeps
+ * being one everywhere text is entered.
+ */
+import { describe, expect, it } from "vitest";
+import {
+ isTextEntryTarget,
+ shouldOpenShortcutOverlay,
+} from "./shortcutOverlayTrigger";
+
+function ev(over: Partial<Parameters<typeof shouldOpenShortcutOverlay>[0]> = {}) {
+ return {
+ key: "?",
+ ctrlKey: false,
+ metaKey: false,
+ altKey: false,
+ defaultPrevented: false,
+ target: null,
+ ...over,
+ };
+}
+
+function el(html: string): HTMLElement {
+ const host = document.createElement("div");
+ host.innerHTML = html;
+ return host.firstElementChild as HTMLElement;
+}
+
+describe("shouldOpenShortcutOverlay", () => {
+ it("opens on a bare question mark", () => {
+ expect(shouldOpenShortcutOverlay(ev())).toBe(true);
+ });
+
+ it("ignores any other key", () => {
+ expect(shouldOpenShortcutOverlay(ev({ key: "/" }))).toBe(false);
+ expect(shouldOpenShortcutOverlay(ev({ key: "Escape" }))).toBe(false);
+ });
+
+ it("leaves Ctrl / Cmd / Alt chords to whoever claims them", () => {
+ expect(shouldOpenShortcutOverlay(ev({ ctrlKey: true }))).toBe(false);
+ expect(shouldOpenShortcutOverlay(ev({ metaKey: true }))).toBe(false);
+ expect(shouldOpenShortcutOverlay(ev({ altKey: true }))).toBe(false);
+ });
+
+ it("stays out of the way once something else handled the key", () => {
+ expect(shouldOpenShortcutOverlay(ev({ defaultPrevented: true }))).toBe(false);
+ });
+
+ it("does not steal the character out of a text field", () => {
+ for (const html of [
+ "<input>",
+ '<input type="text">',
+ '<input type="search">',
+ "<textarea></textarea>",
+ '<div contenteditable="true"></div>',
+ ]) {
+ expect(shouldOpenShortcutOverlay(ev({ target: el(html) }))).toBe(false);
+ }
+ });
+
+ it("still opens from a control that is not text entry", () => {
+ for (const html of ['<input type="checkbox">', "<button></button>", "<div></div>"]) {
+ expect(shouldOpenShortcutOverlay(ev({ target: el(html) }))).toBe(true);
+ }
+ });
+
+ it("respects a region that claims the keyboard, such as a terminal pane", () => {
+ const pane = el('<div data-keyboard-capture="true"><span></span></div>');
+ const inner = pane.querySelector("span") as HTMLElement;
+ expect(shouldOpenShortcutOverlay(ev({ target: inner }))).toBe(false);
+ });
+});
+
+describe("isTextEntryTarget", () => {
+ it("treats a non-element target as safe", () => {
+ expect(isTextEntryTarget(null)).toBe(false);
+ });
+
+ it("treats a bare input with no type as text, the safe default", () => {
+ expect(isTextEntryTarget(el("<input>"))).toBe(true);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts b/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts
new file mode 100644
index 0000000000..1dffecc6b3
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/shortcutOverlayTrigger.ts
@@ -0,0 +1,82 @@
+/**
+ * When `?` should open the shortcut overlay — and, more importantly, when it
+ * must not.
+ *
+ * `?` is a character people type. A global listener that opened a dialog every
+ * time it appeared would eat the question mark out of a chat message, a wiki
+ * note, a search box and every command typed into a terminal pane, which is a
+ * far worse bug than the missing overlay it was meant to fix. So the guard
+ * below is the substance of this feature, not a detail of it.
+ *
+ * Kept as a plain function on the event rather than inside the hook so the
+ * rules are testable without mounting anything.
+ */
+
+/** Elements that are text entry by their tag alone. */
+const TEXT_TAGS = new Set(["INPUT", "TEXTAREA", "SELECT"]);
+
+/**
+ * `<input type="checkbox">` and friends are not text entry, so `?` is free
+ * there. Everything not on this list — including a bare `<input>` with no type
+ * — is treated as text, because the safe default is to let the character
+ * through.
+ */
+const NON_TEXT_INPUT_TYPES = new Set([
+ "button",
+ "checkbox",
+ "color",
+ "file",
+ "image",
+ "radio",
+ "range",
+ "reset",
+ "submit",
+]);
+
+export function isTextEntryTarget(target: EventTarget | null): boolean {
+ if (!(target instanceof HTMLElement)) return false;
+ // Read the attribute as well as the property: `isContentEditable` is
+ // computed from the rendered tree, so it is false for an element that is
+ // editable but not attached to the document yet — and an element that is
+ // about to receive typed text is exactly the case this must catch.
+ const editable = target.getAttribute("contenteditable");
+ if (target.isContentEditable || editable === "" || editable === "true") {
+ return true;
+ }
+ if (target.closest?.('[contenteditable=""], [contenteditable="true"]')) {
+ return true;
+ }
+ const tag = target.tagName;
+ if (tag === "INPUT") {
+ const type = (target as HTMLInputElement).type?.toLowerCase() ?? "text";
+ return !NON_TEXT_INPUT_TYPES.has(type);
+ }
+ if (TEXT_TAGS.has(tag)) return true;
+ // xterm renders an off-screen textarea that is caught above, but a pane can
+ // also mark a whole region as keyboard-owning; honour that claim.
+ return Boolean(target.closest?.('[data-keyboard-capture="true"]'));
+}
+
+export interface OverlayTriggerEvent {
+ key: string;
+ ctrlKey: boolean;
+ metaKey: boolean;
+ altKey: boolean;
+ defaultPrevented: boolean;
+ target: EventTarget | null;
+}
+
+/**
+ * True when this keystroke is 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.
+ */
+export function shouldOpenShortcutOverlay(event: OverlayTriggerEvent): boolean {
+ if (event.defaultPrevented) return false;
+ 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
new file mode 100644
index 0000000000..005cacbe98
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.test.ts
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+import { describe, expect, it } from "vitest";
+import { zoomIntentFor } from "@/components/agentic/terminalZoom";
+import {
+ SHORTCUTS,
+ SHORTCUT_AREAS,
+ keyLabel,
+ shortcutsForArea,
+ type FixedShortcut,
+} from "./shortcutRegistry";
+import { shouldOpenShortcutOverlay } from "./shortcutOverlayTrigger";
+
+/** 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];
+ return {
+ key,
+ code: "",
+ ctrlKey: mod && !isMac,
+ metaKey: mod && isMac,
+ altKey: false,
+ };
+}
+
+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));
+ expect([...declared].sort()).toEqual([...SHORTCUT_AREAS].sort());
+ });
+
+ it("never spells out a chord for a rebindable shortcut", () => {
+ for (const shortcut of SHORTCUTS) {
+ if (shortcut.kind !== "rebindable") continue;
+ // A `keys` field here would be a copy of a configurable value — exactly
+ // the staleness this design exists to avoid.
+ expect(shortcut).not.toHaveProperty("keys");
+ expect(shortcut.action).toBeTruthy();
+ }
+ });
+
+ it("gives every entry a label key", () => {
+ for (const shortcut of SHORTCUTS) {
+ expect(shortcut.labelKey.startsWith("shortcut_overlay.")).toBe(true);
+ }
+ });
+});
+
+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);
+ });
+
+ 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("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);
+ });
+});
+
+describe("keyLabel", () => {
+ it("draws the platform modifier the way each keyboard prints it", () => {
+ expect(keyLabel("Mod", true)).toBe("⌘");
+ expect(keyLabel("Mod", false)).toBe("Ctrl");
+ });
+
+ it("passes every other token through untouched", () => {
+ expect(keyLabel("F9", true)).toBe("F9");
+ expect(keyLabel("+", false)).toBe("+");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
new file mode 100644
index 0000000000..8f47cf58e7
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/shortcutRegistry.ts
@@ -0,0 +1,124 @@
+/**
+ * The list of keyboard shortcuts the app is willing to teach — the single
+ * source the `?` overlay renders from.
+ *
+ * ## Two kinds of entry, and why they are different
+ *
+ * A **rebindable** entry carries no key at all, only the backend action name.
+ * The voice keys (push-to-talk, hands-free, call, hang up, paste last) are
+ * configurable in Settings, so writing their chord down here would be a copy
+ * that goes stale the moment someone rebinds one — and an overlay that shows
+ * the default after a rebind is worse than no overlay. The renderer resolves
+ * 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.
+ *
+ * Entries are grouped by area so the overlay can render sections without a
+ * second ordering table.
+ */
+import type { KeybindAction } from "@/hooks/useHotkey";
+
+export type ShortcutArea = "voice" | "workspace";
+
+interface ShortcutBase {
+ /** i18n key for the one-line description. */
+ labelKey: string;
+ area: ShortcutArea;
+}
+
+export interface RebindableShortcut extends ShortcutBase {
+ kind: "rebindable";
+ /** Backend keybind action; the current combo is read live, never stored. */
+ 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[][];
+}
+
+export type Shortcut = RebindableShortcut | FixedShortcut;
+
+export const SHORTCUTS: readonly Shortcut[] = [
+ // ── Voice — every one of these is rebindable in Settings ───────────────
+ { kind: "rebindable", area: "voice", action: "dictate", labelKey: "shortcut_overlay.voice.dictate" },
+ {
+ kind: "rebindable",
+ area: "voice",
+ action: "dictate_toggle",
+ labelKey: "shortcut_overlay.voice.dictate_toggle",
+ },
+ { kind: "rebindable", area: "voice", action: "call", labelKey: "shortcut_overlay.voice.call" },
+ { kind: "rebindable", area: "voice", action: "hangup", labelKey: "shortcut_overlay.voice.hangup" },
+ {
+ kind: "rebindable",
+ area: "voice",
+ action: "paste_last",
+ labelKey: "shortcut_overlay.voice.paste_last",
+ },
+
+ // ── Workspace — fixed chords, verified against their matcher by the test ──
+ {
+ kind: "fixed",
+ area: "workspace",
+ keys: ["Mod", "+"],
+ alternateKeys: [["Mod", "="]],
+ labelKey: "shortcut_overlay.workspace.zoom_in",
+ },
+ {
+ kind: "fixed",
+ area: "workspace",
+ keys: ["Mod", "-"],
+ alternateKeys: [["Mod", "_"]],
+ labelKey: "shortcut_overlay.workspace.zoom_out",
+ },
+ {
+ kind: "fixed",
+ area: "workspace",
+ keys: ["Mod", "0"],
+ labelKey: "shortcut_overlay.workspace.zoom_reset",
+ },
+ {
+ kind: "fixed",
+ area: "workspace",
+ keys: ["?"],
+ labelKey: "shortcut_overlay.workspace.open_overlay",
+ },
+] as const;
+
+/** Areas in the order the overlay renders them. */
+export const SHORTCUT_AREAS: readonly ShortcutArea[] = ["voice", "workspace"];
+
+export function shortcutsForArea(area: ShortcutArea): Shortcut[] {
+ return SHORTCUTS.filter((s) => s.area === area);
+}
+
+/**
+ * Render one key token for display.
+ *
+ * Only `Mod` is platform-dependent; every other token is already the label a
+ * reader expects to see on their keycap.
+ */
+export function keyLabel(token: string, isMac: boolean): string {
+ if (token === "Mod") return isMac ? "⌘" : "Ctrl";
+ return token;
+}