Skip to content

feat: add minimum terminal size warning for pager browsers#50

Merged
eitsupi merged 7 commits intomainfrom
feat/terminal-size-warning
Feb 4, 2026
Merged

feat: add minimum terminal size warning for pager browsers#50
eitsupi merged 7 commits intomainfrom
feat/terminal-size-warning

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Feb 4, 2026

Summary

  • When the terminal is too small for the history browser or help browser to render correctly, a centered warning screen is shown with the current and required dimensions
  • History browser: minimum 70 columns × 10 rows (column layout overflow threshold)
  • Help browser: minimum 30 columns × 8 rows
  • The check runs every render cycle, so resizing the terminal immediately restores the normal UI without restarting the browser

Test plan

  • Launch history browser (:history) in a terminal smaller than 70×10 and verify the warning appears
  • Resize the terminal larger and verify the browser UI appears immediately
  • Launch help browser (:help) in a terminal smaller than 30×8 and verify the warning appears
  • Verify q/Esc exit works from the warning screen
  • Verify cargo test -p arf-console passes (including new pager::tests unit tests)

🤖 Generated with Claude Code

eitsupi and others added 7 commits February 4, 2026 15:19
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]>
@eitsupi eitsupi merged commit 39c4adb into main Feb 4, 2026
10 checks passed
@eitsupi eitsupi deleted the feat/terminal-size-warning branch February 4, 2026 15:40
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