(repo: &Repository, limit: usize, json: bool)
| 132 | } |
| 133 | |
| 134 | fn show_recent_sessions(repo: &Repository, limit: usize, json: bool) -> CliResult<()> { |
| 135 | let ledgers = repo |
| 136 | .list_session_ledgers(limit) |
| 137 | .map_err(CliError::Repository)?; |
| 138 | // The per-session intent counts: prefer turn plan ids, else the vault |
| 139 | // manifest's session links. |
| 140 | let intent_map = build_session_intent_map(repo); |
| 141 | let intent_counts: Vec<usize> = ledgers |
| 142 | .iter() |
| 143 | .map(|(record, turns)| { |
| 144 | let from_turns: std::collections::HashSet<&str> = |
| 145 | turns.iter().filter_map(|t| t.plan_id.as_deref()).collect(); |
| 146 | if !from_turns.is_empty() { |
| 147 | from_turns.len() |
| 148 | } else { |
| 149 | intent_map |
| 150 | .get(&record.session_id) |
| 151 | .map(|ids| ids.len()) |
| 152 | .unwrap_or(0) |
| 153 | } |
| 154 | }) |
| 155 | .collect(); |
| 156 | render_recent_sessions(ledgers, intent_counts, json) |
| 157 | } |
| 158 | |
| 159 | /// The listing render, over the gathered data — the repository path and the |
| 160 | /// routed path (ListSessions' ledger bundle + intent counts) share it. |
no test coverage detected