fix(tui): don't panic when the terminal reports a degenerate size#3736
Merged
aheritier merged 2 commits intoJul 18, 2026
Merged
Conversation
renderResizeHandle guarded width <= 0 but the padded inner width (width - appPaddingHorizontal) still went negative for tiny widths (e.g. a 1x1 terminal), feeding strings.Repeat a negative count. Guard on the inner width instead. Adds regression tests: a unit test on renderResizeHandle, a full-TUI e2e resize cycle through degenerate sizes, and a board-TUI render sweep across sizes and dialogs. Assisted-By: Claude
MaxWidth(innerWidth-suffixWidth) is ignored by lipgloss when non-positive, letting the handle line overflow the row when the paused/working suffix is wider than the terminal. Extract the duplicated suffix logic into lineWithSuffix, which truncates the suffix itself when it alone does not fit. Also drop a now-redundant max(0, …), switch the regression test to testify, and clarify the e2e comment. Assisted-By: Claude
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The degenerate-size panic fix is correct and well-tested. The innerWidth <= 0 guard properly catches all cases where width - appPaddingHorizontal would be non-positive, preventing the negative strings.Repeat count that caused the panic. The extracted lineWithSuffix helper handles both the overflow and normal paths correctly. The three test layers (unit, e2e, board-TUI sweep) provide solid coverage.
aheritier
approved these changes
Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a terminal reports a degenerate size (0×0 or 1×1), the resize handle in
pkg/tui/tui.gocomputed a negative repeat count forstrings.Repeat, crashing the TUI withpanic: strings: negative Repeat count. The existingwidth <= 0guard did not account for the horizontal padding subtracted afterwards, so any width narrower thanappPaddingHorizontalslipped through and produced a negative inner width.The fix adds a guard on the padded inner width itself. A follow-up commit also handles the status suffix:
lipglossignores non-positiveMaxWidth, so a paused/working suffix wider than the terminal could overflow the row on very narrow terminals. The suffix logic is extracted into alineWithSuffixhelper that truncates the suffix when the terminal is too narrow to accommodate it.Both fixes are covered by a unit test over tiny widths (
pkg/tui/tui_resize_handle_test.go), a full-TUI e2e resize cycle through degenerate sizes (e2e/tui/degenerate_resize_test.go), and a board-TUI render sweep across degenerate sizes × all dialogs (pkg/board/tui/degenerate_size_test.go). All three tests were verified to panic on main without the fix.