From 5b621b95d4a1fd46dda5ed44d6fa6d6bdacc156e Mon Sep 17 00:00:00 2001 From: cemaxecuter Date: Sat, 31 Jan 2026 08:48:32 -0500 Subject: [PATCH] Auto-refresh agent capabilities after monitor mode toggle When monitor mode is toggled on a remote agent, the controller now automatically refreshes the agent's capabilities and updates the database. This keeps the UI interface list in sync without requiring a manual refresh. --- routes/controller.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/routes/controller.py b/routes/controller.py index e46ebc7..3d29ef4 100644 --- a/routes/controller.py +++ b/routes/controller.py @@ -493,6 +493,24 @@ def proxy_wifi_monitor(agent_id: int): client = create_client_from_agent(agent) result = client.post('/wifi/monitor', data) + # Refresh agent capabilities after monitor mode toggle so UI stays in sync + if result.get('status') == 'success': + try: + metadata = client.refresh_metadata() + if metadata.get('healthy'): + caps = metadata.get('capabilities') or {} + agent_interfaces = caps.get('interfaces', {}) + if not agent_interfaces.get('sdr_devices') and caps.get('devices'): + agent_interfaces['sdr_devices'] = caps.get('devices', []) + update_agent( + agent_id, + capabilities=caps.get('modes'), + interfaces=agent_interfaces, + update_last_seen=True + ) + except Exception: + pass # Non-fatal if refresh fails + return jsonify({ 'status': result.get('status', 'error'), 'agent_id': agent_id,