Handle the start of a new dialog turn
(&mut self, turn_id: &str, user_input: &str)
| 386 | |
| 387 | /// Handle the start of a new dialog turn |
| 388 | pub fn handle_turn_started(&mut self, turn_id: &str, user_input: &str) { |
| 389 | self.current_turn_id = Some(turn_id.to_string()); |
| 390 | self.current_flow_items.clear(); |
| 391 | self.tool_index.clear(); |
| 392 | self.is_processing = true; |
| 393 | let user_display_input = strip_prompt_markup(user_input); |
| 394 | |
| 395 | // Add user message |
| 396 | self.messages.push(ChatMessage { |
| 397 | id: uuid::Uuid::new_v4().to_string(), |
| 398 | role: MessageRole::User, |
| 399 | timestamp: SystemTime::now(), |
| 400 | flow_items: vec![FlowItem::Text { |
| 401 | content: user_display_input, |
| 402 | is_streaming: false, |
| 403 | }], |
| 404 | is_streaming: false, |
| 405 | version: 0, |
| 406 | }); |
| 407 | self.metadata.message_count += 1; |
| 408 | |
| 409 | // Add empty assistant message (will be filled by streaming) |
| 410 | self.messages.push(ChatMessage { |
| 411 | id: uuid::Uuid::new_v4().to_string(), |
| 412 | role: MessageRole::Assistant, |
| 413 | timestamp: SystemTime::now(), |
| 414 | flow_items: Vec::new(), |
| 415 | is_streaming: true, |
| 416 | version: 0, |
| 417 | }); |
| 418 | } |
| 419 | |
| 420 | /// Handle a text chunk from the AI. |
| 421 | /// Appends to the last Text flow item if it exists, otherwise creates a new one. |
no test coverage detected