From 4b49797b4d57c2d2cf63472636622a7a6280a38e Mon Sep 17 00:00:00 2001 From: historia Date: Tue, 25 Aug 2026 18:10:08 -0400 Subject: feat: no console drop when uninstalling backends --- app/backends/qwen.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'app/backends/qwen.py') diff --git a/app/backends/qwen.py b/app/backends/qwen.py index be7ebfe..c6a11bf 100644 --- a/app/backends/qwen.py +++ b/app/backends/qwen.py @@ -354,17 +354,25 @@ def _detect_remote(managed: bool = False): return remote_models, remote_urls -def uninstall() -> int: +def uninstall(*, emit=None, cancel=None) -> int: """Remove the qwen-tts backend entirely: stop its servers, pip uninstall. qwen-tts is a pip package (``qwen_tts`` + the ``qwen-tts-demo`` script) installed into the managed venv, so uninstalling it removes the backend. - Any server this tool started is stopped first (best-effort). Returns the - exit code. + Any server this tool started is stopped first (best-effort). + + With EMIT given (the in-TUI task view) pip runs piped, streaming into + EMIT, so its output never touches the terminal behind curses. CANCEL is + a ``threading.Event`` honored between phases only (after the servers + have been stopped, before pip starts) — a started phase always completes, + so pip is never killed mid-run. Returns the exit code (130 when + cancelled before pip ran). """ servers.stop("qwen-custom") servers.stop("qwen-clone") - rc = common.pip_uninstall([QWEN_PIP_PKG]) + if common.cancel_requested(cancel): + return 130 + rc = common.pip_uninstall([QWEN_PIP_PKG], emit=emit) if rc != 0: print(f"[WARNING] pip uninstall failed (exit {rc}); remove " f"{QWEN_PIP_PKG} from the managed venv manually") -- cgit v1.2.3