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
@@ -56,11 +56,11 @@ async fn deliver_rolling_rate_limit_snapshot(
|
||||
) {
|
||||
app.handle_app_server_event(
|
||||
app_server,
|
||||
codex_app_server_client::AppServerEvent::ServerNotification(
|
||||
codex_app_server_client::AppServerEvent::ServerNotification(Box::new(
|
||||
ServerNotification::AccountRateLimitsUpdated(AccountRateLimitsUpdatedNotification {
|
||||
rate_limits: snapshot,
|
||||
}),
|
||||
),
|
||||
)),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ async fn next_turn_started(
|
||||
.await
|
||||
.expect("app-server should emit a turn/start event")
|
||||
.expect("app-server event stream should remain open");
|
||||
let started_turn_id = match &event {
|
||||
AppServerEvent::ServerNotification(ServerNotification::TurnStarted(notification))
|
||||
if notification.thread_id == thread_id.to_string() =>
|
||||
{
|
||||
Some(notification.turn.id.clone())
|
||||
}
|
||||
_ => None,
|
||||
let started_turn_id = if let AppServerEvent::ServerNotification(notification) = &event
|
||||
&& let ServerNotification::TurnStarted(notification) = notification.as_ref()
|
||||
&& notification.thread_id == thread_id.to_string()
|
||||
{
|
||||
Some(notification.turn.id.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
app.handle_app_server_event(app_server, event).await;
|
||||
drain_active_thread_events(app);
|
||||
@@ -138,8 +138,12 @@ async fn wait_for_turn_completed(
|
||||
.expect("app-server event stream should remain open");
|
||||
let completed = matches!(
|
||||
&event,
|
||||
AppServerEvent::ServerNotification(ServerNotification::TurnCompleted(notification))
|
||||
if notification.thread_id == thread_id.to_string()
|
||||
AppServerEvent::ServerNotification(notification)
|
||||
if matches!(
|
||||
notification.as_ref(),
|
||||
ServerNotification::TurnCompleted(notification)
|
||||
if notification.thread_id == thread_id.to_string()
|
||||
)
|
||||
);
|
||||
app.handle_app_server_event(app_server, event).await;
|
||||
drain_active_thread_events(app);
|
||||
@@ -237,12 +241,12 @@ stream_max_retries = 0
|
||||
}
|
||||
|
||||
while app_event_rx.try_recv().is_ok() {}
|
||||
app.handle_thread_event_now(ThreadBufferedEvent::Notification(
|
||||
app.handle_thread_event_now(ThreadBufferedEvent::Notification(Box::new(
|
||||
ServerNotification::Warning(WarningNotification {
|
||||
thread_id: Some(thread_id.to_string()),
|
||||
message: "event handled while interrupt is pending".to_string(),
|
||||
}),
|
||||
));
|
||||
)));
|
||||
assert!(matches!(
|
||||
app_event_rx.try_recv(),
|
||||
Ok(AppEvent::InsertHistoryCell(_))
|
||||
@@ -507,16 +511,18 @@ goals = true
|
||||
|
||||
app.handle_app_server_event(
|
||||
&app_server,
|
||||
AppServerEvent::ServerNotification(ServerNotification::ModelSafetyBufferingUpdated(
|
||||
ModelSafetyBufferingUpdatedNotification {
|
||||
thread_id: source_thread_id.to_string(),
|
||||
turn_id: active_turn_id.clone(),
|
||||
model: CURRENT_MODEL.to_string(),
|
||||
use_cases: Vec::new(),
|
||||
reasons: Vec::new(),
|
||||
show_buffering_ui: true,
|
||||
faster_model: Some(FASTER_MODEL.to_string()),
|
||||
},
|
||||
AppServerEvent::ServerNotification(Box::new(
|
||||
ServerNotification::ModelSafetyBufferingUpdated(
|
||||
ModelSafetyBufferingUpdatedNotification {
|
||||
thread_id: source_thread_id.to_string(),
|
||||
turn_id: active_turn_id.clone(),
|
||||
model: CURRENT_MODEL.to_string(),
|
||||
use_cases: Vec::new(),
|
||||
reasons: Vec::new(),
|
||||
show_buffering_ui: true,
|
||||
faster_model: Some(FASTER_MODEL.to_string()),
|
||||
},
|
||||
),
|
||||
)),
|
||||
)
|
||||
.await;
|
||||
@@ -584,16 +590,18 @@ goals = true
|
||||
.await;
|
||||
app.handle_app_server_event(
|
||||
&app_server,
|
||||
AppServerEvent::ServerNotification(ServerNotification::ModelSafetyBufferingUpdated(
|
||||
ModelSafetyBufferingUpdatedNotification {
|
||||
thread_id: first_retry_thread_id.to_string(),
|
||||
turn_id: first_retry_turn_id.clone(),
|
||||
model: FASTER_MODEL.to_string(),
|
||||
use_cases: Vec::new(),
|
||||
reasons: Vec::new(),
|
||||
show_buffering_ui: true,
|
||||
faster_model: Some(FASTER_MODEL.to_string()),
|
||||
},
|
||||
AppServerEvent::ServerNotification(Box::new(
|
||||
ServerNotification::ModelSafetyBufferingUpdated(
|
||||
ModelSafetyBufferingUpdatedNotification {
|
||||
thread_id: first_retry_thread_id.to_string(),
|
||||
turn_id: first_retry_turn_id.clone(),
|
||||
model: FASTER_MODEL.to_string(),
|
||||
use_cases: Vec::new(),
|
||||
reasons: Vec::new(),
|
||||
show_buffering_ui: true,
|
||||
faster_model: Some(FASTER_MODEL.to_string()),
|
||||
},
|
||||
),
|
||||
)),
|
||||
)
|
||||
.await;
|
||||
|
||||
Reference in new issue
Block a user