Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(remote-access): reconcile outside config lock

cyha7e5a7043836
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 75dfb82d9..47bf25725 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from config.v2_config import AgentsConfig, PlatformsConfig, RemoteAccessConfig, RuntimeConfig, SlackConfig, UiConfig, V2Config
+from config.v2_config import CONFIG_LOCK
from tests.ui_server_test_helpers import csrf_headers
from vibe import api
from vibe import remote_access
@@ -241,6 +242,29 @@ def test_config_post_returns_saved_config_when_remote_reconcile_fails(monkeypatc
assert saved.remote_access.vibe_cloud.session_secret != old_secret
+def test_config_post_reconciles_after_releasing_config_lock(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ _save_config(tmp_path)
+ client = app.test_client()
+ lock_states = []
+
+ def reconcile(next_config):
+ lock_states.append(CONFIG_LOCK._is_owned())
+ return {"ok": True, "stopped": True}
+
+ monkeypatch.setattr(remote_access, "reconcile", reconcile)
+
+ response = client.post(
+ "/config",
+ json={"remote_access": {"vibe_cloud": {"enabled": False}}},
+ headers=csrf_headers(client, "http://127.0.0.1:5123"),
+ base_url="http://127.0.0.1:5123",
+ )
+
+ assert response.status_code == 200
+ assert lock_states == [False]
+
+
def test_remote_callback_rejects_nonce_mismatch(monkeypatch, tmp_path):
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
config = _save_config(tmp_path)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 7beafa583..703635951 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -625,13 +625,16 @@ def config_post():
payload = request.json or {}
remote_access_runtime = None
+ should_reconcile_remote_access = False
with CONFIG_LOCK:
previous_config = _load_remote_access_config() if "remote_access" in payload else None
config = api.save_config(payload)
if _remote_access_settings_changed(previous_config, config, payload):
if _should_rotate_remote_session_secret(previous_config, config, payload):
remote_access.rotate_session_secret(config)
- remote_access_runtime = remote_access.reconcile(config)
+ should_reconcile_remote_access = True
+ if should_reconcile_remote_access:
+ remote_access_runtime = remote_access.reconcile(config)
response_payload = api.config_to_payload(config)
if remote_access_runtime is not None:
response_payload["remote_access_runtime"] = remote_access_runtime