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

Method list

atomic-agent/src/turn/session.rs:541–575  ·  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

539 /// Returns sessions sorted by `started_at` (newest first).
540 /// Skips corrupted session files with a warning log.
541 pub fn list(&self) -> AgentResult<Vec<AgentSession>> {
542 let entries = match std::fs::read_dir(&self.sessions_dir) {
543 Ok(entries) => entries,
544 Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),
545 Err(e) => return Err(e.into()),
546 };
547
548 let mut sessions = Vec::new();
549
550 for entry in entries {
551 let entry = entry?;
552 let name = entry.file_name();
553 let name_str = name.to_string_lossy();
554
555 // Only process .json files (skip .tmp files, etc.)
556 if !name_str.ends_with(".json") || name_str.ends_with(".json.tmp") {
557 continue;
558 }
559
560 let session_id = name_str.trim_end_matches(".json");
561
562 match self.load(session_id) {
563 Ok(Some(session)) => sessions.push(session),
564 Ok(None) => {} // File disappeared between readdir and load
565 Err(e) => {
566 log::warn!("Skipping corrupted session file {}: {}", name_str, e);
567 }
568 }
569 }
570
571 // Sort by started_at, newest first
572 sessions.sort_by_key(|s| std::cmp::Reverse(s.started_at));
573
574 Ok(sessions)
575 }
576
577 /// Find all active (non-ended) sessions.
578 ///

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