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-03 07:53)

Ruben Lütke1d042cb08694
diff --git a/jarvis/ui/web/frontend/src/hooks/useDictionary.ts b/jarvis/ui/web/frontend/src/hooks/useDictionary.ts
new file mode 100644
index 0000000000..b3a459587c
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/hooks/useDictionary.ts
@@ -0,0 +1,98 @@
+import { useCallback, useEffect, useState } from "react";
+
+/**
+ * One STT-dictionary entry from /api/dictionary: the canonical `word` plus
+ * the misheard variants that should be rewritten into it. An empty
+ * `misheard` list means "plain vocabulary word" (casing + near-miss repair).
+ */
+export interface DictionaryEntry {
+ id: string;
+ word: string;
+ misheard: string[];
+ created_at: string;
+ updated_at: string;
+}
+
+export interface DictionaryEntryPayload {
+ word: string;
+ misheard: string[];
+}
+
+async function unwrap<T>(res: Response): Promise<T> {
+ const body = await res.json().catch(() => ({}));
+ if (!res.ok) {
+ throw new Error(
+ (body as { detail?: string }).detail ?? `HTTP ${res.status}`,
+ );
+ }
+ return body as T;
+}
+
+/**
+ * Loads /api/dictionary and exposes create/update/remove. Corrections apply
+ * on the next utterance (the backend corrector live-reloads), so there is no
+ * restart plumbing here — mirrors useSystemPrompt.
+ */
+export function useDictionary() {
+ const [entries, setEntries] = useState<DictionaryEntry[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState<string | null>(null);
+
+ const refetch = useCallback(async () => {
+ setError(null);
+ try {
+ const res = await fetch("/api/dictionary");
+ const data = await unwrap<{ entries: DictionaryEntry[] }>(res);
+ setEntries(data.entries ?? []);
+ } catch (e) {
+ setError((e as Error).message);
+ } finally {
+ setLoading(false);
+ }
+ }, []);
+
+ useEffect(() => {
+ void refetch();
+ }, [refetch]);
+
+ const createEntry = useCallback(
+ async (payload: DictionaryEntryPayload): Promise<DictionaryEntry> => {
+ const res = await fetch("/api/dictionary", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(payload),
+ });
+ const created = await unwrap<DictionaryEntry>(res);
+ setEntries((prev) => [...prev, created]);
+ return created;
+ },
+ [],
+ );
+
+ const updateEntry = useCallback(
+ async (
+ id: string,
+ payload: Partial<DictionaryEntryPayload>,
+ ): Promise<DictionaryEntry> => {
+ const res = await fetch(`/api/dictionary/${encodeURIComponent(id)}`, {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(payload),
+ });
+ const updated = await unwrap<DictionaryEntry>(res);
+ setEntries((prev) => prev.map((e) => (e.id === id ? updated : e)));
+ return updated;
+ },
+ [],
+ );
+
+ const removeEntry = useCallback(async (id: string): Promise<void> => {
+ const res = await fetch(`/api/dictionary/${encodeURIComponent(id)}`, {
+ method: "DELETE",
+ });
+ await unwrap<{ ok: boolean }>(res);
+ setEntries((prev) => prev.filter((e) => e.id !== id));
+ }, []);
+
+ return { entries, loading, error, refetch, createEntry, updateEntry, removeEntry };
+}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index b989987a64..6a0c3302b1 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -156,6 +156,33 @@
"other": "Andere"
}
},
+ "dictionary": {
+ "title": "Wörterbuch",
+ "description": "Bring der Spracherkennung deine Wörter bei — Namen, Marken, Fachbegriffe. Füge ein Wort hinzu oder korrigiere, was sie immer wieder falsch versteht.",
+ "add": "Wort hinzufügen",
+ "search": "Wörterbuch durchsuchen…",
+ "loading": "Wörterbuch wird geladen…",
+ "empty": "Noch keine Wörter — füge Namen oder Begriffe hinzu, die die Spracherkennung kennen soll.",
+ "no_matches": "Keine Einträge passen zu deiner Suche.",
+ "edit": "Bearbeiten",
+ "delete": "Löschen",
+ "added": "„{0}\" wurde ins Wörterbuch aufgenommen.",
+ "saved": "Wörterbuch-Eintrag gespeichert.",
+ "deleted": "„{0}\" wurde aus dem Wörterbuch entfernt.",
+ "applies_note": "Änderungen gelten ab deiner nächsten Äußerung — kein Neustart nötig.",
+ "dialog_add_title": "Zum Wortschatz hinzufügen",
+ "dialog_edit_title": "Wörterbuch-Eintrag bearbeiten",
+ "correction_toggle": "Falsch Erkanntes korrigieren",
+ "correction_hint_on": "Immer wenn die linke Seite verstanden wird, wird sie durch die rechte ersetzt.",
+ "correction_hint_off": "Füge ein Wort hinzu, damit die Erkennung es kennt und genau so schreibt.",
+ "word_placeholder": "Neues Wort hinzufügen",
+ "word_correct_placeholder": "Richtige Schreibweise",
+ "misheard_placeholder": "Falsch erkannt als…",
+ "misheard_comma_hint": "Mehrere falsch erkannte Varianten mit Kommas trennen.",
+ "cancel": "Abbrechen",
+ "save": "Speichern",
+ "add_confirm": "Wort hinzufügen"
+ },
"voice_state": {
"idle": "Bereit",
"listening": "Hört zu",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index b77a7f5d6e..79b8ee7eae 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -156,6 +156,33 @@
"other": "Other"
}
},
+ "dictionary": {
+ "title": "Dictionary",
+ "description": "Teach speech recognition your words — names, brands, technical terms. Add a word, or fix something it keeps hearing wrong.",
+ "add": "Add word",
+ "search": "Search dictionary…",
+ "loading": "Loading dictionary…",
+ "empty": "No words yet — add names or terms the voice recognition should know.",
+ "no_matches": "No entries match your search.",
+ "edit": "Edit",
+ "delete": "Delete",
+ "added": "\"{0}\" added to the dictionary.",
+ "saved": "Dictionary entry saved.",
+ "deleted": "\"{0}\" removed from the dictionary.",
+ "applies_note": "Changes apply to the next thing you say — no restart needed.",
+ "dialog_add_title": "Add to your vocabulary",
+ "dialog_edit_title": "Edit dictionary entry",
+ "correction_toggle": "Fix a misrecognition",
+ "correction_hint_on": "Whenever the left side is heard, it is replaced by the right side.",
+ "correction_hint_off": "Add a word so the recognition knows it and spells it exactly like this.",
+ "word_placeholder": "Add a new word",
+ "word_correct_placeholder": "Correct spelling",
+ "misheard_placeholder": "Misrecognized as…",
+ "misheard_comma_hint": "Separate several misheard variants with commas.",
+ "cancel": "Cancel",
+ "save": "Save",
+ "add_confirm": "Add word"
+ },
"voice_state": {
"idle": "Ready",
"listening": "Listening",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 1800b26773..21e57ca238 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -156,6 +156,33 @@
"other": "Otro"
}
},
+ "dictionary": {
+ "title": "Diccionario",
+ "description": "Enseña al reconocimiento de voz tus palabras — nombres, marcas, términos técnicos. Añade una palabra o corrige lo que siempre entiende mal.",
+ "add": "Añadir palabra",
+ "search": "Buscar en el diccionario…",
+ "loading": "Cargando diccionario…",
+ "empty": "Aún no hay palabras — añade nombres o términos que el reconocimiento de voz deba conocer.",
+ "no_matches": "Ninguna entrada coincide con tu búsqueda.",
+ "edit": "Editar",
+ "delete": "Eliminar",
+ "added": "«{0}» se añadió al diccionario.",
+ "saved": "Entrada del diccionario guardada.",
+ "deleted": "«{0}» se eliminó del diccionario.",
+ "applies_note": "Los cambios se aplican a tu próxima frase — no hace falta reiniciar.",
+ "dialog_add_title": "Añadir a tu vocabulario",
+ "dialog_edit_title": "Editar entrada del diccionario",
+ "correction_toggle": "Corregir un error de reconocimiento",
+ "correction_hint_on": "Siempre que se entienda el lado izquierdo, se sustituye por el derecho.",
+ "correction_hint_off": "Añade una palabra para que el reconocimiento la conozca y la escriba exactamente así.",
+ "word_placeholder": "Añadir una palabra nueva",
+ "word_correct_placeholder": "Escritura correcta",
+ "misheard_placeholder": "Reconocido erróneamente como…",
+ "misheard_comma_hint": "Separa varias variantes mal reconocidas con comas.",
+ "cancel": "Cancelar",
+ "save": "Guardar",
+ "add_confirm": "Añadir palabra"
+ },
"voice_state": {
"idle": "Listo",
"listening": "Escuchando",
diff --git a/jarvis/ui/web/frontend/src/views/SettingsView.tsx b/jarvis/ui/web/frontend/src/views/SettingsView.tsx
index 85718e15f6..1e69afe9ea 100644
--- a/jarvis/ui/web/frontend/src/views/SettingsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/SettingsView.tsx
@@ -14,6 +14,7 @@ import { AppSettingsGroup } from "@/views/settings/AppSettingsGroup";
import { SilenceWindowGroup } from "@/views/settings/SilenceWindowGroup";
import { VolumeGroup } from "@/views/settings/VolumeGroup";
import { SystemPromptGroup } from "@/views/settings/SystemPromptGroup";
+import { DictionaryGroup } from "@/views/settings/DictionaryGroup";
import { useWakeWord, type WakeWordSaveResult } from "@/hooks/useWakeWord";
import {
useKeybinds,
@@ -66,6 +67,7 @@ export function SettingsView() {
<AppSettingsGroup />
<SystemPromptGroup />
<WakeWordPanel />
+ <DictionaryGroup />
<SilenceWindowGroup />
<VolumeGroup />
<KeybindsPanel />
diff --git a/jarvis/ui/web/frontend/src/views/settings/DictionaryGroup.tsx b/jarvis/ui/web/frontend/src/views/settings/DictionaryGroup.tsx
new file mode 100644
index 0000000000..c515602377
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/settings/DictionaryGroup.tsx
@@ -0,0 +1,351 @@
+import { useMemo, useState } from "react";
+import {
+ ArrowRight,
+ BookOpen,
+ Loader2,
+ Pencil,
+ Plus,
+ Search,
+ Trash2,
+ X,
+} from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { Switch } from "@/components/ui/switch";
+import {
+ useDictionary,
+ type DictionaryEntry,
+} from "@/hooks/useDictionary";
+import { useEventStore } from "@/store/events";
+import { useT } from "@/i18n";
+
+/**
+ * "Dictionary" panel inside the Settings view — the a dictation app-style custom
+ * vocabulary for speech recognition. Users add words the STT keeps getting
+ * wrong (proper nouns, brand names, e-mail addresses) either as a plain
+ * vocabulary word or as an explicit "misheard → correct" fix. Entries apply
+ * to the NEXT utterance (the backend corrector live-reloads) — no restart.
+ *
+ * Backed by /api/dictionary (GET/POST/PATCH/DELETE) via useDictionary.
+ */
+export function DictionaryGroup() {
+ const t = useT();
+ const { entries, loading, error, createEntry, updateEntry, removeEntry } =
+ useDictionary();
+ const pushToast = useEventStore((s) => s.pushToast);
+
+ const [query, setQuery] = useState("");
+ const [dialogOpen, setDialogOpen] = useState(false);
+ const [editing, setEditing] = useState<DictionaryEntry | null>(null);
+ const [deletingId, setDeletingId] = useState<string | null>(null);
+
+ const filtered = useMemo(() => {
+ const q = query.trim().toLowerCase();
+ if (!q) return entries;
+ return entries.filter(
+ (e) =>
+ e.word.toLowerCase().includes(q) ||
+ e.misheard.some((m) => m.toLowerCase().includes(q)),
+ );
+ }, [entries, query]);
+
+ async function onDelete(entry: DictionaryEntry) {
+ setDeletingId(entry.id);
+ try {
+ await removeEntry(entry.id);
+ pushToast("success", t("dictionary.deleted").replace("{0}", entry.word));
+ } catch (e) {
+ pushToast("error", (e as Error).message);
+ } finally {
+ setDeletingId(null);
+ }
+ }
+
+ return (
+ <div className="mt-2 rounded-lg border border-border bg-card/60 p-4">
+ <div className="flex items-start gap-3">
+ <BookOpen className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <h4 className="font-display text-sm font-semibold">
+ {t("dictionary.title")}
+ </h4>
+ {entries.length > 0 && (
+ <span className="rounded-full border border-border bg-muted/60 px-2 py-0.5 text-[10px] font-medium text-muted-foreground">
+ {entries.length}
+ </span>
+ )}
+ <div className="flex-1" />
+ <Button
+ size="sm"
+ className="gap-1.5"
+ data-testid="dictionary-add"
+ onClick={() => {
+ setEditing(null);
+ setDialogOpen(true);
+ }}
+ >
+ <Plus className="h-3.5 w-3.5" />
+ {t("dictionary.add")}
+ </Button>
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {t("dictionary.description")}
+ </p>
+
+ {error && <p className="mt-3 text-xs text-destructive">{error}</p>}
+
+ {entries.length > 3 && (
+ <div className="relative mt-3">
+ <Search className="absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
+ <input
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder={t("dictionary.search")}
+ data-testid="dictionary-search"
+ className="w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-primary"
+ />
+ </div>
+ )}
+
+ {loading ? (
+ <div className="mt-4 flex items-center gap-2 text-xs text-muted-foreground">
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ {t("dictionary.loading")}
+ </div>
+ ) : entries.length === 0 ? (
+ <p className="mt-4 text-xs text-muted-foreground">
+ {t("dictionary.empty")}
+ </p>
+ ) : filtered.length === 0 ? (
+ <p className="mt-4 text-xs text-muted-foreground">
+ {t("dictionary.no_matches")}
+ </p>
+ ) : (
+ <ul className="mt-3 divide-y divide-border/60" data-testid="dictionary-list">
+ {filtered.map((entry) => (
+ <li
+ key={entry.id}
+ className="group flex items-center gap-2 py-2"
+ >
+ <div className="min-w-0 flex-1 text-sm">
+ {entry.misheard.length > 0 ? (
+ <span className="flex flex-wrap items-center gap-1.5">
+ <span className="text-muted-foreground">
+ {entry.misheard.join(", ")}
+ </span>
+ <ArrowRight className="h-3 w-3 shrink-0 text-muted-foreground" />
+ <span className="font-medium">{entry.word}</span>
+ </span>
+ ) : (
+ <span className="font-medium">{entry.word}</span>
+ )}
+ </div>
+ <button
+ type="button"
+ aria-label={t("dictionary.edit")}
+ data-testid={`dictionary-edit-${entry.id}`}
+ onClick={() => {
+ setEditing(entry);
+ setDialogOpen(true);
+ }}
+ className="text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus:opacity-100 group-hover:opacity-100"
+ >
+ <Pencil className="h-3.5 w-3.5" />
+ </button>
+ <button
+ type="button"
+ aria-label={t("dictionary.delete")}
+ data-testid={`dictionary-delete-${entry.id}`}
+ disabled={deletingId === entry.id}
+ onClick={() => void onDelete(entry)}
+ className="text-muted-foreground opacity-0 transition-opacity hover:text-destructive focus:opacity-100 group-hover:opacity-100 disabled:opacity-50"
+ >
+ {deletingId === entry.id ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Trash2 className="h-3.5 w-3.5" />
+ )}
+ </button>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ <p className="mt-3 text-[11px] text-muted-foreground">
+ {t("dictionary.applies_note")}
+ </p>
+ </div>
+ </div>
+
+ {dialogOpen && (
+ <DictionaryEntryDialog
+ initial={editing}
+ onClose={() => setDialogOpen(false)}
+ onSave={async (payload) => {
+ if (editing) {
+ await updateEntry(editing.id, payload);
+ pushToast("success", t("dictionary.saved"));
+ } else {
+ await createEntry(payload);
+ pushToast(
+ "success",
+ t("dictionary.added").replace("{0}", payload.word),
+ );
+ }
+ setDialogOpen(false);
+ }}
+ />
+ )}
+ </div>
+ );
+}
+
+const inputClass =
+ "w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary";
+
+/**
+ * Add/edit dialog mirroring a dictation app: the "correct a misrecognition"
+ * toggle switches between a single new-word input and a
+ * "misheard → correct spelling" pair.
+ */
+function DictionaryEntryDialog({
+ initial,
+ onClose,
+ onSave,
+}: {
+ initial: DictionaryEntry | null;
+ onClose: () => void;
+ onSave: (payload: { word: string; misheard: string[] }) => Promise<void>;
+}) {
+ const t = useT();
+ const [word, setWord] = useState(initial?.word ?? "");
+ const [misheardText, setMisheardText] = useState(
+ initial?.misheard.join(", ") ?? "",
+ );
+ const [isCorrection, setIsCorrection] = useState(
+ (initial?.misheard.length ?? 0) > 0,
+ );
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ const misheard = isCorrection
+ ? misheardText
+ .split(",")
+ .map((m) => m.trim())
+ .filter(Boolean)
+ : [];
+ const valid =
+ word.trim().length > 0 && (!isCorrection || misheard.length > 0);
+
+ async function submit() {
+ if (!valid || saving) return;
+ setSaving(true);
+ setError(null);
+ try {
+ await onSave({ word: word.trim(), misheard });
+ } catch (e) {
+ setError((e as Error).message);
+ setSaving(false);
+ }
+ }
+
+ return (
+ <div
+ className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"
+ onClick={onClose}
+ >
+ <div
+ className="w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-xl"
+ onClick={(e) => e.stopPropagation()}
+ data-testid="dictionary-dialog"
+ >
+ <header className="mb-4 flex items-center gap-3">
+ <h3 className="flex-1 font-display text-base font-semibold">
+ {initial
+ ? t("dictionary.dialog_edit_title")
+ : t("dictionary.dialog_add_title")}
+ </h3>
+ <button
+ type="button"
+ onClick={onClose}
+ aria-label={t("dictionary.cancel")}
+ className="text-muted-foreground hover:text-foreground"
+ >
+ <X className="h-4 w-4" />
+ </button>
+ </header>
+
+ <div className="space-y-4">
+ <label className="flex items-center justify-between gap-3">
+ <span className="text-sm">{t("dictionary.correction_toggle")}</span>
+ <Switch
+ checked={isCorrection}
+ onCheckedChange={setIsCorrection}
+ data-testid="dictionary-correction-toggle"
+ />
+ </label>
+ <p className="-mt-2 text-xs text-muted-foreground">
+ {isCorrection
+ ? t("dictionary.correction_hint_on")
+ : t("dictionary.correction_hint_off")}
+ </p>
+
+ {isCorrection ? (
+ <div className="flex items-center gap-2">
+ <input
+ value={misheardText}
+ onChange={(e) => setMisheardText(e.target.value)}
+ placeholder={t("dictionary.misheard_placeholder")}
+ data-testid="dictionary-misheard-input"
+ className={inputClass}
+ autoFocus
+ />
+ <ArrowRight className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <input
+ value={word}
+ onChange={(e) => setWord(e.target.value)}
+ placeholder={t("dictionary.word_correct_placeholder")}
+ data-testid="dictionary-word-input"
+ className={inputClass}
+ onKeyDown={(e) => e.key === "Enter" && void submit()}
+ />
+ </div>
+ ) : (
+ <input
+ value={word}
+ onChange={(e) => setWord(e.target.value)}
+ placeholder={t("dictionary.word_placeholder")}
+ data-testid="dictionary-word-input"
+ className={inputClass}
+ autoFocus
+ onKeyDown={(e) => e.key === "Enter" && void submit()}
+ />
+ )}
+ {isCorrection && (
+ <p className="-mt-2 text-[11px] text-muted-foreground">
+ {t("dictionary.misheard_comma_hint")}
+ </p>
+ )}
+
+ {error && <p className="text-xs text-destructive">{error}</p>}
+ </div>
+
+ <div className="mt-6 flex justify-end gap-3">
+ <Button size="sm" variant="outline" onClick={onClose} disabled={saving}>
+ {t("dictionary.cancel")}
+ </Button>
+ <Button
+ size="sm"
+ onClick={() => void submit()}
+ disabled={!valid || saving}
+ data-testid="dictionary-save"
+ className="gap-1.5"
+ >
+ {saving && <Loader2 className="h-3.5 w-3.5 animate-spin" />}
+ {initial ? t("dictionary.save") : t("dictionary.add_confirm")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/scripts/config-soll.json b/scripts/config-soll.json
index 66e024cbfd..2c935b08a7 100644
--- a/scripts/config-soll.json
+++ b/scripts/config-soll.json
@@ -6,7 +6,7 @@
"single_turn_mode": false
},
"tts": {
- "provider": "grok-voice",
+ "provider": "openrouter-tts",
"fallback": "grok-voice",
"voice_de": "Kore",
"voice_en": "Kore",