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:
1 parent
3cc3012b3a
commit
e8a29a0087
291 files changed
+12194
-3979
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from collections.abc import Iterable
|
||||
from copy import deepcopy
|
||||
from dataclasses import dataclass
|
||||
@@ -11,7 +12,7 @@ from typing import TYPE_CHECKING, Any, Callable, Literal, TypeGuard, cast
|
||||
if TYPE_CHECKING:
|
||||
from nanobot.channels.plugin import ChannelPlugin
|
||||
|
||||
FieldKind = Literal["string", "secret", "list", "bool", "int", "enum"]
|
||||
FieldKind = Literal["string", "secret", "list", "bool", "int", "float", "json", "enum"]
|
||||
RouteFieldType = str | tuple[str, set[str]]
|
||||
|
||||
|
||||
@@ -162,6 +163,7 @@ class ChannelSetupSpec:
|
||||
required: tuple[SetupRequirement, ...] = ()
|
||||
official_url: str | None = None
|
||||
validator: SetupValidator | None = None
|
||||
verifies_connection: bool = False
|
||||
|
||||
@property
|
||||
def secrets(self) -> frozenset[str]:
|
||||
@@ -211,9 +213,20 @@ class ChannelSetupSpec:
|
||||
fields.append(public_field)
|
||||
payload: dict[str, Any] = {
|
||||
"fields": fields,
|
||||
"requirements": [
|
||||
{
|
||||
"alternatives": [
|
||||
[f"channels.{channel_name}.{name}" for name in alternative]
|
||||
for alternative in requirement.alternatives
|
||||
]
|
||||
}
|
||||
for requirement in self.required
|
||||
],
|
||||
}
|
||||
if self.official_url:
|
||||
payload["official_url"] = self.official_url
|
||||
if self.verifies_connection:
|
||||
payload["verifies_connection"] = True
|
||||
return payload
|
||||
|
||||
|
||||
@@ -572,6 +585,8 @@ def stringify_channel_value(value: Any) -> str:
|
||||
return "true" if value else "false"
|
||||
if isinstance(value, list):
|
||||
return ", ".join(str(item) for item in cast(list[Any], value))
|
||||
if isinstance(value, dict):
|
||||
return json.dumps(value, ensure_ascii=False, indent=2)
|
||||
return str(value)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user