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(remote-access): keep connector lock order consistent
cyhc778e72bbcae
diff --git a/tests/test_remote_access_vibe_cloud.py b/tests/test_remote_access_vibe_cloud.pyindex 0fe1782a2..03d8ef1ee 100644--- a/tests/test_remote_access_vibe_cloud.py+++ b/tests/test_remote_access_vibe_cloud.py@@ -274,7 +274,7 @@ def test_start_returns_failure_when_remote_access_is_disabled(monkeypatch, tmp_pconfig = _config()config.remote_access.vibe_cloud.enabled = False- monkeypatch.setattr(remote_access, "stop", lambda: {"ok": True, "stopped": False})+ monkeypatch.setattr(remote_access, "stop", lambda config=None: {"ok": True, "stopped": False})result = remote_access.start(config)@@ -282,12 +282,49 @@ def test_start_returns_failure_when_remote_access_is_disabled(monkeypatch, tmp_passert result["error"] == "remote_access_disabled"+def test_start_loads_config_before_connector_lock(monkeypatch, tmp_path) -> None:+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ config = _config()+ config.remote_access.vibe_cloud.enabled = False+ load_lock_states = []++ def load_config():+ load_lock_states.append(remote_access._CONNECTOR_LOCK._is_owned())+ return config++ monkeypatch.setattr(remote_access.V2Config, "load", load_config)+ monkeypatch.setattr(remote_access, "stop", lambda loaded_config=None: {"ok": True, "stopped": False})++ result = remote_access.start()++ assert result["ok"] is False+ assert result["error"] == "remote_access_disabled"+ assert load_lock_states == [False]+++def test_stop_loads_config_before_connector_lock(monkeypatch, tmp_path) -> None:+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ config = _config()+ load_lock_states = []++ def load_config():+ load_lock_states.append(remote_access._CONNECTOR_LOCK._is_owned())+ return config++ monkeypatch.setattr(remote_access.V2Config, "load", load_config)++ result = remote_access.stop()++ assert result["ok"] is True+ assert load_lock_states == [False]++def test_reconcile_stops_when_remote_access_is_disabled(monkeypatch, tmp_path) -> None:monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))config = _config()config.remote_access.vibe_cloud.enabled = False- monkeypatch.setattr(remote_access, "stop", lambda: {"ok": True, "stopped": True})+ monkeypatch.setattr(remote_access, "stop", lambda next_config=None: {"ok": True, "stopped": True})result = remote_access.reconcile(config)diff --git a/vibe/remote_access.py b/vibe/remote_access.pyindex 763d98177..9f930d6ec 100644--- a/vibe/remote_access.py+++ b/vibe/remote_access.py@@ -254,23 +254,27 @@ def status(config: V2Config | None = None) -> dict[str, Any]:}-def stop() -> dict[str, Any]:+def stop(config: V2Config | None = None) -> dict[str, Any]:+ try:+ config = config or V2Config.load()+ except Exception:+ config = Nonewith _CONNECTOR_LOCK:pid = _read_pid()pid_state = _cloudflared_pid_state(pid)if pid is not None and pid_state == "unknown":- return {**status(), "ok": False, "error": "cloudflared_process_unknown", "stopped": False}+ return {**status(config), "ok": False, "error": "cloudflared_process_unknown", "stopped": False}if pid is not None and pid_state in {"dead", "other"}:_pid_path().unlink(missing_ok=True)_state_path().unlink(missing_ok=True)- return {**status(), "ok": True, "stopped": False, "stale_pid": True}+ return {**status(config), "ok": True, "stopped": False, "stale_pid": True}stopped = runtime.stop_pid(pid, timeout=8) if pid is not None else Falseif stopped:_pid_path().unlink(missing_ok=True)_state_path().unlink(missing_ok=True)if pid is not None and not stopped and _is_cloudflared_pid(pid):- return {**status(), "ok": False, "error": "cloudflared_stop_failed", "stopped": False}- return {**status(), "ok": True, "stopped": stopped}+ return {**status(config), "ok": False, "error": "cloudflared_stop_failed", "stopped": False}+ return {**status(config), "ok": True, "stopped": stopped}def rotate_session_secret(config: V2Config) -> None:@@ -279,14 +283,14 @@ def rotate_session_secret(config: V2Config) -> None:def start(config: V2Config | None = None) -> dict[str, Any]:+ config = config or V2Config.load()with _CONNECTOR_LOCK:- config = config or V2Config.load()cloud = config.remote_access.vibe_cloudif not cloud.enabled:- stop_result = stop()+ stop_result = stop(config)return {**stop_result, "ok": False, "error": "remote_access_disabled"}if not cloud.tunnel_token:- stop_result = stop()+ stop_result = stop(config)return {**stop_result, "ok": False, "error": "missing_tunnel_token"}binary = _resolve_binary(config)if not binary:@@ -302,7 +306,7 @@ def start(config: V2Config | None = None) -> dict[str, Any]:desired_sig = _runtime_signature(config, binary)if running_sig == desired_sig:return {**current, "ok": True, "started": False}- stop_result = stop()+ stop_result = stop(config)if stop_result.get("ok") is False or stop_result.get("running"):return {**stop_result,@@ -333,7 +337,7 @@ def reconcile(config: V2Config | None = None) -> dict[str, Any]:config = config or V2Config.load()if config.remote_access.provider == "vibe_cloud" and config.remote_access.vibe_cloud.enabled:return start(config)- return stop()+ return stop(config)def _json_request(url: str, payload: dict[str, Any], timeout: float = 20.0) -> dict[str, Any]: