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:33:31 -07:00
co-authored by Nucleic
parent 4ffa069191
commit 711144fde8
@@ -68,7 +68,7 @@ enum SessionCache {
guard let root, let url = summariesURL, let dir = transcriptsDir else { return }
try? FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
let kept = Array(summaries.sorted { $0.updatedAt > $1.updatedAt }.prefix(sessionLimit))
if let data = try? encoder.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.
let keep = Set(kept.map(transcriptFileName))
if let files = try? FileManager.default.contentsOfDirectory(