agent-zero/plugins/_whatsapp_integration/api/test_connection.py
Alessandro 2000ba74a3 ui: redesign email, Telegram, and WhatsApp settings
Redesign the three messaging integration panels with a clearer, more guided
setup flow and polished user experience.

- simplify the email panel by surfacing the essentials first, moving
  advanced scheduling behind Advanced, and making connection checks more
  visible
- redesign Telegram and WhatsApp as step-based setup flows with clearer
  status states, safer access warnings, richer test feedback, and more
  responsive layouts
- add shared plugin-settings wizard footer support, extract WhatsApp state
  into its own store, and align test-connection messages with the new UX

ux: ease Email connector setup and refresh copy

- Redesign the Email connector settings around a guided first-run flow with a clearer empty state, provider presets, and much friendlier copy
- Move server, routing, and scheduling power-user controls into an `Advanced` section while keeping the existing config model compatible
- Improve connection-test messaging, add Exchange inbound validation, and refresh the dashboard Email card copy while keeping the card visible
- Verify the updated setup flow in the browser on desktop and mobile

update and simplify x-data based on established frontend patterns

Update 10_discovery_cards.py

further polishing and first-draft no-click model for email and telegram

update whatsapp

Update telegram-config-store.js
2026-04-11 01:40:24 +02:00

50 lines
1.8 KiB
Python

"""Test WhatsApp bridge connection health."""
from helpers.api import ApiHandler, Request
from helpers.errors import format_error
from helpers import plugins
PLUGIN_NAME = "_whatsapp_integration"
class TestConnection(ApiHandler):
async def process(self, input: dict, request: Request) -> dict:
config = input.get("config") or plugins.get_plugin_config(PLUGIN_NAME) or {}
port = int(config.get("bridge_port", 3100))
results: list[dict] = []
await self._test_bridge(port, results)
ok = all(r["ok"] for r in results)
return {"success": ok, "results": results}
async def _test_bridge(self, port: int, results: list[dict]) -> None:
from plugins._whatsapp_integration.helpers.wa_client import get_health
from plugins._whatsapp_integration.helpers.bridge_manager import get_bridge_url
try:
health = await get_health(get_bridge_url(port))
status = health.get("status", "unknown")
queue = health.get("queueLength", 0)
uptime = health.get("uptime", 0)
if status == "connected":
results.append({
"test": "WhatsApp bridge",
"ok": True,
"message": f"Connected and ready (uptime: {uptime:.0f}s, queue: {queue})",
})
else:
results.append({
"test": "WhatsApp bridge",
"ok": False,
"message": f"The bridge is running, but WhatsApp is not fully connected yet (status: {status}).",
})
except Exception as e:
results.append({
"test": "WhatsApp bridge",
"ok": False,
"message": f"Could not reach the local WhatsApp bridge: {format_error(e)}",
})