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,
)
| 451 | /// Filters messages to only those related to the given message_id |
| 452 | /// (the user message and its assistant responses), then computes diffs. |
| 453 | pub 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 | /// |
no test coverage detected