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.

fix(ui): name the Mac modifiers the way a Mac keycap prints them

Personal Jarvis Maintainere174f9f8faab
diff --git a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.test.tsx b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.test.tsx
new file mode 100644
index 0000000000..2145ff3c8e
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.test.tsx
@@ -0,0 +1,73 @@
+/**
+ * The saved-shortcut chip must name the keys the user's OWN keyboard prints.
+ *
+ * A Mac keycap reads ⌃ ⌥ ⌘ — the words "Ctrl", "Alt" and "Win" appear nowhere
+ * on the hardware. Rendering them anyway put a chip on screen naming a key the
+ * machine does not have, directly beside the on-screen keyboard drawing that
+ * same physical key as ⌥, which is how a shortcut saved on a Mac read back as a
+ * Windows one (reported 2026-08-11). ``win`` had already been fixed this way;
+ * ``ctrl`` and ``alt`` had not, so this pins BOTH platforms for every modifier
+ * rather than the one that happened to be reported.
+ *
+ * ``formatCombo`` reads the platform ONCE at module scope, so each case has to
+ * re-import the module behind a stubbed ``navigator``.
+ */
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+type Format = (combo: string) => string;
+
+async function formatComboOn(platform: "mac" | "pc"): Promise<Format> {
+ vi.resetModules();
+ vi.stubGlobal("navigator", {
+ platform: platform === "mac" ? "MacIntel" : "Win32",
+ userAgent:
+ platform === "mac"
+ ? "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
+ : "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
+ });
+ const mod = await import("./KeybindRow");
+ return mod.formatCombo;
+}
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.resetModules();
+});
+
+describe("formatCombo modifier vocabulary", () => {
+ it("prints Mac glyphs on a Mac", async () => {
+ const formatCombo = await formatComboOn("mac");
+ expect(formatCombo("ctrl+right_alt+j")).toBe("⌃ + ⌥ + J");
+ expect(formatCombo("alt+shift+d")).toBe("⌥ + Shift + D");
+ expect(formatCombo("win+space")).toBe("⌘ + Space");
+ expect(formatCombo("left_alt+right_ctrl+k")).toBe("⌥ + ⌃ + K");
+ });
+
+ it("never leaks a PC modifier word onto a Mac", async () => {
+ const formatCombo = await formatComboOn("mac");
+ // Every modifier token the backend can hand back, in one sweep: none of
+ // them may render a word that a Mac keyboard does not print.
+ const combo = formatCombo(
+ "ctrl+control+right_ctrl+alt+left_alt+right_alt+altgr+win+meta+cmd+j",
+ );
+ expect(combo).not.toMatch(/Ctrl|Alt|Win|AltGr/i);
+ });
+
+ it("keeps the PC words on a PC", async () => {
+ const formatCombo = await formatComboOn("pc");
+ expect(formatCombo("ctrl+right_alt+j")).toBe("Ctrl + AltGr + J");
+ expect(formatCombo("alt+shift+d")).toBe("Alt + Shift + D");
+ expect(formatCombo("win+space")).toBe("Win + Space");
+ expect(formatCombo("left_alt+right_ctrl+k")).toBe("Left-Alt + Right-Ctrl + K");
+ });
+
+ it("leaves the non-modifier vocabulary alone on both platforms", async () => {
+ for (const platform of ["mac", "pc"] as const) {
+ const formatCombo = await formatComboOn(platform);
+ expect(formatCombo("f3+f4")).toBe("F3 + F4");
+ expect(formatCombo("numpad_3")).toBe("Num 3");
+ expect(formatCombo("page_up")).toBe("PageUp");
+ expect(formatCombo("mouse_x1")).toBe("Mouse Back");
+ }
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
index b07fd41597..012cf063a1 100644
--- a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
@@ -56,11 +56,16 @@ const _LOST_KEYUP_MS = 900;
/** Pretty-print a combo string ("ctrl+right_alt+j" → "Ctrl + AltGr + J"). */
export function formatCombo(combo: string): string {
const labels: Record<string, string> = {
- ctrl: "Ctrl",
- control: "Ctrl",
- right_ctrl: "Right-Ctrl",
- alt: "Alt",
- left_alt: "Left-Alt",
+ // Same rule as ``win`` below, applied to the other two Mac modifiers: a
+ // Mac keycap prints ⌃ and ⌥, never "Ctrl" or "Alt". Leaving these as PC
+ // words put a chip on screen that named a key the machine does not have,
+ // right next to the on-screen keyboard drawing that very key as ⌥ — and
+ // the mismatch is what made a saved Mac shortcut read as a Windows one.
+ ctrl: _KB_PLATFORM === "mac" ? "⌃" : "Ctrl",
+ control: _KB_PLATFORM === "mac" ? "⌃" : "Ctrl",
+ right_ctrl: _KB_PLATFORM === "mac" ? "⌃" : "Right-Ctrl",
+ alt: _KB_PLATFORM === "mac" ? "⌥" : "Alt",
+ left_alt: _KB_PLATFORM === "mac" ? "⌥" : "Left-Alt",
// The right Alt key is labelled the way the keycap actually reads — "AltGr"
// on a PC layout, the Option glyph on a Mac — so the chip in the row and the
// cap on the on-screen keyboard name the SAME physical key. "Right-Alt"