Repository navigation
Description
Summary
On an idle screen the TUI blanks everything except the animation rows: transcript, header and composer disappear. Typing brings them back, so the reported symptom is "the TUI blinks: I can see it while I write, it's gone when I stop".
Still present on master at v0.75.5 (crates/jcode-tui/src/tui/app/run_shell.rs, the seeded_animation_area path at ~line 402, and the swap_buffers site at ~line 429).
Root cause
draw_idle_animation_only ends in terminal.swap_buffers(). ratatui's swap_buffers resets the now-inactive buffer (Buffer::reset blanks every cell) before flipping, and that inactive buffer is the one the next tick draws into.
The seeding optimization assumes the opposite. Once seeded_animation_area == Some(area) it copies only the animated rectangle and trusts every cell outside it:
if self.seeded_animation_area == Some(area) {
copy_cells_in(previous_frame, current_buffer, area);
} else {
current_buffer.clone_from(previous_frame);
self.seeded_animation_area = Some(area);
}Against a freshly reset buffer that trust is misplaced for the whole rest of the screen. The flushed diff therefore erases the transcript, header and composer and leaves the animation alone on screen. Typing repaints it only because a changed composer trips the input_changed guard and forces a full frame.
invalidate() clears the seed, but nothing clears it at the swap, which is the moment the seed stops being valid.
Why the existing tests missed it
Every test in that module compares one rendered buffer against another. None model what ratatui does to its own buffers between frames, which is where the bug lives. It is a buffer-lifecycle mismatch, not a rendering error.
Fix
Clear the seed at the swap, so a seed is only ever reused within a tick, never across one:
/// Record that a frame was handed to the terminal and the buffers swapped.
///
/// `Terminal::swap_buffers` resets the now-inactive buffer, which is the
/// one the next tick draws into, so no part of the previous frame survives
/// there. Any partial-repaint path that skips cells because they are
/// "already correct" must call this after swapping, or it will skip cells
/// that are in fact blank and erase the screen around its own rectangle.
fn note_animation_frame_presented(&mut self) {
self.seeded_animation_area = None;
}called immediately after terminal.swap_buffers() in draw_idle_animation_only.
I have this running locally as a single commit against v0.75.5 (+137/-6 in run_shell.rs, all but ~10 lines being comments and two regression tests). I do not have push access to open the PR; happy to attach the patch or have someone apply it.
The two tests it adds:
the_idle_animation_repaint_does_not_blank_the_rest_of_the_screendrives the two real production helpers through the real buffer lifecycle (seed, swap/reset, copy) for three consecutive ticks and asserts the cells outside the animated rectangle survive. It takes the seeding branch from the renderer's own state rather than assuming an answer, so the fix is what makes it pass.a_presented_animation_frame_requires_reseeding_the_next_tickpins the invariant on the renderer itself, so a future edit cannot reinstate the optimization without keeping the seed valid across a swap.
Environment
Windows 11 x86_64, jcode built from source. Originally hit on v0.65.0, verified by inspection that master (994b8d3, v0.75.5) still contains the unguarded path.
Related, though distinct: #289 "Flashing violently after auto updating" (closed).
Activity
YalmutairiAisc commentedon Aug 12, 2026
Patch against
master(rebased onto 994b8d3, v0.75.5), applies clean withgit am:0001-fix-tui-idle-animation-blanked-everything-outside-its.patch
1jehuang commentedon Aug 13, 2026
I fixed the stale seeded-animation state after
swap_buffersand added two real-buffer lifecycle regressions. Fix: #918.--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)
chore: sync fork with upstream jcode (fresh merge onto current master) (
chore: sync with upstream (#53)
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)
fix: invalidate animation seed after buffer swap (fixes 1jehuang#913)