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
This commit is contained in:
dob-oai
2026-11-23 00:56:11 +00:00
committed by copyberry
parent 44848822b1
commit 9e3479e00a
+11 -3
View File
@@ -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(),