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(appshots): accept both Alt keys on AltGr keyboards (#385)

Ruben Lütkef79114290c6c
diff --git a/jarvis/ui/web/frontend/src/lib/appshotChord.test.ts b/jarvis/ui/web/frontend/src/lib/appshotChord.test.ts
index d23acb6ec2..b87000af6b 100644
--- a/jarvis/ui/web/frontend/src/lib/appshotChord.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/appshotChord.test.ts
@@ -16,6 +16,24 @@ describe("chordFromCodes", () => {
expect(chordFromCodes(["F9"])).toEqual({ combo: "f9" });
});
+ it("records both Alt keys with the extra left Ctrl reported by Windows AltGr", () => {
+ expect(chordFromCodes(["AltLeft", "ControlLeft", "AltRight"]))
+ .toEqual({ combo: "alt+alt" });
+ expect(chordFromCodes(["ControlLeft", "AltRight", "AltLeft"]))
+ .toEqual({ combo: "alt+alt" });
+ });
+
+ it("keeps other modifiers and ordinary Ctrl+AltGr shortcuts intact", () => {
+ expect(chordFromCodes(["ControlLeft", "AltRight"]))
+ .toEqual({ problem: "modifier_only" });
+ expect(chordFromCodes(["AltLeft", "AltRight", "ShiftLeft"]))
+ .toEqual({ problem: "modifier_only" });
+ expect(chordFromCodes(["AltLeft", "AltRight", "ControlRight"]))
+ .toEqual({ problem: "modifier_only" });
+ expect(chordFromCodes(["ControlLeft", "AltRight", "KeyS"]))
+ .toEqual({ combo: "ctrl+right_alt+s" });
+ });
+
it("refuses a lone modifier and ignores Escape", () => {
expect(chordFromCodes(["ShiftLeft"])).toEqual({ problem: "modifier_only" });
expect(chordFromCodes(["ShiftLeft", "ControlLeft"])).toEqual({ problem: "modifier_only" });
diff --git a/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx b/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx
index 884e0a3a52..a4d45182b9 100644
--- a/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/AppshotsView.test.tsx
@@ -281,6 +281,31 @@ describe("AppshotsView shortcut recorder", () => {
await waitFor(() => expect(puts()).toEqual([{ hotkey: "ctrl+shift+s" }]));
});
+ it.each([
+ ["AltLeft", "ControlLeft", "AltRight"],
+ ["ControlLeft", "AltRight", "AltLeft"],
+ ])("records both Alt keys from Off with Windows AltGr events (%s first)", async (...codes) => {
+ fetchMock.mockImplementation(async (url: string, init?: RequestInit) => {
+ if (url === "/api/appshot/settings" && init?.method === "PUT") {
+ return json({ ...SETTINGS, ...JSON.parse(String(init.body)) });
+ }
+ if (url === "/api/appshot/settings") return json({ ...SETTINGS, hotkey: "" });
+ return json({ appshot: null });
+ });
+ render(<AppshotsView />);
+ const change = await screen.findByTestId("appshots-hotkey-change");
+ expect(change.textContent).toBe("Off");
+ fireEvent.click(change);
+ const keys: Record<string, string> = {
+ AltLeft: "Alt", ControlLeft: "Control", AltRight: "AltGraph",
+ };
+ for (const code of codes) fireEvent.keyDown(window, { code, key: keys[code] });
+ for (const code of [...codes].reverse()) fireEvent.keyUp(window, { code, key: keys[code] });
+ await waitFor(() => expect(puts()).toEqual([{ hotkey: "alt+alt" }]));
+ expect(change.textContent).toBe("Alt+Alt");
+ expect(screen.queryByRole("alert")).toBeNull();
+ });
+
it("saves the actual letter rather than the US keyboard position", async () => {
render(<AppshotsView />);
fireEvent.click(await screen.findByTestId("appshots-hotkey-change"));