From 739304b00dc92bafbb6f7a5c860f7316550e891c Mon Sep 17 00:00:00 2001 From: ThreeFish Date: Thu, 28 May 2026 17:06:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(routes):=20GET=20/=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=87=8D=E5=AE=9A=E5=90=91=E8=87=B3=20/dashboard;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将根路径的 HEAD 与 GET handler 拆分:HEAD / 保持 200 响应(Claude Code 连通性探针依赖), GET / 改为 307 Temporary Redirect 至 /dashboard,提升浏览器访问体验。 同步更新单元测试与 E2E 测试的断言。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang --- src/coding/proxy/server/routes.py | 10 +++++++--- tests/e2e/test_e2e_http.py | 7 +++++-- tests/test_app_routes.py | 9 +++++---- 3 files changed, 17 insertions(+), 9 deletions(-) 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 透传 ──────────────────────────────────────── From 8c467194d9bbe4638aa4b244e4f8ff61c4e3fec9 Mon Sep 17 00:00:00 2001 From: ThreeFish Date: Thu, 28 May 2026 17:13:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf(dashboard):=20=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=8A=B6=E6=80=81=E8=BD=AE=E8=AF=A2=E9=97=B4?= =?UTF-8?q?=E9=9A=94=E4=BB=8E=201.5s=20=E6=94=BE=E5=AE=BD=E8=87=B3=2010s?= =?UTF-8?q?=20=E4=BB=A5=E9=99=8D=E4=BD=8E=E5=90=8E=E7=AB=AF=E8=B4=9F?= =?UTF-8?q?=E8=BD=BD;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang --- src/coding/proxy/server/dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }