@@ -689,56 +689,30 @@ impl EventHandler for DiscordEventHandler {
689689 {
690690 Ok ( mut stream) => {
691691 use futures:: StreamExt ;
692- let mut response_text = String :: new ( ) ;
693692
694693 while let Some ( event) = stream. next ( ) . await {
695694 match event {
696- pattern_core:: coordination:: groups:: GroupResponseEvent :: TextChunk { text , is_final , .. } => {
697- if text . len ( ) > 1 {
698- response_text . push_str ( & text ) ;
699-
700- // Send complete chunks as they arrive
701- if is_final || text . ends_with ( '\n' ) || response_text . len ( ) > 1000 {
702- if !response_text . trim ( ) . is_empty ( ) {
703- // Send the response to Discord
704- if let Err ( e ) = channel_id . say ( & ctx_clone . http , & response_text ) . await {
705- warn ! ( "Failed to send reaction response to Discord: {} " , e ) ;
706- }
707- response_text . clear ( ) ;
708- }
695+ pattern_core:: coordination:: groups:: GroupResponseEvent :: TextChunk { .. } => {
696+
697+ }
698+ pattern_core :: coordination :: groups :: GroupResponseEvent :: ToolCallStarted { fn_name , .. } => {
699+ // Show tool activity for reactions too
700+ let tool_msg = match fn_name . as_str ( ) {
701+ "context" => "💭 Processing reaction context..." . to_string ( ) ,
702+ "recall" => "🔍 Searching reaction history..." . to_string ( ) ,
703+ "send_message" => { continue ; } ,
704+ _ => format ! ( "🔧 Processing with {}... " , fn_name )
705+ } ;
706+ if let Err ( e ) = channel_id . say ( & ctx_clone . http , tool_msg ) . await {
707+ debug ! ( "Failed to send tool activity: {}" , e ) ;
709708 }
710709 }
711- }
712- pattern_core:: coordination:: groups:: GroupResponseEvent :: ToolCallStarted { fn_name, .. } => {
713- // Show tool activity for reactions too
714- let tool_msg = match fn_name. as_str ( ) {
715- "context" => "💭 Processing reaction context..." . to_string ( ) ,
716- "recall" => "🔍 Searching reaction history..." . to_string ( ) ,
717- _ => format ! ( "🔧 Processing with {}..." , fn_name)
718- } ;
719- if let Err ( e) = channel_id. say ( & ctx_clone. http , tool_msg) . await {
720- debug ! ( "Failed to send tool activity: {}" , e) ;
710+ pattern_core:: coordination:: groups:: GroupResponseEvent :: Error { message, .. } => {
711+ warn ! ( "Error processing reaction: {}" , message) ;
721712 }
713+ _ => { }
722714 }
723- pattern_core:: coordination:: groups:: GroupResponseEvent :: Error { message, .. } => {
724- warn ! ( "Error processing reaction: {}" , message) ;
725- }
726- _ => { }
727715 }
728- }
729-
730- // Send any remaining text
731- // if !response_text.trim().is_empty() {
732- // if let Err(e) = channel_id
733- // .say(&ctx_clone.http, &response_text)
734- // .await
735- // {
736- // warn!(
737- // "Failed to send final reaction response: {}",
738- // e
739- // );
740- // }
741- // }
742716 }
743717 Err ( e) => {
744718 warn ! (
@@ -1059,44 +1033,28 @@ impl DiscordBot {
10591033 } else {
10601034 stream
10611035 } ;
1062- let mut response = String :: new ( ) ;
10631036 let mut has_response = false ;
10641037
1038+ let ctx_clone = ctx. clone ( ) ;
10651039 while let Some ( event) = stream. next ( ) . await {
1040+ has_response = true ;
10661041 match event {
1067- pattern_core:: coordination:: groups:: GroupResponseEvent :: TextChunk { text, is_final, .. } => {
1068- if !text. is_empty ( ) && text. trim ( ) != "." {
1069- response. push_str ( & text) ;
1070- has_response = true ;
1071-
1072- // Send complete chunks
1073- if is_final || text. ends_with ( '\n' ) || response. len ( ) > 1500 {
1074- if !response. trim ( ) . is_empty ( ) {
1075- for chunk in split_message ( & response, 2000 ) {
1076- if let Err ( e) = ChannelId :: new ( channel_id) . say ( & ctx. http , chunk) . await {
1077- warn ! ( "Failed to send batch response: {}" , e) ;
1078- }
1079- }
1080- response. clear ( ) ;
1081- }
1082- }
1083- }
1042+ pattern_core:: coordination:: groups:: GroupResponseEvent :: ToolCallStarted { fn_name, .. } => {
1043+ // // Show tool activity for reactions too
1044+ // let tool_msg = match fn_name.as_str() {
1045+ // "context" => "💭 Processing reaction context...".to_string(),
1046+ // "recall" => "🔍 Searching reaction history...".to_string(),
1047+ // "send_message" => {continue;},
1048+ // _ => format!("🔧 Processing with {}...", fn_name)
1049+ // };
1050+ // if let Err(e) = channel_id.say(&ctx_clone.http, tool_msg).await {
1051+ // debug!("Failed to send tool activity: {}", e);
1052+ // }
10841053 }
10851054 _ => { } // Ignore other events for batch processing
10861055 }
10871056 }
10881057
1089- // Send any remaining response
1090- if !response. trim ( ) . is_empty ( ) {
1091- for chunk in split_message ( & response, 2000 ) {
1092- if let Err ( e) =
1093- ChannelId :: new ( channel_id) . say ( & ctx. http , chunk) . await
1094- {
1095- warn ! ( "Failed to send final batch response: {}" , e) ;
1096- }
1097- }
1098- }
1099-
11001058 if !has_response {
11011059 // No response to batch, send indicator
11021060 let _ = ChannelId :: new ( channel_id) . say ( & ctx. http , "💭 ..." ) . await ;
0 commit comments