MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / append_delta_part

Method append_delta_part

crates/opencode-session/src/prompt.rs:1387–1422  ·  view source on GitHub ↗
(message: &mut SessionMessage, reasoning: bool, delta: &str)

Source from the content-addressed store, hash-verified

1385 }
1386
1387 fn append_delta_part(message: &mut SessionMessage, reasoning: bool, delta: &str) {
1388 if delta.is_empty() {
1389 return;
1390 }
1391
1392 for part in message.parts.iter_mut().rev() {
1393 match (&mut part.part_type, reasoning) {
1394 (PartType::Reasoning { text }, true) => {
1395 text.push_str(delta);
1396 return;
1397 }
1398 (PartType::Text { text, .. }, false) => {
1399 text.push_str(delta);
1400 return;
1401 }
1402 _ => {}
1403 }
1404 }
1405
1406 message.parts.push(crate::MessagePart {
1407 id: opencode_core::id::create(opencode_core::id::Prefix::Part, true, None),
1408 part_type: if reasoning {
1409 PartType::Reasoning {
1410 text: delta.to_string(),
1411 }
1412 } else {
1413 PartType::Text {
1414 text: delta.to_string(),
1415 synthetic: None,
1416 ignored: None,
1417 }
1418 },
1419 created_at: chrono::Utc::now(),
1420 message_id: None,
1421 });
1422 }
1423
1424 /// Mark any tool calls that lack a corresponding tool result as aborted.
1425 ///

Callers

nothing calls this directly

Calls 2

createFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected