From 48b6f390a83f2b4db144bb3dec6ceb8b5a91b603 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 10 Mar 2026 14:10:10 -0500 Subject: [PATCH] fix: handle alert_changed messages in AgentLive.Index The StatusTitleComponent (rendered in authenticated layout) subscribes to organization:*:alerts PubSub topic. Since LiveComponents run in the parent process, both the component and parent LiveView receive these messages. Added catch-all handler to prevent FunctionClauseError when alert changes broadcast. The component already handles the message properly. --- lib/towerops_web/live/agent_live/index.ex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/towerops_web/live/agent_live/index.ex b/lib/towerops_web/live/agent_live/index.ex index 14d48cb8..dac3c101 100644 --- a/lib/towerops_web/live/agent_live/index.ex +++ b/lib/towerops_web/live/agent_live/index.ex @@ -398,6 +398,12 @@ defmodule ToweropsWeb.AgentLive.Index do {:noreply, maybe_update_agent(socket, agent_token_id, organization_id)} end + # Handled by StatusTitleComponent in layout - ignore to prevent crashes + @impl true + def handle_info({:alert_changed, _org_id}, socket) do + {:noreply, socket} + end + @impl true def handle_info({:agents_stale, _stale_agents}, socket) do {:noreply, reload_agent_data(socket)}