cut some lines

This commit is contained in:
Ahmed Ibrahim
2025-08-01 17:40:10 -07:00
parent 21c334ae54
commit 5ccd02b0fe
2 changed files with 6 additions and 22 deletions

View File

@@ -272,33 +272,17 @@ impl McpProcess {
}
/// Connect stream for a conversation and wait for the initial_state notification.
/// Returns the params of the initial_state notification for further inspection.
/// Returns (requestId, params) where params are the initial_state notification params.
pub async fn connect_stream_and_expect_initial_state(
&mut self,
session_id: &str,
) -> anyhow::Result<serde_json::Value> {
) -> anyhow::Result<(i64, serde_json::Value)> {
let req_id = self.send_conversation_stream_tool_call(session_id).await?;
// Wait for stream() tool-call response first
let _ = self
.read_stream_until_response_message(RequestId::Integer(req_id))
.await?;
// Then the initial_state notification
let note = self
.read_stream_until_notification_method("notifications/initial_state")
.await?;
note.params
.ok_or_else(|| anyhow::format_err!("initial_state must have params"))
}
/// Connect stream and also return the request id for later cancellation.
pub async fn connect_stream_get_req_and_initial_state(
&mut self,
session_id: &str,
) -> anyhow::Result<(i64, serde_json::Value)> {
let req_id = self.send_conversation_stream_tool_call(session_id).await?;
let _ = self
.read_stream_until_response_message(RequestId::Integer(req_id))
.await?;
let note = self
.read_stream_until_notification_method("notifications/initial_state")
.await?;

View File

@@ -38,7 +38,7 @@ async fn test_connect_then_send_receives_initial_state_and_notifications() {
.expect("create conversation");
// Connect the stream
let params = mcp
let (_stream_req, params) = mcp
.connect_stream_and_expect_initial_state(&conv_id)
.await
.expect("initial_state params");
@@ -94,7 +94,7 @@ async fn test_send_then_connect_receives_initial_state_with_message() {
.expect("send message ok");
// Now connect stream and expect InitialState with the prior message included
let params = mcp
let (_stream_req, params) = mcp
.connect_stream_and_expect_initial_state(&conv_id)
.await
.expect("initial_state params");
@@ -151,7 +151,7 @@ async fn test_cancel_stream_then_reconnect_catches_up_initial_state() {
.await
.expect("create");
let (stream_a_id, _params) = mcp
.connect_stream_get_req_and_initial_state(&conv_id)
.connect_stream_and_expect_initial_state(&conv_id)
.await
.expect("stream A initial_state");
@@ -183,7 +183,7 @@ async fn test_cancel_stream_then_reconnect_catches_up_initial_state() {
);
// Connect stream B and expect initial_state that includes the response
let params = mcp
let (_stream_req, params) = mcp
.connect_stream_and_expect_initial_state(&conv_id)
.await
.expect("stream B initial_state");