@@ -881,64 +881,49 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
881881 // Trigger manual summarization of the conversation context
882882 const currentCline = provider . getCurrentCline ( )
883883 if ( currentCline ) {
884- try {
885- // First send a message to the webview to show a progress indicator
886- provider . postMessageToWebview ( {
887- type : "summarizationStatus" ,
888- status : "started" ,
889- text : t ( "common:info.summarizing_context" ) ,
890- } )
891-
892- // Notify user that summarization is in progress
893- vscode . window . showInformationMessage ( t ( "common:info.summarizing_context" ) )
894-
895- // Add a "summarizing" message to the chat
896- await currentCline . say ( "summarizing" , t ( "common:info.summarizing_context" ) , undefined , true )
897-
898- // Trigger the summarization process
899- await currentCline . summarizeConversationContext ( true ) // true indicates manual trigger
900-
901- // Update the "summarizing" message to show completion
902- const lastMessage = currentCline . clineMessages . at ( - 1 )
903- if ( lastMessage && lastMessage . say === "summarizing" && lastMessage . partial ) {
904- lastMessage . text = t ( "common:info.summarization_complete" )
905- lastMessage . partial = false
906- await currentCline . saveClineMessages ( )
907- await provider . postStateToWebview ( )
908- }
909-
910- // Send a message to the webview to hide the progress indicator
911- provider . postMessageToWebview ( {
912- type : "summarizationStatus" ,
913- status : "completed" ,
914- text : t ( "common:info.summarization_complete" ) ,
915- } )
884+ // First send a message to the webview to show a progress indicator
885+ void provider . postMessageToWebview ( {
886+ type : "summarizationStatus" ,
887+ status : "started" ,
888+ text : t ( "common:info.summarizing_context" ) ,
889+ } )
916890
917- // Notify user that summarization is complete
918- vscode . window . showInformationMessage ( t ( "common:info.summarization_complete" ) )
919- } catch ( error ) {
920- provider . log (
921- `Error during manual summarization: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
922- )
891+ // Use a non-blocking approach with proper error handling
892+ ; ( async function summarizeContext ( ) {
893+ try {
894+ // Add a system notification message that doesn't require user interaction
895+ await currentCline . say ( "text" , "[System: Summarizing conversation context...]" )
896+
897+ // Trigger the summarization process
898+ await currentCline . summarizeConversationContext ( true ) // true indicates manual trigger
899+
900+ // Add a completion message
901+ await currentCline . say ( "text" , "[System: Conversation context summarization complete]" )
902+
903+ // Send a message to the webview to hide the progress indicator
904+ void provider . postMessageToWebview ( {
905+ type : "summarizationStatus" ,
906+ status : "completed" ,
907+ text : t ( "common:info.summarization_complete" ) ,
908+ } )
909+ } catch ( error ) {
910+ provider . log (
911+ `Error during manual summarization: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
912+ )
923913
924- // Update the UI to show the error
925- provider . postMessageToWebview ( {
926- type : "summarizationStatus" ,
927- status : "failed" ,
928- text : t ( "common:errors.summarization_failed" ) ,
929- } )
914+ // Update the UI to show the error
915+ void provider . postMessageToWebview ( {
916+ type : "summarizationStatus" ,
917+ status : "failed" ,
918+ text : t ( "common:errors.summarization_failed" ) ,
919+ } )
930920
931- // Update any partial message
932- const lastMessage = currentCline . clineMessages . at ( - 1 )
933- if ( lastMessage && lastMessage . say === "summarizing" && lastMessage . partial ) {
934- lastMessage . text = t ( "common:errors.summarization_failed" )
935- lastMessage . partial = false
936- await currentCline . saveClineMessages ( )
937- await provider . postStateToWebview ( )
921+ // Add an error message
922+ await currentCline . say ( "error" , t ( "common:errors.summarization_failed" ) )
938923 }
939-
940- vscode . window . showErrorMessage ( t ( "common:errors.summarization_failed" ) )
941- }
924+ } ) ( ) . catch ( ( error ) => {
925+ provider . log ( `Unhandled error in summarization: ${ String ( error ) } ` )
926+ } )
942927 }
943928 break
944929 // --- End Context Summarization ---
0 commit comments