From 9e3479e00a2aa22dd3e9e8662420b07ae3185951 Mon Sep 17 00:00:00 2001 From: dob-oai Date: Mon, 23 Nov 2026 00:43:22 +0000 Subject: [PATCH] Keep turn diff updates out of the TUI replay buffer (#63218) ## Why Repeated turn diff updates can fill the bounded replay buffer with large payloads and evict events needed to restore the thread. The updates only refresh the status line, which thread replay already refreshes after rebuilding the chat widget. ## What changed Skip `TurnDiffUpdated` notifications when storing events for thread replay. ## Testing Extend the replay buffer regression test with repeated 1 MiB turn diff updates. The test checks that the store retains the pending approval and active turn. GitOrigin-RevId: 371bb1fc989bbb61c498840896779c5ff6479fdf --- codex-rs/tui/src/app/thread_events.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/codex-rs/tui/src/app/thread_events.rs b/codex-rs/tui/src/app/thread_events.rs index f49f7826e9..282074b878 100644 --- a/codex-rs/tui/src/app/thread_events.rs +++ b/codex-rs/tui/src/app/thread_events.rs @@ -331,12 +331,12 @@ impl ThreadEventStore { _ => {} } - // These notifications are either handled before routing or ignored by ChatWidget on - // replay. In particular, raw response items and realtime audio can carry large payloads, - // so cloning them into every thread's replay buffer only retains data the TUI cannot use. + // These notifications add no replayable content. Turn diffs only refresh the status + // line, which replay_thread_snapshot already refreshes after rebuilding the widget. if matches!( notification.as_ref(), ServerNotification::RawResponseItemCompleted(_) + | ServerNotification::TurnDiffUpdated(_) | ServerNotification::FileChangePatchUpdated(_) | ServerNotification::ServerRequestResolved(_) | ServerNotification::McpToolCallProgress(_) @@ -744,6 +744,7 @@ mod tests { use codex_app_server_protocol::ThreadRealtimeAudioChunk; use codex_app_server_protocol::ThreadRealtimeOutputAudioDeltaNotification; use codex_app_server_protocol::TurnCompletedNotification; + use codex_app_server_protocol::TurnDiffUpdatedNotification; use codex_app_server_protocol::TurnStartedNotification; use codex_app_server_protocol::UserInput; use codex_config::types::ApprovalsReviewer; @@ -1002,6 +1003,13 @@ mod tests { let large_payload = "x".repeat(1024 * 1024); for _ in 0..32 { + store.push_notification_ref(&ServerNotification::TurnDiffUpdated( + TurnDiffUpdatedNotification { + thread_id: thread_id.to_string(), + turn_id: "turn-1".to_string(), + diff: large_payload.clone(), + }, + )); store.push_notification_ref(&ServerNotification::ThreadAttachmentUpdated( ThreadAttachmentUpdatedNotification { thread_id: thread_id.to_string(),