MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / collect_run_sessions

Function collect_run_sessions

atomic-cli/src/commands/agent/lifecycle.rs:535–571  ·  view source on GitHub ↗

Collect sessions stamped with `run_id` from the canonical session store.

(dot_dir: &Path, run_id: &str)

Source from the content-addressed store, hash-verified

533
534/// Collect sessions stamped with `run_id` from the canonical session store.
535fn collect_run_sessions(dot_dir: &Path, run_id: &str) -> Vec<RunSessionSummary> {
536 let store = match SessionStore::new(dot_dir.join("sessions")) {
537 Ok(store) => store,
538 Err(e) => {
539 log::warn!("could not open session store for run summary: {}", e);
540 return Vec::new();
541 }
542 };
543 let sessions = match store.list() {
544 Ok(sessions) => sessions,
545 Err(e) => {
546 log::warn!("could not list sessions for run summary: {}", e);
547 return Vec::new();
548 }
549 };
550
551 sessions
552 .into_iter()
553 .filter(|s| {
554 s.managed_run
555 .as_ref()
556 .map(|m| m.run_id == run_id)
557 .unwrap_or(false)
558 })
559 .map(|s| RunSessionSummary {
560 session_id: s.session_id.clone(),
561 agent_name: s.agent_name.clone(),
562 view: s.view_name.clone(),
563 turn_count: s.turn_count,
564 change_hashes: s
565 .recorded_change_hashes
566 .iter()
567 .map(|h| h.to_base32())
568 .collect(),
569 })
570 .collect()
571}
572
573fn print_lifecycle(lifecycle: &ManagedLifecycle, json: bool) -> CliResult<()> {
574 if json {

Callers 2

runMethod · 0.85

Calls 6

as_refMethod · 0.80
listMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45
iterMethod · 0.45
to_base32Method · 0.45

Tested by 1