refactor(webui): separate gateway mutations and UI state (#6727)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-19 22:22:51 +08:00
1 parent ce12bfdd0d
commit 5537bdabd3
70 files changed
+4058 -3650

No files matched your search

+2 -10
View File
@@ -1,10 +1,6 @@
from __future__ import annotations
from types import SimpleNamespace
from typing import cast
from websockets.datastructures import Headers
from websockets.http11 import Request as WsRequest
from nanobot.channels.websocket.runtime import WebSocketConfig
from nanobot.webui.ws_http import GatewayHTTPHandler
@@ -16,14 +12,10 @@ def _handler(config: WebSocketConfig) -> GatewayHTTPHandler:
return handler
def _request(**headers: str) -> WsRequest:
return cast(WsRequest, SimpleNamespace(headers=Headers(headers)))
def test_mcp_oauth_callback_uses_configured_public_websocket_origin() -> None:
handler = _handler(WebSocketConfig(path="/ws", public_ws_url="wss://agent.example/ws"))
redirect_uri = handler._mcp_oauth_redirect_uri(_request(Host="ignored.example"))
redirect_uri = handler._mcp_oauth_redirect_uri(Headers({"Host": "ignored.example"}))
assert redirect_uri == "https://agent.example/auth/mcp/callback"
@@ -32,7 +24,7 @@ def test_mcp_oauth_callback_uses_safe_forwarded_request_origin() -> None:
handler = _handler(WebSocketConfig(path="/ws", host="127.0.0.1", port=8765))
redirect_uri = handler._mcp_oauth_redirect_uri(
_request(Host="nanobot.example:9443", **{"X-Forwarded-Proto": "https"})
Headers({"Host": "nanobot.example:9443", "X-Forwarded-Proto": "https"})
)
assert redirect_uri == "https://nanobot.example:9443/auth/mcp/callback"