MCPcopy Create free account
hub / github.com/acking-you/static_flow / extract_final_reply_markdown

Function extract_final_reply_markdown

crates/backend/src/comment_worker.rs:625–654  ·  view source on GitHub ↗
(raw: &str)

Source from the content-addressed store, hash-verified

623
624#[cfg(test)]
625fn extract_final_reply_markdown(raw: &str) -> Option<String> {
626 let mut candidates = Vec::new();
627
628 if let Ok(value) = serde_json::from_str::<Value>(raw) {
629 collect_markdown_candidates(&value, &mut candidates);
630 }
631
632 for value in serde_json::Deserializer::from_str(raw)
633 .into_iter::<Value>()
634 .flatten()
635 {
636 collect_markdown_candidates(&value, &mut candidates);
637 }
638
639 for line in raw.lines() {
640 let line = line.trim();
641 if line.is_empty() {
642 continue;
643 }
644 if let Ok(value) = serde_json::from_str::<Value>(line) {
645 collect_markdown_candidates(&value, &mut candidates);
646 }
647 }
648
649 candidates
650 .into_iter()
651 .rev()
652 .find(|item| !item.trim().is_empty())
653 .map(|item| item.trim().to_string())
654}
655
656fn collect_markdown_candidates(value: &Value, output: &mut Vec<String>) {
657 match value {

Callers 1

parse_runner_outputFunction · 0.85

Calls 4

trimMethod · 0.80
findMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected