diff options
| author | historia <historiavg@proton.me> | 2026-09-01 16:42:15 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-09-01 16:42:15 -0400 |
| commit | 391f50da7a085bec75155c0eb9b47910266058cc (patch) | |
| tree | d443ee758c6f6b74aca9d766ef6ed0e7cc7fb4a3 /app/ui | |
| parent | 6cfcd564c0684c52618235e6366f4a81c02b9a5b (diff) | |
| download | tts-audiobook-generator-391f50da7a085bec75155c0eb9b47910266058cc.tar.gz | |
fix: server status for already-running server
Diffstat (limited to 'app/ui')
| -rw-r--r-- | app/ui/runview.py | 25 |
1 files changed, 21 insertions, 4 deletions
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: |
