app: add reconnection status to status bar

This commit is contained in:
Username
2026-02-24 14:54:07 +01:00
parent e443facd3b
commit 6f590ede38

View File

@@ -75,6 +75,7 @@ class StatusBar(Static):
ptt_active = reactive(False)
connected = reactive(False)
reconnecting = reactive(False)
self_deaf = reactive(False)
server_info = reactive("")
output_vol = reactive(100)
@@ -92,6 +93,9 @@ class StatusBar(Static):
if self.connected:
conn_sym = "[#9ece6a]\u25cf[/]"
conn_full = f"{conn_sym} connected"
elif self.reconnecting:
conn_sym = "[#e0af68]\u25d0[/]"
conn_full = f"{conn_sym} reconnecting"
else:
conn_sym = "[#f7768e]\u25cb[/]"
conn_full = f"{conn_sym} disconnected"
@@ -538,6 +542,8 @@ class TuimbleApp(App):
def _log_reconnect(self, attempt: int, delay: int) -> None:
"""Log reconnection attempt to chatlog."""
status = self.query_one("#status", StatusBar)
status.reconnecting = True
chatlog = self.query_one("#chatlog", ChatLog)
chatlog.write(
f"[dim]reconnecting in {delay}s "
@@ -550,6 +556,8 @@ class TuimbleApp(App):
def _on_reconnect_exhausted(self) -> None:
"""Handle all reconnection attempts exhausted."""
status = self.query_one("#status", StatusBar)
status.reconnecting = False
chatlog = self.query_one("#chatlog", ChatLog)
chatlog.write(
f"[#f7768e]reconnection failed after "
@@ -561,6 +569,11 @@ class TuimbleApp(App):
"""Cancel an in-progress reconnect loop."""
self._reconnecting = False
self._reconnect_attempt = 0
try:
status = self.query_one("#status", StatusBar)
status.reconnecting = False
except Exception:
pass
# -- message handlers ----------------------------------------------------
@@ -568,6 +581,7 @@ class TuimbleApp(App):
self._intentional_disconnect = False
status = self.query_one("#status", StatusBar)
status.reconnecting = False
status.connected = True
srv = self._config.server
status.server_info = f"{srv.host}:{srv.port}"