Name session checkpoints by their session title

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Georg Bauer
2026-07-26 09:25:37 +02:00
parent 1f27270d66
commit 76a5dd5b26
3 changed files with 27 additions and 3 deletions

View File

@@ -694,6 +694,8 @@ const CACHE_ENTRY_ROWS: usize = 12;
pub(crate) struct KvCacheEntry {
pub(crate) path: PathBuf,
pub(crate) name: String,
/// Set for session checkpoints, so the view can name the conversation.
pub(crate) session: Option<i32>,
pub(crate) bytes: u64,
pub(crate) age_seconds: u64,
}
@@ -762,6 +764,10 @@ pub(crate) fn kv_cache_report(root: &Path, budget_bytes: u64) -> KvCacheReport {
}
report.entries.push(KvCacheEntry {
name: entry_name(&path, transient),
session: (!transient)
.then(|| path.file_stem().and_then(|value| value.to_str()))
.flatten()
.and_then(|stem| stem.parse().ok()),
bytes: bytes.saturating_add(
fs::metadata(path.with_extension("meta")).map_or(0, |index| index.len()),
),
@@ -924,6 +930,9 @@ mod tests {
assert_eq!(report.entries.len(), 2);
assert_eq!(report.entries[0].bytes, 140);
assert_eq!(report.entries[1].name, "Session 7");
// The session id survives on the row, so the view can add its title.
assert_eq!(report.entries[1].session, Some(7));
assert_eq!(report.entries[0].session, None);
fs::remove_dir_all(root).unwrap();
}