feat(webui): improve setup flows across chat channels (NAN-112) (#5356)

* feat(webui): improve channel setup flows

* fix(webui): refine channel setup interactions (NAN-112)

* fix(webui): keep email setup sections channel-owned

* fix(webui): remove concrete channel details from shared components

* refactor(webui): remove unused channel setup resources

* fix(webui): finish channel-owned setup boundaries

* fix(webui): update channel switches optimistically

* test(channels): remove obsolete absence assertions

* fix(webui): flatten channel instance settings disclosure

* fix(webui): complete channel setup and connection flows

* fix(whatsapp): wait for session database release

* fix(webui): preserve scrolling channel controls

* fix(webui): stage channel connection checks

* fix(channels): align verification actions

* fix(email): expose connection checks

* fix(webui): align channel field actions

* fix(email): verify account credentials

* fix(wecom): bypass system proxy for websocket

* fix(channels): stabilize async connection cleanup

* fix(webui): autosave channel credentials

* fix(email): make provider presets non-destructive

* test(weixin): isolate persisted QR credentials
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-11 15:22:14 +08:00
1 parent 3cc3012b3a
commit e8a29a0087
291 files changed
+12194 -3979

No files matched your search

+52 -6
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio
import inspect
import json
import re
import time
from collections.abc import Callable, Iterable, Mapping
@@ -265,6 +266,8 @@ def coerce_channel_value(
allowed = None
if kind in {"string", "secret"}:
if kind == "secret" and raw_value is None:
return ""
value = raw_value.strip() if isinstance(raw_value, str) else str(raw_value)
if kind == "secret" and not value:
return _SKIP_FIELD
@@ -291,6 +294,25 @@ def coerce_channel_value(
except (TypeError, ValueError) as exc:
raise WebUISettingsError(f"'{raw_key}' must be a number") from exc
if kind == "float":
if raw_value in (None, ""):
return _SKIP_FIELD
try:
return float(raw_value)
except (TypeError, ValueError) as exc:
raise WebUISettingsError(f"'{raw_key}' must be a number") from exc
if kind == "json":
if raw_value in (None, ""):
return _SKIP_FIELD
try:
value = json.loads(raw_value) if isinstance(raw_value, str) else raw_value
except (TypeError, ValueError) as exc:
raise WebUISettingsError(f"'{raw_key}' must be valid JSON") from exc
if not isinstance(value, dict):
raise WebUISettingsError(f"'{raw_key}' must be a JSON object")
return cast(dict[str, Any], value)
if kind == "bool":
if isinstance(raw_value, bool):
return raw_value
@@ -366,6 +388,24 @@ class SystemSettingsHandler:
self.logger = logger
self._channel_connectors: dict[str, Any] = {}
async def close(self) -> None:
"""Release channel-owned setup sessions during gateway shutdown."""
connectors = tuple(self._channel_connectors.items())
self._channel_connectors.clear()
for channel_name, connector in connectors:
close = getattr(connector, "close", None)
if not callable(close):
continue
try:
result = close()
if inspect.isawaitable(result):
await result
except Exception:
self.logger.exception(
"failed to close {} WebUI connector",
channel_name,
)
async def handle(
self,
action: str,
@@ -524,6 +564,11 @@ class SystemSettingsHandler:
action: str,
operations: SystemSettingsOperations,
) -> SettingsRouteResult:
install_only = (
action == "enable"
and (query_first(request.query, "install_only") or "").strip().lower()
in {"1", "true", "yes"}
)
try:
payload = await asyncio.to_thread(
self._nanobot_features_action,
@@ -546,12 +591,13 @@ class SystemSettingsHandler:
action,
)
return SettingsRouteResult.failure(status, message)
payload = await self._apply_feature_runtime_change(
action,
request.query,
payload,
operations,
)
if not install_only:
payload = await self._apply_feature_runtime_change(
action,
request.query,
payload,
operations,
)
payload = self._with_channel_runtime_status(payload, operations)
return SettingsRouteResult.success(
payload,