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(wizard): mic check degrades gracefully when no audio backend

Ruben Lütke15e3d651e423
diff --git a/jarvis/setup/wizard.py b/jarvis/setup/wizard.py
index f408160168..010a9a1fec 100644
--- a/jarvis/setup/wizard.py
+++ b/jarvis/setup/wizard.py
@@ -380,11 +380,22 @@ def step_mic_check() -> None:
_println("=" * 60)
try:
import sounddevice as sd # type: ignore[import-untyped]
+
+ devices = sd.query_devices()
except ImportError:
_println("⚠ sounddevice not installed. Run `pip install -r requirements.txt`.")
return
+ except Exception as exc: # noqa: BLE001 — no audio backend must not kill setup
+ # sd.query_devices() raises (e.g. PortAudioError "library not found") on a
+ # host with no audio backend: a headless server, or a Linux desktop without
+ # libportaudio2. Degrade gracefully — a mic-check failure must NEVER abort
+ # the wizard, or step_finalize never writes the .setup-complete marker and
+ # the app re-runs its whole onboarding (same failure mode as the step-7 bug).
+ _println(f"⚠ Audio system unavailable ({exc}).")
+ _println(" Skipping the microphone check — setup continues.")
+ _println(" Headless server: expected. Linux desktop: install libportaudio2.")
+ return
- devices = sd.query_devices()
inputs = [d for d in devices if d["max_input_channels"] > 0]
if not inputs:
_println("⚠ No microphone detected. Plug in a headset and restart.")
diff --git a/tests/unit/setup/test_wizard_mic_degrade.py b/tests/unit/setup/test_wizard_mic_degrade.py
new file mode 100644
index 0000000000..c1f7189902
--- /dev/null
+++ b/tests/unit/setup/test_wizard_mic_degrade.py
@@ -0,0 +1,29 @@
+"""The microphone check must degrade, never abort the wizard.
+
+Regression guard: `sd.query_devices()` raises (e.g. PortAudioError "library not
+found") on any host with no audio backend — a headless server, or a Linux
+desktop without libportaudio2. If that error propagated, the wizard would die
+before step_finalize writes the .setup-complete marker, and the app would re-run
+its whole onboarding (the same failure mode as the step-7 OpenClaw crash).
+"""
+from __future__ import annotations
+
+import sys
+import types
+from unittest.mock import patch
+
+from jarvis.setup import wizard
+
+
+def test_mic_check_survives_missing_audio_backend() -> None:
+ """A PortAudio/backend failure in the mic check returns quietly, no raise."""
+ fake_sd = types.ModuleType("sounddevice")
+
+ def _boom(*_a: object, **_k: object) -> object:
+ raise OSError("PortAudio library not found")
+
+ fake_sd.query_devices = _boom # type: ignore[attr-defined]
+
+ with patch.dict(sys.modules, {"sounddevice": fake_sd}):
+ # Must NOT raise — a mic-check failure may never abort setup.
+ wizard.step_mic_check()