eleven / messenger Public

web: only show 'Reconnecting…' on sustained outages, not brief blips

Defer the reconnect pill by 2.5s and cancel it on a successful reopen, so quick reconnects (the common case, ~1.5s) show nothing. A genuine, lasting outage still surfaces the pill so you know the feed isn't live.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Paul Campbell 2054f46452c57af008c2c54fd2145a55c0c8e3cd parent 3b2c611
1 file changed, +12 −1
  • web/static/chat.js +12 −1
diff --git a/web/static/chat.js b/web/static/chat.js
index c916782..bae10bf 100644
--- a/web/static/chat.js
+++ b/web/static/chat.js
@@ -761,6 +761,13 @@ async function start(session) {
// 2) Live updates over WebSocket, with reconnect + gap fill.
let ws;
let pingTimer = null;
+ // Only surface "Reconnecting…" once an outage has actually persisted — quick
+ // blips reconnect within ~1.5s and shouldn't flash anything at all.
+ let reconnectBannerTimer = null;
+ const clearReconnectBanner = () => {
+ if (reconnectBannerTimer) clearTimeout(reconnectBannerTimer);
+ reconnectBannerTimer = null;
+ };
const stopPing = () => {
if (pingTimer) clearInterval(pingTimer);
pingTimer = null;
@@ -778,6 +785,7 @@ async function start(session) {
const proto = location.protocol === "https:" ? "wss" : "ws";
ws = new WebSocket(`${proto}://${location.host}/ws?token=${encodeURIComponent(session.token)}`);
ws.onopen = async () => {
+ clearReconnectBanner();
showBanner("", false);
startPing();
// Fill anything missed while disconnected.
@@ -797,7 +805,10 @@ async function start(session) {
};
ws.onclose = () => {
stopPing();
- showBanner("Reconnecting…", false);
+ // Show the pill only if we're still down after a moment (not on quick blips).
+ if (!reconnectBannerTimer) {
+ reconnectBannerTimer = setTimeout(() => showBanner("Reconnecting…", false), 2500);
+ }
setTimeout(connect, 1500);
};
ws.onerror = () => ws.close();