|
@@ -45,6 +45,7 @@ class AssistantTUI(App):
|
|
|
self._seen_transcripts = 0
|
|
self._seen_transcripts = 0
|
|
|
self._seen_lower = 0
|
|
self._seen_lower = 0
|
|
|
self._seen_epoch = 0
|
|
self._seen_epoch = 0
|
|
|
|
|
+ self._timer = None
|
|
|
|
|
|
|
|
def compose(self) -> ComposeResult:
|
|
def compose(self) -> ComposeResult:
|
|
|
yield Static(id="status")
|
|
yield Static(id="status")
|
|
@@ -71,7 +72,7 @@ class AssistantTUI(App):
|
|
|
self.client.start(
|
|
self.client.start(
|
|
|
lambda event: self._events.put(event), on_state=self._on_conn_state
|
|
lambda event: self._events.put(event), on_state=self._on_conn_state
|
|
|
)
|
|
)
|
|
|
- self.set_interval(0.1, self._drain)
|
|
|
|
|
|
|
+ self._timer = self.set_interval(0.1, self._drain)
|
|
|
|
|
|
|
|
def _on_conn_state(self, connected: bool) -> None:
|
|
def _on_conn_state(self, connected: bool) -> None:
|
|
|
self.state.connected = connected
|
|
self.state.connected = connected
|
|
@@ -86,6 +87,10 @@ class AssistantTUI(App):
|
|
|
self._render()
|
|
self._render()
|
|
|
|
|
|
|
|
def _render(self) -> None:
|
|
def _render(self) -> None:
|
|
|
|
|
+ if not self.query("#status"):
|
|
|
|
|
+ # A timer tick can land while the app is shutting down, after the
|
|
|
|
|
+ # widgets are unmounted; there is nothing left to draw into.
|
|
|
|
|
+ return
|
|
|
state = self.state
|
|
state = self.state
|
|
|
health = "ok" if state.health_ok() else "DOWN"
|
|
health = "ok" if state.health_ok() else "DOWN"
|
|
|
conn = "ok" if state.connected else "LOST"
|
|
conn = "ok" if state.connected else "LOST"
|
|
@@ -149,6 +154,8 @@ class AssistantTUI(App):
|
|
|
edit.display = False
|
|
edit.display = False
|
|
|
|
|
|
|
|
def on_unmount(self) -> None:
|
|
def on_unmount(self) -> None:
|
|
|
|
|
+ if self._timer is not None:
|
|
|
|
|
+ self._timer.stop()
|
|
|
self.client.close()
|
|
self.client.close()
|
|
|
|
|
|
|
|
|
|
|