@@ -52,6 +52,7 @@ import { ToastIntent } from '@/components/toast/InlineToaster';
5252interface UsePlanWebSocketProps {
5353 planId : string | undefined ;
5454 scrollToBottom : ( ) => void ;
55+ scrollToFinalResult : ( ) => void ;
5556 formatErrorMessage : ( content : string ) => string ;
5657 showToast : ( content : React . ReactNode , intent ?: ToastIntent , options ?: { dismissible ?: boolean ; timeoutMs ?: number | null } ) => number ;
5758}
@@ -91,6 +92,7 @@ function persistAgentMessage(
9192export function usePlanWebSocket ( {
9293 planId,
9394 scrollToBottom,
95+ scrollToFinalResult,
9496 formatErrorMessage,
9597 showToast,
9698} : UsePlanWebSocketProps ) {
@@ -132,13 +134,14 @@ export function usePlanWebSocket({
132134 const unsub = webSocketService . on (
133135 WebsocketMessageType . AGENT_MESSAGE_STREAMING ,
134136 ( msg : any ) => {
135- const line = PlanDataService . simplifyHumanClarification ( msg . data . content ) ;
137+ const line = PlanDataService . simplifyHumanClarification ( msg . data ? .content || msg . content || '' ) ;
136138 dispatch ( setShowBufferingText ( true ) ) ;
137139 dispatch ( appendToStreamingBuffer ( line ) ) ;
140+ scrollToBottom ( ) ;
138141 } ,
139142 ) ;
140143 return unsub ;
141- } , [ dispatch ] ) ;
144+ } , [ dispatch , scrollToBottom ] ) ;
142145
143146 // ── USER_CLARIFICATION_REQUEST ────────────────────────────────
144147 useEffect ( ( ) => {
@@ -188,15 +191,15 @@ export function usePlanWebSocket({
188191 timestamp : Date . now ( ) ,
189192 steps : [ ] ,
190193 next_steps : [ ] ,
191- content : '\u{1F389}\u{1F389} ' + ( finalMessage . data ?. content || '' ) ,
194+ content : finalMessage . data ?. content || '' ,
192195 raw_data : finalMessage ,
193196 } ;
194197 dispatch ( setShowBufferingText ( true ) ) ;
195198 dispatch ( addAgentMessage ( agentMessageData ) ) ;
196199 dispatch ( setSelectedTeam ( planData ?. team || null ) ) ;
197200 /* P0: single compound action replaces setShowProcessingPlanSpinner(false) + markPlanCompleted() */
198201 dispatch ( planCompletedFinal ( ) ) ;
199- scrollToBottom ( ) ;
202+ scrollToFinalResult ( ) ;
200203 webSocketService . disconnect ( ) ;
201204 persistAgentMessage ( agentMessageData , planData , dispatch , true , streamingMessageBuffer ) ;
202205 } else if ( messageStatus === 'error' ) {
@@ -222,7 +225,7 @@ export function usePlanWebSocket({
222225 } ,
223226 ) ;
224227 return unsub ;
225- } , [ dispatch , scrollToBottom , planData , streamingMessageBuffer , formatErrorMessage , showToast ] ) ;
228+ } , [ dispatch , scrollToBottom , scrollToFinalResult , planData , streamingMessageBuffer , formatErrorMessage , showToast ] ) ;
226229
227230 // ── ERROR_MESSAGE ─────────────────────────────────────────────
228231 useEffect ( ( ) => {
0 commit comments