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(upgrade): restart running runtime after install (#553)
Call White7e314b542dbc
diff --git a/docs/CLI.md b/docs/CLI.mdindex f12d9596b..81fb49931 100644--- a/docs/CLI.md+++ b/docs/CLI.md@@ -279,6 +279,10 @@ Upgrade to the latest version.vibe upgrade```+If Avibe is already running, the command schedules a managed restart so the+service and Web UI switch to the upgraded code. If Avibe is stopped, the command+keeps it stopped and the new version is used on the next start.+## Service Lifecycle### Understanding "Restart" vs "Stop"diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.mdindex d9e38e498..75f0a8c09 100644--- a/docs/CLI_ZH.md+++ b/docs/CLI_ZH.md@@ -255,6 +255,9 @@ vibe check-updatevibe upgrade```+如果 Avibe 已在运行,该命令会安排一次受控重启,让服务和 Web UI 切换到升级后的代码。+如果 Avibe 原本是停止状态,则保持停止,下次启动时使用新版本。+## 服务生命周期### 理解「重启」与「停止」的区别diff --git a/docs/COMMANDS.md b/docs/COMMANDS.mdindex 4bb716d4c..7d133c04c 100644--- a/docs/COMMANDS.md+++ b/docs/COMMANDS.md@@ -670,7 +670,8 @@ vibe upgrade```- upgrades Avibe using the selected upgrade plan-- usually recommends `vibe restart --delay-seconds 60` after success+- schedules a managed restart after success when Avibe is already running+- keeps Avibe stopped when it was not running before the upgrade## 5.2 `vibe task`diff --git a/docs/COMMANDS_ZH.md b/docs/COMMANDS_ZH.mdindex 4392aeef1..9196267b5 100644--- a/docs/COMMANDS_ZH.md+++ b/docs/COMMANDS_ZH.md@@ -649,7 +649,8 @@ vibe upgrade```- 按升级计划升级 Avibe-- 成功后通常建议再执行 `vibe restart --delay-seconds 60`+- 如果 Avibe 已在运行,成功后安排一次受控重启+- 如果 Avibe 原本未运行,则保持停止状态## 5.2 `vibe task`diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.pyindex a5cc90fd4..376e889ed 100644--- a/tests/test_upgrade_flow.py+++ b/tests/test_upgrade_flow.py@@ -339,6 +339,7 @@ def test_do_upgrade_uses_upgrade_plan_env_and_restarts(monkeypatch):monkeypatch.setattr(api, "build_upgrade_plan", lambda **kwargs: plan)monkeypatch.setattr(api, "get_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(api, "_runtime_process_was_running", lambda: True)monkeypatch.setattr(api, "schedule_restart", lambda **kwargs: calls.setdefault("restart_kwargs", kwargs))def fake_run(cmd, **kwargs):@@ -379,6 +380,7 @@ def test_do_upgrade_auto_restart_does_not_block_on_runtime_prepare(monkeypatch):monkeypatch.setattr(api, "build_upgrade_plan", lambda **kwargs: plan)monkeypatch.setattr(api, "get_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(api, "_runtime_process_was_running", lambda: True)monkeypatch.setattr(api, "schedule_restart", lambda **kwargs: events.append("restart") or {"job_id": "restart"})def fake_run(cmd, **kwargs):@@ -396,6 +398,62 @@ def test_do_upgrade_auto_restart_does_not_block_on_runtime_prepare(monkeypatch):assert events == ["upgrade", "restart"]+def test_do_upgrade_running_runtime_honors_show_runtime_skip_for_restart(monkeypatch):+ plan = UpgradePlan(+ command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],+ env=None,+ method="uv",+ )+ calls: dict[str, Any] = {}++ monkeypatch.setenv("VIBE_INSTALL_SKIP_SHOW_RUNTIME", "1")+ monkeypatch.setattr(api, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(api, "get_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(api, "_runtime_process_was_running", lambda: True)+ monkeypatch.setattr(api, "schedule_restart", lambda **kwargs: calls.setdefault("restart_kwargs", kwargs))+ monkeypatch.setattr(+ api.subprocess,+ "run",+ lambda cmd, **kwargs: subprocess.CompletedProcess(cmd, 0, stdout="done", stderr=""),+ )++ result = api.do_upgrade(auto_restart=True)++ assert result["ok"] is True+ assert result["restarting"] is True+ assert calls["restart_kwargs"]["prepare_show_runtime"] is False+++def test_do_upgrade_reports_restart_scheduling_failure_as_partial_success(monkeypatch):+ plan = UpgradePlan(+ command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],+ env=None,+ method="uv",+ )++ monkeypatch.setattr(api, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(api, "get_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(api, "_runtime_process_was_running", lambda: True)++ def fail_restart(**kwargs):+ raise RuntimeError("bad launcher")++ monkeypatch.setattr(api, "schedule_restart", fail_restart)+ monkeypatch.setattr(+ api.subprocess,+ "run",+ lambda cmd, **kwargs: subprocess.CompletedProcess(cmd, 0, stdout="done", stderr=""),+ )++ result = api.do_upgrade(auto_restart=True)++ assert result["ok"] is True+ assert result["restarting"] is False+ assert result["message"] == "Upgrade successful, but restart scheduling failed. Please restart vibe."+ assert "Restart scheduling failed" in result["output"]+ assert "bad launcher" in result["output"]++def test_do_upgrade_without_auto_restart_prepares_runtime(monkeypatch):plan = UpgradePlan(command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],@@ -406,6 +464,7 @@ def test_do_upgrade_without_auto_restart_prepares_runtime(monkeypatch):monkeypatch.setattr(api, "build_upgrade_plan", lambda **kwargs: plan)monkeypatch.setattr(api, "get_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(api, "_runtime_process_was_running", lambda: True)def fail_restart(**kwargs):raise AssertionError("schedule_restart should not run when auto_restart is disabled")@@ -437,6 +496,75 @@ def test_do_upgrade_without_auto_restart_prepares_runtime(monkeypatch):assert calls["runtime_prepare_kwargs"]["cwd"] == calls["upgrade_kwargs"]["cwd"]+def test_do_upgrade_keeps_runtime_stopped_when_it_was_not_running(monkeypatch):+ plan = UpgradePlan(+ command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],+ env=None,+ method="uv",+ )+ calls: dict[str, Any] = {}++ monkeypatch.setattr(api, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(api, "get_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(api, "_runtime_process_was_running", lambda: False)++ def fail_restart(**kwargs):+ raise AssertionError("schedule_restart should not run when Avibe was not running")++ monkeypatch.setattr(api, "schedule_restart", fail_restart)++ def fake_run(cmd, **kwargs):+ if cmd == plan.command:+ calls["upgrade_cmd"] = cmd+ calls["upgrade_kwargs"] = kwargs+ return subprocess.CompletedProcess(cmd, 0, stdout="done", stderr="")+ if cmd == ["/custom/bin/vibe", "runtime", "prepare", "--strict"]:+ calls["runtime_prepare_cmd"] = cmd+ calls["runtime_prepare_kwargs"] = kwargs+ return subprocess.CompletedProcess(cmd, 0, stdout="runtime ready", stderr="")+ raise AssertionError(f"unexpected subprocess command: {cmd}")++ monkeypatch.setattr(api.subprocess, "run", fake_run)++ result = api.do_upgrade(auto_restart=True)++ assert result["ok"] is True+ assert result["restarting"] is False+ assert result["message"] == "Upgrade successful. Please restart vibe."+ assert calls["runtime_prepare_cmd"] == ["/custom/bin/vibe", "runtime", "prepare", "--strict"]+++def test_api_runtime_process_was_running_checks_service_and_ui_pid_files(monkeypatch, tmp_path):+ service_pid_path = tmp_path / "service.pid"+ ui_pid_path = tmp_path / "ui.pid"+ service_pid_path.write_text("111", encoding="utf-8")+ ui_pid_path.write_text("222", encoding="utf-8")++ monkeypatch.setattr(api.paths, "get_runtime_pid_path", lambda: service_pid_path)+ monkeypatch.setattr(api.paths, "get_runtime_ui_pid_path", lambda: ui_pid_path)++ from vibe import runtime++ service_running = False+ ui_running = False++ def fake_service_running(pid_path):+ return pid_path == service_pid_path and service_running++ def fake_ui_running(pid_path):+ return pid_path == ui_pid_path and ui_running++ monkeypatch.setattr(runtime, "service_pid_file_points_to_running_service", fake_service_running)+ monkeypatch.setattr(runtime, "ui_pid_file_points_to_running_ui", fake_ui_running)++ assert api._runtime_process_was_running() is False+ ui_running = True+ assert api._runtime_process_was_running() is True+ ui_running = False+ service_running = True+ assert api._runtime_process_was_running() is True++def test_cmd_upgrade_uses_upgrade_plan_env(monkeypatch):plan = UpgradePlan(command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],@@ -448,14 +576,18 @@ def test_cmd_upgrade_uses_upgrade_plan_env(monkeypatch):monkeypatch.setattr(cli, "get_latest_version", lambda: {"error": None, "has_update": True, "latest": "2.2.0"})monkeypatch.setattr(cli, "cache_running_vibe_path", lambda: "/custom/bin/vibe")monkeypatch.setattr(cli, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(cli, "_runtime_process_was_running", lambda: True)++ def fake_schedule_restart(**kwargs):+ calls["restart_kwargs"] = kwargs+ return {"job_id": "restart"}++ monkeypatch.setattr(cli, "schedule_restart", fake_schedule_restart)def fake_run(cmd, **kwargs):if cmd == plan.command:calls["cmd"] = cmdcalls["kwargs"] = kwargs- elif cmd == ["/custom/bin/vibe", "runtime", "prepare", "--strict"]:- calls["runtime_prepare_cmd"] = cmd- calls["runtime_prepare_kwargs"] = kwargselse:raise AssertionError(f"unexpected subprocess command: {cmd}")return subprocess.CompletedProcess(cmd, 0, stdout="done", stderr="")@@ -471,10 +603,107 @@ def test_cmd_upgrade_uses_upgrade_plan_env(monkeypatch):assert calls["kwargs"]["env"] == plan.envassert "cwd" in calls["kwargs"], "subprocess.run must specify cwd to avoid stale venv cwd"assert os.path.isabs(calls["kwargs"]["cwd"]), f"cwd must be absolute, got {calls['kwargs']['cwd']!r}"+ assert calls["restart_kwargs"] == {+ "delay_seconds": 0.0,+ "vibe_path": "/custom/bin/vibe",+ "trigger": "upgrade",+ "prepare_show_runtime": True,+ }+++def test_cmd_upgrade_running_runtime_honors_show_runtime_skip_for_restart(monkeypatch):+ plan = UpgradePlan(+ command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],+ env=None,+ method="uv",+ )+ calls: dict[str, Any] = {}++ monkeypatch.setenv("VIBE_INSTALL_SKIP_SHOW_RUNTIME", "true")+ monkeypatch.setattr(cli, "get_latest_version", lambda: {"error": None, "has_update": True, "latest": "2.2.0"})+ monkeypatch.setattr(cli, "cache_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(cli, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(cli, "_runtime_process_was_running", lambda: True)++ def fake_schedule_restart(**kwargs):+ calls["restart_kwargs"] = kwargs+ return {"job_id": "restart"}++ monkeypatch.setattr(cli, "schedule_restart", fake_schedule_restart)+ monkeypatch.setattr(+ cli.subprocess,+ "run",+ lambda cmd, **kwargs: subprocess.CompletedProcess(cmd, 0, stdout="done", stderr=""),+ )++ assert cli.cmd_upgrade() == 0+ assert calls["restart_kwargs"]["prepare_show_runtime"] is False+++def test_cmd_upgrade_reports_restart_scheduling_failure_as_partial_success(monkeypatch, capsys):+ plan = UpgradePlan(+ command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],+ env=None,+ method="uv",+ )++ monkeypatch.setattr(cli, "get_latest_version", lambda: {"error": None, "has_update": True, "latest": "2.2.0"})+ monkeypatch.setattr(cli, "cache_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(cli, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(cli, "_runtime_process_was_running", lambda: True)++ def fail_restart(**kwargs):+ raise RuntimeError("bad launcher")++ monkeypatch.setattr(cli, "schedule_restart", fail_restart)+ monkeypatch.setattr(+ cli.subprocess,+ "run",+ lambda cmd, **kwargs: subprocess.CompletedProcess(cmd, 0, stdout="done", stderr=""),+ )++ assert cli.cmd_upgrade() == 2+ output = capsys.readouterr().out+ assert "Upgrade installed, but restart scheduling failed." in output+ assert "Restart error: bad launcher" in output+ assert "Run `vibe restart` to use the new version." in output+ assert "Upgrade failed" not in output+++def test_cmd_upgrade_keeps_runtime_stopped_when_it_was_not_running(monkeypatch):+ plan = UpgradePlan(+ command=["/usr/local/bin/uv", "tool", "install", "avibe-os", "--upgrade"],+ env=None,+ method="uv",+ )+ calls: dict[str, Any] = {}++ monkeypatch.setattr(cli, "get_latest_version", lambda: {"error": None, "has_update": True, "latest": "2.2.0"})+ monkeypatch.setattr(cli, "cache_running_vibe_path", lambda: "/custom/bin/vibe")+ monkeypatch.setattr(cli, "build_upgrade_plan", lambda **kwargs: plan)+ monkeypatch.setattr(cli, "_pid_file_points_to_live_process", lambda path: False)++ def fail_restart(**kwargs):+ raise AssertionError("schedule_restart should not run when Avibe was not running")++ monkeypatch.setattr(cli, "schedule_restart", fail_restart)++ def fake_run(cmd, **kwargs):+ if cmd == plan.command:+ calls["cmd"] = cmd+ calls["kwargs"] = kwargs+ return subprocess.CompletedProcess(cmd, 0, stdout="done", stderr="")+ if cmd == ["/custom/bin/vibe", "runtime", "prepare", "--strict"]:+ calls["runtime_prepare_cmd"] = cmd+ calls["runtime_prepare_kwargs"] = kwargs+ return subprocess.CompletedProcess(cmd, 0, stdout="runtime ready", stderr="")+ raise AssertionError(f"unexpected subprocess command: {cmd}")++ monkeypatch.setattr(cli.subprocess, "run", fake_run)++ assert cli.cmd_upgrade() == 0+ assert calls["cmd"] == plan.commandassert calls["runtime_prepare_cmd"] == ["/custom/bin/vibe", "runtime", "prepare", "--strict"]- assert calls["runtime_prepare_kwargs"]["capture_output"] is True- assert calls["runtime_prepare_kwargs"]["text"] is True- assert calls["runtime_prepare_kwargs"]["timeout"] == 600 # prepare now budgets for Show Runtime + askilldef test_cmd_upgrade_skips_install_when_already_latest(monkeypatch):diff --git a/vibe/api.py b/vibe/api.pyindex 33b545272..f18fa7002 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -41,6 +41,7 @@ from vibe.upgrade import (get_latest_version_info,get_running_vibe_path,get_safe_cwd,+ should_skip_show_runtime_prepare,)from vibe.restart_supervisor import schedule_restartfrom vibe.claude_model_catalog import DEFAULT_CLAUDE_MODEL_ALIASES, load_catalog_models@@ -1783,6 +1784,22 @@ def get_slack_manifest() -> dict:return {"ok": False, "error": str(exc)}+def _pid_file_points_to_live_process(pid_path: Path) -> bool:+ from vibe import runtime++ if pid_path == paths.get_runtime_pid_path():+ return runtime.service_pid_file_points_to_running_service(pid_path)+ if pid_path == paths.get_runtime_ui_pid_path():+ return runtime.ui_pid_file_points_to_running_ui(pid_path)+ return False+++def _runtime_process_was_running() -> bool:+ return _pid_file_points_to_live_process(paths.get_runtime_pid_path()) or _pid_file_points_to_live_process(+ paths.get_runtime_ui_pid_path()+ )++def get_version_info() -> dict:"""Get current version and check for updates.@@ -1810,6 +1827,7 @@ def do_upgrade(auto_restart: bool = True) -> dict:"""current_vibe_path = get_running_vibe_path()plan = build_upgrade_plan(vibe_path=current_vibe_path)+ runtime_was_running = _runtime_process_was_running()# Use a stable directory as cwd to avoid "Current directory does not exist"# errors. The vibe service process cwd may be inside the uv tool venv@@ -1827,21 +1845,32 @@ def do_upgrade(auto_restart: bool = True) -> dict:)if result.returncode == 0:restarting = False+ restart_failed = Falseruntime_output = None- if auto_restart:- schedule_restart(- delay_seconds=2.0,- vibe_path=current_vibe_path,- trigger="upgrade",- prepare_show_runtime=True,- )- restarting = True+ if auto_restart and runtime_was_running:+ try:+ schedule_restart(+ delay_seconds=2.0,+ vibe_path=current_vibe_path,+ trigger="upgrade",+ prepare_show_runtime=not should_skip_show_runtime_prepare(),+ )+ restarting = True+ except Exception as exc:+ restart_failed = True+ runtime_output = f"Restart scheduling failed; run `vibe restart` to use the new version.\n{exc}"else:runtime_output = _prepare_show_runtime_after_upgrade(current_vibe_path, safe_cwd)+ if restarting:+ message = "Upgrade successful. Restarting..."+ elif restart_failed:+ message = "Upgrade successful, but restart scheduling failed. Please restart vibe."+ else:+ message = "Upgrade successful. Please restart vibe."return {"ok": True,- "message": "Upgrade successful." + (" Restarting..." if restarting else " Please restart vibe."),+ "message": message,"output": _append_upgrade_output(result.stdout, runtime_output),"restarting": restarting,}@@ -1871,7 +1900,7 @@ def _append_upgrade_output(output: str | None, runtime_output: str | None) -> stdef _prepare_show_runtime_after_upgrade(vibe_path: str | None, cwd: str) -> str | None:- if os.environ.get("VIBE_INSTALL_SKIP_SHOW_RUNTIME", "").strip().lower() in {"1", "true", "yes", "on"}:+ if should_skip_show_runtime_prepare():return "Show Runtime preparation skipped because VIBE_INSTALL_SKIP_SHOW_RUNTIME is set."if not vibe_path:return "Show Runtime was not prepared because the vibe executable path was not available."diff --git a/vibe/cli.py b/vibe/cli.pyindex c70f54410..113edc942 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -52,6 +52,7 @@ from vibe.upgrade import (cache_running_vibe_path,get_latest_version_info,get_safe_cwd,+ should_skip_show_runtime_prepare,)from storage.db import create_sqlite_enginefrom storage.background import compute_next_run_at, normalize_run_status@@ -4243,6 +4244,10 @@ def _pid_file_points_to_live_process(pid_path: Path) -> bool:return _pid_alive(pid)+def _runtime_process_was_running() -> bool:+ return runtime.service_pid_file_points_to_running_service() or runtime.ui_pid_file_points_to_running_ui()++def cmd_stop():service_was_running = _pid_file_points_to_live_process(paths.get_runtime_pid_path())ui_was_running = _pid_file_points_to_live_process(paths.get_runtime_ui_pid_path())@@ -5295,6 +5300,7 @@ def cmd_upgrade():current_vibe_path = cache_running_vibe_path()plan = build_upgrade_plan(vibe_path=current_vibe_path)print(f"Using {plan.method}: {' '.join(plan.command)}")+ runtime_was_running = _runtime_process_was_running()# Use a stable directory as cwd to avoid issues when running from a# directory that uv may delete during upgrade (e.g. inside the uv tool venv).@@ -5304,9 +5310,26 @@ def cmd_upgrade():result = subprocess.run(plan.command, capture_output=True, text=True, env=plan.env, cwd=safe_cwd)if result.returncode == 0:print("\033[32mUpgrade successful!\033[0m")- _prepare_show_runtime_after_install(current_vibe_path)- print("Please restart vibe to use the new version:")- print(" vibe restart")+ if runtime_was_running:+ try:+ restart = schedule_restart(+ delay_seconds=0.0,+ vibe_path=current_vibe_path,+ trigger="upgrade",+ prepare_show_runtime=not should_skip_show_runtime_prepare(),+ )+ except Exception as exc:+ print("\033[33mUpgrade installed, but restart scheduling failed.\033[0m")+ print(f"Restart error: {exc}")+ print("Run `vibe restart` to use the new version.")+ return 2+ else:+ print("Restart scheduled to use the new version.")+ print(f"Job ID: {restart['job_id']}")+ print("Run `vibe status` to inspect the restart result.")+ else:+ _prepare_show_runtime_after_install(current_vibe_path)+ print("Avibe was not running; the new version will be used next time you start it.")return 0else:print(f"\033[31mUpgrade failed:\033[0m\n{result.stderr}")@@ -5395,7 +5418,7 @@ def cmd_runtime(args) -> int:def _prepare_show_runtime_after_install(vibe_path: str | None) -> None:- if os.environ.get("VIBE_INSTALL_SKIP_SHOW_RUNTIME", "").strip().lower() in {"1", "true", "yes", "on"}:+ if should_skip_show_runtime_prepare():print("\033[33mSkipping Show Runtime preparation because VIBE_INSTALL_SKIP_SHOW_RUNTIME is set.\033[0m")returnexecutable = vibe_path or shutil.which("vibe")diff --git a/vibe/runtime.py b/vibe/runtime.pyindex 10cae5762..fb50a2ad3 100644--- a/vibe/runtime.py+++ b/vibe/runtime.py@@ -632,6 +632,14 @@ def _clear_service_pid_reservation(pid: int) -> None:pid_path.unlink(missing_ok=True)+def _read_pid_file(pid_path: Path) -> int | None:+ try:+ pid = int(pid_path.read_text(encoding="utf-8").strip())+ except (OSError, ValueError):+ return None+ return pid if pid > 0 else None++def service_lock_held_by(pid: int) -> bool:lock_path = get_service_lock_path()lock_path.parent.mkdir(parents=True, exist_ok=True)@@ -667,6 +675,11 @@ def service_pid_recorded(pid: int) -> bool:return recorded_pid == pid and pid_alive(pid) and service_lock_held_by(pid)+def service_pid_file_points_to_running_service(pid_path: Path | None = None) -> bool:+ pid = _read_pid_file(pid_path or paths.get_runtime_pid_path())+ return bool(pid and service_pid_recorded(pid))++def wait_for_service_pid(pid: int, timeout: float = SERVICE_LOCK_READY_TIMEOUT_SECONDS) -> bool:deadline = time.monotonic() + timeoutwhile time.monotonic() < deadline:@@ -905,6 +918,11 @@ def _pid_matches_ui_server(pid: int) -> bool:return "vibe.ui_server" in command and "run_ui_server" in command+def ui_pid_file_points_to_running_ui(pid_path: Path | None = None) -> bool:+ pid = _read_pid_file(pid_path or paths.get_runtime_ui_pid_path())+ return bool(pid and pid_alive(pid) and _pid_matches_ui_server(pid))++def resolve_localhost_family() -> str:"""Return the loopback family ``localhost`` actually maps to on this host.diff --git a/vibe/upgrade.py b/vibe/upgrade.pyindex 10f7265d4..ca731c59c 100644--- a/vibe/upgrade.py+++ b/vibe/upgrade.py@@ -18,6 +18,8 @@ PACKAGE_NAME = "avibe-os"LEGACY_PACKAGE_NAME = "vibe-remote"DEFAULT_UPDATE_METADATA_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"CURRENT_VIBE_EXECUTABLE_ENV = "VIBE_CURRENT_EXECUTABLE"+SHOW_RUNTIME_SKIP_ENV = "VIBE_INSTALL_SKIP_SHOW_RUNTIME"+TRUTHY_ENV_VALUES = {"1", "true", "yes", "on"}UV_FALLBACK_BIN_DIRS = (".local/bin", ".cargo/bin")_VERSION_RE = re.compile(r"^\s*v?(?P<release>\d+(?:\.\d+)*)"@@ -83,6 +85,11 @@ def get_known_uv_paths(base_env: Mapping[str, str] | None = None) -> list[str]:return [os.path.expanduser(f"~/{bin_dir}/uv") for bin_dir in UV_FALLBACK_BIN_DIRS]+def should_skip_show_runtime_prepare(base_env: Mapping[str, str] | None = None) -> bool:+ env = base_env or os.environ+ return env.get(SHOW_RUNTIME_SKIP_ENV, "").strip().lower() in TRUTHY_ENV_VALUES++def find_uv_binary(uv_path: str | None = None, base_env: Mapping[str, str] | None = None) -> str | None:env = base_env or os.environsearch_path = env.get("PATH")