MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / summarize_message

Function summarize_message

crates/opencode-session/src/summary.rs:453–476  ·  view source on GitHub ↗

Summarize a specific message's diffs. Filters messages to only those related to the given message_id (the user message and its assistant responses), then computes diffs.

(
    message_id: &str,
    messages: &[MessageWithParts],
    worktree: &std::path::Path,
)

Source from the content-addressed store, hash-verified

451/// Filters messages to only those related to the given message_id
452/// (the user message and its assistant responses), then computes diffs.
453pub fn summarize_message(
454 message_id: &str,
455 messages: &[MessageWithParts],
456 worktree: &std::path::Path,
457) -> Vec<SummaryFileDiff> {
458 let filtered: Vec<&MessageWithParts> = messages
459 .iter()
460 .filter(|m| {
461 let id = match &m.info {
462 MessageInfo::User { id, .. } => id,
463 MessageInfo::Assistant { id, .. } => id,
464 };
465 let parent_id = match &m.info {
466 MessageInfo::Assistant { parent_id, .. } => Some(parent_id.as_str()),
467 _ => None,
468 };
469 id == message_id || parent_id == Some(message_id)
470 })
471 .collect();
472
473 // Convert to owned for compute_diff
474 let owned: Vec<MessageWithParts> = filtered.into_iter().cloned().collect();
475 compute_diff(&owned, worktree)
476}
477
478/// Unquote git paths in diff results and return cleaned diffs.
479///

Callers 1

Calls 3

compute_diffFunction · 0.85
filterMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected