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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-02 09:01)

Ruben Lütke89e6dbce31b2
diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.keybinds.test.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.keybinds.test.tsx
new file mode 100644
index 0000000000..9ff79d2b0a
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/SettingsView.keybinds.test.tsx
@@ -0,0 +1,90 @@
+/**
+ * Tests for the Clear button on the Voice Keybinds rows (KeybindsPanel,
+ * rendered inside SettingsView).
+ */
+import { cleanup, render, screen, fireEvent, waitFor } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("@/i18n", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@/i18n")>();
+ return {
+ ...actual,
+ useT: () => actual.useT(),
+ useUiLanguage: () => "en",
+ useReplyLanguage: () => "auto",
+ };
+});
+
+const { saveKeybind, state } = vi.hoisted(() => {
+ const defaultConfig = {
+ keybinds: { call: "f3+f4", hangup: "f1+f2", ptt: "ctrl+right_alt+j" },
+ defaults: { call: "f3+f4", hangup: "f1+f2", ptt: "ctrl+right_alt+j" },
+ push_to_talk: true,
+ suggestions: [] as string[],
+ restart_required: false,
+ };
+ const saveKeybind = vi.fn().mockResolvedValue({
+ ok: true,
+ action: "hangup",
+ hotkey: "",
+ persisted: true,
+ applied_live: true,
+ restart_required: false,
+ });
+ return { saveKeybind, state: { config: defaultConfig, defaultConfig } };
+});
+
+vi.mock("@/hooks/useHotkey", async (importOriginal) => {
+ const actual = await importOriginal<typeof import("@/hooks/useHotkey")>();
+ return {
+ ...actual,
+ useKeybinds: () => ({
+ config: state.config,
+ loading: false,
+ error: null,
+ refetch: vi.fn(),
+ saveKeybind,
+ }),
+ };
+});
+
+import { KeybindsPanel } from "@/views/SettingsView";
+
+afterEach(() => {
+ cleanup();
+ saveKeybind.mockClear();
+ state.config = state.defaultConfig;
+});
+
+describe("KeybindsPanel — Clear button", () => {
+ it("renders a Clear button for every bound row", () => {
+ render(<KeybindsPanel />);
+ expect(screen.queryByTestId("clear-keybind-call")).not.toBeNull();
+ expect(screen.queryByTestId("clear-keybind-hangup")).not.toBeNull();
+ expect(screen.queryByTestId("clear-keybind-ptt")).not.toBeNull();
+ });
+
+ it("clicking Clear saves an empty hotkey for that action", async () => {
+ render(<KeybindsPanel />);
+ fireEvent.click(screen.getByTestId("clear-keybind-hangup"));
+ await waitFor(() => expect(saveKeybind).toHaveBeenCalledWith("hangup", ""));
+ });
+
+ it("shows 'No key assigned' after a successful clear", async () => {
+ render(<KeybindsPanel />);
+ fireEvent.click(screen.getByTestId("clear-keybind-hangup"));
+ await waitFor(() => {
+ expect(screen.queryAllByText("No key assigned").length).toBeGreaterThan(0);
+ });
+ });
+
+ it("disables Clear when the action is already unbound", () => {
+ state.config = {
+ ...state.defaultConfig,
+ keybinds: { ...state.defaultConfig.keybinds, hangup: "" },
+ };
+ render(<KeybindsPanel />);
+ const btn = screen.getByTestId("clear-keybind-hangup") as HTMLButtonElement;
+ expect(btn.disabled).toBe(true);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsx
index 0601e43e62..3c7f8bde7e 100644
--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx
@@ -3,6 +3,7 @@ import {
Settings,
Mic,
Keyboard,
+ X,
} from "lucide-react";
import { ViewHeader } from "@/views/ChatsView";
import { Switch } from "@/components/ui/switch";
@@ -631,6 +632,24 @@ function KeybindRow({
}
}
+ // Immediate, one-click unbind — no staging step, mirroring the "Reset to
+ // default" link's immediacy. Bypasses onSaveClick's trimmed-empty guard,
+ // which exists to stop an in-progress recording from saving nothing.
+ async function onClearClick() {
+ setSaving(true);
+ try {
+ const res = await onSave(action, "");
+ setCombo("");
+ setCapturing(false);
+ setSaved(res.restart_required);
+ pushToast("success", t("settings_view.keybinds.cleared"));
+ } catch (e) {
+ pushToast("error", (e as Error).message);
+ } finally {
+ setSaving(false);
+ }
+ }
+
const dirty = !!config && combo.trim().toLowerCase() !== current;
const showReset = !!def && combo.trim().toLowerCase() !== def;