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(ui): gate the Start-menu shortcut on either on-device speech role

rubenluetke10-beep2c8f10ac71bf
diff --git a/jarvis/ui/icon_utils.py b/jarvis/ui/icon_utils.py
index a98d83a8ce..d143dd1721 100644
--- a/jarvis/ui/icon_utils.py
+++ b/jarvis/ui/icon_utils.py
@@ -226,14 +226,22 @@ def _interpreter_can_open_a_window() -> bool:
_ON_DEVICE_STT_PROVIDER = "faster-whisper"
-def _configured_stt_provider() -> str:
- """The recognizer named in ``jarvis.toml``, or ``""`` when it cannot be read.
+def _config_wants_on_device_speech() -> bool:
+ """Does ``jarvis.toml`` name the on-device recognizer as EITHER role?
+
+ Both ``[stt].provider`` and ``[stt].fallback`` count, and the fallback is
+ not the lesser half: a cloud-first setup that names the local engine as its
+ floor is relying on it for exactly the case that broke — the cloud account
+ answering 402 mid-dictation. An interpreter without the engine silently
+ removes that floor, which is how 24.3 s of speech were lost with no local
+ recognizer left to catch them.
A direct, BOM-safe TOML read (the idiom
``jarvis.ui.jarvisbar.interaction._load_jarvisbar_section`` already uses):
one file stat and a parse, no pydantic, no provider catalogue, nothing
- initialised (AP-26). An unreadable or absent file answers ``""``, which the
- caller treats as "cannot tell" and therefore never as a reason to refuse.
+ initialised (AP-26). An unreadable or absent file answers ``False``, which
+ the caller treats as "cannot tell" and therefore never as a reason to
+ refuse — a base install with no config yet must still get its shortcut.
"""
import tomllib
@@ -245,15 +253,18 @@ def _configured_stt_provider() -> str:
except (OSError, UnicodeDecodeError, tomllib.TOMLDecodeError, ImportError) as exc:
# Silence is correct and load-bearing here (AP-30): every one of these
# means "this build cannot tell what the user chose", and the caller
- # reads "" as "no reason to refuse". Logging a warning per boot for a
+ # reads that as "no reason to refuse". Logging a warning per boot for a
# base install that has no config file yet would be pure noise.
- logger.debug("Could not read the configured STT provider: {}", exc)
- return ""
+ logger.debug("Could not read the configured STT roles: {}", exc)
+ return False
section = data.get("stt")
if not isinstance(section, dict):
- return ""
- provider = section.get("provider")
- return provider.strip() if isinstance(provider, str) else ""
+ return False
+ return any(
+ isinstance(value := section.get(role), str)
+ and value.strip() == _ON_DEVICE_STT_PROVIDER
+ for role in ("provider", "fallback")
+ )
def _interpreter_can_run_the_configured_speech() -> bool:
@@ -276,7 +287,7 @@ def _interpreter_can_run_the_configured_speech() -> bool:
``find_spec`` only resolves; nothing is imported (AP-26).
"""
- if _configured_stt_provider() != _ON_DEVICE_STT_PROVIDER:
+ if not _config_wants_on_device_speech():
return True
import importlib.util
diff --git a/tests/unit/ui/test_start_menu_shortcut_target.py b/tests/unit/ui/test_start_menu_shortcut_target.py
index b6bc106592..2cb1ea64ce 100644
--- a/tests/unit/ui/test_start_menu_shortcut_target.py
+++ b/tests/unit/ui/test_start_menu_shortcut_target.py
@@ -408,6 +408,19 @@ class TestImportPathHasNoShortcutSideEffect:
)
+def _stt_config(tmp_path: Path, *, provider: str, fallback: str) -> Path:
+ """Write a minimal ``jarvis.toml`` naming both STT roles."""
+ toml = tmp_path / "jarvis.toml"
+ body = [
+ "[stt]",
+ f'provider = "{provider}"',
+ f'fallback = "{fallback}"',
+ ]
+ toml.write_text("
+".join(body), encoding="utf-8")
+ return toml
+
+
class TestSpeechCapabilityProbe:
"""The other half of the rule: a speech-LESS interpreter may not claim it either.
@@ -427,7 +440,9 @@ class TestSpeechCapabilityProbe:
Requiring the engine unconditionally would leave the common install with
no Start-Menu entry at all — a far worse bug than the one being fixed.
"""
- monkeypatch.setattr(icon_utils, "_configured_stt_provider", lambda: "groq-api")
+ monkeypatch.setattr(
+ icon_utils, "_config_wants_on_device_speech", lambda: False
+ )
assert icon_utils._interpreter_can_run_the_configured_speech() is True
@@ -436,9 +451,7 @@ class TestSpeechCapabilityProbe:
) -> None:
import importlib.util
- monkeypatch.setattr(
- icon_utils, "_configured_stt_provider", lambda: "faster-whisper"
- )
+ monkeypatch.setattr(icon_utils, "_config_wants_on_device_speech", lambda: True)
monkeypatch.setattr(importlib.util, "find_spec", lambda name: None)
assert icon_utils._interpreter_can_run_the_configured_speech() is False
@@ -447,10 +460,37 @@ class TestSpeechCapabilityProbe:
self, monkeypatch: pytest.MonkeyPatch
) -> None:
""""Cannot tell" must behave exactly as it did before this guard existed."""
- monkeypatch.setattr(icon_utils, "_configured_stt_provider", lambda: "")
+ monkeypatch.setattr(
+ icon_utils, "_config_wants_on_device_speech", lambda: False
+ )
assert icon_utils._interpreter_can_run_the_configured_speech() is True
+ def test_the_local_engine_as_FALLBACK_counts_too(self, tmp_path: Path) -> None:
+ """The floor is what the cloud-first user leans on when the cloud 402s.
+
+ The live loss happened in exactly this shape: provider was a cloud
+ recognizer, the local engine was the configured fallback, and the
+ interpreter that owned the shortcut did not have it — so the 402 hit a
+ chain with nothing underneath it.
+ """
+ import jarvis.core.config as core_cfg
+
+ toml = _stt_config(tmp_path, provider="groq-api", fallback="faster-whisper")
+ with pytest.MonkeyPatch.context() as mp:
+ mp.setattr(core_cfg, "DEFAULT_CONFIG_FILE", toml)
+ assert icon_utils._config_wants_on_device_speech() is True
+
+ def test_a_purely_cloud_config_wants_no_on_device_engine(
+ self, tmp_path: Path
+ ) -> None:
+ import jarvis.core.config as core_cfg
+
+ toml = _stt_config(tmp_path, provider="groq-api", fallback="openai-api")
+ with pytest.MonkeyPatch.context() as mp:
+ mp.setattr(core_cfg, "DEFAULT_CONFIG_FILE", toml)
+ assert icon_utils._config_wants_on_device_speech() is False
+
def test_the_gate_needs_both_capabilities(
self, monkeypatch: pytest.MonkeyPatch
) -> None:
@@ -473,7 +513,7 @@ class TestSpeechCapabilityProbe:
monkeypatch.setattr(core_cfg, "DEFAULT_CONFIG_FILE", tmp_path / "absent.toml")
- assert icon_utils._configured_stt_provider() == ""
+ assert icon_utils._config_wants_on_device_speech() is False
@windows_only