mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Avoid buffering replay-irrelevant thread notifications (#34222)
## Why Raw response items, realtime audio, and other notifications that the TUI does not consume during replay can carry large payloads. Retaining them in each thread's replay buffer wastes memory and can evict useful buffered events. ## What changed - Skip replay buffering for notification types that are handled before routing or ignored during replay, while still updating turn and approval state. - Borrow notifications when recording events for an active thread so routing does not require an extra clone. ## Testing Add coverage that repeatedly sends large MCP progress and realtime audio notifications and verifies that the replay buffer, pending approval, and active turn state remain intact. GitOrigin-RevId: 5b3414f1db7f3ae1feea4fe6c0275e4a7a1a4174
This commit is contained in:
1 parent
854a82dbfd
commit
d0516cfe4b
2 files changed
+92
-10
No files matched your search
@@ -926,11 +926,13 @@ impl App {
|
||||
let inferred_session = self
|
||||
.infer_session_for_thread_notification(thread_id, ¬ification)
|
||||
.await;
|
||||
let is_turn_started = matches!(notification, ServerNotification::TurnStarted(_));
|
||||
let notification_status_change = SideParentStatusChange::for_notification(¬ification);
|
||||
let (sender, store) = {
|
||||
let channel = self.ensure_thread_channel(thread_id);
|
||||
(channel.sender.clone(), Arc::clone(&channel.store))
|
||||
};
|
||||
let (should_send, pending_status, turn_stopped) = {
|
||||
let (notification, pending_status, turn_stopped) = {
|
||||
let mut guard = store.lock().await;
|
||||
if guard.session.is_none()
|
||||
&& let Some(session) = inferred_session
|
||||
@@ -944,21 +946,26 @@ impl App {
|
||||
ServerNotification::ThreadClosed(_) => true,
|
||||
_ => false,
|
||||
};
|
||||
guard.push_notification(notification.clone());
|
||||
let notification = if guard.active {
|
||||
guard.push_notification_ref(¬ification);
|
||||
Some(notification)
|
||||
} else {
|
||||
guard.push_notification(notification);
|
||||
None
|
||||
};
|
||||
(
|
||||
guard.active,
|
||||
notification,
|
||||
guard.side_parent_pending_status(),
|
||||
turn_stopped,
|
||||
)
|
||||
};
|
||||
if matches!(notification, ServerNotification::TurnStarted(_)) {
|
||||
if is_turn_started {
|
||||
self.agent_navigation.mark_running(thread_id);
|
||||
} else if turn_stopped {
|
||||
self.agent_navigation.mark_stopped(thread_id);
|
||||
}
|
||||
let notification_status_change = SideParentStatusChange::for_notification(¬ification);
|
||||
|
||||
if should_send {
|
||||
if let Some(notification) = notification {
|
||||
match sender.try_send(ThreadBufferedEvent::Notification(notification)) {
|
||||
Ok(()) => {}
|
||||
Err(TrySendError::Full(event)) => {
|
||||
|
||||
Reference in new issue
Block a user