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): parse latest tunnel origin log

cyh6ddf40332828
diff --git a/tests/test_remote_access_vibe_cloud.py b/tests/test_remote_access_vibe_cloud.py
index 824a2d893..e3976073f 100644
--- a/tests/test_remote_access_vibe_cloud.py
+++ b/tests/test_remote_access_vibe_cloud.py
@@ -198,6 +198,18 @@ def test_observed_cloudflared_origin_service_reads_only_log_tail(monkeypatch, tm
assert remote_access._observed_cloudflared_origin_service() == "http://new.local:5123"
+def test_observed_cloudflared_origin_service_uses_latest_mixed_log_format(monkeypatch, tmp_path) -> None:
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ remote_access._cloudflared_stderr_path().parent.mkdir(parents=True, exist_ok=True)
+ remote_access._cloudflared_stderr_path().write_text(
+ 'ERR originService=http://100.97.103.112:5123\n'
+ 'INF Updated to new configuration config="{\\"ingress\\":[{\\"service\\":\\"http://127.0.0.1:5123\\"}]}"\n',
+ encoding="utf-8",
+ )
+
+ assert remote_access._observed_cloudflared_origin_service() == "http://127.0.0.1:5123"
+
+
def test_report_runtime_status_posts_to_backend(monkeypatch, tmp_path) -> None:
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
config = _config()
diff --git a/vibe/remote_access.py b/vibe/remote_access.py
index 5a95def33..3b6b7eab3 100644
--- a/vibe/remote_access.py
+++ b/vibe/remote_access.py
@@ -260,16 +260,15 @@ def _observed_cloudflared_origin_service() -> str | None:
content = _read_text_tail(_cloudflared_stderr_path(), STATUS_LOG_TAIL_BYTES)
if content is None:
return None
- patterns = (
- r'originService=([^\s"]+)',
- r'\\"service\\":\\"(http://[^"\\]+)\\"',
- r'"service":"(http://[^"]+)"',
+ pattern = re.compile(
+ r'originService=([^\s"]+)'
+ r'|\\"service\\":\\"(http://[^"\\]+)\\"'
+ r'|(?<!\\)"service":"(http://[^"]+)"'
)
- for pattern in patterns:
- matches = re.findall(pattern, content)
- if matches:
- return str(matches[-1])
- return None
+ last_origin = None
+ for match in pattern.finditer(content):
+ last_origin = next((group for group in match.groups() if group), None)
+ return str(last_origin) if last_origin else None
def _running_signature(pid: int | None) -> dict[str, str] | None: