MCPcopy Create free account
hub / github.com/GCWing/BitFun / handle_turn_started

Method handle_turn_started

src/apps/cli/src/chat_state.rs:388–418  ·  view source on GitHub ↗

Handle the start of a new dialog turn

(&mut self, turn_id: &str, user_input: &str)

Source from the content-addressed store, hash-verified

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.

Callers 1

runMethod · 0.45

Calls 3

strip_prompt_markupFunction · 0.85
clearMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected