(repo: &Repository, session_id: &str, json: bool)
| 206 | } |
| 207 | |
| 208 | fn show_session_detail(repo: &Repository, session_id: &str, json: bool) -> CliResult<()> { |
| 209 | let (record, turns) = repo |
| 210 | .get_session_ledger(session_id) |
| 211 | .map_err(CliError::Repository)? |
| 212 | .ok_or_else(|| CliError::VaultEntityNotFound { |
| 213 | kind: "session", |
| 214 | id: session_id.to_string(), |
| 215 | // No hint: there is no session-listing command to point at, and the |
| 216 | // id comes from the caller's own ledger rather than something a |
| 217 | // user would create on demand. |
| 218 | hint: None, |
| 219 | })?; |
| 220 | |
| 221 | if json { |
| 222 | println!( |
| 223 | "{}", |
| 224 | serde_json::to_string_pretty(&(record, turns)).map_err(|e| { |
| 225 | CliError::Internal(anyhow::anyhow!("failed to encode session ledger: {}", e)) |
| 226 | })? |
| 227 | ); |
| 228 | return Ok(()); |
| 229 | } |
| 230 | |
| 231 | // Build turn→intent map for this session from vault paths. |
| 232 | let turn_intents = build_turn_intent_map(repo, session_id); |
| 233 | |
| 234 | println!("Session {}", record.session_id); |
| 235 | println!( |
| 236 | " Status: {}", |
| 237 | if record.ended_at.is_some() { |
| 238 | "ended" |
| 239 | } else { |
| 240 | "active" |
| 241 | } |
| 242 | ); |
| 243 | if let Some(view) = &record.view_name { |
| 244 | println!(" View: {}", view); |
| 245 | } |
| 246 | if let Some(parent) = &record.parent_view { |
| 247 | println!(" Parent view: {}", parent); |
| 248 | } |
| 249 | println!(" JSON: {}", record.json_path); |
| 250 | println!(" Turns: {}", record.turn_count); |
| 251 | |
| 252 | // Show all intents linked to this session. |
| 253 | let all_intents: Vec<&str> = { |
| 254 | let mut ids: Vec<&str> = turn_intents.values().map(|s| s.as_str()).collect(); |
| 255 | ids.sort(); |
| 256 | ids.dedup(); |
| 257 | ids |
| 258 | }; |
| 259 | if !all_intents.is_empty() { |
| 260 | println!(" Intents: {}", all_intents.join(", ")); |
| 261 | } |
| 262 | |
| 263 | if let Ok(Some(head)) = repo.get_session_head(session_id) { |
| 264 | println!(" Manifest head: {}", head.to_base32()); |
| 265 | if let Ok(Some(manifest)) = repo.get_session_manifest(&head) { |
no test coverage detected