diff --git a/linux/CHANGELOG.md b/linux/CHANGELOG.md index cac3dcb..aee23a8 100644 --- a/linux/CHANGELOG.md +++ b/linux/CHANGELOG.md @@ -9,6 +9,13 @@ The version is defined in [`blitztext/__init__.py`](blitztext/__init__.py). ## [Unreleased] +### Fixed +- **Voice-routing default went to a rewrite**: when no `[routing] default` preset + is set, the no-keyword fallback used the *first* preset — which, if that happened + to be an LLM rewrite (e.g. "Improve text"), sent every unrouted wakeword command + to the language model (and failed when the LLM was down). The fallback now + prefers a `transcribe` preset, so the default action is plain transcription. + ## [1.3.0] - 2026-06-07 ### Added diff --git a/linux/blitztext/config.py b/linux/blitztext/config.py index be848e4..ec0cfdd 100644 --- a/linux/blitztext/config.py +++ b/linux/blitztext/config.py @@ -110,7 +110,15 @@ class Config: @property def default_preset(self) -> "Workflow | None": - return self.preset_by_name(self.routing_default) or (self.workflows[0] if self.workflows else None) + named = self.preset_by_name(self.routing_default) + if named: + return named + if not self.workflows: + return None + # No explicit default configured: prefer a plain transcribe preset over + # whatever happens to be first, so the no-keyword fallback never silently + # routes to an LLM rewrite. + return next((w for w in self.workflows if w.mode == "transcribe"), self.workflows[0]) @property def all_keywords(self) -> list[str]: diff --git a/linux/tests/test_config.py b/linux/tests/test_config.py index 16de815..5e58c7f 100644 --- a/linux/tests/test_config.py +++ b/linux/tests/test_config.py @@ -68,3 +68,26 @@ def test_properties(): ] assert cfg.preset_by_name("WF2").name == "WF2" assert cfg.preset_by_name("NonExistent") is None + + +def test_default_preset_prefers_transcribe_when_unset(): + """With no routing default, fall back to a transcribe preset, not whatever + happens to be first (which could be an LLM rewrite).""" + cfg = Config() + cfg.routing_default = "" + cfg.workflows = [ + Workflow(name="Improve text", hotkey="", mode="rewrite"), + Workflow(name="Transcribe", hotkey="", mode="transcribe"), + ] + dp = cfg.default_preset + assert dp is not None and dp.mode == "transcribe" and dp.name == "Transcribe" + + +def test_default_preset_honours_explicit_name(): + cfg = Config() + cfg.workflows = [ + Workflow(name="Improve text", hotkey="", mode="rewrite"), + Workflow(name="Transcribe", hotkey="", mode="transcribe"), + ] + cfg.routing_default = "Improve text" + assert cfg.default_preset.name == "Improve text"