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

+1
View File
@@ -973,6 +973,7 @@ class WebUICommandRouter:
self.request_tasks.clear()
self.request_locks.clear()
self.request_operations.clear()
await self._http_router.settings_routes.close()
self.gateway.tokens.clear()
self.gateway.endpoint.clear()
self._temporary_chats.close()
+16
View File
@@ -9,6 +9,7 @@ from nanobot.optional_features import (
OptionalFeatureError,
disable_optional_feature,
enable_optional_feature,
install_optional_feature_support,
optional_features_payload,
)
from nanobot.webui.http_utils import query_first
@@ -42,9 +43,24 @@ def nanobot_features_action(
) -> dict[str, Any]:
name = (query_first(query, "name") or "").strip()
instance_id = nanobot_feature_instance_target(query)
raw_install_only = query_first(query, "install_only")
install_only = False
if raw_install_only is not None:
normalized = raw_install_only.strip().lower()
if normalized not in {"1", "0", "true", "false", "yes", "no"}:
raise OptionalFeatureError("install_only must be boolean")
install_only = normalized in {"1", "true", "yes"}
if action != "enable":
raise OptionalFeatureError("install_only is only supported for enable actions")
if not name:
raise OptionalFeatureError("missing feature name")
if action == "enable":
if install_only:
return install_optional_feature_support(
name,
config_path=config_path,
allow_install=allow_install,
)
return enable_optional_feature(
name,
config_path=config_path,
+4
View File
@@ -258,6 +258,10 @@ class WebUISettingsRouter:
)
self._system = system_domain.SystemSettingsHandler(settings, logger)
async def close(self) -> None:
"""Release state owned by settings domains."""
await self._system.close()
async def dispatch(
self,
connection: Any,
+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,