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): harden stop and pairing failures
cyh13a93e8e1104
diff --git a/tests/test_remote_access_vibe_cloud.py b/tests/test_remote_access_vibe_cloud.pyindex 0c915bac5..5793c56e1 100644--- a/tests/test_remote_access_vibe_cloud.py+++ b/tests/test_remote_access_vibe_cloud.py@@ -3,7 +3,9 @@ from __future__ import annotationsimport jsonfrom config.v2_config import AgentsConfig, PlatformsConfig, RemoteAccessConfig, RuntimeConfig, SlackConfig, UiConfig, V2Config+from config import pathsfrom vibe import remote_access+from vibe import runtimedef _config() -> V2Config:@@ -70,3 +72,24 @@ def test_pair_redeems_key_and_starts_connector(monkeypatch, tmp_path) -> None:assert saved_payload["remote_access"]["vibe_cloud"]["enabled"] is Trueassert saved_payload["remote_access"]["vibe_cloud"]["tunnel_token"] == "tunnel-token"assert saved_payload["remote_access"]["vibe_cloud"]["session_secret"]+++def test_pair_returns_structured_error_when_backend_request_fails(monkeypatch) -> None:+ monkeypatch.setattr(remote_access, "_json_request", lambda *args, **kwargs: (_ for _ in ()).throw(OSError("offline")))++ result = remote_access.pair("vrp_test", "https://backend.test")++ assert result["ok"] is False+ assert result["error"] == "pairing_request_failed"+ assert "offline" in result["detail"]+++def test_stop_ui_continues_when_remote_access_stop_fails(monkeypatch, tmp_path) -> None:+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ stop_calls = []++ monkeypatch.setattr(remote_access, "stop", lambda: {"ok": False, "error": "cloudflared_stop_failed"})+ monkeypatch.setattr(runtime, "stop_process", lambda pid_path: stop_calls.append(pid_path) or True)++ assert runtime.stop_ui() is False+ assert stop_calls == [paths.get_runtime_ui_pid_path()]diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex 16521820a..348178dc3 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -2,6 +2,7 @@ from __future__ import annotationsfrom config.v2_config import AgentsConfig, PlatformsConfig, RemoteAccessConfig, RuntimeConfig, SlackConfig, UiConfig, V2Configfrom vibe import remote_access+from vibe import ui_serverfrom vibe.ui_server import app@@ -57,3 +58,15 @@ def test_remote_host_allows_valid_remote_session(monkeypatch, tmp_path):response = client.get("/dashboard", base_url="https://alex.vibe.io", follow_redirects=False)assert response.status_code != 302+++def test_remote_host_fails_closed_when_config_load_fails(monkeypatch):+ def fail_load():+ raise ValueError("corrupt config")++ monkeypatch.setattr(ui_server.V2Config, "load", fail_load)++ response = app.test_client().get("/dashboard", base_url="https://alex.vibe.io", follow_redirects=False)++ assert response.status_code == 503+ assert response.get_json()["error"] == "remote_access_config_unavailable"diff --git a/vibe/remote_access.py b/vibe/remote_access.pyindex bfb645361..f006d2a52 100644--- a/vibe/remote_access.py+++ b/vibe/remote_access.py@@ -273,10 +273,13 @@ def pair(pairing_key: str, backend_url: str, device_name: str = "Vibe Remote") -backend_url = (backend_url or "https://vibe.io").strip().rstrip("/")if not pairing_key:return {"ok": False, "error": "missing_pairing_key"}- result = _json_request(- f"{backend_url}/api/v1/pairing/redeem",- {"pairing_key": pairing_key, "device_name": device_name, "local_version": "dev"},- )+ try:+ result = _json_request(+ f"{backend_url}/api/v1/pairing/redeem",+ {"pairing_key": pairing_key, "device_name": device_name, "local_version": "dev"},+ )+ except Exception as exc:+ return {"ok": False, "error": "pairing_request_failed", "detail": str(exc)}required = ("instance_id", "client_id", "issuer", "authorization_endpoint", "token_endpoint", "jwks_uri", "public_url", "redirect_uri", "tunnel_token", "instance_secret")missing = [field for field in required if not result.get(field)]if missing:diff --git a/vibe/runtime.py b/vibe/runtime.pyindex fcfebf5c3..797e318f9 100644--- a/vibe/runtime.py+++ b/vibe/runtime.py@@ -384,14 +384,16 @@ def stop_service():def stop_ui():+ remote_access_stopped = Truetry:from vibe import remote_accessresult = remote_access.stop()if isinstance(result, dict) and result.get("ok") is False:logger.warning("Failed to stop remote access before UI stop: %s", result.get("error"))- return False+ remote_access_stopped = Falseexcept Exception:logger.warning("Failed to stop remote access before UI stop", exc_info=True)- return False- return stop_process(paths.get_runtime_ui_pid_path())+ remote_access_stopped = False+ ui_stopped = stop_process(paths.get_runtime_ui_pid_path())+ return bool(ui_stopped and remote_access_stopped)diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 2d98e1aef..812eb5c90 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -187,9 +187,19 @@ def _load_remote_access_config() -> V2Config | None:try:return V2Config.load()except Exception:+ logger.warning("Failed to load remote access config", exc_info=True)return None+def _is_local_request_host() -> bool:+ raw_host = (request.host or "").lower()+ if raw_host.startswith("[") and "]" in raw_host:+ host = raw_host[1 : raw_host.index("]")]+ else:+ host = raw_host.split(":", 1)[0]+ return host in {"localhost", "127.0.0.1", "::1"} or host.startswith("127.")++def _is_remote_access_request(config: V2Config) -> bool:cloud = config.remote_access.vibe_cloudif not cloud.enabled or not cloud.public_url:@@ -268,7 +278,11 @@ def _redirect_to_vibe_cloud_login(config: V2Config):@app.before_requestdef enforce_remote_access_cookie():config = _load_remote_access_config()- if config is None or not _is_remote_access_request(config) or _remote_auth_exempt_path():+ if config is None:+ if _is_local_request_host():+ return None+ return jsonify({"ok": False, "error": "remote_access_config_unavailable"}), 503+ if not _is_remote_access_request(config) or _remote_auth_exempt_path():return Nonefrom vibe import remote_access