Extract a human-readable one-liner from a provenance node's detail JSON. Returns `None` if the detail is empty or has no interesting fields.
(detail: &str)
| 413 | /// |
| 414 | /// Returns `None` if the detail is empty or has no interesting fields. |
| 415 | pub(super) fn format_node_detail(detail: &str) -> Option<String> { |
| 416 | let v: serde_json::Value = serde_json::from_str(detail).ok()?; |
| 417 | let obj = v.as_object()?; |
| 418 | |
| 419 | // Command (bash/execution nodes) |
| 420 | if let Some(cmd) = obj.get("command").and_then(|v| v.as_str()) { |
| 421 | return Some(format!("$ {}", truncate_bytes(cmd, 120))); |
| 422 | } |
| 423 | |
| 424 | // File path (read/write/edit nodes) |
| 425 | if let Some(file) = obj |
| 426 | .get("file") |
| 427 | .or_else(|| obj.get("file_path")) |
| 428 | .or_else(|| obj.get("target")) |
| 429 | .and_then(|v| v.as_str()) |
| 430 | { |
| 431 | let op = obj.get("operation").and_then(|v| v.as_str()).unwrap_or(""); |
| 432 | if op.is_empty() { |
| 433 | return Some(file.to_string()); |
| 434 | } |
| 435 | return Some(format!("{}: {}", op, file)); |
| 436 | } |
| 437 | |
| 438 | // Output summary (fallback for nodes with only output) |
| 439 | if let Some(summary) = obj.get("output_summary").and_then(|v| v.as_str()) { |
| 440 | return Some(truncate_bytes(summary, 120)); |
| 441 | } |
| 442 | |
| 443 | None |
| 444 | } |
| 445 | |
| 446 | impl Default for ChangeCmd { |
| 447 | fn default() -> Self { |