From 1b0b42bfcaa6bdac5ab0acafd0d99fda87de2c47 Mon Sep 17 00:00:00 2001 From: Benjamin Carlsson Date: Mon, 23 Nov 2026 01:39:40 +0000 Subject: [PATCH] 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 --- codex-rs/tui/src/app/owned_transcript_input_tests.rs | 3 +-- codex-rs/tui/src/chatwidget/interaction.rs | 9 +++------ codex-rs/tui/src/startup_recovery_tests.rs | 5 ++++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/codex-rs/tui/src/app/owned_transcript_input_tests.rs b/codex-rs/tui/src/app/owned_transcript_input_tests.rs index 1488dc82e0..daca6bf9fa 100644 --- a/codex-rs/tui/src/app/owned_transcript_input_tests.rs +++ b/codex-rs/tui/src/app/owned_transcript_input_tests.rs @@ -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")); diff --git a/codex-rs/tui/src/chatwidget/interaction.rs b/codex-rs/tui/src/chatwidget/interaction.rs index 1968b2e648..3042fae263 100644 --- a/codex-rs/tui/src/chatwidget/interaction.rs +++ b/codex-rs/tui/src/chatwidget/interaction.rs @@ -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(), ); diff --git a/codex-rs/tui/src/startup_recovery_tests.rs b/codex-rs/tui/src/startup_recovery_tests.rs index 381dd7bcab..ce9ed4b500 100644 --- a/codex-rs/tui/src/startup_recovery_tests.rs +++ b/codex-rs/tui/src/startup_recovery_tests.rs @@ -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;