Extract user content from a transcript message value.
(message: &serde_json::Value)
| 259 | |
| 260 | /// Extract user content from a transcript message value. |
| 261 | fn extract_user_content(message: &serde_json::Value) -> Option<String> { |
| 262 | // User content can be a string or an array of content blocks |
| 263 | if let Some(s) = message.get("content").and_then(|c| c.as_str()) { |
| 264 | if !s.is_empty() { |
| 265 | return Some(s.to_string()); |
| 266 | } |
| 267 | } |
| 268 | if let Some(arr) = message.get("content").and_then(|c| c.as_array()) { |
| 269 | for item in arr { |
| 270 | if let Some(text) = item.get("text").and_then(|t| t.as_str()) { |
| 271 | if !text.is_empty() { |
| 272 | return Some(text.to_string()); |
| 273 | } |
| 274 | } |
| 275 | // Also handle plain string items in the array |
| 276 | if let Some(text) = item.as_str() { |
| 277 | if !text.is_empty() { |
| 278 | return Some(text.to_string()); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | // Direct string message |
| 284 | if let Some(s) = message.as_str() { |
| 285 | if !s.is_empty() { |
| 286 | return Some(s.to_string()); |
| 287 | } |
| 288 | } |
| 289 | None |
| 290 | } |
| 291 | |
| 292 | /// Extract appropriate detail for a tool call. |
| 293 | /// |
no test coverage detected