mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
## Why Clients using `thread/search` have to wait for the search to finish before they can show any matches. A search can also outlive the query that triggered it, such as when a user changes their task mention query. ## What changed - Add experimental `thread/search/stream` with best-effort `thread/search/partial` notifications. Each notification carries the original `requestId` and a batch of verified matches. Clients replace provisional matches with the final page, which determines results, ordering, and cursors. - Support connection-scoped cancellation through `thread/search/stream/cancel` and `thread/search/cancel` for their respective search methods. Disconnecting also stops active searches and reaps their search subprocesses. - Cancel superseded or timed-out TUI task mention searches without delaying available title matches. ## Testing Add coverage for incremental results and final-page parity, slow clients, connection-scoped cancellation and subprocess cleanup, and TUI task search cancellation. GitOrigin-RevId: b58abf7a1df424f191c8ede806d1d5266d299548
676 lines
23 KiB
Rust
676 lines
23 KiB
Rust
use super::*;
|
|
use codex_app_server_protocol::AuthRecoveryNotification;
|
|
use codex_app_server_protocol::ConfigWarningNotification;
|
|
use codex_app_server_protocol::RequestId;
|
|
use codex_app_server_protocol::ServerNotification;
|
|
use codex_app_server_protocol::ServerNotificationEnvelope;
|
|
use codex_app_server_protocol::ThreadRealtimeStartedNotification;
|
|
use codex_app_server_protocol::ThreadSearchPartialNotification;
|
|
use codex_protocol::protocol::RealtimeConversationVersion;
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
use pretty_assertions::assert_eq;
|
|
use serde_json::json;
|
|
use tokio::time::Duration;
|
|
use tokio::time::timeout;
|
|
|
|
fn absolute_path(path: &str) -> AbsolutePathBuf {
|
|
AbsolutePathBuf::from_absolute_path(path).expect("absolute path")
|
|
}
|
|
|
|
fn thread_realtime_started_notification() -> ServerNotification {
|
|
ServerNotification::ThreadRealtimeStarted(ThreadRealtimeStartedNotification {
|
|
thread_id: "thread-1".to_string(),
|
|
realtime_session_id: None,
|
|
version: RealtimeConversationVersion::V1,
|
|
})
|
|
}
|
|
|
|
fn app_server_notification(notification: ServerNotification) -> OutgoingMessage {
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification,
|
|
emitted_at_ms: Some(1_234),
|
|
})
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn optional_search_progress_does_not_disconnect_a_slow_connection() {
|
|
let connection_id = ConnectionId(7);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
let disconnect = CancellationToken::new();
|
|
let mut connections = HashMap::from([(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx.clone(),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
Some(disconnect.clone()),
|
|
),
|
|
)]);
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(ServerNotification::ThreadSearchPartial(
|
|
ThreadSearchPartialNotification {
|
|
request_id: RequestId::Integer(4),
|
|
data: Vec::new(),
|
|
},
|
|
)),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(thread_realtime_started_notification()),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
assert!(!disconnect.is_cancelled());
|
|
assert!(connections.contains_key(&connection_id));
|
|
assert!(writer_rx.try_recv().is_ok());
|
|
assert!(writer_rx.try_recv().is_err());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn to_connection_notification_respects_opt_out_filters() {
|
|
let connection_id = ConnectionId(7);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
let initialized = Arc::new(AtomicBool::new(true));
|
|
let opted_out_notification_methods =
|
|
Arc::new(RwLock::new(HashSet::from(["configWarning".to_string()])));
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
initialized,
|
|
Arc::new(AtomicBool::new(true)),
|
|
opted_out_notification_methods,
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(ServerNotification::ConfigWarning(
|
|
ConfigWarningNotification {
|
|
summary: "task_started".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
},
|
|
)),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
assert!(
|
|
writer_rx.try_recv().is_err(),
|
|
"opted-out notification should be dropped"
|
|
);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn to_connection_notifications_are_dropped_for_opted_out_clients() {
|
|
let connection_id = ConnectionId(10);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::from(["configWarning".to_string()]))),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(ServerNotification::ConfigWarning(
|
|
ConfigWarningNotification {
|
|
summary: "task_started".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
},
|
|
)),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
assert!(
|
|
writer_rx.try_recv().is_err(),
|
|
"opted-out notifications should not reach clients"
|
|
);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn to_connection_notifications_are_preserved_for_non_opted_out_clients() {
|
|
let connection_id = ConnectionId(11);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(ServerNotification::ConfigWarning(
|
|
ConfigWarningNotification {
|
|
summary: "task_started".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
},
|
|
)),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
let message = writer_rx
|
|
.recv()
|
|
.await
|
|
.expect("notification should reach non-opted-out clients");
|
|
assert!(matches!(
|
|
message.message,
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification: ServerNotification::ConfigWarning(ConfigWarningNotification { summary, .. }),
|
|
..
|
|
}) if summary == "task_started"
|
|
));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn experimental_notifications_are_dropped_without_capability() {
|
|
let connection_id = ConnectionId(12);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(false)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(thread_realtime_started_notification()),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
assert!(
|
|
writer_rx.try_recv().is_err(),
|
|
"experimental notifications should not reach clients without capability"
|
|
);
|
|
|
|
let recovery = AuthRecoveryNotification {
|
|
thread_id: "thread-1".to_string(),
|
|
turn_id: "turn-1".to_string(),
|
|
provider: "Amazon Bedrock".to_string(),
|
|
message: "Refreshing AWS authentication.".to_string(),
|
|
};
|
|
|
|
for (method, notification) in [
|
|
(
|
|
"modelProvider/authRecoveryStarted",
|
|
ServerNotification::AuthRecoveryStarted(recovery.clone()),
|
|
),
|
|
(
|
|
"modelProvider/authRecoveryCompleted",
|
|
ServerNotification::AuthRecoveryCompleted(recovery),
|
|
),
|
|
] {
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(notification),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
let message = writer_rx
|
|
.recv()
|
|
.await
|
|
.expect("stable auth recovery notification should reach clients without capability");
|
|
let OutgoingMessage::AppServerNotification(envelope) = message.message else {
|
|
panic!("stable auth recovery notification should be delivered");
|
|
};
|
|
assert_eq!(envelope.notification.to_string(), method);
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn experimental_notifications_are_preserved_with_capability() {
|
|
let connection_id = ConnectionId(13);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(thread_realtime_started_notification()),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
let message = writer_rx
|
|
.recv()
|
|
.await
|
|
.expect("experimental notification should reach opted-in client");
|
|
assert!(matches!(
|
|
message.message,
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification: ServerNotification::ThreadRealtimeStarted(_),
|
|
..
|
|
})
|
|
));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn command_execution_request_approval_strips_additional_permissions_without_capability() {
|
|
let connection_id = ConnectionId(8);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(false)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: OutgoingMessage::Request(ServerRequest::CommandExecutionRequestApproval {
|
|
request_id: RequestId::Integer(1),
|
|
params: codex_app_server_protocol::CommandExecutionRequestApprovalParams {
|
|
kind: Default::default(),
|
|
thread_id: "thr_123".to_string(),
|
|
turn_id: "turn_123".to_string(),
|
|
item_id: "call_123".to_string(),
|
|
started_at_ms: 0,
|
|
approval_id: None,
|
|
environment_id: None,
|
|
reason: Some("Need extra read access".to_string()),
|
|
network_approval_context: None,
|
|
command: Some("cat file".to_string()),
|
|
cwd: Some(absolute_path("/tmp").into()),
|
|
command_actions: None,
|
|
additional_permissions: Some(
|
|
codex_app_server_protocol::AdditionalPermissionProfile {
|
|
network: None,
|
|
file_system: Some(
|
|
codex_app_server_protocol::AdditionalFileSystemPermissions {
|
|
read: Some(vec![absolute_path("/tmp/allowed").into()]),
|
|
write: None,
|
|
glob_scan_max_depth: None,
|
|
entries: None,
|
|
},
|
|
),
|
|
},
|
|
),
|
|
proposed_execpolicy_amendment: None,
|
|
proposed_network_policy_amendments: None,
|
|
available_decisions: None,
|
|
},
|
|
}),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
let message = writer_rx
|
|
.recv()
|
|
.await
|
|
.expect("request should be delivered to the connection");
|
|
let json = serde_json::to_value(message.message).expect("request should serialize");
|
|
assert_eq!(json["params"].get("additionalPermissions"), None);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn command_execution_request_approval_keeps_additional_permissions_with_capability() {
|
|
let connection_id = ConnectionId(9);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: OutgoingMessage::Request(ServerRequest::CommandExecutionRequestApproval {
|
|
request_id: RequestId::Integer(1),
|
|
params: codex_app_server_protocol::CommandExecutionRequestApprovalParams {
|
|
kind: Default::default(),
|
|
thread_id: "thr_123".to_string(),
|
|
turn_id: "turn_123".to_string(),
|
|
item_id: "call_123".to_string(),
|
|
started_at_ms: 0,
|
|
approval_id: None,
|
|
environment_id: None,
|
|
reason: Some("Need extra read access".to_string()),
|
|
network_approval_context: None,
|
|
command: Some("cat file".to_string()),
|
|
cwd: Some(absolute_path("/tmp").into()),
|
|
command_actions: None,
|
|
additional_permissions: Some(
|
|
codex_app_server_protocol::AdditionalPermissionProfile {
|
|
network: None,
|
|
file_system: Some(
|
|
codex_app_server_protocol::AdditionalFileSystemPermissions {
|
|
read: Some(vec![absolute_path("/tmp/allowed").into()]),
|
|
write: None,
|
|
glob_scan_max_depth: None,
|
|
entries: None,
|
|
},
|
|
),
|
|
},
|
|
),
|
|
proposed_execpolicy_amendment: None,
|
|
proposed_network_policy_amendments: None,
|
|
available_decisions: None,
|
|
},
|
|
}),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await;
|
|
|
|
let message = writer_rx
|
|
.recv()
|
|
.await
|
|
.expect("request should be delivered to the connection");
|
|
let json = serde_json::to_value(message.message).expect("request should serialize");
|
|
let allowed_path = absolute_path("/tmp/allowed").to_string_lossy().into_owned();
|
|
assert_eq!(
|
|
json["params"]["additionalPermissions"],
|
|
json!({
|
|
"network": null,
|
|
"fileSystem": {
|
|
"read": [allowed_path],
|
|
"write": null,
|
|
},
|
|
})
|
|
);
|
|
}
|
|
|
|
/// Broadcasts preserve their payload for eligible recipients and skip every other connection.
|
|
/// The empty eligible set must not accidentally send to an uninitialized or opted-out client.
|
|
#[tokio::test]
|
|
async fn broadcast_only_reaches_eligible_connections() {
|
|
for eligible_count in 0..=2 {
|
|
let notification = thread_realtime_started_notification();
|
|
let method = notification.to_string();
|
|
let message = app_server_notification(notification);
|
|
let expected = serde_json::to_value(&message).expect("serialize notification");
|
|
let mut connections = HashMap::new();
|
|
let mut receivers = Vec::new();
|
|
let configs = [
|
|
(false, true, HashSet::new()),
|
|
(true, false, HashSet::new()),
|
|
(true, true, HashSet::from([method])),
|
|
]
|
|
.into_iter()
|
|
.chain((0..eligible_count).map(|_| (true, true, HashSet::new())));
|
|
for (index, (initialized, experimental_api, opted_out_methods)) in configs.enumerate() {
|
|
let (writer_tx, writer_rx) = mpsc::channel(1);
|
|
connections.insert(
|
|
ConnectionId(index as u64),
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(initialized)),
|
|
Arc::new(AtomicBool::new(experimental_api)),
|
|
Arc::new(RwLock::new(opted_out_methods)),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
receivers.push(writer_rx);
|
|
}
|
|
|
|
route_outgoing_envelope(&mut connections, OutgoingEnvelope::Broadcast { message }).await;
|
|
|
|
for (index, mut receiver) in receivers.into_iter().enumerate() {
|
|
if index < 3 {
|
|
assert!(receiver.try_recv().is_err());
|
|
} else {
|
|
let queued = receiver
|
|
.try_recv()
|
|
.expect("eligible client receives notification");
|
|
assert_eq!(serde_json::to_value(&queued.message).unwrap(), expected);
|
|
assert!(queued.write_complete_tx.is_none());
|
|
assert!(receiver.try_recv().is_err());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn broadcast_does_not_block_on_slow_connection() {
|
|
let fast_connection_id = ConnectionId(1);
|
|
let slow_connection_id = ConnectionId(2);
|
|
|
|
let (fast_writer_tx, mut fast_writer_rx) = mpsc::channel(1);
|
|
let (slow_writer_tx, mut slow_writer_rx) = mpsc::channel(1);
|
|
let fast_disconnect_token = CancellationToken::new();
|
|
let slow_disconnect_token = CancellationToken::new();
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
fast_connection_id,
|
|
OutboundConnectionState::new(
|
|
fast_writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
Some(fast_disconnect_token.clone()),
|
|
),
|
|
);
|
|
connections.insert(
|
|
slow_connection_id,
|
|
OutboundConnectionState::new(
|
|
slow_writer_tx.clone(),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
Some(slow_disconnect_token.clone()),
|
|
),
|
|
);
|
|
|
|
let queued_message = app_server_notification(ServerNotification::ConfigWarning(
|
|
ConfigWarningNotification {
|
|
summary: "already-buffered".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
},
|
|
));
|
|
slow_writer_tx
|
|
.try_send(QueuedOutgoingMessage::new(queued_message))
|
|
.expect("channel should have room");
|
|
|
|
let broadcast_message = app_server_notification(ServerNotification::ConfigWarning(
|
|
ConfigWarningNotification {
|
|
summary: "test".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
},
|
|
));
|
|
timeout(
|
|
Duration::from_millis(100),
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::Broadcast {
|
|
message: broadcast_message,
|
|
},
|
|
),
|
|
)
|
|
.await
|
|
.expect("broadcast should return even when one connection is slow");
|
|
assert!(!connections.contains_key(&slow_connection_id));
|
|
assert!(slow_disconnect_token.is_cancelled());
|
|
assert!(!fast_disconnect_token.is_cancelled());
|
|
let fast_message = fast_writer_rx
|
|
.try_recv()
|
|
.expect("fast connection should receive the broadcast notification");
|
|
assert!(matches!(
|
|
fast_message.message,
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification: ServerNotification::ConfigWarning(ConfigWarningNotification { summary, .. }),
|
|
..
|
|
}) if summary == "test"
|
|
));
|
|
|
|
let slow_message = slow_writer_rx
|
|
.try_recv()
|
|
.expect("slow connection should retain its original buffered message");
|
|
assert!(matches!(
|
|
slow_message.message,
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification: ServerNotification::ConfigWarning(ConfigWarningNotification { summary, .. }),
|
|
..
|
|
}) if summary == "already-buffered"
|
|
));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn to_connection_stdio_waits_instead_of_disconnecting_when_writer_queue_is_full() {
|
|
let connection_id = ConnectionId(3);
|
|
let (writer_tx, mut writer_rx) = mpsc::channel(1);
|
|
writer_tx
|
|
.send(QueuedOutgoingMessage::new(app_server_notification(
|
|
ServerNotification::ConfigWarning(ConfigWarningNotification {
|
|
summary: "queued".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
}),
|
|
)))
|
|
.await
|
|
.expect("channel should accept the first queued message");
|
|
|
|
let mut connections = HashMap::new();
|
|
connections.insert(
|
|
connection_id,
|
|
OutboundConnectionState::new(
|
|
writer_tx,
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(AtomicBool::new(true)),
|
|
Arc::new(RwLock::new(HashSet::new())),
|
|
/*disconnect_sender*/ None,
|
|
),
|
|
);
|
|
|
|
let route_task = tokio::spawn(async move {
|
|
route_outgoing_envelope(
|
|
&mut connections,
|
|
OutgoingEnvelope::ToConnection {
|
|
connection_id,
|
|
message: app_server_notification(ServerNotification::ConfigWarning(
|
|
ConfigWarningNotification {
|
|
summary: "second".to_string(),
|
|
details: None,
|
|
path: None,
|
|
range: None,
|
|
},
|
|
)),
|
|
write_complete_tx: None,
|
|
},
|
|
)
|
|
.await
|
|
});
|
|
|
|
let first = timeout(Duration::from_millis(100), writer_rx.recv())
|
|
.await
|
|
.expect("first queued message should be readable")
|
|
.expect("first queued message should exist");
|
|
timeout(Duration::from_millis(100), route_task)
|
|
.await
|
|
.expect("routing should finish after the first queued message is drained")
|
|
.expect("routing task should succeed");
|
|
|
|
assert!(matches!(
|
|
first.message,
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification: ServerNotification::ConfigWarning(ConfigWarningNotification { summary, .. }),
|
|
..
|
|
}) if summary == "queued"
|
|
));
|
|
let second = writer_rx
|
|
.try_recv()
|
|
.expect("second notification should be delivered once the queue has room");
|
|
assert!(matches!(
|
|
second.message,
|
|
OutgoingMessage::AppServerNotification(ServerNotificationEnvelope {
|
|
notification: ServerNotification::ConfigWarning(ConfigWarningNotification { summary, .. }),
|
|
..
|
|
}) if summary == "second"
|
|
));
|
|
}
|