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

Method list

atomic-agent/src/turn/session.rs:569–603  ·  view source on GitHub ↗

List all stored sessions. Returns sessions sorted by `started_at` (newest first). Skips corrupted session files with a warning log.

(&self)

Source from the content-addressed store, hash-verified

567 /// Returns sessions sorted by `started_at` (newest first).
568 /// Skips corrupted session files with a warning log.
569 pub fn list(&self) -> AgentResult<Vec<AgentSession>> {
570 let entries = match std::fs::read_dir(&self.sessions_dir) {
571 Ok(entries) => entries,
572 Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),
573 Err(e) => return Err(e.into()),
574 };
575
576 let mut sessions = Vec::new();
577
578 for entry in entries {
579 let entry = entry?;
580 let name = entry.file_name();
581 let name_str = name.to_string_lossy();
582
583 // Only process .json files (skip .tmp files, etc.)
584 if !name_str.ends_with(".json") || name_str.ends_with(".json.tmp") {
585 continue;
586 }
587
588 let session_id = name_str.trim_end_matches(".json");
589
590 match self.load(session_id) {
591 Ok(Some(session)) => sessions.push(session),
592 Ok(None) => {} // File disappeared between readdir and load
593 Err(e) => {
594 log::warn!("Skipping corrupted session file {}: {}", name_str, e);
595 }
596 }
597 }
598
599 // Sort by started_at, newest first
600 sessions.sort_by_key(|s| std::cmp::Reverse(s.started_at));
601
602 Ok(sessions)
603 }
604
605 /// Find all active (non-ended) sessions.
606 ///

Callers 8

find_activeMethod · 0.45
find_endedMethod · 0.45
countMethod · 0.45
test_store_list_emptyFunction · 0.45
test_store_list_multipleFunction · 0.45

Calls 4

file_nameMethod · 0.80
kindMethod · 0.45
loadMethod · 0.45
pushMethod · 0.45