From d04a2c53b926ccde0d582dbf4a7360dc0f072205 Mon Sep 17 00:00:00 2001 From: historia Date: Wed, 2 Sep 2026 22:53:07 -0400 Subject: fix: warn before using a likely too-big chunk size for sglang-omni models --- app/ui/hub.py | 32 ++++++++++++++++++++++++++++++++ app/ui/runview.py | 13 +++++++++++++ 2 files changed, 45 insertions(+) (limited to 'app/ui') diff --git a/app/ui/hub.py b/app/ui/hub.py index 13f17e7..7a6bfcc 100644 --- a/app/ui/hub.py +++ b/app/ui/hub.py @@ -1133,6 +1133,32 @@ def _tui_confirm(stdscr) -> Callable: return confirm +def _tui_chunk_clamp(stdscr, entry) -> Optional[int]: + """The chunk-cap popup for an sglomni run (None = no clamp). + + A model whose catalog entry caps a sub-request below CHUNK_SIZE + (Higgs: the server pins each request's prompt plus generation at a + fixed window) asks before the run: clamp CHUNK_SIZE for this run, + keep it (audio may cut off mid-chunk), or go back to the form. The + answer rides the command's kwargs (``chunk_size``) so the converter + and its client see it; the config.CHUNK_SIZE setting itself is never + rewritten. + """ + if not converter_mod.chunk_clamp_needed(entry): + return None + words = entry.chunk_words + answer = tui.menu( + stdscr, "Generation cap", + [(f"Set Chunk to {words} (this run)", "clamp"), + ("Try anyway", "anyway"), + ("Cancel", "cancel")], + help_lines=converter_mod.chunk_clamp_message(entry), + back_value="cancel") + if answer == "cancel": + raise _BackToForm() + return words if answer == "clamp" else None + + def _check_preflight_plan(stdscr, book_files: list, planned: dict) -> bool: """The shared nothing-to-convert flashes; True when there is a plan. @@ -1180,6 +1206,12 @@ def _preflight(stdscr, cmd: tuple) -> bool: confirm=_tui_confirm(stdscr)) if not _check_preflight_plan(stdscr, book_files, {"": planned}): return False + if backend == BACKEND_SGLOMNI: + entry = sglomni_backend.entry_by_key((kwargs.get("model_id") + or "").strip()) + clamp = _tui_chunk_clamp(stdscr, entry) + if clamp is not None: + kwargs["chunk_size"] = clamp kwargs["book_files"] = book_files kwargs["planned"] = planned return True diff --git a/app/ui/runview.py b/app/ui/runview.py index 4fcaeb1..73ad315 100644 --- a/app/ui/runview.py +++ b/app/ui/runview.py @@ -193,6 +193,19 @@ class RunView(ScreenView): self.boot_hint = event.get("hint") or "" self._record_boot_failure() self._finish("error") + elif kind == "port_taken": + # The launcher moved the server to a random port (the + # configured one was taken) and the boot was killed as + # unreachable: same terminal treatment as a crash, with the + # port specifics as the message. + self.server = "error" + self.server_message = str(event.get("message") + or "the server moved itself to " + "another port") + self.log_tail = list(event.get("log_tail") or []) + self.boot_hint = event.get("hint") or "" + self._record_boot_failure() + self._finish("error") elif kind == "cancelled": self.cancelled = True if self.server in ("starting", "ready", "processing"): -- cgit v1.2.3