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(ui): tighten aggregated doctor logs

cyh8c9841feba3a
diff --git a/tests/test_ui_server_logs.py b/tests/test_ui_server_logs.py
index 50387920e..88328ec7d 100644
--- a/tests/test_ui_server_logs.py
+++ b/tests/test_ui_server_logs.py
@@ -71,6 +71,78 @@ def test_logs_endpoint_returns_aggregated_all_view(monkeypatch, tmp_path):
assert {entry["source"] for entry in payload["logs"]} == {"service", "service_stderr", "ui_stderr"}
+def test_logs_endpoint_caps_aggregated_all_view_to_requested_lines(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ paths.ensure_data_dirs()
+
+ (paths.get_logs_dir() / "vibe_remote.log").write_text(
+ "\n".join(
+ [
+ "2026-03-25 15:51:17,428 - service.main - INFO - service line 1",
+ "2026-03-25 15:51:18,428 - service.main - INFO - service line 2",
+ ]
+ )
+ + "\n",
+ encoding="utf-8",
+ )
+ (paths.get_runtime_dir() / "service_stderr.log").write_text(
+ "\n".join(
+ [
+ "2026-03-25 15:51:19,428 - service.stderr - ERROR - service stderr line 1",
+ "2026-03-25 15:51:20,428 - service.stderr - ERROR - service stderr line 2",
+ ]
+ )
+ + "\n",
+ encoding="utf-8",
+ )
+ (paths.get_runtime_dir() / "ui_stderr.log").write_text(
+ "\n".join(
+ [
+ "2026-03-25 15:51:21,428 - ui.stderr - ERROR - ui stderr line 1",
+ "2026-03-25 15:51:22,428 - ui.stderr - ERROR - ui stderr line 2",
+ ]
+ )
+ + "\n",
+ encoding="utf-8",
+ )
+
+ client = app.test_client()
+ response = client.post("/logs", json={"lines": 2, "source": "all"})
+
+ assert response.status_code == 200
+ payload = response.get_json()
+ assert payload["source"] == "all"
+ assert payload["total"] == 6
+ assert len(payload["logs"]) == 2
+ assert [entry["message"] for entry in payload["logs"]] == [
+ "ui stderr line 1",
+ "ui stderr line 2",
+ ]
+
+
+def test_logs_endpoint_keeps_traceback_exception_summary_with_error_entry(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ paths.ensure_data_dirs()
+
+ (paths.get_logs_dir() / "vibe_remote.log").write_text(
+ "2026-03-25 15:51:17,428 - asyncio - ERROR - Task was destroyed but it is pending!\n"
+ "Traceback (most recent call last):\n"
+ ' File "/app/core/update_checker.py", line 222, in _check_loop\n'
+ "ValueError: boom\n",
+ encoding="utf-8",
+ )
+
+ client = app.test_client()
+ response = client.post("/logs", json={"lines": 20, "source": "service"})
+
+ assert response.status_code == 200
+ payload = response.get_json()
+ assert payload["source"] == "service"
+ assert len(payload["logs"]) == 1
+ assert payload["logs"][0]["level"] == "ERROR"
+ assert payload["logs"][0]["message"].endswith("ValueError: boom")
+
+
def test_logs_endpoint_falls_back_to_service_for_unknown_source(monkeypatch, tmp_path):
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
paths.ensure_data_dirs()
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 99e2cc3af..e5294c05c 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -27,6 +27,9 @@ log.setLevel(logging.WARNING)
STRUCTURED_LOG_PATTERN = re.compile(r"^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s+-\s+([\w.]+)\s+-\s+(\w+)\s+-\s+(.*)$")
LEVEL_HINT_PATTERN = re.compile(r"\b(DEBUG|INFO|WARNING|ERROR|CRITICAL)\b")
+TRACEBACK_EXCEPTION_PATTERN = re.compile(
+ r"^[A-Za-z_][\w.]*(?:Error|Exception|Warning|Exit|Interrupt|Failure|Fault|Group)(?:[:(]|$)"
+)
LOG_SOURCES = (
("service", "vibe_remote.log", lambda: paths.get_logs_dir() / "vibe_remote.log"),
("service_stdout", "service_stdout.log", lambda: paths.get_runtime_dir() / "service_stdout.log"),
@@ -60,7 +63,7 @@ def _run_async(coro, timeout: float = 10.0) -> dict:
return result
-def _is_continuation_line(line: str) -> bool:
+def _is_continuation_line(line: str, previous_message: str | None = None) -> bool:
stripped = line.lstrip()
return (
line[:1].isspace()
@@ -69,6 +72,11 @@ def _is_continuation_line(line: str) -> bool:
or stripped.startswith("File ")
or stripped.startswith("task:")
or stripped.startswith("^")
+ or (
+ previous_message is not None
+ and "Traceback " in previous_message
+ and bool(TRACEBACK_EXCEPTION_PATTERN.match(stripped))
+ )
)
@@ -113,7 +121,7 @@ def _read_log_entries(log_path: Path, source_key: str, lines: int) -> tuple[list
if not line:
continue
- if logs_list and _is_continuation_line(line):
+ if logs_list and _is_continuation_line(line, logs_list[-1]["message"]):
logs_list[-1]["message"] += "\n" + line
continue
@@ -553,6 +561,8 @@ def logs():
aggregated_logs,
key=lambda entry: (entry.get("timestamp") or "", entry.get("source") or "", entry.get("logger") or ""),
)
+ if len(active_logs) > lines:
+ active_logs = active_logs[-lines:]
active_total = aggregated_total
return jsonify(
{