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(autostart): start the app tree at Normal priority, not BelowNormal (BUG-210)
rubenluetke10-beepd30c531824c3
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex 9ab82180dc..43c73b9b27 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -14777,3 +14777,51 @@ invisible until someone else's config file was unreadable. Note the remainingsharp edge this exposed, not fixed here: an unwritable `jarvis.toml` silentlydiscards *every* in-app setting, because best-effort persistence is what allthese routes do. Only the onboarding dead end is closed.++## BUG-210: the autostart task started the whole app tree at BelowNormal priority (HIGH, FIXED 2026-09-01)++**Symptom.** The first start after a cold Windows boot felt broken across the+board: multi-second freezes, clicks that landed late or seemingly misfired, the+bar and window stalling together. BUG-204's forensics already named the+amplifier — three of seven event-loop stalls that afternoon sat in+`GetQueuedCompletionStatus`, i.e. the loop was idle and simply **not+scheduled** — and recorded it as unfixed.++**Root cause.** The logon Scheduled Task ("Personal Jarvis Autostart") was+registered without `-Priority`, so Task Scheduler applied its default (7):+the launched process runs at `BELOW_NORMAL_PRIORITY_CLASS`, and every+descendant — launcher, backend, WebView2 browser processes, PTY panes,+Ollama — inherits it. On a cold boot the machine is paging and every other+autostart competes for the disk; a BelowNormal tree loses every one of those+races, which stretched the wake warm-up to 17-44 s and turned 1-2 s hiccups+into 15-30 s freezes. Two side doors kept the demotion alive even after a+restart: the de-elevated relaunch (`CreateProcessWithTokenW` passes no+priority class, so the child inherits the creator's) and restarts spawned+from an already-demoted pane.++**Fix.** Three lanes, all raise-only:++* `build_register_task_script` passes `-Priority 5` (Normal) — new and+ re-registered tasks start the tree at Normal+ (`jarvis/autostart/windows.py`).+* `process_utils.ensure_normal_process_priority()` runs first thing in the+ launcher: if the process inherited BelowNormal/Idle it raises itself to+ Normal before anything is spawned. Never demotes, quiet no-op off Windows+ (macOS launchd already runs LaunchAgents with `ProcessType=Interactive`;+ Linux desktop autostart is not niced).+* `token_creationflags` adds `NORMAL_PRIORITY_CLASS` so the de-elevated+ relaunch pins Normal instead of inheriting.++Existing installs need no UAC prompt: the stored task keeps priority 7 until+it is ever re-registered, but the launcher self-correction covers the gap at+every start.++**Guard.** `tests/unit/autostart/test_windows_task.py`+(`test_register_script_pins_normal_priority`),+`tests/unit/core/test_process_utils_priority.py` (raise-only contract,+off-Windows no-op), `tests/unit/platform/test_deescalate.py`+(`test_relaunch_never_inherits_a_demoted_priority_class`).++**Related.** BUG-204 (the VRAM holder this amplified), BUG-189 (the cold-boot+start storm the priority made fatal), AP-17 (the task stays `RunLevel+Limited` — priority is orthogonal to elevation).diff --git a/jarvis/autostart/windows.py b/jarvis/autostart/windows.pyindex 327b34986a..b482a7e6c2 100644--- a/jarvis/autostart/windows.py+++ b/jarvis/autostart/windows.py@@ -142,7 +142,12 @@ def build_register_task_script(``RunLevel=Limited`` → the launched Jarvis is NOT elevated (mic access);``AtLogOn`` + ``Delay`` → fires a few seconds after login, off the Explorer- startup throttle.+ startup throttle. ``-Priority 5`` → Normal process priority: Task Scheduler's+ default (7) starts the whole tree BelowNormal, which turned a paging cold+ boot into 15-30 s whole-app freezes (BUG-204 amplifier). Existing tasks keep+ their stored priority until re-registered; the launcher self-corrects at+ runtime (``process_utils.ensure_normal_process_priority``) so old installs+ are covered without a UAC prompt."""args = " ".join(spec.args)return (@@ -156,7 +161,7 @@ def build_register_task_script("-LogonType Interactive -RunLevel Limited\n"" $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries ""-DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) "- "-MultipleInstances IgnoreNew\n"+ "-MultipleInstances IgnoreNew -Priority 5\n"f" Register-ScheduledTask -TaskName '{_ps_lit(task_name)}' -Action $action ""-Trigger $trigger -Principal $principal -Settings $settings "f"-Description '{_ps_lit(WINDOWS_AUTOSTART_DESCRIPTION)}' -Force | Out-Null\n"diff --git a/jarvis/core/process_utils.py b/jarvis/core/process_utils.pyindex a3bd5341ef..c00012d98d 100644--- a/jarvis/core/process_utils.py+++ b/jarvis/core/process_utils.py@@ -224,9 +224,52 @@ def wake_thread_message_loop(native_thread_id: int) -> bool:return False+_BELOW_NORMAL_PRIORITY_CLASS = 0x00004000+_IDLE_PRIORITY_CLASS = 0x00000040+_NORMAL_PRIORITY_CLASS = 0x00000020+++def ensure_normal_process_priority() -> str | None:+ """Raise this process to Normal priority if it inherited a lower class.++ The autostart Scheduled Task historically registered without ``-Priority``,+ so Task Scheduler's default (7) started the entire tree — launcher, backend,+ WebView2, PTY panes, Ollama — at BelowNormal, which turned a paging cold+ boot into 15-30 s whole-app freezes (BUG-204 amplifier). New registrations+ pass ``-Priority 5``; this call covers every other lane: an old task that+ was never re-registered, the de-elevated relaunch, and a restart spawned+ from an already-demoted pane.++ Only ever RAISES BelowNormal/Idle to Normal — a deliberately niced process+ (or one already Normal or above) is left alone. Quiet no-op off Windows:+ login-launched GUI apps start at normal priority on macOS (launchd+ ``ProcessType=Interactive``) and Linux, so there is nothing to repair.++ Returns a short human-readable detail when the class was changed, ``None``+ when nothing needed doing or the probe failed. Never raises.+ """+ if sys.platform != "win32":+ return None+ try:+ import ctypes # noqa: PLC0415 — Windows-only, keep it off the import floor++ kernel32 = ctypes.windll.kernel32+ handle = kernel32.GetCurrentProcess()+ current = int(kernel32.GetPriorityClass(handle))+ if current not in (_BELOW_NORMAL_PRIORITY_CLASS, _IDLE_PRIORITY_CLASS):+ return None+ if not kernel32.SetPriorityClass(handle, _NORMAL_PRIORITY_CLASS):+ return None+ was = "Idle" if current == _IDLE_PRIORITY_CLASS else "BelowNormal"+ return f"{was} -> Normal"+ except Exception: # noqa: BLE001 — priority repair is best-effort, never fatal+ return None++__all__ = ["NO_WINDOW_CREATIONFLAGS","disable_windows_app_ghosting",+ "ensure_normal_process_priority","ensure_standard_streams","resolve_executable","thread_message_loop_wake_supported",diff --git a/jarvis/platform/deescalate.py b/jarvis/platform/deescalate.pyindex b29844786f..ec284dc1ba 100644--- a/jarvis/platform/deescalate.py+++ b/jarvis/platform/deescalate.py@@ -41,6 +41,7 @@ log = logging.getLogger(__name__)_LOGON_WITH_PROFILE = 0x00000001_CREATE_UNICODE_ENVIRONMENT = 0x00000400_DETACHED_PROCESS = 0x00000008+_NORMAL_PRIORITY_CLASS = 0x00000020_TOKEN_QUERY = 0x0008_TOKEN_DUPLICATE = 0x0002_TOKEN_ASSIGN_PRIMARY = 0x0001@@ -83,8 +84,17 @@ def token_creationflags(creationflags: int) -> int:through produced ``ERROR_INVALID_PARAMETER`` (87). ``CREATE_NO_WINDOW`` issufficient for this helper, and Windows does not tie a child process'slifetime to its parent merely because this flag is absent.++ ``NORMAL_PRIORITY_CLASS`` is added explicitly: without it the child inherits+ the creator's priority class, and an elevated launcher started by the old+ autostart task (no ``-Priority``) ran BelowNormal — the de-elevated relaunch+ then carried that demotion into the whole app tree (BUG-204 amplifier)."""- return (creationflags & ~_DETACHED_PROCESS) | _CREATE_UNICODE_ENVIRONMENT+ return (+ (creationflags & ~_DETACHED_PROCESS)+ | _CREATE_UNICODE_ENVIRONMENT+ | _NORMAL_PRIORITY_CLASS+ )def _spawn_unelevated_windows(diff --git a/jarvis/ui/web/launcher.py b/jarvis/ui/web/launcher.pyindex 5a1813aba9..3bad1382cc 100644--- a/jarvis/ui/web/launcher.py+++ b/jarvis/ui/web/launcher.py@@ -1649,6 +1649,23 @@ def _main(argv: list[str] | None = None) -> int:_ilog.getLogger(__name__).warning("instance data dir could not be prepared: %s", exc)+ # A launch inherited from the old autostart Scheduled Task (registered+ # without -Priority) runs the whole tree at BelowNormal — on a paging cold+ # boot that meant 15-30 s whole-app freezes (BUG-204 amplifier). Repair it+ # before anything is spawned so every descendant inherits Normal. Raises+ # only, quiet no-op off Windows (two syscalls, AP-26-safe).+ from jarvis.core.process_utils import ensure_normal_process_priority++ _priority_repair = ensure_normal_process_priority()+ if _priority_repair:+ from loguru import logger as _plog++ _plog.info(+ "Process priority repaired: {} (inherited from the autostart task; "+ "new registrations pass -Priority 5).",+ _priority_repair,+ )+# GUI/desktop launches carry a minimal PATH (macOS launchd, Windows tray# relaunch) — append the well-known CLI install dirs before any provider# probe or worker spawn resolves binaries (stat-only, AP-26-safe).diff --git a/tests/unit/autostart/test_windows_task.py b/tests/unit/autostart/test_windows_task.pyindex c53c45d01a..6394347960 100644--- a/tests/unit/autostart/test_windows_task.py+++ b/tests/unit/autostart/test_windows_task.py@@ -72,6 +72,13 @@ def test_register_script_bakes_logon_delay() -> None:assert "PT20S" in script+def test_register_script_pins_normal_priority() -> None:+ # Task Scheduler's default (7) starts the whole tree BelowNormal — on a+ # paging cold boot that meant 15-30 s whole-app freezes (BUG-204 amplifier).+ script = build_register_task_script(TASK_NAME, _SPEC, user_id="u")+ assert "-Priority 5" in script++def test_unregister_script_is_idempotent() -> None:script = build_unregister_task_script(TASK_NAME)assert "Unregister-ScheduledTask" in scriptdiff --git a/tests/unit/core/test_process_utils_priority.py b/tests/unit/core/test_process_utils_priority.pynew file mode 100644index 0000000000..337d8b5d49--- /dev/null+++ b/tests/unit/core/test_process_utils_priority.py@@ -0,0 +1,77 @@+"""``ensure_normal_process_priority`` — the BUG-204-amplifier repair.++The old autostart Scheduled Task registered without ``-Priority`` and Task+Scheduler's default (7) started the whole tree BelowNormal. The repair must+only ever RAISE BelowNormal/Idle to Normal, never demote, and must be a quiet+no-op off Windows (macOS/Linux login launches already start at normal+priority).+"""++from __future__ import annotations++import sys++import pytest++from jarvis.core import process_utils+++class _FakeKernel32:+ """Capability fake for the two Win32 calls the repair makes."""++ def __init__(self, current_class: int, set_ok: bool = True) -> None:+ self.current_class = current_class+ self.set_ok = set_ok+ self.set_calls: list[int] = []++ def GetCurrentProcess(self) -> int: # noqa: N802 — Win32 spelling+ return -1++ def GetPriorityClass(self, _handle: int) -> int: # noqa: N802+ return self.current_class++ def SetPriorityClass(self, _handle: int, new_class: int) -> int: # noqa: N802+ self.set_calls.append(new_class)+ return 1 if self.set_ok else 0+++class _FakeCtypes:+ def __init__(self, kernel32: _FakeKernel32) -> None:+ self.windll = type("windll", (), {"kernel32": kernel32})()+++def _run_with(monkeypatch: pytest.MonkeyPatch, kernel32: _FakeKernel32) -> str | None:+ monkeypatch.setattr(process_utils.sys, "platform", "win32")+ monkeypatch.setitem(sys.modules, "ctypes", _FakeCtypes(kernel32))+ return process_utils.ensure_normal_process_priority()+++def test_off_windows_is_a_quiet_noop(monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(process_utils.sys, "platform", "linux")+ assert process_utils.ensure_normal_process_priority() is None+++def test_raises_below_normal_to_normal(monkeypatch: pytest.MonkeyPatch) -> None:+ kernel32 = _FakeKernel32(current_class=0x00004000) # BELOW_NORMAL+ detail = _run_with(monkeypatch, kernel32)+ assert detail == "BelowNormal -> Normal"+ assert kernel32.set_calls == [0x00000020] # NORMAL+++def test_raises_idle_to_normal(monkeypatch: pytest.MonkeyPatch) -> None:+ kernel32 = _FakeKernel32(current_class=0x00000040) # IDLE+ detail = _run_with(monkeypatch, kernel32)+ assert detail == "Idle -> Normal"+ assert kernel32.set_calls == [0x00000020]+++def test_never_touches_a_normal_or_higher_class(monkeypatch: pytest.MonkeyPatch) -> None:+ for cls in (0x00000020, 0x00008000, 0x00000080): # NORMAL, ABOVE_NORMAL, HIGH+ kernel32 = _FakeKernel32(current_class=cls)+ assert _run_with(monkeypatch, kernel32) is None+ assert kernel32.set_calls == []+++def test_failed_set_is_reported_as_nothing_done(monkeypatch: pytest.MonkeyPatch) -> None:+ kernel32 = _FakeKernel32(current_class=0x00004000, set_ok=False)+ assert _run_with(monkeypatch, kernel32) is Nonediff --git a/tests/unit/platform/test_deescalate.py b/tests/unit/platform/test_deescalate.pyindex ac096c887f..28c9597f27 100644--- a/tests/unit/platform/test_deescalate.py+++ b/tests/unit/platform/test_deescalate.py@@ -46,18 +46,29 @@ class TestTokenCreationFlags:detached_process = 0x00000008create_unicode_environment = 0x00000400create_no_window = 0x08000000+ normal_priority_class = 0x00000020flags = token_creationflags(detached_process | create_no_window)- assert flags == create_no_window | create_unicode_environment+ assert flags == create_no_window | create_unicode_environment | normal_priority_classdef test_preserves_unrelated_creation_flags(self):create_new_process_group = 0x00000200create_unicode_environment = 0x00000400+ normal_priority_class = 0x00000020flags = token_creationflags(create_new_process_group)- assert flags == create_new_process_group | create_unicode_environment+ assert flags == (+ create_new_process_group | create_unicode_environment | normal_priority_class+ )++ def test_relaunch_never_inherits_a_demoted_priority_class(self):+ # Without an explicit class the child inherits the creator's — and an+ # elevated launcher started by the old autostart task ran BelowNormal+ # (BUG-204 amplifier). The relaunch must pin Normal explicitly.+ normal_priority_class = 0x00000020+ assert token_creationflags(0) & normal_priority_classclass TestPlatformGating: