@@ -67,7 +67,6 @@ const PlanPage: React.FC = () => {
6767 } else if ( line . trim ( ) === '' ) {
6868 return '' ; // Preserve blank lines
6969 } else {
70- // Use HTML non-breaking spaces to avoid Markdown code block formatting
7170 return ` ${ line } ` ;
7271 }
7372 } ) ;
@@ -231,18 +230,12 @@ const PlanPage: React.FC = () => {
231230 } , 100 ) ;
232231 } , [ ] ) ;
233232
234- const [ networkError , setNetworkError ] = useState < boolean > ( false ) ;
235233 const [ isProcessing , setIsProcessing ] = useState < boolean > ( false ) ;
236234 const [ showProcessingMessage , setShowProcessingMessage ] = useState < boolean > ( false ) ;
237235
238236 //WebsocketMessageType.PLAN_APPROVAL_REQUEST
239237 useEffect ( ( ) => {
240238 const unsubscribe = webSocketService . on ( WebsocketMessageType . PLAN_APPROVAL_REQUEST , ( approvalRequest : any ) => {
241- // Ignore all messages when there's a network error
242- if ( networkError ) {
243- console . log ( '⚠️ Ignoring PLAN_APPROVAL_REQUEST due to network error' ) ;
244- return ;
245- }
246239 console . log ( '📋 Plan received:' , approvalRequest ) ;
247240
248241 let mPlanData : MPlanData | null = null ;
@@ -284,11 +277,7 @@ const PlanPage: React.FC = () => {
284277 //(WebsocketMessageType.AGENT_MESSAGE_STREAMING
285278 useEffect ( ( ) => {
286279 const unsubscribe = webSocketService . on ( WebsocketMessageType . AGENT_MESSAGE_STREAMING , ( streamingMessage : any ) => {
287- // Ignore all messages when there's a network error
288- if ( networkError ) {
289- console . log ( '⚠️ Ignoring AGENT_MESSAGE_STREAMING due to network error' ) ;
290- return ;
291- }
280+
292281 //console.log('📋 Streaming Message', streamingMessage);
293282 // if is final true clear buffer and add final message to agent messages
294283 const line = PlanDataService . simplifyHumanClarification ( streamingMessage . data . content ) ;
@@ -299,16 +288,11 @@ const PlanPage: React.FC = () => {
299288 } ) ;
300289
301290 return ( ) => unsubscribe ( ) ;
302- } , [ scrollToBottom , networkError ] ) ;
291+ } , [ scrollToBottom ] ) ;
303292
304293 //WebsocketMessageType.USER_CLARIFICATION_REQUEST
305294 useEffect ( ( ) => {
306295 const unsubscribe = webSocketService . on ( WebsocketMessageType . USER_CLARIFICATION_REQUEST , ( clarificationMessage : any ) => {
307- // Ignore all messages when there's a network error
308- if ( networkError ) {
309- console . log ( '⚠️ Ignoring USER_CLARIFICATION_REQUEST due to network error' ) ;
310- return ;
311- }
312296 console . log ( '📋 Clarification Message' , clarificationMessage ) ;
313297 console . log ( '📋 Current plan data User clarification' , planData ) ;
314298 if ( ! clarificationMessage ) {
@@ -337,32 +321,22 @@ const PlanPage: React.FC = () => {
337321 } ) ;
338322
339323 return ( ) => unsubscribe ( ) ;
340- } , [ scrollToBottom , planData , processAgentMessage , networkError ] ) ;
324+ } , [ scrollToBottom , planData , processAgentMessage ] ) ;
341325 //WebsocketMessageType.AGENT_TOOL_MESSAGE
342326 useEffect ( ( ) => {
343327 const unsubscribe = webSocketService . on ( WebsocketMessageType . AGENT_TOOL_MESSAGE , ( toolMessage : any ) => {
344- // Ignore all messages when there's a network error
345- if ( networkError ) {
346- console . log ( '⚠️ Ignoring AGENT_TOOL_MESSAGE due to network error' ) ;
347- return ;
348- }
349328 console . log ( '📋 Tool Message' , toolMessage ) ;
350329 // scrollToBottom()
351330
352331 } ) ;
353332
354333 return ( ) => unsubscribe ( ) ;
355- } , [ scrollToBottom , networkError ] ) ;
334+ } , [ scrollToBottom ] ) ;
356335
357336
358337 //WebsocketMessageType.FINAL_RESULT_MESSAGE
359338 useEffect ( ( ) => {
360339 const unsubscribe = webSocketService . on ( WebsocketMessageType . FINAL_RESULT_MESSAGE , ( finalMessage : any ) => {
361- // Ignore all messages when there's a network error
362- if ( networkError ) {
363- console . log ( '⚠️ Ignoring FINAL_RESULT_MESSAGE due to network error' ) ;
364- return ;
365- }
366340 console . log ( '📋 Final Result Message' , finalMessage ) ;
367341 if ( ! finalMessage ) {
368342
@@ -406,7 +380,7 @@ const PlanPage: React.FC = () => {
406380 } ) ;
407381
408382 return ( ) => unsubscribe ( ) ;
409- } , [ scrollToBottom , planData , processAgentMessage , streamingMessageBuffer , setSelectedTeam , networkError ] ) ;
383+ } , [ scrollToBottom , planData , processAgentMessage , streamingMessageBuffer , setSelectedTeam ] ) ;
410384
411385 // WebsocketMessageType.ERROR_MESSAGE
412386 useEffect ( ( ) => {
@@ -463,35 +437,26 @@ const PlanPage: React.FC = () => {
463437 } ) ;
464438
465439 return ( ) => unsubscribe ( ) ;
466- } , [ scrollToBottom , showToast , formatErrorMessage , networkError ] ) ;
440+ } , [ scrollToBottom , showToast , formatErrorMessage ] ) ;
467441
468442 //WebsocketMessageType.AGENT_MESSAGE
469443 useEffect ( ( ) => {
470444 const unsubscribe = webSocketService . on ( WebsocketMessageType . AGENT_MESSAGE , ( agentMessage : any ) => {
471- // Ignore all messages when there's a network error
472- if ( networkError ) {
473- console . log ( '⚠️ Ignoring AGENT_MESSAGE due to network error' ) ;
474- return ;
475- }
476445 console . log ( '📋 Agent Message' , agentMessage )
477446 console . log ( '📋 Current plan data' , planData ) ;
478447 const agentMessageData = agentMessage . data as AgentMessageData ;
479448 if ( agentMessageData ) {
480449 agentMessageData . content = PlanDataService . simplifyHumanClarification ( agentMessageData ?. content ) ;
481450 setAgentMessages ( prev => [ ...prev , agentMessageData ] ) ;
482- // Only show processing spinner if there's no network error
483- if ( ! networkError ) {
484- console . log ( '🔄 [AGENT_MESSAGE] Setting showProcessingPlanSpinner = true' ) ;
485- setShowProcessingPlanSpinner ( true ) ;
486- }
451+ setShowProcessingPlanSpinner ( true ) ;
487452 scrollToBottom ( ) ;
488453 processAgentMessage ( agentMessageData , planData ) ;
489454 }
490455
491456 } ) ;
492457
493458 return ( ) => unsubscribe ( ) ;
494- } , [ scrollToBottom , planData , processAgentMessage , networkError ] ) ; //onPlanReceived, scrollToBottom
459+ } , [ scrollToBottom , planData , processAgentMessage ] ) ; //onPlanReceived, scrollToBottom
495460
496461 // Loading message rotation effect
497462 useEffect ( ( ) => {
@@ -508,8 +473,8 @@ const PlanPage: React.FC = () => {
508473
509474 // WebSocket connection with proper error handling and v3 backend compatibility
510475 useEffect ( ( ) => {
511- if ( planId ) {
512- console . log ( '🔌 Connecting WebSocket:' , { planId } ) ;
476+ if ( planId && continueWithWebsocketFlow ) {
477+ console . log ( '🔌 Connecting WebSocket:' , { planId, continueWithWebsocketFlow } ) ;
513478
514479 const connectWebSocket = async ( ) => {
515480 try {
@@ -567,44 +532,7 @@ const PlanPage: React.FC = () => {
567532 webSocketService . disconnect ( ) ;
568533 } ;
569534 }
570- } , [ planId ] ) ;
571-
572- // Force spinner off whenever network error occurs
573- useEffect ( ( ) => {
574- if ( networkError ) {
575- console . log ( '[NETWORK ERROR DETECTED] Forcing spinner OFF' ) ;
576- setShowProcessingPlanSpinner ( false ) ;
577- setIsProcessing ( false ) ;
578- setShowProcessingMessage ( false ) ;
579- setShowBufferingText ( false ) ;
580- }
581- } , [ networkError ] ) ;
582-
583- useEffect ( ( ) => {
584- const handleOffline = ( ) => {
585- console . log ( 'Network disconnected - stopping all processing' ) ;
586- // Set a flag to show network error and stop all processing states
587- setNetworkError ( true ) ;
588- setShowProcessingMessage ( false ) ;
589- console . log ( '[OFFLINE] Setting showProcessingPlanSpinner = false' ) ;
590- setShowProcessingPlanSpinner ( false ) ;
591- setIsProcessing ( false ) ;
592- setShowBufferingText ( false ) ;
593- } ;
594-
595- const handleOnline = ( ) => {
596- console . log ( 'Network reconnected' ) ;
597- setNetworkError ( false ) ;
598- } ;
599-
600- window . addEventListener ( 'offline' , handleOffline ) ;
601- window . addEventListener ( 'online' , handleOnline ) ;
602-
603- return ( ) => {
604- window . removeEventListener ( 'offline' , handleOffline ) ;
605- window . removeEventListener ( 'online' , handleOnline ) ;
606- } ;
607- } , [ ] ) ;
535+ } , [ planId , loading , continueWithWebsocketFlow ] ) ;
608536
609537 // Create loadPlanData function with useCallback to memoize it
610538 const loadPlanData = useCallback (
@@ -662,40 +590,21 @@ const PlanPage: React.FC = () => {
662590 setProcessingApproval ( true ) ;
663591 let id = showToast ( "Submitting Approval" , "progress" ) ;
664592
665- // Start a 10-second timeout
666- const timeoutId = setTimeout ( ( ) => {
667- dismissToast ( id ) ;
668- setShowProcessingPlanSpinner ( false ) ;
669- setProcessingApproval ( false ) ;
670- setNetworkError ( true ) ;
671- setIsProcessing ( false ) ;
672- setShowProcessingMessage ( false ) ;
673- showToast ( "Approval timed out. Please check your network and try again." , "error" ) ;
674- } , 10000 ) ;
675-
676593 try {
677594 await apiService . approvePlan ( {
678595 m_plan_id : planApprovalRequest . id ,
679596 plan_id : planData ?. plan ?. id ,
680597 approved : true ,
681598 feedback : 'Plan approved by user'
682599 } ) ;
683-
684- clearTimeout ( timeoutId ) ;
600+
685601 dismissToast ( id ) ;
686- // Only show processing spinner if there's no network error
687- if ( ! networkError ) {
688- console . log ( '🔄 [APPROVAL] Setting showProcessingPlanSpinner = true' ) ;
689- setShowProcessingPlanSpinner ( true ) ;
690- } else {
691- console . log ( '⚠️ [APPROVAL] Skipping spinner due to network error' ) ;
692- }
602+ setShowProcessingPlanSpinner ( true ) ;
693603 setShowApprovalButtons ( false ) ;
694604 setIsProcessing ( false ) ;
695605 setShowProcessingMessage ( false ) ;
696606
697607 } catch ( error ) {
698- clearTimeout ( timeoutId ) ;
699608 dismissToast ( id ) ;
700609 showToast ( "Failed to submit approval" , "error" ) ;
701610 console . error ( '❌ Failed to approve plan:' , error ) ;
@@ -773,13 +682,7 @@ const PlanPage: React.FC = () => {
773682
774683 setAgentMessages ( prev => [ ...prev , agentMessageData ] ) ;
775684 setSubmittingChatDisableInput ( true ) ;
776- // Only show processing spinner if there's no network error
777- if ( ! networkError ) {
778- console . log ( '🔄 [CLARIFICATION] Setting showProcessingPlanSpinner = true' ) ;
779- setShowProcessingPlanSpinner ( true ) ;
780- } else {
781- console . log ( '⚠️ [CLARIFICATION] Skipping spinner due to network error' ) ;
782- }
685+ setShowProcessingPlanSpinner ( true ) ;
783686 scrollToBottom ( ) ;
784687
785688 } catch ( error : any ) {
@@ -884,32 +787,7 @@ const PlanPage: React.FC = () => {
884787 </ >
885788 ) : (
886789 < >
887-
888- { networkError && (
889- < div style = { {
890- maxWidth : '800px' ,
891- margin : '0 auto 32px auto' ,
892- padding : '0 24px'
893- } } >
894- < div style = { {
895- display : 'flex' ,
896- alignItems : 'center' ,
897- gap : '16px' ,
898- backgroundColor : 'var(--colorPaletteRedBackground1)' ,
899- borderRadius : '8px' ,
900- border : '1px solid var(--colorPaletteRedBorder1)' ,
901- padding : '16px'
902- } } >
903- < span style = { {
904- fontSize : '14px' ,
905- color : 'var(--colorPaletteRedForeground1)' ,
906- fontWeight : '500'
907- } } >
908- ❌ Network connection lost. Please reconnect to the internet and try again.
909- </ span >
910- </ div >
911- </ div >
912- ) }
790+
913791 < ContentToolbar
914792 panelTitle = "Multi-Agent Planner"
915793 >
@@ -939,7 +817,6 @@ const PlanPage: React.FC = () => {
939817 processingApproval = { processingApproval }
940818 handleApprovePlan = { handleApprovePlan }
941819 handleRejectPlan = { handleRejectPlan }
942- networkError = { networkError }
943820
944821 />
945822 </ >
0 commit comments