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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(dictation): translation worked for English only, and flipped languages
Ruben Lütke8b778ca9963b
diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex 6f38f2800a..f3d3c0f782 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -2889,8 +2889,14 @@ class DictationConfig(BaseModel):#: my own language and write in this one", and a rule table would trade#: that one clear switch for a screen of pairs nobody audits.#:- #: A dictation already in this language is not sent on a round trip at all- #: (``resolve_translate_target``) — it takes the plain polish path.+ #: The decision reads THIS BLOCK only (``resolve_translate_target``), never+ #: the language the recognizer reported. Skipping the translation whenever+ #: the recognized language already matched the target sounded like a saved+ #: round trip and behaved like a coin flip — that tag is documented to be+ #: wrong — so the delivered language alternated with nothing the user+ #: touched explaining it. The one exception is ``language`` above: a PIN is+ #: a deliberate statement, so pinning it to this target means "I dictate in+ #: it already" and nothing is translated.#:#: Unrelated to ``[brain].reply_language``, which governs what the#: assistant SAYS BACK. Dictating into an English document while beingdiff --git a/jarvis/dictation/polish.py b/jarvis/dictation/polish.pyindex d021fecab4..a9c024b1ab 100644--- a/jarvis/dictation/polish.py+++ b/jarvis/dictation/polish.py@@ -271,7 +271,7 @@ def translate_enabled(cfg: Any) -> bool:return bool(getattr(cfg, "translate", False))-def resolve_translate_target(cfg: Any, source_language: str) -> str:+def resolve_translate_target(cfg: Any) -> str:"""The language this dictation must be delivered in; ``""`` for no change.Module-level and public for the same reason@@ -280,35 +280,41 @@ def resolve_translate_target(cfg: Any, source_language: str) -> str:this decision is how one recording ends up translated by one button and notby the other.- ``""`` on all four of the ways there is nothing to do: the switch is off, no- target is set, the target is ``auto`` (which is not a language), or the- dictation is ALREADY in the target language. That last one is what keeps an- English dictation with an English target on the plain polish path instead of- paying a translation to produce the same sentence.-- The comparison is deliberately conservative: only a source we can place with- confidence counts as "already there". An ``auto``/``unknown`` source resolves- to a translation attempt, and the prompt handles the already-in-target case- by cleaning the text up rather than re-wording it. Guessing wrong in that- direction costs one model call; guessing wrong in the other silently leaves- the text in the wrong language, which is the failure the user would notice.+ **It reads the CONFIG and nothing else.** That is the whole design, and it+ is a correction of the first version, which also skipped the translation+ when the RECOGNIZED language already matched the target. That sounded like a+ saved round trip and behaved like a coin flip: the recognizer's language tag+ is documented-unreliable (``resolve_dictation_language`` exists because it+ confidently reports German dictations as English), so with an English target+ a mislabelled dictation silently kept its German — and the user watched+ their text alternate between two languages with nothing they touched+ explaining it. A switch that is on has to mean one thing.++ ``""`` on the three ways there is genuinely nothing to do, all of them+ statements the USER made rather than guesses about them:++ * the switch is off,+ * no target is set, or the target is ``auto`` — which is not a language,+ * the dictation LANGUAGE IS PINNED to the target. A pin is the one language+ signal a person sets deliberately, so "I dictate in English and I want+ English out" is a coherent instruction to do nothing, and the settings+ screen says so out loud rather than leaving the switch looking inert.++ Anything else translates. A dictation that turns out to be in the target+ language anyway is handled by the prompt (it cleans the text up instead of+ re-wording it) and costs the one model call the polish pass would have made+ regardless."""if not translate_enabled(cfg):return ""target = str(getattr(cfg, "translate_target", "") or "").strip().lower()if not target or target == _AUTO:return ""- source = str(source_language or "").strip().lower()- if source and source not in (_AUTO, "unknown"):- # Compare on the language SUBTAG so a "de-DE" pin and a "de" tag are one- # language, then fall back to the canonical resolver for a provider that- # answered with a NAME ("German") rather than a code.- head = source.replace("_", "-").split("-", 1)[0]- if head == target:- return ""- from jarvis.core.turn_language import normalize_language_tag-- if normalize_language_tag(source) == target:+ # Compare on the primary subtag so a "de-DE" pin and a "de" target are one+ # language rather than two.+ pinned = str(getattr(cfg, "language", _AUTO) or _AUTO).strip().lower()+ if pinned and pinned != _AUTO:+ if pinned.replace("_", "-").split("-", 1)[0] == target:return ""return targetdiff --git a/jarvis/dictation/polish_guards.py b/jarvis/dictation/polish_guards.pyindex ccda14214a..cb169d0875 100644--- a/jarvis/dictation/polish_guards.py+++ b/jarvis/dictation/polish_guards.py@@ -93,6 +93,32 @@ TRANSLATE_DRIFT_REASONS: Final[tuple[str, ...]] = (#: short tokens are dominated by inflections, particles and recognizer debris._RARE_MIN_CHARS = 4+#: Scripts that do not put spaces between words. A "word count" over these is+#: meaningless — a whole Chinese sentence counts as ONE token — so any+#: length-ratio check that spans one of them and a space-separated script is+#: comparing two different units and will fire on every correct answer.+#:+#: Chinese (incl. the CJK extension block used by Cantonese), Japanese kana,+#: Thai, Lao, Khmer, Burmese and Tibetan. Hangul is deliberately ABSENT: Korean+#: does separate words with spaces, so its word counts are comparable.+_NO_WORD_BOUNDARY_RE: Final[re.Pattern[str]] = re.compile(+ "[-ヿ㐀-䶿一-鿿豈-"+ "--ក-က-႟ༀ-]"+)++#: How much of a text has to be in such a script before its word count is+#: treated as meaningless. A ratio rather than "any character", so one CJK+#: brand name inside a German sentence does not disable the check.+_NO_WORD_BOUNDARY_SHARE = 0.15++#: The only length rule left when a translation crosses between a spaced and an+#: unspaced script, measured in CHARACTERS because words are not comparable+#: there. Deliberately crude: German into Chinese roughly quarters the character+#: count while Chinese into German roughly quadruples it, so anything tight+#: enough to be informative would reject one of the two directions. It exists to+#: catch a model that wrote an essay, nothing finer.+_CROSS_SCRIPT_MAX_CHAR_GROWTH = 6.0+_TOKEN_RE = re.compile(r"[^\W\d_]+", re.UNICODE)_WORDLIKE_RE = re.compile(r"[\w']+", re.UNICODE)_WHITESPACE_RE = re.compile(r"\s+", re.UNICODE)@@ -422,12 +448,40 @@ def drift_reason(if needle in raw_haystack and needle not in haystack:return "lost_term"- if rare_tokens(raw, language=language) - rare_tokens(polished, language=language):+ # The frequency list has to describe the TEXT, not its label. Where the two+ # disagree the label loses, because trusting it fails silently and+ # completely: an English transcript looked up against the German word list+ # makes every ordinary English word "rare", so the guard fires on any+ # wording change at all and the dictation is delivered unpolished with+ # `rejected_drift` on the row and nothing saying why.+ #+ # The disagreement is real and has its own cause upstream — a segment-sized+ # upload lets Whisper re-decide the language, and on a short segment it+ # sometimes TRANSLATES rather than transcribes, so a row can carry a German+ # tag and an English transcript. That is fixed where it happens; this is the+ # guard declining to compound it. `raw_language` is already computed above,+ # so the correction costs nothing.+ lookup = raw_language if raw_language != "unknown" else language+ if rare_tokens(raw, language=lookup) - rare_tokens(polished, language=lookup):return "lost_term"return ""+def writes_without_word_spaces(text: str) -> bool:+ """Whether *text* is mostly in a script that puts no spaces between words.++ Public because the answer decides whether a word COUNT means anything at+ all, and that question belongs to whoever is comparing two texts — not+ hidden inside one guard.+ """+ body = str(text or "").strip()+ if not body:+ return False+ hits = len(_NO_WORD_BOUNDARY_RE.findall(body))+ return hits / len(body) >= _NO_WORD_BOUNDARY_SHARE++def translate_drift_reason(raw: str,translated: str,@@ -468,14 +522,31 @@ def translate_drift_reason(if _is_meta_output(raw, translated):return "meta_output"- raw_words = count_words(raw)- out_words = count_words(translated)- if raw_words:- ratio = out_words / raw_words- if ratio < max_shrink:- return "ratio_shrink"- if ratio > max_growth:+ # The length check only means something when both sides are counted in the+ # SAME unit. Chinese, Japanese, Thai, Khmer, Lao, Burmese and Tibetan write+ # without spaces, so a whole sentence counts as one or two "words": a German+ # sentence translated into Chinese scores a word ratio of ~0.10 and every+ # single correct translation was rejected as ``ratio_shrink``. That is the+ # bug that made this feature look like it worked for English only.+ #+ # Where the scripts differ, length carries no signal at all and the check is+ # skipped — the same "silence beats a veto" rule the language and rare-token+ # checks already follow. What replaces it is a deliberately crude character+ # ceiling: it cannot tell a good translation from an average one, but it+ # still catches the failure that matters, a model that answered the+ # transcript instead of translating it.+ if writes_without_word_spaces(raw) != writes_without_word_spaces(translated):+ if len(translated) > len(raw) * _CROSS_SCRIPT_MAX_CHAR_GROWTH:return "ratio_growth"+ else:+ raw_words = count_words(raw)+ out_words = count_words(translated)+ if raw_words:+ ratio = out_words / raw_words+ if ratio < max_shrink:+ return "ratio_shrink"+ if ratio > max_growth:+ return "ratio_growth"# Only meaningful when we can classify the target at all. ``_language_key``# is not reused here on purpose: it answers "do we hold a frequency table",diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex beea301245..886b24fed7 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -10033,9 +10033,12 @@ class SpeechPipeline:# Resolved HERE and not inside the pass so both callers of the# pass — this one and the Restore route — reach the same answer# from the same function, exactly like ``effective_language``- # above. Empty means "no translation": the switch is off, or the- # dictation is already in the target language.- translate_to = resolve_translate_target(cfg, effective_language)+ # above. It reads the CONFIG only, deliberately NOT+ # ``effective_language``: deciding per dictation whether to+ # translate, based on a recognizer tag that is documented to be+ # wrong, is what made the delivered language alternate between+ # two with nothing the user touched explaining it.+ translate_to = resolve_translate_target(cfg)if polish_enabled(cfg) or translate_to:result = await polish_transcript(cleaned,diff --git a/jarvis/ui/web/dictation_routes.py b/jarvis/ui/web/dictation_routes.pyindex ce41478dbb..6ee67c489b 100644--- a/jarvis/ui/web/dictation_routes.py+++ b/jarvis/ui/web/dictation_routes.py@@ -252,7 +252,7 @@ async def _format_restored_text(# delivery uses, for the same reason the language is: a Restore that# handed back the original language while the live path translates would# be a quiet lie about what the button does.- translate_to = resolve_translate_target(cfg, language)+ translate_to = resolve_translate_target(cfg)if text.strip() and (polish_enabled(cfg) or translate_to):pipeline = _pipeline()terms = ()@@ -1168,10 +1168,11 @@ async def test_polish(request: Request) -> dict[str, Any]:)cfg = _dictation_cfg(request)- # The sample is English, so a target of "en" correctly resolves to "no- # translation needed" and the probe measures the plain polish path — which- # is exactly what a dictation in the target language would get.- translate_to = resolve_translate_target(cfg, "en")+ # Whatever a real dictation would get, including the translation — the probe+ # is the only way to SEE this feature, so it has to run the same pass. The+ # fixed sample is English, so a target of English exercises the+ # already-in-target path, which is the honest answer for that setup.+ translate_to = resolve_translate_target(cfg)if not polish_enabled(cfg) and not translate_to:# Reported rather than refused: "you switched it off" is a complete# answer to "why is my dictation not being polished", and a 409 herediff --git a/tests/unit/dictation/test_polish_guards.py b/tests/unit/dictation/test_polish_guards.pyindex 9bc8c9b1f9..372439b910 100644--- a/tests/unit/dictation/test_polish_guards.py+++ b/tests/unit/dictation/test_polish_guards.py@@ -247,3 +247,50 @@ def test_rare_tokens_is_empty_for_a_language_we_hold_no_word_list_for() -> None:answer for ~95 of the 100 recognition languages."""assert rare_tokens("Jutro wysylam raport", language="pl") == frozenset()assert rare_tokens("Jutro wysylam raport", language="") == frozenset()+++def test_the_rare_token_lookup_follows_the_TEXT_not_its_label() -> None:+ """A mislabelled transcript must not make every ordinary word "rare".++ The recognizer uploads a dictation in segments, and on a short segment+ Whisper sometimes re-decides the language — so a German-tagged row can hold+ an English transcript (and vice versa). Looking the frequency list up by the+ LABEL then means checking English words against the German vocabulary, where+ every one of them is unknown: the guard fires on any wording change at all,+ the polish is thrown away, and the row says `rejected_drift` with nothing+ explaining it. That was 12 of the last 40 rows in the live history+ (2026-07-29).++ The fix is narrow: when the detector has an opinion about the text, it+ outranks the tag for THIS lookup. The tag still decides nothing else.+ """+ raw = "so i think we should probably ship the report on tuesday and tell them"+ polished = "I think we should ship the report on Tuesday and tell them."++ # Correctly labelled: passes, and always did.+ assert (+ drift_reason(+ raw, polished, language="en", protected=(), max_shrink=0.55, max_growth=1.20+ )+ == ""+ )+ # MIS-labelled as German by the recognizer — same text, same edit.+ assert (+ drift_reason(+ raw, polished, language="de", protected=(), max_shrink=0.55, max_growth=1.20+ )+ == ""+ ), "an English transcript tagged German must not be judged by the German list"+++def test_a_genuinely_lost_word_is_still_caught_under_a_wrong_label() -> None:+ """Following the text is not the same as disarming the guard."""+ raw = "please send the Kubernetes report to Marlowe before the meeting starts"+ dropped = "Please send the report to Marlowe before the meeting starts."++ assert (+ drift_reason(+ raw, dropped, language="de", protected=(), max_shrink=0.55, max_growth=1.20+ )+ == "lost_term"+ )diff --git a/tests/unit/dictation/test_translate.py b/tests/unit/dictation/test_translate.pyindex 354a9b172c..ac3ddb59cb 100644--- a/tests/unit/dictation/test_translate.py+++ b/tests/unit/dictation/test_translate.py@@ -46,6 +46,7 @@ from jarvis.dictation.polish_guards import (TRANSLATE_DRIFT_REASONS,drift_reason,translate_drift_reason,+ writes_without_word_spaces,)from jarvis.dictation.polish_prompt import RAW_OPEN_DELIMITER@@ -163,38 +164,63 @@ def test_the_switch_ships_off() -> None:cfg = DictationConfig()assert cfg.translate is Falseassert translate_enabled(cfg) is False- assert resolve_translate_target(cfg, "de") == ""+ assert resolve_translate_target(cfg) == ""-def test_a_pinned_source_equal_to_the_target_is_not_translated() -> None:- """No round trip to turn English into English."""- cfg = _cfg(translate=True, translate_target="en")- assert resolve_translate_target(cfg, "en") == ""- assert resolve_translate_target(cfg, "en-US") == ""- # The cloud Whisper APIs answer with the language NAME, not a code. Reaching- # the canonical resolver rather than slicing the string is what keeps that- # from being read as an unknown language and paying for a translation of- # English into English.- assert resolve_translate_target(cfg, "English") == ""+def test_a_pinned_dictation_language_equal_to_the_target_does_nothing() -> None:+ """A pin is a statement, so "I speak English, I want English" is coherent.+ The settings screen says so out loud too, rather than leaving a switch that+ looks on and does nothing.+ """+ assert resolve_translate_target(_cfg(translate=True, translate_target="en",+ language="en")) == ""+ assert resolve_translate_target(_cfg(translate=True, translate_target="de",+ language="de")) == ""+ # A different pin is a real translation job.+ assert resolve_translate_target(_cfg(translate=True, translate_target="en",+ language="de")) == "en"+++def test_the_decision_never_depends_on_what_the_recognizer_reported() -> None:+ """The regression that made the delivered language alternate.++ The first version also skipped the translation when the RECOGNIZED language+ matched the target. The recognizer's tag is documented-unreliable — that is+ the entire reason ``resolve_dictation_language`` exists — so with an English+ target a mislabelled German dictation silently kept its German, and the user+ watched their text flip between two languages with nothing they touched+ explaining it.++ The function now takes the config and nothing else, so this test is+ structural: there is no per-dictation input left to be wrong about.+ """+ import inspect-def test_a_different_source_resolves_to_the_target() -> None:- cfg = _cfg(translate=True, translate_target="en")- assert resolve_translate_target(cfg, "de") == "en"- assert resolve_translate_target(cfg, "German") == "en"+ params = list(inspect.signature(resolve_translate_target).parameters)+ assert params == ["cfg"], (+ "resolve_translate_target must decide from configuration alone; a "+ f"per-dictation argument reintroduces the flip: {params}"+ )+ # On by default for an unpinned dictation language, whatever is spoken.+ assert resolve_translate_target(_cfg(translate=True, translate_target="en")) == "en"-def test_an_unknown_source_still_attempts_the_translation() -> None:- """Undecided means try, not skip.+def test_auto_is_not_a_translation_target() -> None:+ """There is nothing to detect on the output side (AP-31).- Guessing wrong this way costs one model call. Guessing wrong the other way- leaves the text in the language the user was translating out of, which is- the failure they would actually notice.+ Two layers, because they fail differently. The config VALIDATOR refuses to+ store it at all, so nothing the UI or the API can send leaves the setting in+ that state; and the resolver still treats it as "no target" for a config+ object that got one past the validator (a hand-edited file, an older+ install), where the honest answer is to translate nothing rather than to+ pick a language on the user's behalf."""- cfg = _cfg(translate=True, translate_target="en")- assert resolve_translate_target(cfg, "auto") == "en"- assert resolve_translate_target(cfg, "unknown") == "en"- assert resolve_translate_target(cfg, "") == "en"+ from types import SimpleNamespace++ assert DictationConfig(translate_target="auto").translate_target != "auto"+ smuggled = SimpleNamespace(translate=True, translate_target="auto", language="auto")+ assert resolve_translate_target(smuggled) == ""def test_a_hand_edited_target_falls_back_to_a_working_language() -> None:@@ -508,6 +534,83 @@ def test_a_model_that_answered_instead_of_translating_is_caught() -> None:)+def test_a_language_without_spaces_between_words_is_not_rejected_on_length() -> None:+ """The bug that made the whole feature look English-only.++ Chinese, Japanese, Thai, Khmer, Lao, Burmese and Tibetan write without+ spaces, so `count_words` sees a whole sentence as one or two tokens: a+ German sentence translated into Chinese scored a word ratio of ~0.10 against+ a 0.40 floor, and EVERY correct translation was thrown away as+ ``ratio_shrink``. The user got their German back and reported, accurately,+ that only English worked.++ Both directions, because the failure is symmetric: into an unspaced script+ the count collapses, out of one it explodes.+ """+ kwargs: dict[str, Any] = {+ "protected": (),+ "max_shrink": 0.40,+ "max_growth": 2.50,+ }+ # i18n-allow: the CJK strings below are the material under test — a+ # translation test needs text in the script whose word count is meaningless.+ chinese = "我想我们应该在星期二把报告发出去。" # i18n-allow+ japanese = "火曜日にレポートを送るべきだと思います。" # i18n-allow+ thai = "ผมคิดว่าเราควรส่งรายงานในวันอังคาร" # i18n-allow+ korean = "화요일에 보고서를 보내야 한다고 생각합니다." # i18n-allow++ assert translate_drift_reason(GERMAN, chinese, target_language="zh", **kwargs) == ""+ assert translate_drift_reason(GERMAN, japanese, target_language="ja", **kwargs) == ""+ assert translate_drift_reason(GERMAN, thai, target_language="th", **kwargs) == ""+ # Out of an unspaced script, too.+ assert translate_drift_reason(chinese, GERMAN, target_language="de", **kwargs) == ""+ # Korean DOES separate words, so it keeps the ordinary word-ratio check.+ assert writes_without_word_spaces(korean) is False+ assert translate_drift_reason(GERMAN, korean, target_language="ko", **kwargs) == ""+++def test_the_cross_script_path_still_catches_a_model_that_wrote_an_essay() -> None:+ """Skipping the word ratio is not the same as skipping every length rule."""+ chinese = "我想我们应该在星期二把报告发出去。" # i18n-allow: material under test+ assert (+ translate_drift_reason(+ GERMAN,+ chinese * 40,+ target_language="zh",+ protected=(),+ max_shrink=0.40,+ max_growth=2.50,+ )+ == "ratio_growth"+ )+++def test_the_other_guards_still_apply_across_scripts() -> None:+ """Numbers and meta-output are script-independent and stay enforced."""+ kwargs: dict[str, Any] = {+ "target_language": "zh",+ "protected": (),+ "max_shrink": 0.40,+ "max_growth": 2.50,+ }+ assert (+ translate_drift_reason(+ "wir treffen uns um 3 uhr am bahnhof", # i18n-allow: material under test+ "我们在车站见面。", # i18n-allow: material under test+ **kwargs,+ )+ == "lost_number"+ )+ assert (+ translate_drift_reason(+ GERMAN,+ "Here is the translation: 我想我们应该发报告", # i18n-allow: material under test+ **kwargs,+ )+ == "meta_output"+ )++def test_a_target_the_detector_cannot_place_is_a_no_op_not_a_veto() -> None:"""~96 of the 100 targets are undecidable; that must not mean "reject".diff --git a/tests/unit/ui/web/test_dictation_polish_routes.py b/tests/unit/ui/web/test_dictation_polish_routes.pyindex 0d9004cb9c..454a184fe6 100644--- a/tests/unit/ui/web/test_dictation_polish_routes.py+++ b/tests/unit/ui/web/test_dictation_polish_routes.py@@ -507,3 +507,77 @@ def test_the_settings_route_still_takes_auto(assert body.status_code == 200assert body.json()["settings"]["polish_provider"] == "auto"assert ("polish_provider", "auto") in written+++# --------------------------------------------------------------------------+# Switching translation on and off has to take effect NOW, not on restart+# --------------------------------------------------------------------------+++def test_translation_switches_take_effect_without_a_restart(+ app: FastAPI, monkeypatch: pytest.MonkeyPatch+) -> None:+ """The reported failure: switch it off, and dictations keep translating.++ Two objects have to learn about a saved setting for it to be live — the+ config the REST layer holds and the copy the RUNNING pipeline reads on the+ delivery path — and a save that updates only the first produces exactly the+ symptom the user described: the settings screen shows the new value, and+ every dictation keeps behaving like the old one until the app is restarted.++ Asserted through ``resolve_translate_target`` rather than by reading the+ attribute, because that function is what the delivery path actually asks.+ """+ from jarvis.core import config_writer+ from jarvis.dictation.polish import resolve_translate_target++ monkeypatch.setattr(+ config_writer, "set_dictation_setting", lambda key, value, **_kw: None+ )+ pipeline = SimpleNamespace(_dictation_cfg=app.state.config.dictation)+ monkeypatch.setattr(+ "jarvis.ui.web.dictation_routes._pipeline", lambda: pipeline+ )+ client = TestClient(app)++ on = client.put(+ "/api/dictation/settings", json={"translate": True, "translate_target": "zh"}+ )+ assert on.status_code == 200+ assert on.json()["applied_live"] is True+ assert resolve_translate_target(pipeline._dictation_cfg) == "zh"++ # Re-pointing the target is live too — the reported "I chose Chinese and+ # kept getting English".+ client.put("/api/dictation/settings", json={"translate_target": "ja"})+ assert resolve_translate_target(pipeline._dictation_cfg) == "ja"++ off = client.put("/api/dictation/settings", json={"translate": False})+ assert off.status_code == 200+ assert resolve_translate_target(pipeline._dictation_cfg) == ""+++def test_a_saved_translation_setting_survives_the_restart_too(+ app: FastAPI, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Live is only half of it: the keys must reach jarvis.toml as well.++ A key missing from ``DICTATION_SETTING_KEYS`` is a switch that works+ perfectly until the next restart and then silently reverts.+ """+ from jarvis.core import config_writer++ written: list[tuple[str, Any]] = []+ monkeypatch.setattr(+ config_writer,+ "set_dictation_setting",+ lambda key, value, **_kw: written.append((key, value)),+ )++ body = TestClient(app).put(+ "/api/dictation/settings", json={"translate": True, "translate_target": "zh"}+ )++ assert body.status_code == 200+ assert ("translate", True) in written+ assert ("translate_target", "zh") in written