Upgrade rmcp to 3.5.1 and harden lifecycle tests (#52972)

## What changed

- Update the pinned `rmcp` dependency and Cargo/Bazel lockfiles, and migrate MCP handlers and fixtures to `ClientConfig` and `ServerConfig`.
- Stop requiring responses for cancelled elicitation requests in cancellation tests while retaining checks for cleanup and continued connection usability.
- Handle client disconnects during WebSocket writes in the TUI test server, use an asynchronous HTTP mock for loopback proxy testing, and improve remote executor test diagnostics and the Windows subprocess fixture.
- Use `invalid_prompt` for the memory worker failure fixture.

## Testing

Add a regression test covering transport EOF during both form elicitation and user verification. Keep the client alive while checking that pending response channels close, the timeout pause clears, and the service exits with `QuitReason::Closed`.

GitOrigin-RevId: c0166b83fab3b59d84a5207c6630cb6adcf3b230
This commit is contained in:
alishobeiri-oai
2026-10-10 19:43:24 +00:00
committed by copyberry
parent 34f33e4ada
commit de8fab6d7a
26 changed files with 212 additions and 162 deletions
@@ -39,11 +39,26 @@ use tokio::net::TcpListener;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use tokio_tungstenite::accept_async;
use tokio_tungstenite::tungstenite::Error as WebSocketError;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::tungstenite::error::ProtocolError;
pub(super) type RecordedRequests = Arc<Mutex<Vec<JSONRPCRequest>>>;
pub(super) type RecordingAppServer = (AppServerSession, RecordedRequests, JoinHandle<Result<()>>);
fn is_recording_client_disconnect(error: &WebSocketError) -> bool {
match error {
WebSocketError::Protocol(ProtocolError::ResetWithoutClosingHandshake) => true,
WebSocketError::Io(error) => matches!(
error.kind(),
std::io::ErrorKind::BrokenPipe
| std::io::ErrorKind::ConnectionReset
| std::io::ErrorKind::ConnectionAborted
),
_ => false,
}
}
#[tokio::test]
async fn daybreak_command_persists_and_confirms_each_selection() -> Result<()> {
use codex_protocol::openai_models::ModelAccessPrograms;
@@ -495,20 +510,19 @@ pub(super) async fn start_recording_app_server_with_realtime_speech(
if let codex_app_server_client::InProcessServerEvent::ServerNotification(notification) = event
&& matches!(*notification, ServerNotification::ThreadSettingsUpdated(_))
{
websocket.send(Message::Text(serde_json::to_string(&notification)?.into())).await?;
let result = websocket.send(Message::Text(serde_json::to_string(&notification)?.into())).await;
if result.as_ref().is_err_and(is_recording_client_disconnect) {
break;
}
result?;
}
continue;
}
};
let Some(frame) = frame else { break };
// The client can close with an unread settings notification during shutdown.
match &frame {
Err(tokio_tungstenite::tungstenite::Error::Protocol(
tokio_tungstenite::tungstenite::error::ProtocolError::ResetWithoutClosingHandshake,
)) => break,
Err(tokio_tungstenite::tungstenite::Error::Io(error))
if matches!(error.kind(), std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted) => break,
_ => {}
// The client can close with requests or notifications pending during shutdown.
if frame.as_ref().is_err_and(is_recording_client_disconnect) {
break;
}
let Message::Text(text) = frame? else {
continue;
@@ -516,7 +530,7 @@ pub(super) async fn start_recording_app_server_with_realtime_speech(
let message = serde_json::from_str::<JSONRPCMessage>(&text)?;
match message {
JSONRPCMessage::Request(request) if request.method == "initialize" => {
websocket
let result = websocket
.send(Message::Text(
serde_json::to_string(&JSONRPCMessage::Response(JSONRPCResponse {
id: request.id,
@@ -527,7 +541,11 @@ pub(super) async fn start_recording_app_server_with_realtime_speech(
}))?
.into(),
))
.await?;
.await;
if result.as_ref().is_err_and(is_recording_client_disconnect) {
break;
}
result?;
}
JSONRPCMessage::Request(request) => {
request_sink
@@ -803,9 +821,13 @@ pub(super) async fn start_recording_app_server_with_realtime_speech(
}
}
};
websocket
let result = websocket
.send(Message::Text(serde_json::to_string(&response)?.into()))
.await?;
.await;
if result.as_ref().is_err_and(is_recording_client_disconnect) {
break;
}
result?;
}
JSONRPCMessage::Notification(notification)
if notification.method == "initialized" => {}