Skip to content

Commit 620adc5

Browse files
authored
test: Add test for unstable session info feature (#35)
1 parent 6025456 commit 620adc5

File tree

2 files changed

+54
-7
lines changed

2 files changed

+54
-7
lines changed

examples/client.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,7 @@ impl acp::Client for ExampleClient {
9090
};
9191
println!("| Agent: {text}");
9292
}
93-
acp::SessionUpdate::UserMessageChunk { .. }
94-
| acp::SessionUpdate::AgentThoughtChunk { .. }
95-
| acp::SessionUpdate::ToolCall(_)
96-
| acp::SessionUpdate::ToolCallUpdate(_)
97-
| acp::SessionUpdate::Plan(_)
98-
| acp::SessionUpdate::CurrentModeUpdate { .. }
99-
| acp::SessionUpdate::AvailableCommandsUpdate { .. } => {}
93+
_ => {} // Handle future variants gracefully
10094
}
10195
Ok(())
10296
}

src/agent-client-protocol/src/rpc_tests.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,3 +819,56 @@ async fn test_resume_session() {
819819
})
820820
.await;
821821
}
822+
823+
#[cfg(feature = "unstable_session_info_update")]
824+
#[tokio::test]
825+
async fn test_session_info_update() {
826+
let local_set = tokio::task::LocalSet::new();
827+
local_set
828+
.run_until(async {
829+
let client = TestClient::new();
830+
let agent = TestAgent::new();
831+
832+
let (_agent_conn, client_conn) = create_connection_pair(&client, &agent);
833+
834+
let session_id = SessionId::new("test-session");
835+
836+
// Send a session info update notification
837+
client_conn
838+
.session_notification(SessionNotification::new(
839+
session_id.clone(),
840+
SessionUpdate::SessionInfoUpdate(
841+
agent_client_protocol_schema::SessionInfoUpdate::new()
842+
.title("Test Session Title")
843+
.updated_at("2025-01-15T12:00:00Z"),
844+
),
845+
))
846+
.await
847+
.expect("session_notification failed");
848+
849+
tokio::task::yield_now().await;
850+
851+
// Verify client received the notification
852+
let notifications = client.session_notifications.lock().unwrap();
853+
assert_eq!(notifications.len(), 1);
854+
assert_eq!(notifications[0].session_id, session_id);
855+
856+
if let SessionUpdate::SessionInfoUpdate(info_update) = &notifications[0].update {
857+
assert_eq!(
858+
info_update.title,
859+
agent_client_protocol_schema::MaybeUndefined::Value(
860+
"Test Session Title".to_string()
861+
)
862+
);
863+
assert_eq!(
864+
info_update.updated_at,
865+
agent_client_protocol_schema::MaybeUndefined::Value(
866+
"2025-01-15T12:00:00Z".to_string()
867+
)
868+
);
869+
} else {
870+
panic!("Expected SessionInfoUpdate variant");
871+
}
872+
})
873+
.await;
874+
}

0 commit comments

Comments
 (0)