Session Cache Implementation

Nucleic-Session: B2346642-3353-4BD5-9DE2-A8B77BD66C98
Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
2026-07-05 22:36:29 -07:00
co-authored by Nucleic
parent f5d2a13a79
commit cb11fa21b4
@@ -70,7 +70,7 @@ enum SessionCache {
let kept = Array(summaries.sorted { $0.updatedAt > $1.updatedAt }.prefix(sessionLimit)) let kept = Array(summaries.sorted { $0.updatedAt > $1.updatedAt }.prefix(sessionLimit))
if let data = try? JSONEncoder().encode(kept) { try? data.write(to: url, options: .atomic) } if let data = try? JSONEncoder().encode(kept) { try? data.write(to: url, options: .atomic) }
// Drop transcript files for sessions that fell out of the recent set. // Drop transcript files for sessions that fell out of the recent set.
let keep = Set(kept.map(transcriptFileName)) let keep = Set(kept.map { transcriptFileName($0.sessionID) })
if let files = try? FileManager.default.contentsOfDirectory( if let files = try? FileManager.default.contentsOfDirectory(
at: dir, includingPropertiesForKeys: nil) { at: dir, includingPropertiesForKeys: nil) {
for file in files where !keep.contains(file.lastPathComponent) { for file in files where !keep.contains(file.lastPathComponent) {