aboutsummaryrefslogtreecommitdiff
path: root/app/ui/hub.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-26 03:02:23 -0400
committerhistoria <historiavg@proton.me>2026-08-26 03:02:23 -0400
commitc147087c9d4707bffaeee58d390653637a21cce8 (patch)
treeb080c40eaa388609dea38c2cc413cb912aa7b4af /app/ui/hub.py
parent8b5c8697740ff415cf7f1d03c9fb5a8c8851d420 (diff)
downloadtts-audiobook-generator-c147087c9d4707bffaeee58d390653637a21cce8.tar.gz
refactor: put shared ui screen code into ui.viewkit
Diffstat (limited to 'app/ui/hub.py')
-rw-r--r--app/ui/hub.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/ui/hub.py b/app/ui/hub.py
index 5f29ed1..1c0cafa 100644
--- a/app/ui/hub.py
+++ b/app/ui/hub.py
@@ -36,6 +36,7 @@ from backends import (
ServerSpec,
common,
detect_all,
+ invalidate_detect_cache,
get,
servers,
)
@@ -217,9 +218,11 @@ class _Hub:
return self.screen_uninstall
if choice == "download_models":
_download_models_action(self.stdscr)
+ invalidate_detect_cache()
continue # an inline action: re-show this same menu
if choice == "build_audiocpp":
audiocpp_backend.build_screen(self.stdscr)
+ invalidate_detect_cache()
continue # an inline action: re-show this same menu
_kind, key = choice
info = get(key)
@@ -236,6 +239,7 @@ class _Hub:
"""
def screen():
self._run_setup(info)
+ invalidate_detect_cache()
return tui.Wizard.BACK
return screen
@@ -290,6 +294,7 @@ class _Hub:
lambda emit, cancel: info.uninstall(emit=emit, cancel=cancel))
rc = taskview.run_steps(self.stdscr, title, [step],
wait_on_finish=False)
+ invalidate_detect_cache()
# The uninstallers warn-and-continue (a failed pip step still
# returns 0), so rc == 0 means "finished"; anything else covers a
# failure or an Esc-cancelled run between phases.
@@ -398,6 +403,7 @@ class _Hub:
self.stdscr.timeout(-1)
except Exception:
pass
+ invalidate_detect_cache()
return False
# -- settings -------------------------------------------------------
@@ -490,6 +496,7 @@ class _Hub:
wait_on_finish=False)
# Re-check the server instead of trusting the step's exit code
# (cancel and failure both come back non-zero): did the toggle take?
+ invalidate_detect_cache()
now_running = common.server_running(spec.url)
if action == "start" and not now_running:
tui.flash(self.stdscr, f"Could not start the {spec.name} "
@@ -1391,6 +1398,8 @@ def _apply_settings(values: dict) -> None:
if not common.update_config_value(name, value):
raise ValueError(f"Could not save {name} to "
f"{common.CONFIG_PATH}")
+ # Ports/URLs may have changed: the cached backend statuses are stale.
+ invalidate_detect_cache()
def _read_port(values: dict, key: str) -> int:
@@ -1465,7 +1474,8 @@ def _prepare_run_config(backend: str, kwargs: dict
server_url=api_url, server_identity=identity,
log_path=log_path, stop_and_exit=stop_and_exit)
- status = next((s for s in detect_all() if s.key == backend), None)
+ status = next((s for s in detect_all(refresh=True)
+ if s.key == backend), None)
notice = ""
spec: Optional[ServerSpec] = None
if autostart:
@@ -1536,7 +1546,7 @@ def _select_spec(status, kwargs) -> Optional[ServerSpec]:
def _find_spec(name: str) -> Optional[ServerSpec]:
"""Look up a server spec by name across every backend's detect()."""
- for st in detect_all():
+ for st in detect_all(refresh=True):
for spec in st.servers:
if spec.name == name:
return spec