Read the leading `session_meta` line of a rollout for cwd/session-id/model.
(path: &Path)
| 239 | |
| 240 | /// Read the leading `session_meta` line of a rollout for cwd/session-id/model. |
| 241 | fn session_meta(path: &Path) -> Option<CodexMeta> { |
| 242 | let file = std::fs::File::open(path).ok()?; |
| 243 | let reader = std::io::BufReader::new(file); |
| 244 | for line in reader.lines().take(4).map_while(Result::ok) { |
| 245 | let trimmed = line.trim(); |
| 246 | if trimmed.is_empty() { |
| 247 | continue; |
| 248 | } |
| 249 | let Ok(value) = serde_json::from_str::<Value>(trimmed) else { |
| 250 | continue; |
| 251 | }; |
| 252 | if let Some(meta) = session_meta_from_record(&value, path) { |
| 253 | return Some(meta); |
| 254 | } |
| 255 | } |
| 256 | None |
| 257 | } |
| 258 | |
| 259 | fn session_meta_from_record(record: &Value, path: &Path) -> Option<CodexMeta> { |
| 260 | if record.get("type").and_then(Value::as_str) != Some("session_meta") { |
no test coverage detected