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

Method handle_text_chunk

src/apps/cli/src/chat_state.rs:423–435  ·  view source on GitHub ↗

Handle a text chunk from the AI. Appends to the last Text flow item if it exists, otherwise creates a new one. This ensures text and tool blocks remain interleaved in chronological order.

(&mut self, text: &str)

Source from the content-addressed store, hash-verified

421 /// Appends to the last Text flow item if it exists, otherwise creates a new one.
422 /// This ensures text and tool blocks remain interleaved in chronological order.
423 pub fn handle_text_chunk(&mut self, text: &str) {
424 // Try to append to the last flow item if it's a Text block
425 if let Some(FlowItem::Text { content, .. }) = self.current_flow_items.last_mut() {
426 content.push_str(text);
427 } else {
428 // Last item is not Text (it's a Tool, Thinking, or empty) — create a new Text block
429 self.current_flow_items.push(FlowItem::Text {
430 content: text.to_string(),
431 is_streaming: true,
432 });
433 }
434 self.rebuild_streaming_message();
435 }
436
437 /// Handle a thinking/reasoning chunk from the AI.
438 /// Thinking blocks typically appear at the start, before text/tool content.

Callers 1

runMethod · 0.45

Calls 3

push_strMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected