fix: adapt selector layout after terminal resize - #195
Conversation
|
Warning Review limit reached
Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c699c24 to
fffd733
Compare
Greptile SummaryThe PR makes selector layouts resize-aware.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported selector focus and list-offset resize issues are corrected by preserving their absolute positions before recalculating pagination. Important Files Changed
Reviews (6): Last reviewed commit: "fix: reset selector viewport after resiz..." | Re-trigger Greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cd236c4. Configure here.

Summary
SelectandMultiSelectRoot cause
The wrapped-row fix in #192 recorded how many physical rows a frame occupied when it was drawn. After a terminal resize, that number could become stale because the terminal reflows the same text at a different width. Selector capacity was also calculated only at construction, so pagination continued using the original terminal height.
Behavior
Select,MultiSelect, andListnow retain the previous frame text. On the next redraw after a resize, they measure that old frame at the new width, erase the reflowed footprint, recalculate capacity from the new height, clamp navigation state, and render the corrected layout.This intentionally updates on the next input/redraw. Immediate idle redraw would require a resize-aware input event API;
console::Term::read_keycurrently blocks on key input and does not expose resize events.The branch is rebased onto the merged #193, so resize correction is enclosed in the synchronized-output update: geometry is recalculated correctly and the clear/redraw transition is presented atomically.
Validation
cargo fmt --checkcargo test --lib --tests(45 unit tests and 16 integration tests passed)cargo clippy --all-targets -- -D warningsThis PR was generated by an AI coding assistant.
Note
Medium Risk
Unix-only low-level TTY/signal/
selectcode affects all three interactive prompts; non-Unix still uses blockingread_keyonly, but incorrect raw-mode or signal handling could break input or leave the terminal in a bad state.Overview
Terminal resize handling for
Select,MultiSelect, andListon Unix: prompts now react when the window changes size, not only on the next keypress.Adds
EventReader(src/event.rs) that multiplexes keyboard input with SIGWINCH viaselect, raw TTY mode, and a signal-hook pipe. Resize events surface asread_keyreturningNone, which triggers a full-screen clear and redraw on the next loop.Layout and erase fixes: widgets keep the previous frame text (
last_frame) instead of a fixed row count. Before clearing, wrapped height is recomputed at the current terminal width; each redraw callsrefresh_layoutto derive page capacity from terminal height and clamp page, cursor, and list scroll so the focused / first-visible item stays stable.Selectpaging now counts filtered options.Tests: unit tests for
resize_layout, plus a PTY integration test (tests/resize.rs) asserting an idle prompt emits a second synchronized frame after resize without keyboard input.libc(unix) andportable-pty(dev) dependencies added.Reviewed by Cursor Bugbot for commit 1f712ca. Bugbot is set up for automated code reviews on this repo. Configure here.