Render flushed TUI input in the same frame (#63233)

## Why

The TUI skipped the frame that flushed buffered input, so pasted text
and pending Vim replacement keys only appeared on a follow-up redraw.

## What changed

Refresh startup recovery after a flush and render in the current frame
once all editors have finished buffering. If an editor is still
buffering, defer rendering and schedule another tick.

## Testing

Update the multiline paste test to require the text to appear on the
first draw after the paste timeout. Update the startup recovery test to
check that committing a pending Vim replacement key allows that frame
to render.

GitOrigin-RevId: 8c92f075aa2c9ada3b60ecdf83b1f677ffd52f1a
This commit is contained in:
Benjamin Carlsson
2026-11-23 01:51:00 +00:00
committed by copyberry
parent ae6c0c8ac1
commit 1b0b42bfca
3 changed files with 8 additions and 9 deletions
@@ -886,8 +886,7 @@ async fn raw_multiline_paste_defers_rendering_and_submits_once() -> Result<()> {
let during_paste = screen(&tui);
// Wait out Windows' active-paste timeout and accidental-Enter suppression window.
tokio::time::advance(Duration::from_secs(/*secs*/ 1)).await;
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Draw)
.await?;
// The draw that flushes the paste should also display it.
app.handle_tui_event(&mut tui, &mut server, TuiEvent::Draw)
.await?;
assert!(screen(&tui).contains("After paste"));
+3 -6
View File
@@ -663,12 +663,9 @@ impl ChatWidget {
fn finish_paste_burst_tick(&mut self, frame_requester: FrameRequester, flushed: bool) -> bool {
if flushed {
self.refresh_startup_recovery();
// A paste just flushed; request an immediate redraw and skip this frame.
self.request_redraw();
true
} else if self.is_in_paste_burst() {
// While capturing a burst, schedule a follow-up tick and skip this frame
// to avoid redundant renders between ticks.
}
// Paint the flushed input on this frame unless an editor is still buffering.
if self.is_in_paste_burst() {
frame_requester.schedule_frame_in(
crate::bottom_pane::ChatComposer::recommended_paste_flush_delay(),
);
+4 -1
View File
@@ -70,7 +70,10 @@ async fn recovery_after_handoff_preserves_pending_vim_replace_key() {
insta::assert_snapshot!(take_unsent_text().unwrap(), @"Xbcd");
assert_eq!(chat.composer_text_with_pending(), "abcd");
tokio::time::advance(std::time::Duration::from_millis(100)).await;
assert!(chat.handle_paste_burst_tick(crate::tui::FrameRequester::test_dummy()));
assert!(
!chat.handle_paste_burst_tick(crate::tui::FrameRequester::test_dummy()),
"the draw that commits the replacement key should render it"
);
assert_eq!(chat.composer_text_with_pending(), "Xbcd");
})
.await;