diff --git a/cli.py b/cli.py index 84735ad3d80..c7832ab3794 100644 --- a/cli.py +++ b/cli.py @@ -13979,7 +13979,12 @@ class HermesCLI: reserved_below = 6 available = max(0, term_rows - reserved_below) - mandatory_full = chrome_full + len(choice_wrapped) + len(other_wrapped) + # The compact decision must reserve room for at least one question + # row on top of the choices, otherwise full chrome (3 blank + # separators) gets kept when there is no room for it and the panel + # overflows the viewport — HSplit then clips the panel's tail, + # silently dropping the choices (the reported bug). + mandatory_full = chrome_full + 1 + len(choice_wrapped) + len(other_wrapped) use_compact_chrome = mandatory_full > available chrome_rows = chrome_tight if use_compact_chrome else chrome_full @@ -13987,9 +13992,24 @@ class HermesCLI: max_question_rows = max(1, available - chrome_rows - len(choice_wrapped) - len(other_wrapped)) max_question_rows = min(max_question_rows, 12) # soft cap on huge terminals + # When the choices alone (plus compact chrome) already exceed the + # viewport, drop the question entirely — the choices are the only + # thing the user must see to make a selection. Without this the + # question would still claim its 1-row floor above and push the + # tail of the choices off-screen (HSplit clips the overflow). + choices_overflow = chrome_rows + len(choice_wrapped) + len(other_wrapped) >= available + if choices_overflow: + max_question_rows = 0 + question_wrapped = _wrap_panel_text(question, inner_text_width) - if len(question_wrapped) > max_question_rows: - keep = max(1, max_question_rows - 1) + if max_question_rows <= 0: + question_wrapped = [] + elif len(question_wrapped) > max_question_rows: + # The truncation marker is itself a row, so it must count + # against the budget. With a 1-row budget there is no room for + # both a question line and the marker — show the marker alone + # so the rendered question never exceeds max_question_rows. + keep = max(0, max_question_rows - 1) question_wrapped = question_wrapped[:keep] + ["… (question truncated)"] lines = []