Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(whatsapp): passive status paths consult the supervisor, not the wire
trohitgda2c43e18503
diff --git a/server/nodes/whatsapp/_refresh.py b/server/nodes/whatsapp/_refresh.pyindex 2c96f77b..6ffd33dd 100644--- a/server/nodes/whatsapp/_refresh.py+++ b/server/nodes/whatsapp/_refresh.py@@ -34,11 +34,17 @@ async def refresh_whatsapp_status(broadcaster: "StatusBroadcaster") -> None:with tracer.start_as_current_span("broadcaster.refresh_whatsapp") as span:try:from ._events import broadcast_whatsapp_status+ from ._runtime import get_whatsapp_runtimefrom ._service import get_client- # Passive probe: never boot the optional WhatsApp runtime just to- # report its status. Nodes and explicit start/QR commands spawn it- # on demand via get_client(spawn=True).+ # The backend supervises the daemon itself, so the supervisor is+ # the source of truth: dormant runtime => nothing to refresh.+ # No connect attempt, no error path. Nodes and explicit start/QR+ # commands spawn it on demand via get_client(spawn=True).+ if not get_whatsapp_runtime().is_running():+ span.set_attribute("running", False)+ return+client = await get_client(spawn=False)status_data = await client.call("status")diff --git a/server/nodes/whatsapp/_service.py b/server/nodes/whatsapp/_service.pyindex eba6242c..2d136ac5 100644--- a/server/nodes/whatsapp/_service.py+++ b/server/nodes/whatsapp/_service.py@@ -366,6 +366,18 @@ async def get_client(force_reconnect: bool = False, *, spawn: bool = True) -> RPasync def handle_whatsapp_status() -> dict:"""Get WhatsApp connection status via direct RPC and broadcast to all clients."""+ # Supervisor is the source of truth: a dormant runtime means "not+ # running" — answer directly, no RPC client, no connect attempt.+ from nodes.whatsapp import get_whatsapp_runtime++ if not get_whatsapp_runtime().is_running():+ return {+ "success": False,+ "error": "WhatsApp service not running",+ "connected": False,+ "running": False,+ "timestamp": time.time(),+ }try:client = await get_client(spawn=False)status_data = await client.call("status")@@ -406,6 +418,15 @@ async def handle_whatsapp_connected_phone() -> dict:Returns the phone number of the currently connected WhatsApp account,extracted from the device JID."""+ from nodes.whatsapp import get_whatsapp_runtime++ if not get_whatsapp_runtime().is_running():+ return {+ "success": False,+ "error": "WhatsApp service not running",+ "connected_phone": None,+ "timestamp": time.time(),+ }try:client = await get_client(spawn=False)status_data = await client.call("status")