Skip to content

Size the whiptail dialogs to the terminal and their contents - #11

Merged
lazarevtill merged 1 commit into
mainfrom
tui-geometry
Aug 23, 2026
Merged

Size the whiptail dialogs to the terminal and their contents#11
lazarevtill merged 1 commit into
mainfrom
tui-geometry

Conversation

@lazarevtill

Copy link
Copy Markdown
Member

The container picker in update-lxcs.sh was hard-coded to 20 $width 10. Three problems came out of that, all visible in one screenshot.

Three dead rows under the list. A checklist needs exactly list-height + 8 rows. I measured rather than guessed: at +7 whiptail silently drops the prompt text instead of shrinking the box; at +8 it fits exactly. The old 20-against-10 was two too many.

A ten-item window regardless of screen size. On a 45-row terminal the dialog stayed 20 rows and showed 10 of 40 containers. List height is now the container count capped by the terminal — the same fleet on the same terminal now shows 35.

A width that ignored half its inputs. It was longest-hostname + 12, leaving out the VMID column entirely, so a node whose IDs have run past four digits had those rows clipped. Width is now the widest of a list row (measured id and name widths), the title, and the prompt.

When the list overflows, the prompt now gives the total. whiptail draws its own scrollbar, so the arrows aren't the missing information — the count is, because "8 of 40" is a different decision from "8 of 9".

That notice caught its own bug during testing: at 40 columns it rendered as Select containers to skip (10 total, — clipped mid-sentence, worse than saying nothing. That's why the prompt is now part of the width calculation.

confirm() gets the same treatment; it was fixed at 60 columns, so a long FQDN wrapped awkwardly against the frame.

Verification

Rendered the real function in a pty at 14, 18 and 45 rows and read the frames back — no dead rows, prompt intact, scrollbar and total shown only when the list actually overflows, long names and five-digit VMIDs uncut, and a 43-character FQDN wrapping inside the frame rather than through it. term_size falls back to 24x80 when tput cannot answer (missing TERM, no tty), verified both.

The container picker was hard-coded to `20 $width 10`: 20 rows tall, list
height 10. Three problems came out of that, all visible in one screenshot.

Three dead rows under the list. A checklist needs exactly list-height + 8 rows
-- top border, the prompt's blank/text/blank, a blank, the button row, a blank,
bottom border -- and 20 against a list height of 10 is two more than that. I
measured it rather than guessing: at +7 whiptail silently drops the prompt text
instead of shrinking the box, and at +8 it fits exactly.

A ten-item window regardless of the screen. On a 45-row terminal the dialog
stayed 20 rows and showed 10 of 40 containers. The list height is now the
container count, capped by what the terminal can hold; the same fleet on the
same terminal now shows 35.

A width that ignored half its inputs. It was the longest hostname plus 12,
which left out the VMID column entirely -- so a node whose IDs have run past
four digits had those rows clipped. Width is now the widest of a list row
(measured id and name widths), the title, and the prompt.

When the list does overflow, the prompt says how many there are in total.
whiptail draws its own scrollbar, so the arrows are not the missing
information; the count is, because "8 of 40" is a different decision from
"8 of 9". That notice caught its own bug in testing: at 40 columns it rendered
as "Select containers to skip (10 total," -- clipped mid-sentence, worse than
saying nothing -- which is why the prompt is now part of the width calculation.

confirm() gets the same treatment. It was fixed at 60 columns, so a node with a
long fully-qualified hostname had the question wrapped awkwardly against the
frame; it is now sized to the message and bounded by the terminal.

term_size falls back to 24x80 when tput cannot answer, which covers a missing
TERM and a non-tty. select_exclusions only runs when main has already
established a terminal, so the fallback is belt and braces.

Verified by rendering the real function in a pty at 14, 18 and 45 rows and
reading the frames back: no dead rows, prompt intact, scrollbar and total
shown only when the list actually overflows, long names and five-digit VMIDs
uncut, and a 43-character FQDN wrapping inside the frame rather than through
it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sonarqubecloud

Copy link
Copy Markdown

@lazarevtill
lazarevtill merged commit cb36e56 into main Aug 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant