diff --git a/src/coding/proxy/server/dashboard.py b/src/coding/proxy/server/dashboard.py index a04e1f9..4c96ef0 100644 --- a/src/coding/proxy/server/dashboard.py +++ b/src/coding/proxy/server/dashboard.py @@ -1350,7 +1350,7 @@ def _build_favicon() -> bytes: }).catch(function() {}); } tick(); - _mcTimer = setInterval(tick, 1500); + _mcTimer = setInterval(tick, 10000); } function stopModelCallingPoll() { if (_mcTimer) { clearInterval(_mcTimer); _mcTimer = null; } diff --git a/src/coding/proxy/server/routes.py b/src/coding/proxy/server/routes.py index 5ed90dc..8b47fd0 100644 --- a/src/coding/proxy/server/routes.py +++ b/src/coding/proxy/server/routes.py @@ -8,7 +8,7 @@ import httpx from fastapi import Request, Response -from fastapi.responses import StreamingResponse +from fastapi.responses import RedirectResponse, StreamingResponse from ..vendors.base import NoCompatibleVendorError @@ -197,11 +197,15 @@ async def health() -> dict: return {"status": "ok"} @app.head("/") - @app.get("/") - async def root() -> Response: + async def root_head() -> Response: """根路径连通性探测 — Claude Code 在建连前发送 HEAD / 作为 health probe.""" return Response(status_code=200) + @app.get("/") + async def root_get() -> RedirectResponse: + """GET / 重定向到 Dashboard.""" + return RedirectResponse(url="/dashboard", status_code=307) + def register_status_route(app: Any, router: Any) -> None: """注册状态查询路由.""" diff --git a/tests/e2e/test_e2e_http.py b/tests/e2e/test_e2e_http.py index fe84db5..442577d 100644 --- a/tests/e2e/test_e2e_http.py +++ b/tests/e2e/test_e2e_http.py @@ -188,13 +188,16 @@ async def test_http_health_probe(e2e_client: object) -> None: ) get_resp = await e2e_client.get("/") - assert get_resp.status_code == 200, f"GET / 预期 200,实际 {get_resp.status_code}" + assert get_resp.status_code == 307, f"GET / 预期 307,实际 {get_resp.status_code}" + assert get_resp.headers["location"] == "/dashboard" health_resp = await e2e_client.get("/health") assert health_resp.status_code == 200 assert health_resp.json() == {"status": "ok"} - print("\n[E2E] HTTP health probe 成功: HEAD /=200, GET /=200, /health=ok") + print( + "\n[E2E] HTTP health probe 成功: HEAD /=200, GET /=307→/dashboard, /health=ok" + ) @pytest.mark.e2e diff --git a/tests/test_app_routes.py b/tests/test_app_routes.py index 4c460e3..39aabe6 100644 --- a/tests/test_app_routes.py +++ b/tests/test_app_routes.py @@ -35,11 +35,12 @@ def test_head_root_returns_200(): assert resp.status_code == 200 -def test_get_root_returns_200(): - """GET / 返回 200.""" +def test_get_root_redirects_to_dashboard(): + """GET / 重定向到 /dashboard.""" with _make_app() as client: - resp = client.get("/") - assert resp.status_code == 200 + resp = client.get("/", follow_redirects=False) + assert resp.status_code == 307 + assert resp.headers["location"] == "/dashboard" # ── count_tokens 透传 ────────────────────────────────────────