From 391f50da7a085bec75155c0eb9b47910266058cc Mon Sep 17 00:00:00 2001 From: historia Date: Tue, 1 Sep 2026 16:42:15 -0400 Subject: fix: server status for already-running server --- app/ui/runview.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'app/ui/runview.py') diff --git a/app/ui/runview.py b/app/ui/runview.py index 005db59..ff7cfb2 100644 --- a/app/ui/runview.py +++ b/app/ui/runview.py @@ -12,7 +12,10 @@ The screen is fed by two threads the widget spawns: ``backends.servers.start`` (when the conversion needs to boot a managed server; its progress events stream in as they happen) followed by ``audiobook.convert`` with a ``progress`` callback — so behavior is - identical to the CLI, only the presentation differs; + identical to the CLI, only the presentation differs. When the run does + not boot a server itself (one is already running locally, or a remote + ``api_url``), it probes the target first and reports it "running" or + "down" through the same event stream; * a monitor polls the server URL while the conversion runs and reports when it stops answering. @@ -187,7 +190,10 @@ class RunView(ScreenView): self.server = "stopped" self._finish("cancelled") elif kind == "server_down": - if self.phase == "convert": + # The monitor fires this mid-conversion; the worker's boot-time + # probe of a server this run did not start fires it too. Both + # mean the same thing: the target is not answering. + if self.phase not in _TERMINAL: self.server = "down" elif kind == "server_stopped": self.server = "stopped" @@ -302,6 +308,17 @@ class RunView(ScreenView): if self._cancel.is_set(): self._queue.put({"kind": "cancelled"}) return + # When this run does not boot the server itself, the boot + # events never fire — report the target's state so the + # server panel moves past "starting" (or shows "not + # responding" for a target that never answers). + if config.autostart_spec is None and config.server_url: + if common.server_running(config.server_url): + self._queue.put({"kind": "running", + "name": config.server_name or "", + "url": config.server_url}) + else: + self._queue.put({"kind": "server_down"}) # book_files/planned travel on the config fields; dropping # any stray duplicates from kwargs keeps convert()'s call # binding unambiguous. @@ -588,7 +605,7 @@ class RunView(ScreenView): elif self.server == "stopping" and self.stop_started is not None: state_text += f" ({int(self._now() - self.stop_started)}s)" if self.config.autostart_spec is None and self.server == "ready": - state_text += " (external)" + state_text += " (not started by this run)" _text(scr, theme, y, inner_x, "Status".ljust(label_w), theme["dim"]) _text(scr, theme, y, value_x, _fit(state_text, value_w), theme.get(state_kind, theme["body"])) @@ -673,7 +690,7 @@ class RunView(ScreenView): y += 1 elif self.server == "down": _text(scr, theme, y, inner_x, - _fit("the server stopped responding; the conversion " + _fit("the server is not responding; the conversion " "will fail", width - inner_x - 3), theme["err"]) y += 1 elif self.config.notice: -- cgit v1.2.3