towerops/test/towerops_web/channels
Graham McIntire 303c64ceae fix: set last_heartbeat_db_update on agent join to fix offline detection (#142)
When an agent joins, we update last_seen_at in the database but don't set
last_heartbeat_db_update in the socket. This causes the heartbeat throttling
logic to be out of sync:

- On join: DB updated, but last_heartbeat_db_update not set (nil)
- First heartbeat: Updates DB again because last_heartbeat_db_update is nil
- Subsequent heartbeats: Check if >30s since last DB update
- Problem: last_heartbeat_db_update tracks the first heartbeat, not the join DB update

This manifests when Phoenix recompiles during development - the channel process
continues running with old socket assigns, and if last_heartbeat_db_update is
recent, heartbeats won't update the DB. After 10+ minutes without DB updates,
the agent appears offline even though it's still connected.

Fix: Set last_heartbeat_db_update when we update the DB on join, so the
throttling logic accurately tracks the most recent DB update.

Reviewed-on: graham/towerops-web#142
2026-03-24 12:19:13 -05:00
..
agent_channel_check_proto_test.exs Rewrite protobuf encoding/decoding in pure Gleam with integrated validation (#104) 2026-03-21 16:08:40 -05:00
agent_channel_test.exs fix: set last_heartbeat_db_update on agent join to fix offline detection (#142) 2026-03-24 12:19:13 -05:00
mobile_channel_test.exs add mobile app websocket channel and improve QR linking UX 2026-03-13 17:28:36 -05:00
mobile_socket_test.exs add mobile app websocket channel and improve QR linking UX 2026-03-13 17:28:36 -05:00