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
perf(ui): blocking reads leave the event loop, and sections repaint from cache
rubenluetke10-beep35ac24a70379
diff --git a/jarvis/core/loop_executor.py b/jarvis/core/loop_executor.pyindex ad8a51bccc..063a4f5808 100644--- a/jarvis/core/loop_executor.py+++ b/jarvis/core/loop_executor.py@@ -149,8 +149,12 @@ ANYIO_KEEP_ALIVE_S = 10 * 365 * 24 * 3600#: How many anyio workers :func:`warm_anyio_worker_pool` brings up. Sync routes#: burst in handfuls (a section mounting asks for its settings, its lists and-#: its status at once); eight resident threads cover a burst without a start.-ANYIO_WARM_WORKERS = 8+#: its status at once), and the slowest of them hold a worker for seconds, so+#: a burst that arrives while the long ones are still running finds the pool+#: empty and pays a ``Thread.start()`` on the loop — the very stall the warm-up+#: exists to avoid. Matched to :data:`MAX_WORKERS` so a section can never be+#: starved by another section that is mid-read.+ANYIO_WARM_WORKERS = 32def keep_anyio_workers_alive() -> bool:diff --git a/jarvis/memory/wiki/provider_chain.py b/jarvis/memory/wiki/provider_chain.pyindex 74a0e43349..b07965e4c9 100644--- a/jarvis/memory/wiki/provider_chain.py+++ b/jarvis/memory/wiki/provider_chain.py@@ -25,6 +25,7 @@ from __future__ import annotationsimport asyncioimport loggingimport re+import threadingimport timefrom collections.abc import Callable, Mappingfrom typing import Any@@ -125,6 +126,17 @@ def _exception_summary(exc: Exception) -> str:diagnosis = _SAFE_DIAGNOSIS_RE.search(str(exc))return f"{summary} ({diagnosis.group(0)})" if diagnosis else summary+#: How long a subscription-login probe stands before it is asked again. The+#: probe shells out to a vendor CLI's status command — seconds of subprocess+#: per provider, and every wiki batch asks about all of them. A login does not+#: change second to second, so a short memo removes almost all of that while+#: still noticing a sign-in within one refresh.+_LOGIN_PROBE_TTL_S = 30.0++_login_probe_lock = threading.Lock()+_login_probe_cache: dict[str, tuple[float, bool | None]] = {}++def subscription_login_ready(provider: str, *, registry: Any = None) -> bool | None:"""Subscription-login readiness; ``None`` means no such capability.@@ -133,7 +145,16 @@ def subscription_login_ready(provider: str, *, registry: Any = None) -> bool | Nto future CLIs without another vendor-name branch (AP-21). A failed probestays unknown rather than false so one status-service fault cannot empty anotherwise usable fallback chain.++ The answer is memoised for :data:`_LOGIN_PROBE_TTL_S`: the probe costs a+ subprocess per provider, and the callers ask for every provider on every+ batch, which turned a background job into seconds of blocked work."""+ now = time.monotonic()+ with _login_probe_lock:+ cached = _login_probe_cache.get(provider)+ if cached is not None and (now - cached[0]) < _LOGIN_PROBE_TTL_S:+ return cached[1]try:if registry is None:from jarvis.brain.provider_registry import BrainProviderRegistry@@ -142,10 +163,14 @@ def subscription_login_ready(provider: str, *, registry: Any = None) -> bool | Nprovider_class = registry.get_class(provider)probe = getattr(provider_class, "subscription_connected", None)if not callable(probe):- return None- return bool(probe())+ result: bool | None = None+ else:+ result = bool(probe())except Exception: # noqa: BLE001 - a probe failure must never empty the chainreturn None+ with _login_probe_lock:+ _login_probe_cache[provider] = (time.monotonic(), result)+ return resultdef credential_ready_wiki_providers(diff --git a/jarvis/ui/web/chats_routes.py b/jarvis/ui/web/chats_routes.pyindex c93ccdf52b..e1001dccc9 100644--- a/jarvis/ui/web/chats_routes.py+++ b/jarvis/ui/web/chats_routes.py@@ -286,7 +286,7 @@ def _conversation_title(@router.get("", response_model=list[ConversationSummary])-async def list_conversations(+def list_conversations(request: Request,days: int = Query(default=0, ge=0, le=3650),limit: int = Query(default=200, ge=1, le=1000),diff --git a/jarvis/ui/web/frontend/src/main.tsx b/jarvis/ui/web/frontend/src/main.tsxindex f9b6601e50..836d408738 100644--- a/jarvis/ui/web/frontend/src/main.tsx+++ b/jarvis/ui/web/frontend/src/main.tsx@@ -84,7 +84,20 @@ void import("./lib/uiStallWatch").then(({ watchUiStalls }) => {const queryClient = new QueryClient({defaultOptions: {- queries: { staleTime: 5_000, retry: 1 },+ queries: {+ staleTime: 5_000,+ // Sections are unmounted on every switch, so their queries go inactive+ // the moment you leave one. At the five-minute default the cache was+ // gone before most people came back, and the section repainted from+ // nothing — a blank shell for a whole round trip. Half an hour keeps+ // the last answer on screen while the refetch runs behind it.+ gcTime: 30 * 60_000,+ // Returning to the window used to refire every mounted query at once.+ // The sections already poll or refetch on their own filters, so the+ // burst bought nothing and arrived exactly when the app felt slowest.+ refetchOnWindowFocus: false,+ retry: 1,+ },},});diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.pyindex c378b51742..4b040e9433 100644--- a/jarvis/ui/web/server.py+++ b/jarvis/ui/web/server.py@@ -1131,13 +1131,22 @@ class WebServer:model_resolved = f"{provider_slug}/{primary_deep_model}"binary_path = oc_cfg.binary_path if oc_cfg is not None else "openclaw"- binary_detected: str | None = shutil.which(binary_path)- if not binary_detected:++ def _detect_binary() -> str | None:+ """Resolve the bridge binary — up to four full PATH scans."""+ found = shutil.which(binary_path)+ if found:+ return foundfor ext in (".cmd", ".ps1", ".exe"):cand = shutil.which(binary_path + ext)if cand:- binary_detected = cand- break+ return cand+ return None++ # Off the loop: a PATH scan walks every directory on PATH, and on a+ # long Windows PATH that is the slowest thing this route does. Left+ # inline it froze every other section for as long as it took.+ binary_detected: str | None = await asyncio.to_thread(_detect_binary)from jarvis.brain.assistant_name import agent_brandfrom jarvis.core.config import (@@ -1150,16 +1159,27 @@ class WebServer:# Display brand follows the wake-word-derived assistant name.brand = agent_brand(cfg)++ def _key_flags(+ slot: tuple[str, str] | None, provider: str+ ) -> tuple[bool, bool]:+ """Whether a dedicated and/or a shared credential exists."""+ try:+ dedicated = bool(slot and get_secret(slot[0], env_fallback=slot[1]))+ shared = bool(get_provider_secret(provider))+ except Exception: # noqa: BLE001 — one unreadable store hides no other row+ return False, False+ return dedicated, shared+mapping_rows = []for mapping in MAPPINGS:slot = jarvis_agent_secret_slot(mapping.jarvis)secret_key = slot[0] if slot else None- try:- dedicated_key_set = bool(slot and get_secret(slot[0], env_fallback=slot[1]))- shared_key_set = bool(get_provider_secret(mapping.jarvis))- except Exception: # noqa: BLE001- dedicated_key_set = False- shared_key_set = False+ # Off the loop: each of these reads the OS credential store,+ # which blocks for as long as that store feels like taking.+ dedicated_key_set, shared_key_set = await asyncio.to_thread(+ _key_flags, slot, mapping.jarvis+ )api_key_set = dedicated_key_set or shared_key_setoauth_connected = Falseoauth_stale = False