@@ -606,6 +606,7 @@ pub(in crate::tui::app) fn handle_server_event(
606606 | ServerEvent :: StatusDetail { .. }
607607 ) ;
608608 if externally_started_turn_event {
609+ app. streaming . response_output . reset ( ) ;
609610 crate :: logging:: info (
610611 "Adopting externally started turn: stream event received while idle with no current_message_id" ,
611612 ) ;
@@ -658,6 +659,7 @@ pub(in crate::tui::app) fn handle_server_event(
658659 app. insert_thought_line ( thought_line) ;
659660 return eager_stream_redraw;
660661 }
662+ app. streaming . response_output . text ( & text) ;
661663 let mut needs_redraw = false ;
662664 if matches ! (
663665 app. status,
@@ -678,6 +680,7 @@ pub(in crate::tui::app) fn handle_server_event(
678680 eager_stream_redraw && needs_redraw
679681 }
680682 ServerEvent :: TextReplace { text } => {
683+ app. streaming . response_output . replace_text ( & text) ;
681684 let ops = app. stream_buffer . flush ( ) ;
682685 app. apply_stream_ops ( ops) ;
683686 app. replace_streaming_text ( text) ;
@@ -732,6 +735,7 @@ pub(in crate::tui::app) fn handle_server_event(
732735 eager_stream_redraw
733736 }
734737 ServerEvent :: ToolStart { id, name } => {
738+ app. streaming . response_output . tool ( ) ;
735739 app. usage_reset . openai_quota_rejected = false ;
736740 // Tool-call JSON is provider-generated output and is included in output-token
737741 // usage. Keep the TPS timer running until the server reports ToolExec; actual
@@ -758,6 +762,9 @@ pub(in crate::tui::app) fn handle_server_event(
758762 false
759763 }
760764 ServerEvent :: ToolExec { id, name } => {
765+ // A reconnect can resume during execution, without replaying the
766+ // ToolStart event that normally marks this response as tool work.
767+ app. streaming . response_output . tool ( ) ;
761768 // Provider output generation for this tool call is complete, but final usage
762769 // snapshots often arrive later. Keep collecting deltas while excluding tool
763770 // runtime from the elapsed TPS denominator.
@@ -1099,7 +1106,8 @@ pub(in crate::tui::app) fn handle_server_event(
10991106 true
11001107 }
11011108 ServerEvent :: TextDone => false ,
1102- ServerEvent :: MessageEnd { .. } => {
1109+ ServerEvent :: MessageEnd { stop_reason } => {
1110+ app. streaming . response_output . finish ( stop_reason. as_deref ( ) ) ;
11031111 app. pause_streaming_tps ( true ) ;
11041112 app. stream_message_ended = true ;
11051113 true
@@ -1342,7 +1350,9 @@ pub(in crate::tui::app) fn handle_server_event(
13421350 "client_turn_completed" ,
13431351 std:: time:: Duration :: from_secs ( 30 ) ,
13441352 ) ;
1345- auto_poked = app. schedule_turn_end_followups ( ) ;
1353+ auto_poked = app. schedule_turn_end_followups_after_response (
1354+ app. streaming . response_output . has_final_response ( ) ,
1355+ ) ;
13461356 if !auto_poked {
13471357 app. clear_visible_turn_started ( ) ;
13481358 if app. queued_messages . is_empty ( ) {
0 commit comments