refactor(web): move WebChannel into channel/web/channel.py

The channel and the request handlers were in one module because they shared
helpers; with those in _common there was one thing left holding them together,
a WebChannel method reading ConfigHandler.PROVIDER_MODELS, and that table is
now in providers. WebChannel needs nothing else from the handler module.

The URL table moves with the handlers rather than with the channel, to module
scope as URLS next to the build_app() that feeds it to web.py -- the names in
it are resolved out of the namespace they are defined in, so the table has to
live where the handlers do. WebChannel now asks for the app instead of
assembling one, and imports build_app inside startup(): web_channel.py imports
this module, and by the time startup() runs it is always already imported,
since channel_factory only ever reaches the class through it.

web_channel.py keeps re-exporting WebChannel and SERVING, which app.py and
channel_factory resolve by name through this module.

Two tests imported helpers straight out of web_channel and now take them from
_common, where they live.

Co-authored-by: cowagent <cow@cowagent.ai>
This commit is contained in:
zhayujieandcowagent committed 2026-09-17 15:31:20 +08:00
1 parent 2d897f04ab
commit dc60baa60d
5 files changed
+1654 -1597

No files matched your search

File diff suppressed because it is too large. Load diff
+112 -1594
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -548,7 +548,7 @@ class TestMentionParsing:
@staticmethod
def _resolve(text, roster=None):
from channel.web.web_channel import _addressed_agent_id
from channel.web._common import _addressed_agent_id
if roster is None:
roster = TestMentionParsing.ROSTER
+1 -1
View File
@@ -28,7 +28,7 @@ except ImportError:
web_stub.seeother = lambda *args, **kwargs: Exception("seeother")
sys.modules["web"] = web_stub
from channel.web.web_channel import _log_bind_failure # noqa: E402
from channel.web._common import _log_bind_failure # noqa: E402
class _WinError(OSError):
+1 -1
View File
@@ -153,7 +153,7 @@ def test_the_router_loads_after_the_navigation_it_drives():
def _backend_urls():
with open(os.path.join(WEB, "web_channel.py"), encoding="utf-8") as f:
source = f.read()
table = re.search(r"\n urls = \((.*?)\n \)", source, re.S)
table = re.search(r"\nURLS = \((.*?)\n\)", source, re.S)
assert table, "the URL table is no longer where the tests can read it"
return table.group(1)