@@ -28,7 +28,7 @@ import { AgentMessageData, WebsocketMessageType } from "@/models";
2828import getUserPlan from "./streaming/StreamingUserPlan" ;
2929import renderUserPlanMessage from "./streaming/StreamingUserPlanMessage" ;
3030import renderPlanResponse from "./streaming/StreamingPlanResponse" ;
31- import renderThinkingState from "./streaming/StreamingPlanState" ;
31+ import { renderPlanExecutionMessage , renderThinkingState } from "./streaming/StreamingPlanState" ;
3232import ContentNotFound from "../NotFound/ContentNotFound" ;
3333import PlanChatBody from "./PlanChatBody" ;
3434import renderBufferMessage from "./streaming/StreamingBufferMessage" ;
@@ -42,6 +42,12 @@ interface SimplifiedPlanChatProps extends PlanChatProps {
4242 messagesContainerRef : React . RefObject < HTMLDivElement > ;
4343 streamingMessageBuffer : string ;
4444 agentMessages : AgentMessageData [ ] ;
45+ showProcessingPlanSpinner : boolean ;
46+ showApprovalButtons : boolean ;
47+ handleApprovePlan : ( ) => Promise < void > ;
48+ handleRejectPlan : ( ) => Promise < void > ;
49+ processingApproval : boolean ;
50+
4551}
4652
4753const PlanChat : React . FC < SimplifiedPlanChatProps > = ( {
@@ -57,78 +63,25 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
5763 waitingForPlan,
5864 messagesContainerRef,
5965 streamingMessageBuffer,
60- agentMessages
66+ agentMessages,
67+ showProcessingPlanSpinner,
68+ showApprovalButtons,
69+ handleApprovePlan,
70+ handleRejectPlan,
71+ processingApproval
72+
6173
6274} ) => {
6375 const navigate = useNavigate ( ) ;
6476
6577 const { showToast, dismissToast } = useInlineToaster ( ) ;
6678 // States
6779
68- const [ processingApproval , setProcessingApproval ] = useState ( false ) ;
69-
70- const [ showApprovalButtons , setShowApprovalButtons ] = useState ( true ) ;
71-
72-
73-
74-
75- // Listen for m_plan streaming
7680
7781
78- // Handle plan approval
79- const handleApprovePlan = useCallback ( async ( ) => {
80- if ( ! planApprovalRequest ) return ;
8182
82- setProcessingApproval ( true ) ;
83- let id = showToast ( "Submitting Approval" , "progress" ) ;
84- try {
85- await apiService . approvePlan ( {
86- m_plan_id : planApprovalRequest . id ,
87- plan_id : planData ?. plan ?. id ,
88- approved : true ,
89- feedback : 'Plan approved by user'
90- } ) ;
9183
92- dismissToast ( id ) ;
93- onPlanApproval ?.( true ) ;
94- setShowApprovalButtons ( false ) ;
9584
96- } catch ( error ) {
97- dismissToast ( id ) ;
98- showToast ( "Failed to submit approval" , "error" ) ;
99- console . error ( '❌ Failed to approve plan:' , error ) ;
100- } finally {
101- setProcessingApproval ( false ) ;
102- }
103- } , [ planApprovalRequest , planData , onPlanApproval ] ) ;
104-
105- // Handle plan rejection
106- const handleRejectPlan = useCallback ( async ( ) => {
107- if ( ! planApprovalRequest ) return ;
108-
109- setProcessingApproval ( true ) ;
110- let id = showToast ( "Submitting cancellation" , "progress" ) ;
111- try {
112- await apiService . approvePlan ( {
113- m_plan_id : planApprovalRequest . id ,
114- plan_id : planData ?. plan ?. id ,
115- approved : false ,
116- feedback : 'Plan rejected by user'
117- } ) ;
118-
119- dismissToast ( id ) ;
120- onPlanApproval ?.( false ) ;
121- navigate ( '/' ) ;
122-
123- } catch ( error ) {
124- dismissToast ( id ) ;
125- showToast ( "Failed to submit cancellation" , "error" ) ;
126- console . error ( '❌ Failed to reject plan:' , error ) ;
127- navigate ( '/' ) ;
128- } finally {
129- setProcessingApproval ( false ) ;
130- }
131- } , [ planApprovalRequest , planData , onPlanApproval , navigate ] ) ;
13285
13386 if ( ! planData )
13487 return (
@@ -164,9 +117,10 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
164117 { renderPlanResponse ( planApprovalRequest , handleApprovePlan , handleRejectPlan , processingApproval , showApprovalButtons ) }
165118 { renderAgentMessages ( agentMessages ) }
166119
167-
120+ { showProcessingPlanSpinner && renderPlanExecutionMessage ( ) }
168121 { /* Streaming plan updates */ }
169122 { renderBufferMessage ( streamingMessageBuffer ) }
123+
170124 </ div >
171125
172126 { /* Chat Input - only show if no plan is waiting for approval */ }
0 commit comments