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 latest config snapshot

cyh4c9c49c4dfb3
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 47bf25725..70bfa3c83 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -183,7 +183,7 @@ def test_config_post_rotates_session_secret_when_remote_access_is_disabled(monke
old_secret = config.remote_access.vibe_cloud.session_secret
client = app.test_client()
- monkeypatch.setattr(remote_access, "reconcile", lambda next_config: {"ok": True, "stopped": True})
+ monkeypatch.setattr(remote_access, "reconcile", lambda: {"ok": True, "stopped": True})
response = client.post(
"/config",
@@ -205,7 +205,7 @@ def test_config_post_skips_reconcile_when_remote_access_is_unchanged(monkeypatch
client = app.test_client()
reconcile_calls = []
- monkeypatch.setattr(remote_access, "reconcile", lambda next_config: reconcile_calls.append(next_config) or {"ok": True})
+ monkeypatch.setattr(remote_access, "reconcile", lambda: reconcile_calls.append(True) or {"ok": True})
response = client.post(
"/config",
@@ -224,7 +224,7 @@ def test_config_post_returns_saved_config_when_remote_reconcile_fails(monkeypatc
old_secret = config.remote_access.vibe_cloud.session_secret
client = app.test_client()
- monkeypatch.setattr(remote_access, "reconcile", lambda next_config: {"ok": False, "error": "cloudflared_stop_failed"})
+ monkeypatch.setattr(remote_access, "reconcile", lambda: {"ok": False, "error": "cloudflared_stop_failed"})
response = client.post(
"/config",
@@ -248,7 +248,7 @@ def test_config_post_reconciles_after_releasing_config_lock(monkeypatch, tmp_pat
client = app.test_client()
lock_states = []
- def reconcile(next_config):
+ def reconcile():
lock_states.append(CONFIG_LOCK._is_owned())
return {"ok": True, "stopped": True}
@@ -265,6 +265,29 @@ def test_config_post_reconciles_after_releasing_config_lock(monkeypatch, tmp_pat
assert lock_states == [False]
+def test_config_post_reconciles_from_fresh_config(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ _save_config(tmp_path)
+ client = app.test_client()
+ reconcile_args = []
+
+ def reconcile(*args):
+ reconcile_args.append(args)
+ 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 reconcile_args == [()]
+
+
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/tests/test_vibe_cli.py b/tests/test_vibe_cli.py
index 446e6accb..eeee06bd4 100644
--- a/tests/test_vibe_cli.py
+++ b/tests/test_vibe_cli.py
@@ -2,6 +2,7 @@ import json
import os
import pytest
import signal
+import shlex
import sys
from pathlib import Path
from unittest.mock import patch
@@ -93,6 +94,13 @@ def test_cli_stop_opencode_server_uses_runtime_helpers(tmp_path, monkeypatch):
assert not pid_file.exists()
+def test_proc_cmdline_decode_preserves_argv_boundaries():
+ command = runtime._decode_proc_cmdline(b"/tmp/Vibe Tools/cloudflared\x00tunnel\x00run\x00")
+
+ assert command is not None
+ assert shlex.split(command)[0] == "/tmp/Vibe Tools/cloudflared"
+
+
def test_cmd_restart_schedules_delayed_restart(monkeypatch, capsys):
scheduled = {}
stop_called = []
diff --git a/vibe/runtime.py b/vibe/runtime.py
index 8f7e831dc..c03898ee7 100644
--- a/vibe/runtime.py
+++ b/vibe/runtime.py
@@ -2,6 +2,7 @@ import json
import logging
import os
import signal
+import shlex
import subprocess
import sys
import threading
@@ -207,6 +208,11 @@ def _get_process_command_windows(pid: int) -> str | None:
return None
+def _decode_proc_cmdline(raw: bytes) -> str | None:
+ argv = [part.decode("utf-8", "replace") for part in raw.split(b"\x00") if part]
+ return shlex.join(argv) if argv else None
+
+
def get_process_command(pid: int) -> str | None:
if not isinstance(pid, int) or pid <= 0:
return None
@@ -216,9 +222,9 @@ def get_process_command(pid: int) -> str | None:
proc_cmdline = Path(f"/proc/{pid}/cmdline")
try:
- command = proc_cmdline.read_bytes().replace(b"\x00", b" ").decode("utf-8", "replace").strip()
+ command = _decode_proc_cmdline(proc_cmdline.read_bytes())
except Exception:
- command = ""
+ command = None
if command:
return command
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 703635951..f05dbf3c9 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -634,7 +634,7 @@ def config_post():
remote_access.rotate_session_secret(config)
should_reconcile_remote_access = True
if should_reconcile_remote_access:
- remote_access_runtime = remote_access.reconcile(config)
+ remote_access_runtime = remote_access.reconcile()
response_payload = api.config_to_payload(config)
if remote_access_runtime is not None:
response_payload["remote_access_runtime"] = remote_access_runtime