Avoid redundant TUI redraws while streaming (#34049)

## What changed

- Redraw assistant and plan stream tails only when a completed line changes the visible tail.
- Cache the first reasoning header and update the status indicator only when its visible state changes, while restoring the cached header if the indicator is recreated.
- Keep regular commit ticks able to clear stale stream tails.

## Testing

- Add coverage for unchanged partial deltas, changed newline-delimited tails, reasoning-header redraws, recreated status indicators, stale plan tails, and history-line draw scheduling.

GitOrigin-RevId: 9016175f97ef2db2edc2fd5ba13a4d731dc2d98c
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-07-18 18:19:39 +00:00
1 parent 028edf8c1e
commit 35eaf3ffb0
18 files changed
+359 -44

No files matched your search

+15
View File
@@ -105,6 +105,7 @@ mod tests {
use codex_config::types::NotificationCondition;
use ratatui::layout::Position;
use ratatui::layout::Rect;
use ratatui::text::Line;
#[test]
fn unfocused_notification_condition_is_suppressed_when_focused() {
@@ -170,6 +171,20 @@ mod tests {
"expected stale cells inside the new viewport to be cleared, rows: {rows:?}"
);
}
#[tokio::test(flavor = "current_thread", start_paused = true)]
async fn inserting_history_lines_schedules_a_draw() {
let mut tui = crate::tui::test_support::make_test_tui().expect("test tui");
let mut draw_rx = tui.draw_tx.subscribe();
tui.insert_history_lines(vec![Line::from("committed stream line")]);
tokio::time::advance(std::time::Duration::from_millis(20)).await;
assert!(matches!(
tokio::time::timeout(std::time::Duration::from_millis(50), draw_rx.recv()).await,
Ok(Ok(()))
));
}
}
pub fn set_modes() -> Result<()> {