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): address codex review feedback
cyh24c13f3e039e
diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.pyindex f831b6064..9f6875071 100644--- a/tests/test_upgrade_flow.py+++ b/tests/test_upgrade_flow.py@@ -183,6 +183,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, "get_restart_command", lambda **kwargs: ["/custom/bin/vibe"])+ monkeypatch.setattr(api, "_delayed_restart_helper_command", lambda: ["/usr/bin/python3"])def fake_run(cmd, **kwargs):calls["run_cmd"] = cmd@@ -211,7 +212,7 @@ def test_do_upgrade_uses_upgrade_plan_env_and_restarts(monkeypatch):assert calls["run_kwargs"]["env"] == plan.envsafe_cwd = calls["run_kwargs"].get("cwd")assert safe_cwd and os.path.isabs(safe_cwd), f"subprocess.run cwd must be an absolute path, got {safe_cwd!r}"- assert calls["popen_cmd"][0] == sys.executable+ assert calls["popen_cmd"][0] == "/usr/bin/python3"assert calls["popen_cmd"][1] == "-c"assert "time.sleep(2.0)" in calls["popen_cmd"][2]assert "/custom/bin/vibe" in calls["popen_cmd"][2]@@ -220,6 +221,14 @@ def test_do_upgrade_uses_upgrade_plan_env_and_restarts(monkeypatch):assert popen_cwd and os.path.isabs(popen_cwd), f"Popen cwd must be an absolute path, got {popen_cwd!r}"+def test_delayed_restart_helper_prefers_stable_launcher_over_sys_executable(monkeypatch):+ monkeypatch.setattr(api.os, "name", "posix", raising=False)+ monkeypatch.setattr(api.shutil, "which", lambda binary: f"/usr/bin/{binary}" if binary == "python3" else None)+ monkeypatch.setattr(api.sys, "executable", "/volatile/.venv/bin/python", raising=False)++ assert api._delayed_restart_helper_command() == ["/usr/bin/python3"]++def test_cmd_upgrade_uses_upgrade_plan_env(monkeypatch):plan = UpgradePlan(command=["/usr/local/bin/uv", "tool", "install", "vibe-remote", "--upgrade"],diff --git a/tests/test_vibe_cli.py b/tests/test_vibe_cli.pyindex 0e2b790b6..43485aa4d 100644--- a/tests/test_vibe_cli.py+++ b/tests/test_vibe_cli.py@@ -90,3 +90,15 @@ def test_cli_stop_opencode_server_uses_runtime_helpers(tmp_path, monkeypatch):assert cli._stop_opencode_server() is Trueassert not pid_file.exists()+++def test_stop_pid_handles_process_lookup_race(monkeypatch):+ monkeypatch.setattr(runtime.os, "name", "posix", raising=False)+ monkeypatch.setattr(runtime, "pid_alive", lambda pid: True)++ def _kill(pid, sig):+ raise ProcessLookupError()++ monkeypatch.setattr(runtime.os, "kill", _kill)++ assert runtime.stop_pid(12345) is Falsediff --git a/vibe/api.py b/vibe/api.pyindex 2d1dbf0e2..07ae74af4 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -43,6 +43,31 @@ _OPENCODE_OPTIONS_CACHE: dict[str, dict] = {}_OPENCODE_OPTIONS_TTL_SECONDS = 30.0+def _delayed_restart_helper_command() -> list[str]:+ candidates: list[list[str]] = []++ if os.name == "nt":+ candidates.extend((["py", "-3"], ["python"], ["python3"]))+ else:+ candidates.extend((["python3"], ["python"]))++ current = sys.executable+ if current:+ candidates.append([current])++ for candidate in candidates:+ binary = candidate[0]+ if os.path.isabs(binary):+ if os.path.exists(binary) and os.access(binary, os.X_OK):+ return candidate+ continue+ resolved = shutil.which(binary)+ if resolved:+ return [resolved, *candidate[1:]]++ raise FileNotFoundError("No stable Python launcher available for delayed restart helper")++def _spawn_delayed_restart(command: list[str], cwd: str, delay_seconds: float = 2.0) -> None:helper_code = ("import subprocess, time\n"@@ -50,8 +75,9 @@ def _spawn_delayed_restart(command: list[str], cwd: str, delay_seconds: float =f"subprocess.Popen({command!r}, cwd={cwd!r}, stdout=subprocess.DEVNULL, ""stderr=subprocess.DEVNULL, close_fds=True)\n")+ helper_cmd = [*_delayed_restart_helper_command(), "-c", helper_code]subprocess.Popen(- [sys.executable, "-c", helper_code],+ helper_cmd,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,start_new_session=True,diff --git a/vibe/runtime.py b/vibe/runtime.pyindex 229942d93..5b1c7eb92 100644--- a/vibe/runtime.py+++ b/vibe/runtime.py@@ -254,7 +254,10 @@ def stop_pid(pid: int, timeout: float = 5) -> bool:if os.name == "nt":return _terminate_process_windows(pid, timeout=timeout)- os.kill(pid, signal.SIGTERM)+ try:+ os.kill(pid, signal.SIGTERM)+ except ProcessLookupError:+ return Falsedeadline = time.monotonic() + timeoutwhile time.monotonic() < deadline:if not pid_alive(pid):@@ -262,6 +265,8 @@ def stop_pid(pid: int, timeout: float = 5) -> bool:time.sleep(0.2)try:os.kill(pid, signal.SIGKILL)+ except ProcessLookupError:+ return Trueexcept OSError:passreturn True