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(settings): a skewed backend payload no longer takes the whole view down

Ruben Lütke7fb3744687af
diff --git a/jarvis/ui/web/frontend/src/hooks/useHotkey.ts b/jarvis/ui/web/frontend/src/hooks/useHotkey.ts
index ba6b1c3924..fcecf38d42 100644
--- a/jarvis/ui/web/frontend/src/hooks/useHotkey.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useHotkey.ts
@@ -195,10 +195,19 @@ export function composeCombo(tokens: Iterable<string>): string {
return [...mods, ...keys].join("+");
}
-/** Split a combo string back into its token set ("ctrl+f5" → {"ctrl","f5"}). */
+/**
+ * Split a combo string back into its token set ("ctrl+f5" → {"ctrl","f5"}).
+ *
+ * The `?? ""` is a RUNTIME guard, not redundancy with the `string` type: every
+ * combo originates in a backend JSON payload, where TypeScript guarantees
+ * nothing. A backend that does not yet know an action returns no combo for it,
+ * and the resulting `undefined.split("+")` took the entire Settings view down
+ * instead of one row (2026-07-28). Callers still default at their own level;
+ * this makes the failure impossible rather than merely unlikely.
+ */
export function comboTokens(combo: string): Set<string> {
return new Set(
- combo
+ (combo ?? "")
.split("+")
.map((p) => p.trim().toLowerCase())
.filter(Boolean),
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 20f55c8bb5..0f93de6110 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -2037,7 +2037,10 @@
"title": "Ansicht konnte nicht geladen werden",
"crashed_prefix": "ist abgestuerzt.",
"crashed_suffix": "bleibt bedienbar.",
- "back_to_chats": "Zurueck zu Chats"
+ "back_to_chats": "Zurueck zu Chats",
+ "group_title": "Dieser Bereich konnte nicht geladen werden",
+ "group_hint": "Alle anderen Einstellungen auf dieser Seite funktionieren weiterhin.",
+ "group_retry": "Erneut versuchen"
},
"plan_step_list": {
"no_plan": "Kein strukturierter Plan — Single-Shot-Run.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 421f2c09be..5c30f42317 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -2038,7 +2038,10 @@
"title": "View could not be loaded",
"crashed_prefix": "crashed.",
"crashed_suffix": "stays usable.",
- "back_to_chats": "Back to Chats"
+ "back_to_chats": "Back to Chats",
+ "group_title": "This section could not be loaded",
+ "group_hint": "Every other setting on this page still works.",
+ "group_retry": "Try again"
},
"plan_step_list": {
"no_plan": "No structured plan — single-shot run.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 6bf3264307..285226c386 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -2037,7 +2037,10 @@
"title": "No se pudo cargar la vista",
"crashed_prefix": "se ha bloqueado.",
"crashed_suffix": "sigue disponible.",
- "back_to_chats": "Volver a los chats"
+ "back_to_chats": "Volver a los chats",
+ "group_title": "No se pudo cargar esta sección",
+ "group_hint": "El resto de los ajustes de esta página siguen funcionando.",
+ "group_retry": "Intentar de nuevo"
},
"plan_step_list": {
"no_plan": "Sin plan estructurado: ejecución de un solo paso.",
diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsx
index e68aee8a7e..9bfc75c9b6 100644
--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx
@@ -20,6 +20,7 @@ import { SilenceWindowGroup } from "@/views/settings/SilenceWindowGroup";
import { VolumeGroup } from "@/views/settings/VolumeGroup";
import { AudioDevicesGroup } from "@/views/settings/AudioDevicesGroup";
import { SystemPromptGroup } from "@/views/settings/SystemPromptGroup";
+import { SettingsGroupBoundary } from "@/views/settings/SettingsGroupBoundary";
import {
useWakeWord,
useLocalSpeechInstall,
@@ -86,17 +87,40 @@ export function SettingsView() {
title={t("settings_view.title")}
subtitle={t("settings_view.subtitle")}
/>
+ {/* Each group is fault-isolated. The panels are independent, each backed
+ by its own route, so one of them throwing must cost the user that one
+ panel — not the ability to change any setting at all. */}
<div className="flex-1 overflow-y-auto scrollbar-jarvis p-6">
- <LanguagesGroup />
- <AppSettingsGroup />
- <PermissionsPanel />
- <RealtimeVoiceGroup />
- <SystemPromptGroup />
- <WakeWordPanel />
- <SilenceWindowGroup />
- <VolumeGroup />
- <AudioDevicesGroup />
- <KeybindsPanel />
+ <SettingsGroupBoundary group="languages">
+ <LanguagesGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="app">
+ <AppSettingsGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="permissions">
+ <PermissionsPanel />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="realtime-voice">
+ <RealtimeVoiceGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="system-prompt">
+ <SystemPromptGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="wake-word">
+ <WakeWordPanel />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="silence-window">
+ <SilenceWindowGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="volume">
+ <VolumeGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="audio-devices">
+ <AudioDevicesGroup />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="keybinds">
+ <KeybindsPanel />
+ </SettingsGroupBoundary>
<ul className="mt-2 space-y-2">
{rows.map((r) => (
@@ -104,7 +128,9 @@ export function SettingsView() {
))}
</ul>
- <OverlayTaskbarGroup />
+ <SettingsGroupBoundary group="overlay-taskbar">
+ <OverlayTaskbarGroup />
+ </SettingsGroupBoundary>
</div>
</div>
);
@@ -276,7 +302,11 @@ function WakeWordPanel() {
// Hydrate the form once the GET resolves (and whenever the config changes).
useEffect(() => {
if (!config) return;
- setPhrase(config.phrase);
+ // Every field defaults. The panel derives `phrase.trim()` on the next
+ // render, so a backend that omits the field (older build, degraded route)
+ // would throw out of the render path and take the whole view with it —
+ // the same version-skew failure the keybind rows hit.
+ setPhrase(config.phrase ?? "");
setEngine(config.engine || "auto");
setCustomModelPath(config.custom_model_path ?? "");
// ?? "auto" keeps the dropdown controlled even if an older backend omits it.
diff --git a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
index fac99eff95..1b3c1dd812 100644
--- a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
@@ -61,7 +61,10 @@ export function formatCombo(combo: string): string {
// Numpad digits render as "Num 3" rather than "NUMPAD_3".
const numpad = (p: string) =>
/^numpad_[0-9]$/.test(p) ? "Num " + p.slice(7) : null;
- return combo
+ // `?? ""` for the same reason as in comboTokens: the combo comes from a
+ // backend payload, so an absent action arrives as undefined at runtime no
+ // matter what the type says.
+ return (combo ?? "")
.split("+")
.map((p) => labels[p] ?? numpad(p) ?? p.toUpperCase())
.join(" + ");
@@ -158,10 +161,16 @@ export function KeybindRow({
}: KeybindRowProps) {
const t = useT();
const pushToast = useEventStore((s) => s.pushToast);
- // `?? ""` is load-bearing: a backend that does not know this action yet
- // returns no entry at all, and an undefined combo would crash comboTokens.
- const current = config?.keybinds[action] ?? "";
- const def = config?.defaults[action];
+ // Every read defaults, at BOTH levels. A backend that does not know this
+ // action yet returns no entry (`keybinds.dictate` undefined) and one that
+ // errors or predates the route returns no map at all (`keybinds` undefined) —
+ // the first fed comboTokens an undefined combo, the second dereferenced
+ // undefined directly. Either one used to take the WHOLE Settings view down
+ // with it (reported as "Cannot read properties of undefined (reading
+ // 'split')"), because a frontend build and the running backend are updated
+ // separately and a version skew is the normal state, not an edge case.
+ const current = config?.keybinds?.[action] ?? "";
+ const def = config?.defaults?.[action];
const [combo, setCombo] = useState("");
const [capturing, setCapturing] = useState(false);
@@ -172,14 +181,14 @@ export function KeybindRow({
const [pressedCodes, setPressedCodes] = useState<Set<string>>(new Set());
useEffect(() => {
- if (config) setCombo(config.keybinds[action] ?? "");
+ if (config) setCombo(config.keybinds?.[action] ?? "");
}, [config, action]);
// Tokens already bound to the OTHER actions → marked "used" on the keyboard so
// the user can pick a free key (their keys "can't be free", as reported).
const boundTokens = useMemo(() => {
const out: Record<string, string> = {};
- if (!config) return out;
+ if (!config?.keybinds) return out;
for (const [act, c] of Object.entries(config.keybinds)) {
if (act === action) continue;
const labelKey = ACTION_LABEL_KEY[act as KeybindAction];
@@ -195,7 +204,7 @@ export function KeybindRow({
// id back for the message.
const otherCombos = useMemo(() => {
const out: Record<string, string> = {};
- if (!config) return out;
+ if (!config?.keybinds) return out;
for (const [act, c] of Object.entries(config.keybinds)) {
if (act !== action) out[act] = c ?? "";
}
diff --git a/jarvis/ui/web/frontend/src/views/settings/SettingsGroupBoundary.tsx b/jarvis/ui/web/frontend/src/views/settings/SettingsGroupBoundary.tsx
new file mode 100644
index 0000000000..4ed937c395
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/settings/SettingsGroupBoundary.tsx
@@ -0,0 +1,105 @@
+import { Component, type ErrorInfo, type ReactNode } from "react";
+import { AlertTriangle, RotateCcw } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { translate } from "@/i18n";
+
+interface SettingsGroupBoundaryProps {
+ children: ReactNode;
+ /** Group name for the console log — never shown to the user. */
+ group: string;
+}
+
+interface SettingsGroupBoundaryState {
+ hasError: boolean;
+ message: string;
+ /** Bumped by "Try again" to remount the subtree with fresh state. */
+ attempt: number;
+}
+
+/**
+ * Fault isolation for ONE Settings group.
+ *
+ * Settings is a stack of independent panels, each backed by its own route. The
+ * view-level boundary treats them as one unit, so a single panel throwing
+ * replaced the ENTIRE page with an error card — the user could not change any
+ * setting, including the ones that were working (reported 2026-07-28: a
+ * keybind row hit an undefined combo from a backend that predated the action,
+ * and the whole Settings view died with "Cannot read properties of undefined").
+ *
+ * Frontend and backend are updated separately by design, so a payload the UI
+ * does not expect is a NORMAL state, not an edge case. Wrapping each group
+ * keeps that blast radius at one panel: the broken one shows an honest card
+ * with a retry, every other setting stays editable.
+ */
+export class SettingsGroupBoundary extends Component<
+ SettingsGroupBoundaryProps,
+ SettingsGroupBoundaryState
+> {
+ state: SettingsGroupBoundaryState = {
+ hasError: false,
+ message: "",
+ attempt: 0,
+ };
+
+ static getDerivedStateFromError(
+ error: unknown,
+ ): Partial<SettingsGroupBoundaryState> {
+ return {
+ hasError: true,
+ message: error instanceof Error ? error.message : String(error),
+ };
+ }
+
+ componentDidCatch(error: unknown, info: ErrorInfo) {
+ console.error("Jarvis settings group crashed", {
+ group: this.props.group,
+ error,
+ componentStack: info.componentStack,
+ });
+ }
+
+ private retry = () => {
+ this.setState((s) => ({
+ hasError: false,
+ message: "",
+ attempt: s.attempt + 1,
+ }));
+ };
+
+ render() {
+ if (!this.state.hasError) {
+ // The attempt counter is the key: a retry must remount the subtree so the
+ // failed hook state is rebuilt instead of re-throwing from the old one.
+ return <div key={this.state.attempt}>{this.props.children}</div>;
+ }
+
+ return (
+ <div className="mt-2 rounded-lg border border-destructive/30 bg-card/60 p-4">
+ <div className="flex items-start gap-3">
+ <div className="rounded-md bg-destructive/10 p-2 text-destructive">
+ <AlertTriangle className="h-4 w-4" />
+ </div>
+ <div className="min-w-0 flex-1">
+ <h4 className="font-display text-sm font-semibold">
+ {translate("view_error_boundary.group_title")}
+ </h4>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {translate("view_error_boundary.group_hint")}
+ </p>
+ {this.state.message && (
+ <pre className="mt-2 max-h-24 overflow-auto rounded-md border border-border bg-background/80 p-2 text-[11px] text-muted-foreground">
+ {this.state.message}
+ </pre>
+ )}
+ <Button className="mt-3" size="sm" variant="outline" onClick={this.retry}>
+ <RotateCcw className="h-3.5 w-3.5" />
+ <span className="ml-1.5">
+ {translate("view_error_boundary.group_retry")}
+ </span>
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+ }
+}
diff --git a/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx b/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx
new file mode 100644
index 0000000000..eea1f64184
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/settings/SettingsResilience.test.tsx
@@ -0,0 +1,138 @@
+import { render, screen, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { SettingsView } from "@/views/SettingsView";
+import { KeybindRow } from "@/views/settings/KeybindRow";
+import { SettingsGroupBoundary } from "@/views/settings/SettingsGroupBoundary";
+
+/**
+ * Version-skew resilience of the Settings view.
+ *
+ * The frontend build and the running backend are updated separately, so a
+ * payload the UI does not expect is a NORMAL state. On 2026-07-28 a keybinds
+ * response that lacked one action made a row set its combo to `undefined`,
+ * which reached `comboTokens(...).split("+")` and took the WHOLE Settings view
+ * down with "Cannot read properties of undefined (reading 'split')" — the user
+ * could not change any setting at all until the app was rebuilt and restarted.
+ *
+ * Two independent guarantees are pinned here:
+ * 1. A row survives a payload missing its action, or missing the maps.
+ * 2. Even a group that DOES throw costs only that group; the rest of the
+ * page stays rendered and editable.
+ */
+
+afterEach(() => vi.restoreAllMocks());
+
+function wrap(ui: React.ReactNode) {
+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ return <QueryClientProvider client={qc}>{ui}</QueryClientProvider>;
+}
+
+const noop = async () => ({
+ ok: true,
+ action: "call" as const,
+ hotkey: "",
+ persisted: true,
+ restart_required: false,
+});
+
+describe("KeybindRow against a skewed backend payload", () => {
+ it("renders when the payload does not know the action yet", () => {
+ // A backend that predates `dictate`: the maps exist, the entry does not.
+ const config = {
+ keybinds: { call: "f3+f4" },
+ defaults: { call: "f3+f4" },
+ suggestions: [],
+ restart_required: false,
+ };
+ render(
+ wrap(
+ <KeybindRow
+ action="dictate"
+ label="Dictation"
+ config={config}
+ loading={false}
+ onSave={noop}
+ />,
+ ),
+ );
+ expect(screen.getByTestId("combo-field-dictate")).toBeTruthy();
+ });
+
+ it("renders when the payload carries no keybind maps at all", () => {
+ // A degraded / errored route answering 200 with an empty object.
+ const config = {} as never;
+ render(
+ wrap(
+ <KeybindRow
+ action="call"
+ label="Call"
+ config={config}
+ loading={false}
+ onSave={noop}
+ />,
+ ),
+ );
+ expect(screen.getByTestId("combo-field-call")).toBeTruthy();
+ });
+});
+
+function Exploding(): JSX.Element {
+ throw new Error("Cannot read properties of undefined (reading 'split')");
+}
+
+describe("SettingsGroupBoundary", () => {
+ it("contains a throwing group and leaves its siblings rendered", () => {
+ vi.spyOn(console, "error").mockImplementation(() => {});
+
+ render(
+ wrap(
+ <>
+ <SettingsGroupBoundary group="broken">
+ <Exploding />
+ </SettingsGroupBoundary>
+ <SettingsGroupBoundary group="healthy">
+ <p>Volume</p>
+ </SettingsGroupBoundary>
+ </>,
+ ),
+ );
+
+ // The broken group degrades to its own card, carrying the honest reason...
+ expect(screen.getByText("This section could not be loaded")).toBeTruthy();
+ expect(
+ screen.getByText(/Cannot read properties of undefined/),
+ ).toBeTruthy();
+ // ...while the neighbouring setting is untouched and still on screen.
+ expect(screen.getByText("Volume")).toBeTruthy();
+ });
+});
+
+describe("SettingsView against an empty backend", () => {
+ it("renders the whole page when every route answers {}", async () => {
+ // The shape no group expects — the worst case of a version skew.
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(
+ async () =>
+ ({
+ ok: true,
+ status: 200,
+ json: async () => ({}),
+ text: async () => "{}",
+ }) as unknown as Response,
+ ),
+ );
+ vi.spyOn(console, "error").mockImplementation(() => {});
+
+ render(wrap(<SettingsView />));
+
+ // A locale row (identical in every language) proves the page is rendered,
+ // and the keybind field proves the row that used to kill it survived.
+ await waitFor(() => {
+ // One row per language section (interface / recognition / reply).
+ expect(screen.getAllByText("Deutsch (German)").length).toBeGreaterThan(0);
+ });
+ expect(screen.getByTestId("combo-field-call")).toBeTruthy();
+ });
+});