Handle dialog turn completion
(&mut self, total_rounds: usize, _total_tools: usize)
| 774 | |
| 775 | /// Handle dialog turn completion |
| 776 | pub fn handle_turn_completed(&mut self, total_rounds: usize, _total_tools: usize) { |
| 777 | // Finalize the streaming message |
| 778 | if let Some(last_msg) = self.messages.last_mut() { |
| 779 | if last_msg.role == MessageRole::Assistant { |
| 780 | last_msg.is_streaming = false; |
| 781 | // Mark all text flow items as not streaming |
| 782 | for item in &mut last_msg.flow_items { |
| 783 | if let FlowItem::Text { is_streaming, .. } = item { |
| 784 | *is_streaming = false; |
| 785 | } |
| 786 | } |
| 787 | last_msg.version += 1; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | self.metadata.total_rounds += total_rounds; |
| 792 | self.current_turn_id = None; |
| 793 | self.current_flow_items.clear(); |
| 794 | self.tool_index.clear(); |
| 795 | self.is_processing = false; |
| 796 | self.permission_prompt = None; |
| 797 | self.question_prompt = None; |
| 798 | } |
| 799 | |
| 800 | /// Handle dialog turn failure |
| 801 | pub fn handle_turn_failed(&mut self, error: &str) { |