From 8597e7dd1fa0c256c1a5c00b453e670cb0e3f528 Mon Sep 17 00:00:00 2001 From: Violetta Zhao Date: Wed, 9 Sep 2026 09:39:41 -0500 Subject: [PATCH] Issue-2683: add reconnect notification --- modeling-cmds/src/websocket.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modeling-cmds/src/websocket.rs b/modeling-cmds/src/websocket.rs index 1fbf3826..f1228c03 100644 --- a/modeling-cmds/src/websocket.rs +++ b/modeling-cmds/src/websocket.rs @@ -240,6 +240,11 @@ pub enum OkWebSocketResponseData { /// Result after executing KCL. result: Result, }, + + /// Request that the client end this connection and establish a new session + /// using normal authentication and authorization. + /// This does not guarantee that a new session will be accepted. + Reconnect {}, } /// Successful Websocket response. @@ -912,6 +917,22 @@ mod tests { const REQ_ID: Uuid = uuid::uuid!("cc30d5e2-482b-4498-b5d2-6131c30a50a4"); + #[test] + fn reconnect_response_round_trip() { + let response = WebSocketResponse::success(None, OkWebSocketResponseData::Reconnect {}); + let expected = serde_json::json!({ + "success": true, + "request_id": null, + "resp": { + "type": "reconnect", + "data": {} + } + }); + assert_eq!(serde_json::to_value(&response).unwrap(), expected); + let decoded: WebSocketResponse = serde_json::from_value(expected).unwrap(); + assert_eq!(decoded, response); + } + #[test] fn serialize_websocket_modeling_ok() { let actual = WebSocketResponse::Success(SuccessWebSocketResponse {