feat: add minimum terminal size warning for pager browsers#50
Merged
Conversation
When the terminal is too small for the history browser or help browser to render correctly, a centered warning message is shown asking the user to resize their terminal. The warning displays the current and required size. History browser: minimum 70 columns × 10 rows (column layout overflow threshold). Help browser: minimum 30 columns × 8 rows. The check runs on every render cycle, so resizing the terminal immediately restores the normal UI without restarting the browser. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Eliminate double terminal::size() call by returning (cols, rows) from the check function and passing it to the render function - Replace println! with write!/queue! inside synchronized update block to avoid partial flushes and flickering - Use display_width() instead of msg.len() for correct horizontal centering with multi-byte characters - Avoid printing newline on the last row to prevent terminal scrolling - Add unit tests for the minimum size comparison logic - Use ASCII 'x' instead of Unicode '×' in size display for consistency Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Use content-based check (msg == title) instead of row index for title styling to be robust against message reordering - Remove explicit array length annotation, let Rust infer it - Use queue!() consistently instead of mixing execute() and queue!() to minimize I/O syscalls within synchronized update block Co-Authored-By: Claude Opus 4.5 <[email protected]>
When the terminal is too small and the warning screen is shown, only exit keys (q, Esc, Ctrl+C, Ctrl+D) are accepted. Other key input is discarded to prevent characters from leaking into the filter or other browser state. Previously, the help browser passed 'q' to the filter input (since it has no separate normal mode), and the history browser could also leak input when filter mode was active. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Cache the too-small check result from the render path in a local flag, reusing it in the key handler to avoid a redundant terminal::size() syscall on every keypress - Move feedback_message clearing after the too-small guard in the history browser so it is not silently cleared by discarded keypresses Co-Authored-By: Claude Opus 4.5 <[email protected]>
Move `check_terminal_too_small()` call outside the `if needs_redraw` block so the flag is always fresh when processing key events, even if a resize event and key event arrive in the same poll cycle. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Change `let mut too_small = false` to `let mut too_small` since the variable is always assigned before being read in the loop body. Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.
Summary
Test plan
:history) in a terminal smaller than 70×10 and verify the warning appears:help) in a terminal smaller than 30×8 and verify the warning appearscargo test -p arf-consolepasses (including newpager::testsunit tests)🤖 Generated with Claude Code