Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(backends): address P2 review pass on PR #282
cyh29bb8b0be671
diff --git a/ui/src/components/settings/BackendLifecycleChip.tsx b/ui/src/components/settings/BackendLifecycleChip.tsxindex 32d82c041..a37dea8f8 100644--- a/ui/src/components/settings/BackendLifecycleChip.tsx+++ b/ui/src/components/settings/BackendLifecycleChip.tsx@@ -13,11 +13,20 @@ type Phase = 'idle' | 'loading' | 'upgrading' | 'restarting';type Visual = 'disabled' | 'ready' | 'updating' | 'update' | 'error' | 'loading';type BadgeVariant = 'secondary' | 'success' | 'info' | 'warning' | 'destructive';+export type BackendChipChange = {+ // Path returned by ``install_agent`` when the chip just (re)installed the+ // backend. Parents should treat this as the new source of truth and update+ // their saved ``cli_path`` before re-running detection — otherwise a stale+ // path from the React closure keeps the row in a false ``missing`` state+ // even though the install succeeded.+ installedPath?: string | null;+};+interface BackendLifecycleChipProps {name: string;enabled: boolean;cliStatus: CliStatus;- onChanged?: () => void | Promise<void>;+ onChanged?: (info?: BackendChipChange) => void | Promise<void>;}// Map lifecycle visual states to canonical Badge variants from the design@@ -140,7 +149,8 @@ export const BackendLifecycleChip: React.FC<BackendLifecycleChipProps> = ({if (result.ok) {showToast(t('backendLifecycle.upgradeSuccess'), 'success');await loadRuntime();- await onChanged?.();+ const installedPath = typeof result.path === 'string' && result.path ? result.path : null;+ await onChanged?.({ installedPath });} else {showToast(result.message || t('backendLifecycle.upgradeFailed'), 'error');}diff --git a/ui/src/components/steps/AgentDetection.tsx b/ui/src/components/steps/AgentDetection.tsxindex 49f7796e7..a9fdba25e 100644--- a/ui/src/components/steps/AgentDetection.tsx+++ b/ui/src/components/steps/AgentDetection.tsx@@ -234,7 +234,20 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, onname={name}enabled={agent.enabled}cliStatus={agent.status || 'unknown'}- onChanged={() => detect(name, agent.cli_path)}+ onChanged={async (info) => {+ // After a successful (re)install the chip hands back the+ // path the installer landed at — adopt it before+ // detecting, otherwise a stale ``agent.cli_path`` from+ // this render keeps the row in a false ``missing`` state.+ const installedPath = info?.installedPath || null;+ if (installedPath) {+ setAgents((prev) => ({+ ...prev,+ [name]: { ...prev[name], cli_path: installedPath },+ }));+ }+ await detect(name, installedPath || agent.cli_path);+ }}/><ToggleSwitchenabled={agent.enabled}diff --git a/vibe/api.py b/vibe/api.pyindex 818f6bf6f..6795edde0 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -1486,6 +1486,13 @@ def install_agent(name: str) -> dict:# In-memory caches keyed by (backend, cli_path) so version answers stay tied# to the binary they came from. Trade freshness for fewer probes during rapid# popover opens. Tuned for human pacing (seconds), not bots.+#+# The UI server handles requests on multiple threads, so reads, writes, and+# invalidation can race. A single lock serializes mutation — fast in practice+# (the cache holds at most a handful of entries), and avoids+# ``RuntimeError: dictionary changed size during iteration`` during the+# scan in ``_invalidate_version_cache``.+_BACKEND_CACHE_LOCK = __import__("threading").Lock()_BACKEND_VERSION_CACHE: dict[tuple[str, str], tuple[float, str | None]] = {}_BACKEND_LATEST_CACHE: dict[str, tuple[float, str | None]] = {}_BACKEND_VERSION_TTL_SECONDS = 30.0@@ -1577,28 +1584,39 @@ def _fetch_latest_version(name: str) -> str | None:def _cached_version(name: str, cli_path: str | None) -> str | None:key = (name, cli_path or "")- cached = _BACKEND_VERSION_CACHE.get(key)+ with _BACKEND_CACHE_LOCK:+ cached = _BACKEND_VERSION_CACHE.get(key)if cached and time.time() - cached[0] < _BACKEND_VERSION_TTL_SECONDS:return cached[1]+ # Probe outside the lock — CLI invocation can block on subprocess for+ # seconds, and we don't want unrelated lookups stuck behind it.version = _probe_cli_version(cli_path)- _BACKEND_VERSION_CACHE[key] = (time.time(), version)+ with _BACKEND_CACHE_LOCK:+ _BACKEND_VERSION_CACHE[key] = (time.time(), version)return versiondef _invalidate_version_cache(name: str) -> None:"""Drop all cached version entries for *name* across cli paths."""- for key in [k for k in _BACKEND_VERSION_CACHE if k[0] == name]:- _BACKEND_VERSION_CACHE.pop(key, None)+ with _BACKEND_CACHE_LOCK:+ # Snapshot keys under the lock so the subsequent ``pop`` calls can+ # never observe a partially mutated dict from a concurrent writer.+ stale = [k for k in _BACKEND_VERSION_CACHE if k[0] == name]+ for key in stale:+ _BACKEND_VERSION_CACHE.pop(key, None)def _cached_latest(name: str) -> str | None:- cached = _BACKEND_LATEST_CACHE.get(name)+ with _BACKEND_CACHE_LOCK:+ cached = _BACKEND_LATEST_CACHE.get(name)if cached:ttl = _BACKEND_LATEST_TTL_SECONDS if cached[1] else _BACKEND_LATEST_FAILURE_TTL_SECONDSif time.time() - cached[0] < ttl:return cached[1]+ # Network fetch outside the lock — same reasoning as ``_cached_version``.latest = _fetch_latest_version(name)- _BACKEND_LATEST_CACHE[name] = (time.time(), latest)+ with _BACKEND_CACHE_LOCK:+ _BACKEND_LATEST_CACHE[name] = (time.time(), latest)return latest