@@ -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