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): load the test client only when a test builds one (#2922)

Call Whiteaa3b34447cf1
diff --git a/tests/test_ui_server_reload.py b/tests/test_ui_server_reload.py
index 2090c649b..98a44d639 100644
--- a/tests/test_ui_server_reload.py
+++ b/tests/test_ui_server_reload.py
@@ -2,6 +2,11 @@ from __future__ import annotations
import threading
+# These tests monkeypatch ``threading.Thread`` before building their first test
+# client. The app loads Starlette's client lazily, and its request portal comes
+# from ``anyio.from_thread``, which binds ``threading.Thread`` at import; load it
+# here, before any patch, so anyio keeps the real thread class.
+import fastapi.testclient # noqa: F401
from config.v2_config import (
AgentsConfig,
PlatformsConfig,
diff --git a/vibe/ui_compat.py b/vibe/ui_compat.py
index cde3f4ef8..9cc12dde3 100644
--- a/vibe/ui_compat.py
+++ b/vibe/ui_compat.py
@@ -13,7 +13,6 @@ from urllib.parse import urlsplit
from fastapi import FastAPI, Request as FastAPIRequest
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse, Response as StarletteResponse
-from fastapi.testclient import TestClient
from starlette.concurrency import run_in_threadpool
from starlette.exceptions import HTTPException
from starlette.datastructures import Headers, QueryParams, URL
@@ -279,6 +278,11 @@ class CompatTestResponse:
class CompatTestClient:
def __init__(self, app: "CompatApp") -> None:
+ # Imported here, not at module load: Starlette deprecates its httpx-based
+ # TestClient with a warning on import, and every service and CLI process
+ # imports this module while only tests construct a client.
+ from fastapi.testclient import TestClient
+
self._client = TestClient(app)
self._lock = threading.Lock()