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(audio): stop the busy cursor flashing while the wake word listens (#740)
Ruben Lütkedd75167622b3
diff --git a/dodaios/audio/devices.py b/dodaios/audio/devices.pyindex 058c7ddc7b..6c05ba4ea1 100644--- a/dodaios/audio/devices.py+++ b/dodaios/audio/devices.py@@ -64,7 +64,7 @@ from dodaios.audio.player import (from dodaios.audio.player import (_HOSTAPI_PREFERENCE as _OUTPUT_HOSTAPI_PREFERENCE,)-from dodaios.core.process_utils import NO_WINDOW_CREATIONFLAGS+from dodaios.core.process_utils import NO_WINDOW_CREATIONFLAGS, no_feedback_startupinfo#: The config sentinel for "pick a device automatically" (the default in#: ``[audio].input_device`` / ``[audio].output_device``).@@ -159,6 +159,7 @@ def _query_tables_fresh() -> _DeviceTables | None:check=False,close_fds=True,creationflags=NO_WINDOW_CREATIONFLAGS,+ startupinfo=no_feedback_startupinfo(),)record = output_path.read_text(encoding="utf-8", errors="replace")except (OSError, subprocess.SubprocessError):diff --git a/dodaios/audio/topology.py b/dodaios/audio/topology.pyindex 0ac8d141a8..962f5b251a 100644--- a/dodaios/audio/topology.py+++ b/dodaios/audio/topology.py@@ -73,6 +73,10 @@ DEFAULT_POLL_S = 30.0# wait this long after the first divergent signature so the refresh runs once# against the settled topology instead of once per event._SETTLE_S = 1.5+# Shortest gap between two probes when device-loss signals ask for one early.+# A mic that keeps stalling or failing to open fires those signals back to+# back; without a floor every one of them started another probe process.+MIN_PROBE_GAP_S = 10.0# Set while a watcher runs, so a device-loss signal can skip the poll wait.@@ -249,6 +253,7 @@ async def watch_topology(output_device: Any = None,*,poll_s: float = DEFAULT_POLL_S,+ min_gap_s: float = MIN_PROBE_GAP_S,probe: Callable[[], str | None] | None = None,refresh: Callable[[], bool] | None = None,) -> None:@@ -263,12 +268,23 @@ async def watch_topology(refresh = refresh or (lambda: refresh_audio_backend(player, output_device))_probe_request = asyncio.Event()_probe_loop = asyncio.get_running_loop()+ loop = _probe_looplast: str | None = None+ last_probe_at = float("-inf")while True:# Wake early when a device-loss signal fires, otherwise poll.- with contextlib.suppress(TimeoutError):+ requested = True+ try:await asyncio.wait_for(_probe_request.wait(), timeout=poll_s)+ except TimeoutError: # the poll interval elapsed: a timed probe, not an error+ requested = False+ if requested:+ # An early request still honours the floor between probes.+ remaining = min_gap_s - (loop.time() - last_probe_at)+ if remaining > 0:+ await asyncio.sleep(remaining)_probe_request.clear()+ last_probe_at = loop.time()signature = await asyncio.to_thread(probe)if signature is None:# Probe unavailable (headless, worker timeout) — no judgment.@@ -296,6 +312,7 @@ async def watch_topology(__all__ = ["DEFAULT_POLL_S",+ "MIN_PROBE_GAP_S","refresh_audio_backend","native_stream_operation","register_capture",diff --git a/dodaios/core/process_utils.py b/dodaios/core/process_utils.pyindex 1ffaf4603a..d6cf4f22e0 100644--- a/dodaios/core/process_utils.py+++ b/dodaios/core/process_utils.py@@ -129,6 +129,27 @@ if sys.platform == "win32":else:NO_WINDOW_CREATIONFLAGS = 0+# STARTF_FORCEOFFFEEDBACK: no "working in background" cursor while the child starts.+_STARTF_FORCEOFFFEEDBACK = 0x00000080+++def no_feedback_startupinfo() -> Any:+ """``startupinfo`` for a background child that must not flash the busy cursor.++ ``CREATE_NO_WINDOW`` hides a console, but Windows still shows the+ arrow-and-spinner (AppStarting) cursor for every newly started GUI-subsystem+ process until it opens a window or a few seconds pass. The frozen desktop+ build relaunches its own GUI executable for helpers such as the audio device+ probe, so a recurring helper made the cursor spin over and over (issue #714).+ Pass the result as ``startupinfo=``; it is ``None`` off Windows, where the+ subprocess module rejects any other value.+ """+ if sys.platform != "win32":+ return None+ info = subprocess.STARTUPINFO() # type: ignore[attr-defined] # Windows only+ info.dwFlags |= _STARTF_FORCEOFFFEEDBACK+ return info+def resolve_executable(name: str) -> str:"""Resolve a binary name to its full on-disk path, honoring PATHEXT.diff --git a/dodaios/platform/clipboard_reader.py b/dodaios/platform/clipboard_reader.pyindex 6cccceb751..b5ce0a89b8 100644--- a/dodaios/platform/clipboard_reader.py+++ b/dodaios/platform/clipboard_reader.py@@ -14,7 +14,7 @@ import sysimport threadingfrom pathlib import Path-from dodaios.core.process_utils import NO_WINDOW_CREATIONFLAGS+from dodaios.core.process_utils import NO_WINDOW_CREATIONFLAGS, no_feedback_startupinfolog = logging.getLogger(__name__)READ_TIMEOUT_S = 1.0@@ -46,6 +46,7 @@ def read_with_deadline() -> str | None:timeout=READ_TIMEOUT_S,check=False,creationflags=NO_WINDOW_CREATIONFLAGS,+ startupinfo=no_feedback_startupinfo(),# A desktop shortcut may start in another directory. Source installs# must import the same checkout as their parent (also in tests).cwd=None if getattr(sys, "frozen", False) else str(Path(__file__).resolve().parents[2]),diff --git a/tests/unit/audio/test_devices.py b/tests/unit/audio/test_devices.pyindex 55e5bf575d..a54fa610d8 100644--- a/tests/unit/audio/test_devices.py+++ b/tests/unit/audio/test_devices.py@@ -252,6 +252,13 @@ def test_fresh_options_use_isolated_snapshot_instead_of_stale_live_table(assert inputs[0].is_default is Trueassert calls[0][0][1:3] == ["-m", "dodaios.audio.device_probe"]assert calls[0][1]["creationflags"] == dv.NO_WINDOW_CREATIONFLAGS+ # The frozen build relaunches its GUI exe; without this every probe made+ # the Windows cursor spin (issue #714).+ startupinfo = calls[0][1]["startupinfo"]+ if dv.sys.platform == "win32":+ assert startupinfo.dwFlags & 0x00000080+ else:+ assert startupinfo is Nonedef test_fresh_probe_uses_internal_mode_in_frozen_desktop(monkeypatch, tmp_path) -> None:diff --git a/tests/unit/audio/test_topology.py b/tests/unit/audio/test_topology.pyindex 38e533d464..0fcddbdaf8 100644--- a/tests/unit/audio/test_topology.py+++ b/tests/unit/audio/test_topology.py@@ -113,6 +113,49 @@ async def test_a_device_loss_signal_probes_without_waiting_for_the_poll() -> Nonawait task+async def test_back_to_back_probe_requests_are_throttled() -> None:+ """A mic that keeps stalling fires a probe request every few hundred ms.+ Each probe is a process start (in the desktop build, the whole app exe),+ so requests inside the gap must wait instead of spawning (issue #714)."""+ gap = 1.0+ probes: list[float] = []++ async def wait_for_probes(count: int, deadline_s: float) -> None:+ end = time.monotonic() + deadline_s+ # The probe appends from a worker thread, so poll instead of an Event.+ while len(probes) < count and time.monotonic() < end: # noqa: ASYNC110+ await asyncio.sleep(0.01)++ task = asyncio.create_task(+ topology.watch_topology(+ player=None,+ poll_s=60.0,+ min_gap_s=gap,+ probe=lambda: probes.append(time.monotonic()) or "sig",+ refresh=lambda: True,+ )+ )+ try:+ await asyncio.sleep(0.02)+ topology.request_topology_probe()+ await wait_for_probes(1, deadline_s=2.0)+ assert len(probes) == 1, "the first request after a quiet spell runs at once"++ for _ in range(5):+ topology.request_topology_probe()+ await asyncio.sleep(0.02)+ assert len(probes) == 1, "requests inside the gap must not probe again yet"++ await wait_for_probes(2, deadline_s=gap + 3.0)+ assert len(probes) == 2, "the held request runs once the gap has passed"+ assert probes[1] - probes[0] >= gap * 0.95+ finally:+ task.cancel()+ with pytest.raises(asyncio.CancelledError):+ await task++@pytest.mark.asyncioasync def test_request_probe_is_a_noop_with_no_watcher_running() -> None:"""Called from capture's error paths, which run in tests and headlessdiff --git a/tests/unit/core/test_process_utils_no_feedback.py b/tests/unit/core/test_process_utils_no_feedback.pynew file mode 100644index 0000000000..58a0578d95--- /dev/null+++ b/tests/unit/core/test_process_utils_no_feedback.py@@ -0,0 +1,23 @@+"""Background helpers must not flash the Windows busy cursor (issue #714)."""+from __future__ import annotations++import sys++import pytest++from dodaios.core import process_utils++[email protected](sys.platform != "win32", reason="STARTUPINFO exists only on Windows")+def test_startupinfo_turns_launch_feedback_off_on_windows() -> None:+ info = process_utils.no_feedback_startupinfo()++ assert info is not None+ assert info.dwFlags & 0x00000080, "STARTF_FORCEOFFFEEDBACK must be set"+++def test_startupinfo_is_none_off_windows(monkeypatch) -> None:+ # subprocess rejects any non-None startupinfo outside Windows.+ monkeypatch.setattr(process_utils.sys, "platform", "linux")++ assert process_utils.no_feedback_startupinfo() is None