Skip to content

Fix table viewport panic on small terminal windows#141

Merged
clcollins merged 1 commit intomainfrom
fix/table-viewport-panic-small-terminal
May 5, 2026
Merged

Fix table viewport panic on small terminal windows#141
clcollins merged 1 commit intomainfrom
fix/table-viewport-panic-small-terminal

Conversation

@clcollins
Copy link
Copy Markdown
Owner

Summary

  • Fix panic (slice bounds out of range [2:1]) caused by negative viewport height when terminal is under 36 lines tall (including standard 24-line terminals)
  • The table height calculation subtracted 35 lines of overhead, clamped the result to 1, but table.SetHeight(1) internally subtracts the 2-line styled header, producing viewport.Height = -1
  • Raise minimum tableHeight from 1 to 4 so the viewport always has positive height after header subtraction
  • Add TestWindowSizeMsgHandler_SmallWindow covering standard, tiny, minimum, and zero-height terminals

Test plan

  • go test ./pkg/tui/ -run TestWindowSizeMsgHandler_SmallWindow -v passes
  • go test ./... full suite passes
  • go build succeeds
  • Manual verification: run srepd in a standard 24-line terminal and confirm incidents are visible

🤖 Generated with Claude Code

The table height calculation subtracts 35 lines of overhead from the
terminal height, producing a negative value for any terminal under 36
lines (including standard 24-line terminals). This was clamped to 1,
but table.SetHeight(1) internally subtracts the 2-line header height
(text + bottom border), giving the viewport a height of -1. This
caused either invisible table rows or a panic in viewport.visibleLines
("slice bounds out of range [2:1]") depending on timing.

Raise the minimum tableHeight from 1 to 4 so the viewport always gets
at least 2 lines of content space after the header is subtracted.

Add TestWindowSizeMsgHandler_SmallWindow covering standard 80x24,
tiny, minimum, and zero-height terminals.

Created with assistance from Claude 🤖 <claude@anthropic.com>

Signed-off-by: Christopher Collins <collins.christopher@gmail.com>
@clcollins clcollins merged commit 3de4cf5 into main May 5, 2026
2 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