Skip to content

fix(tui): Clear the terminal buffer when the viewport is resized - #35

Merged
euxaristia merged 1 commit into
mainfrom
fix/tui-resize-redraw
Aug 22, 2026
Merged

fix(tui): Clear the terminal buffer when the viewport is resized#35
euxaristia merged 1 commit into
mainfrom
fix/tui-resize-redraw

Conversation

@euxaristia

Copy link
Copy Markdown
Owner

Summary

Growing the terminal left stale cells on screen. draw() already renders a
Clear widget over frame.area(), but that only wipes the region ratatui
currently treats as the viewport, so cells the viewport just expanded into keep
whatever the terminal had in them.

Handling Event::Resize by calling terminal.clear() makes the next frame
start from a wiped buffer.

Changes

  • src/tui.rs: replace the two early-continue guards in event_loop with a
    single match on event::read(), adding an Event::Resize(..) arm that
    clears the terminal. Key handling is unchanged.

Test plan

  • cargo fmt --check
  • RUSTFLAGS="-Dwarnings" cargo clippy --all-targets
  • cargo test (155 unit tests + 2 doctests pass)
  • Manual: run limits tui, shrink the terminal, then grow it back. Before this
    change the newly exposed rows held leftover shell output; after it they are
    blank and redrawn by the next frame.

Fixes #34

Growing the terminal exposes cells that ratatui never repaints, because the
frame-wide Clear in draw() only covers the area it currently believes is the
viewport. Wipe the whole buffer on Event::Resize so the next frame starts
clean instead of painting around leftover text.

Refs #34

Claude-Session: https://claude.ai/code/session_01PvhTkPF3fvjPUh5ao9MeWL
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ccc6c5c-4170-4f7c-b4e7-ab7d495131e1

📥 Commits

Reviewing files that changed from the base of the PR and between a3f5aeb and 36f3e51.

📒 Files selected for processing (1)
  • src/tui.rs

📝 Walkthrough

Walkthrough

The TUI now clears the terminal after resize events. The event loop passes only key-press events to the application and ignores other event types.

Changes

TUI resize handling

Layer / File(s) Summary
Resize and key event handling
src/tui.rs
Resize events clear the terminal before a fresh frame. Only key-press events reach the application. Other events are ignored.

Estimated code review effort: 2 (Simple) | ~5 minutes

Poem

I’m a rabbit with a freshly cleared screen,
No stale cells remain tucked in between.
Resize the terminal, draw anew,
Key presses hop through, as they should do.
Clean borders bloom in the view. 🐇

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@euxaristia
euxaristia marked this pull request as ready for review August 22, 2026 06:49
@euxaristia
euxaristia merged commit 9670d91 into main Aug 22, 2026
3 of 4 checks passed
@euxaristia
euxaristia deleted the fix/tui-resize-redraw branch August 22, 2026 06:49
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.

TUI leaves stale cells after a terminal resize

1 participant