From 02e9bd0fb5fc0bb579bf1e3c7f793f9b2fb5e921 Mon Sep 17 00:00:00 2001 From: dal Date: Sat, 19 Apr 2025 21:22:00 -0600 Subject: [PATCH] no double complete --- api/server/src/routes/ws/chats/post_chat.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/api/server/src/routes/ws/chats/post_chat.rs b/api/server/src/routes/ws/chats/post_chat.rs index a6941f064..f64924e22 100644 --- a/api/server/src/routes/ws/chats/post_chat.rs +++ b/api/server/src/routes/ws/chats/post_chat.rs @@ -1,4 +1,3 @@ - use anyhow::Result; use handlers::chats::post_chat_handler::ChatCreateNewChat; use handlers::chats::post_chat_handler::{self, ThreadEvent}; @@ -104,17 +103,10 @@ pub async fn post_thread( // Call shared handler with channel for streaming messages match post_chat_handler::post_chat_handler(request, user.clone(), Some(tx)).await { Ok(chat_with_messages) => { - // For prompt-less flows, the handler might already be done, so explicitly send the completed event - // This ensures the client knows the process is complete - let response = WsResponseMessage::new_no_user( - WsRoutes::Chats(ChatsRoute::Post), - WsEvent::Threads(WSThreadEvent::Complete), - &post_chat_handler::BusterContainer::Chat(chat_with_messages), - None, - WsSendMethod::All, - ); - - send_ws_message(&user.id.to_string(), &response).await?; + // The spawned task above already handles forwarding the 'Complete' event + // received from the handler. Sending it again here is redundant. + // The final chat state is implicitly sent when the handler sends + // its BusterContainer::Chat with the Completed event. Ok(()) } Err(e) => {