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
Validate UI pid ownership before reuse
cyh741d1247bd8f
diff --git a/tests/test_vibe_cli.py b/tests/test_vibe_cli.pyindex 969bbb6cc..e278787f3 100644--- a/tests/test_vibe_cli.py+++ b/tests/test_vibe_cli.py@@ -418,6 +418,16 @@ def test_start_ui_reuses_existing_live_pid(tmp_path, monkeypatch):monkeypatch.setattr(runtime, "pid_alive", lambda pid: pid == 12345)monkeypatch.setattr(runtime, "ui_server_healthy", lambda host, port: host == "127.0.0.1" and port == 5123)+ monkeypatch.setattr(+ runtime,+ "get_process_command",+ lambda pid: (+ f"{sys.executable} -c "+ "\"from vibe.ui_server import run_ui_server; run_ui_server('127.0.0.1', 5123)\""+ if pid == 12345+ else None+ ),+ )def fail_spawn(*_args, **_kwargs):raise AssertionError("start_ui should not spawn when an existing UI process is healthy")@@ -427,6 +437,30 @@ def test_start_ui_reuses_existing_live_pid(tmp_path, monkeypatch):assert runtime.start_ui("127.0.0.1", 5123) == 12345+def test_start_ui_does_not_reuse_unrelated_pid_with_healthy_endpoint(tmp_path, monkeypatch):+ monkeypatch.setattr(paths, "get_vibe_remote_dir", lambda: tmp_path / ".vibe_remote")+ runtime.ensure_dirs()+ paths.get_runtime_ui_pid_path().write_text("12345", encoding="utf-8")++ monkeypatch.setattr(runtime, "pid_alive", lambda pid: pid == 12345)+ monkeypatch.setattr(runtime, "ui_server_healthy", lambda host, port: True)+ monkeypatch.setattr(runtime, "get_process_command", lambda pid: "/usr/bin/unrelated --work" if pid == 12345 else None)+ monkeypatch.setattr(runtime, "wait_for_ui_server", lambda host, port: True)++ def fail_stop(pid, timeout=5):+ raise AssertionError(f"unrelated pid should not be stopped: {pid}")++ def fake_spawn(args, pid_path, stdout_name, stderr_name, env=None):+ pid_path.write_text("67890", encoding="utf-8")+ return 67890++ monkeypatch.setattr(runtime, "stop_pid", fail_stop)+ monkeypatch.setattr(runtime, "spawn_background", fake_spawn)++ assert runtime.start_ui("127.0.0.1", 5123) == 67890+ assert paths.get_runtime_ui_pid_path().read_text(encoding="utf-8") == "67890"++def test_start_ui_replaces_stale_live_pid_when_health_check_fails(tmp_path, monkeypatch):monkeypatch.setattr(paths, "get_vibe_remote_dir", lambda: tmp_path / ".vibe_remote")runtime.ensure_dirs()diff --git a/vibe/runtime.py b/vibe/runtime.pyindex 25bc7ccca..71db29ba4 100644--- a/vibe/runtime.py+++ b/vibe/runtime.py@@ -600,9 +600,9 @@ def start_ui(host, port):existing_pid = int(pid_path.read_text(encoding="utf-8").strip())except Exception:existing_pid = 0- if existing_pid and pid_alive(existing_pid) and ui_server_healthy(host, port):- return existing_pidif existing_pid and pid_alive(existing_pid):+ if _pid_matches_ui_server(existing_pid) and ui_server_healthy(host, port):+ return existing_pidif _pid_matches_ui_server(existing_pid):logger.warning("Stopping stale UI process pid=%s because health check failed for %s",