mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Box app-server event payloads (#35854)
## What changed - Store `ServerNotification` and `ServerRequest` payloads behind `Box` in `AppServerEvent`, `InProcessServerEvent`, and TUI `ThreadBufferedEvent` values. - Update app-server delivery, TUI routing and replay, exec, onboarding, and tests to borrow or consume the boxed payloads as appropriate. GitOrigin-RevId: 7d0dab9aba47487114128ce55c914af5bb46c5b5
This commit is contained in:
1 parent
8707a35113
commit
07490c7523
16 files changed
+322
-245
No files matched your search
@@ -18,8 +18,8 @@ pub(super) struct ThreadEventSnapshot {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(super) enum ThreadBufferedEvent {
|
||||
Notification(ServerNotification),
|
||||
Request(ServerRequest),
|
||||
Notification(Box<ServerNotification>),
|
||||
Request(Box<ServerRequest>),
|
||||
HistoryEntryResponse(HistoryLookupResponse),
|
||||
FeedbackSubmission(FeedbackThreadEvent),
|
||||
}
|
||||
@@ -53,14 +53,16 @@ pub(super) struct ThreadEventStore {
|
||||
|
||||
impl ThreadEventStore {
|
||||
pub(super) fn event_survives_session_refresh(event: &ThreadBufferedEvent) -> bool {
|
||||
matches!(
|
||||
event,
|
||||
ThreadBufferedEvent::Request(_)
|
||||
| ThreadBufferedEvent::Notification(ServerNotification::HookStarted(_))
|
||||
| ThreadBufferedEvent::Notification(ServerNotification::HookCompleted(_))
|
||||
| ThreadBufferedEvent::Notification(ServerNotification::McpServerStatusUpdated(_))
|
||||
| ThreadBufferedEvent::FeedbackSubmission(_)
|
||||
)
|
||||
match event {
|
||||
ThreadBufferedEvent::Request(_) | ThreadBufferedEvent::FeedbackSubmission(_) => true,
|
||||
ThreadBufferedEvent::Notification(notification) => matches!(
|
||||
notification.as_ref(),
|
||||
ServerNotification::HookStarted(_)
|
||||
| ServerNotification::HookCompleted(_)
|
||||
| ServerNotification::McpServerStatusUpdated(_)
|
||||
),
|
||||
ThreadBufferedEvent::HistoryEntryResponse(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn new(capacity: usize) -> Self {
|
||||
@@ -159,26 +161,29 @@ impl ThreadEventStore {
|
||||
}
|
||||
|
||||
self.buffer
|
||||
.push_back(ThreadBufferedEvent::Notification(notification.into_owned()));
|
||||
.push_back(ThreadBufferedEvent::Notification(Box::new(
|
||||
notification.into_owned(),
|
||||
)));
|
||||
if self.buffer.len() > self.capacity
|
||||
&& let Some(removed) = self.buffer.pop_front()
|
||||
&& let ThreadBufferedEvent::Request(request) = &removed
|
||||
{
|
||||
self.pending_interactive_replay
|
||||
.note_evicted_server_request(request);
|
||||
.note_evicted_server_request(request.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn push_request(&mut self, request: ServerRequest) {
|
||||
self.pending_interactive_replay
|
||||
.note_server_request(&request);
|
||||
self.buffer.push_back(ThreadBufferedEvent::Request(request));
|
||||
self.buffer
|
||||
.push_back(ThreadBufferedEvent::Request(Box::new(request)));
|
||||
if self.buffer.len() > self.capacity
|
||||
&& let Some(removed) = self.buffer.pop_front()
|
||||
&& let ThreadBufferedEvent::Request(request) = &removed
|
||||
{
|
||||
self.pending_interactive_replay
|
||||
.note_evicted_server_request(request);
|
||||
.note_evicted_server_request(request.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,9 +194,9 @@ impl ThreadEventStore {
|
||||
ThreadBufferedEvent::Request(request)
|
||||
if self
|
||||
.pending_interactive_replay
|
||||
.should_replay_snapshot_request(request) =>
|
||||
.should_replay_snapshot_request(request.as_ref()) =>
|
||||
{
|
||||
Some(request.clone())
|
||||
Some(request.as_ref().clone())
|
||||
}
|
||||
ThreadBufferedEvent::Request(_)
|
||||
| ThreadBufferedEvent::Notification(_)
|
||||
@@ -210,18 +215,20 @@ impl ThreadEventStore {
|
||||
.iter()
|
||||
.rev()
|
||||
.find_map(|event| match event {
|
||||
ThreadBufferedEvent::Notification(ServerNotification::ItemStarted(
|
||||
notification,
|
||||
)) if turn_id_matches(turn_id, ¬ification.turn_id) => {
|
||||
file_change_item_changes(¬ification.item, item_id)
|
||||
}
|
||||
ThreadBufferedEvent::Notification(ServerNotification::ItemCompleted(
|
||||
notification,
|
||||
)) if turn_id_matches(turn_id, ¬ification.turn_id) => {
|
||||
file_change_item_changes(¬ification.item, item_id)
|
||||
}
|
||||
ThreadBufferedEvent::Notification(notification) => match notification.as_ref() {
|
||||
ServerNotification::ItemStarted(notification)
|
||||
if turn_id_matches(turn_id, ¬ification.turn_id) =>
|
||||
{
|
||||
file_change_item_changes(¬ification.item, item_id)
|
||||
}
|
||||
ServerNotification::ItemCompleted(notification)
|
||||
if turn_id_matches(turn_id, ¬ification.turn_id) =>
|
||||
{
|
||||
file_change_item_changes(¬ification.item, item_id)
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
ThreadBufferedEvent::Request(_)
|
||||
| ThreadBufferedEvent::Notification(_)
|
||||
| ThreadBufferedEvent::HistoryEntryResponse(_)
|
||||
| ThreadBufferedEvent::FeedbackSubmission(_) => None,
|
||||
})
|
||||
@@ -247,7 +254,7 @@ impl ThreadEventStore {
|
||||
.filter(|event| match event {
|
||||
ThreadBufferedEvent::Request(request) => self
|
||||
.pending_interactive_replay
|
||||
.should_replay_snapshot_request(request),
|
||||
.should_replay_snapshot_request(request.as_ref()),
|
||||
ThreadBufferedEvent::Notification(_)
|
||||
| ThreadBufferedEvent::HistoryEntryResponse(_)
|
||||
| ThreadBufferedEvent::FeedbackSubmission(_) => true,
|
||||
|
||||
Reference in new issue
Block a user