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