fix: zero-session devices show 'No sessions' tile + grace period prevents flapping

Two federation UX fixes:

1. Zero-session devices: when remote returns empty sessions list, return
   {status: 'empty'} entry. Frontend renders 'No sessions' status tile
   instead of making the device invisible.

2. Flapping prevention: server-side cache of last-known-good federation
   results per remote. On transient failure, return cached sessions for
   up to 3 consecutive failures before marking unreachable. Eliminates
   the visible on/off/on/off pattern caused by occasional 5-second
   timeouts during 2-second poll cycles.

Tests added:
- test_fetch_remote_returns_empty_status_for_zero_sessions (Python)
- test_fetch_remote_uses_cache_on_transient_failure (Python)
- test_fetch_remote_marks_unreachable_after_grace_period (Python)
- renderGrid shows 'No sessions' status tile for status=empty devices (JS)

Also adds reset_federation_cache autouse fixture to prevent cross-test
contamination from the new module-level _federation_cache dict.
This commit is contained in:
Brian Krabach
2026-04-13 14:12:18 -07:00
parent 26a4d30d6f
commit f7519a8058
5 changed files with 305 additions and 3 deletions
+5
View File
@@ -1002,6 +1002,11 @@ body {
border-style: dashed;
}
.source-tile--empty {
opacity: 0.6;
border-style: dashed;
}
.source-tile__name {
font-size: 15px;
font-weight: 600;