fix(tui): clear footer row before rendering statusline#2248
Conversation
There was a problem hiding this comment.
Code Review
This pull request aims to prevent stale glyphs in the footer row by repainting the entire footer area before rendering the spans, and adds a corresponding regression test. However, the reviewer pointed out that rendering a Block with a background style only updates the background color and does not clear the cell symbols (characters). To properly clear stale characters, the reviewer suggests explicitly overwriting each cell in the footer area with a space character.
| Block::default() | ||
| .style(Style::default().bg(self.props.footer_bg)) | ||
| .render(area, buf); |
There was a problem hiding this comment.
In ratatui, rendering a Block with a background style (via Block::default().style(...)) only updates the style (specifically the background color) of the cells in the buffer. It does not clear or reset the symbol (the character) of those cells.
If there are cells in the footer row that are not explicitly overwritten by the subsequent Paragraph render (for example, due to unicode width calculation mismatches or layout constraints), those cells will still retain their stale symbols from the previous frame, even though their background color is updated.
Additionally, the regression test render_clears_stale_cells_across_entire_footer_row passes only because the Paragraph's all_spans (which includes the spacer_span of spaces) happens to cover the entire available_width of 48 cells, thereby overwriting all the seeded 'X' characters. The Block render itself is not what clears the 'X' symbols.
To actually clear the symbols of the entire row and set the background style, we should explicitly overwrite each cell in the area with a space character styled with the footer background color.
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
buf[(x, y)]
.set_symbol(" ")
.set_style(Style::default().bg(self.props.footer_bg));
}
}There was a problem hiding this comment.
Updated in 129c9fc. I switched the footer pre-pass from Block::render to explicitly writing a space plus the footer background into every footer cell before rendering the spans, so stale symbols are cleared even if the later paragraph render leaves any cells untouched. Re-ran the two footer regression tests after the change and both pass.
Hmbown
left a comment
There was a problem hiding this comment.
Clean defensive fix. Adds a pre-clear loop that blanks every cell in the footer row before painting status-line spans, preventing stale transcript glyphs from surviving in untouched cells. The regression test is well-targeted. APPROVE.
Summary
Closes #2244.
Testing
Notes
prompts::tests::system_prompt_skips_locale_preamble_for_englishtest to fail outside an isolated HOMEGreptile Summary
This PR fixes a stale-cell rendering bug (#2244) in the TUI footer widget where leftover glyphs from the transcript pane could persist in footer row cells not touched by the current frame's status spans.
FooterWidget::renderthat fills every cell in the footer area with a space and the configured footer background before painting the status-line spans.render_clears_stale_cells_across_entire_footer_row) that seeds the buffer with visually distinct stale content and asserts both that no stale symbol survives and that the full row carries the correct background colour.Confidence Score: 5/5
Safe to merge — the change is a narrow, well-bounded defensive clear of a single-row buffer before an existing Paragraph render, with a direct regression test covering the exact failure mode.
The pre-clear loop iterates only over the footer area (typically 1 row wide), the bounds use ratatui's own top()/bottom()/left()/right() helpers so there is no off-by-one risk, and the subsequent Paragraph::render call is unchanged. The new regression test seeds the buffer with unmistakable stale content and asserts both symbol-level and background-level correctness, covering the exact scenario from issue #2244.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant F as FooterWidget::render participant B as ratatui Buffer participant P as Paragraph::render F->>F: "guard: height/width == 0?" F->>B: pre-clear loop set every cell to space with footer_bg F->>F: build left_spans, spacer_span, right_spans F->>P: Paragraph::new(spans).style(footer_bg) P->>B: paint spans over cleared cellsReviews (2): Last reviewed commit: "fix(tui): clear footer cells before rend..." | Re-trigger Greptile