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

Method list

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

1096 /// Returns sessions sorted by `started_at` (newest first).
1097 /// Skips corrupted session files with a warning log.
1098 pub fn list(&self) -> AgentResult<Vec<AgentSession>> {
1099 let entries = match std::fs::read_dir(&self.sessions_dir) {
1100 Ok(entries) => entries,
1101 Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),
1102 Err(e) => return Err(e.into()),
1103 };
1104
1105 let mut sessions = Vec::new();
1106
1107 for entry in entries {
1108 let entry = entry?;
1109 let name = entry.file_name();
1110 let name_str = name.to_string_lossy();
1111
1112 // Only process .json files (skip .tmp files, etc.)
1113 if !name_str.ends_with(".json") || name_str.ends_with(".json.tmp") {
1114 continue;
1115 }
1116
1117 let session_id = name_str.trim_end_matches(".json");
1118
1119 match self.load(session_id) {
1120 Ok(Some(session)) => sessions.push(session),
1121 Ok(None) => {} // File disappeared between readdir and load
1122 Err(e) => {
1123 log::warn!("Skipping corrupted session file {}: {}", name_str, e);
1124 }
1125 }
1126 }
1127
1128 // Sort by started_at, newest first
1129 sessions.sort_by_key(|s| std::cmp::Reverse(s.started_at));
1130
1131 Ok(sessions)
1132 }
1133
1134 /// Find all active (non-ended) sessions.
1135 ///

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

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