fix(tui): repaint transcript on tmux detach/reattach#128
Closed
Fullstop000 wants to merge 1 commit into
Closed
Conversation
A tmux/screen detach->reattach re-sends the window size via TIOCSWINSZ, which raises SIGWINCH even when the size is unchanged. crossterm surfaces this as Event::Resize, but the console loop dropped it, and ratatui's autoresize only repaints when the size actually *changed*. So a same-size reattach left the alt-screen blank — the in-memory transcript was intact but never redrawn, so history appeared lost. Handle Event::Resize by forcing a full redraw via terminal.clear(), which resets the back buffer so the next frame repaints the whole transcript.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #128 +/- ##
==========================================
- Coverage 76.47% 76.47% -0.01%
==========================================
Files 66 66
Lines 17440 17441 +1
==========================================
Hits 13338 13338
- Misses 4102 4103 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
Author
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.
Problem
In a tmux/screen session, detaching and reattaching left the TUI blank — the conversation history appeared lost.
Root cause
Since #89 the TUI runs in alternate-screen
Viewport::Fullscreen, so the whole transcript lives inapp.transcript(in memory), not in the terminal's scrollback. On reattach:TIOCSWINSZ→ SIGWINCH even when the size is unchanged.Event::Resize(emitted on every SIGWINCH, no size dedup).Event::Resizeinto_ => {}.autoresizeonly repaints when the size actually changed, so the diff renderer wrote nothing → the pane tmux reset on reattach stayed blank.The data was never lost — it just never got redrawn.
Fix
Handle
Event::Resizeby forcing a full redraw viaterminal.clear()(resets the back buffer so the next frame repaints the entire transcript). 4 lines inrunner.rs.Verification
A/B test with the real binary under tmux — render, wipe the alt-screen out-of-band (simulating tmux's reattach reset), deliver a same-size SIGWINCH, re-capture. Signal confirmed delivered to both binaries:
cargo build,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspace(527 passed) all clean.Scope note
This fixes the reattach blank only. It does not restore native mouse-copy or terminal-native scrollback — both are separate costs of the alt-screen model (#89 / mouse capture in #125). Those would need an inline-rendering change, tracked separately.
🤖 Generated with Claude Code