Extract user content from a transcript message value.
(message: &serde_json::Value)
| 165 | |
| 166 | /// Extract user content from a transcript message value. |
| 167 | fn extract_user_content(message: &serde_json::Value) -> Option<String> { |
| 168 | // User content can be a string or an array of content blocks |
| 169 | if let Some(s) = message.get("content").and_then(|c| c.as_str()) { |
| 170 | if !s.is_empty() { |
| 171 | return Some(s.to_string()); |
| 172 | } |
| 173 | } |
| 174 | if let Some(arr) = message.get("content").and_then(|c| c.as_array()) { |
| 175 | for item in arr { |
| 176 | if let Some(text) = item.get("text").and_then(|t| t.as_str()) { |
| 177 | if !text.is_empty() { |
| 178 | return Some(text.to_string()); |
| 179 | } |
| 180 | } |
| 181 | // Also handle plain string items in the array |
| 182 | if let Some(text) = item.as_str() { |
| 183 | if !text.is_empty() { |
| 184 | return Some(text.to_string()); |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | // Direct string message |
| 190 | if let Some(s) = message.as_str() { |
| 191 | if !s.is_empty() { |
| 192 | return Some(s.to_string()); |
| 193 | } |
| 194 | } |
| 195 | None |
| 196 | } |
| 197 | |
| 198 | /// Extract appropriate detail for a tool call. |
| 199 | /// |
no test coverage detected