aboutsummaryrefslogtreecommitdiff
path: root/app/ui
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-31 17:19:27 -0400
committerhistoria <historiavg@proton.me>2026-08-31 17:19:27 -0400
commit4bd0282da65db9f118ef5250582ab67079fad538 (patch)
tree61983333df69b9cf9efc91f5320fbb51c66fdc97 /app/ui
parent3b109185d642319c2c1870815b25ae1c0ad49445 (diff)
downloadtts-audiobook-generator-4bd0282da65db9f118ef5250582ab67079fad538.tar.gz
fix: truncate excess spaces on generate audiobooks tui
Diffstat (limited to 'app/ui')
-rw-r--r--app/ui/hub.py7
-rw-r--r--app/ui/tui.py12
2 files changed, 18 insertions, 1 deletions
diff --git a/app/ui/hub.py b/app/ui/hub.py
index abb375a..de5701f 100644
--- a/app/ui/hub.py
+++ b/app/ui/hub.py
@@ -1362,6 +1362,9 @@ def _audiocpp_fields(stdscr, api_url: Optional[str] = None,
{"key": prefix + "model_id", "label": "Model", "kind": "choice",
"value": default_model,
"choices": [(_label(m), m.get("id")) for m in models],
+ # The pick menu shows the padded capability table; the form row
+ # collapses its column padding back to the two-space gutter.
+ "compact_label": True,
"on_change": reset_voice},
# The label tracks the entry's capability: a built-in speaker on
# CustomVoice, otherwise the name of a server-side voice to clone.
@@ -1513,7 +1516,9 @@ def _qwen_fields(remote_modes: Optional[list] = None,
initial_clone = str(initial_wavs[0]) if initial_wavs else ""
fields = [
{"key": prefix + "mode", "label": "Model", "kind": "choice",
- "value": default_mode, "choices": model_choices},
+ "value": default_mode, "choices": model_choices,
+ # Same as the audio.cpp picker: padded menu table, compact row.
+ "compact_label": True},
{"key": prefix + "speaker", "label": "Speaker", "kind": "choice",
"value": default_speaker, "choices": speakers,
"visible": lambda fs: _field_value(fs, prefix + "mode") == "custom"},
diff --git a/app/ui/tui.py b/app/ui/tui.py
index a4854b0..1e95353 100644
--- a/app/ui/tui.py
+++ b/app/ui/tui.py
@@ -1035,6 +1035,11 @@ def form(scr, title: str, fields: Sequence[dict],
keep their value across hide/show. A field may set ``on_change`` to
a callable of the field list, invoked whenever its value changes so
dependent fields (choices, visibility, defaults) can be recomputed.
+ A ``choice`` field may set ``compact_label`` to show its picked
+ label on the form row with runs of spaces collapsed back to the
+ two-space gutter — the pick menu always shows the full label, so a
+ padded table (aligned capability columns) reads aligned there and
+ compact on the row.
A choice field whose resolved list is empty cannot be opened: Enter
is a no-op, or flashes the field's optional ``on_empty_choices``
message (string or callable of the field list) — an explanation the
@@ -1130,6 +1135,13 @@ def form(scr, title: str, fields: Sequence[dict],
and len(choices[0]) == 2:
for label, value in choices:
if value == field["value"]:
+ if field.get("compact_label"):
+ # The pick menu keeps the full padded label
+ # (e.g. the model picker's aligned capability
+ # table); the form row collapses its runs of
+ # column padding back to the two-space gutter
+ # so a short pick reads without a far gap.
+ return re.sub(" {2,}", " ", label)
return label
return str(field["value"])