Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(host-core): clean up transcript layout cache in remove_session_files

Morning·Galaxy Dawn7100b67f7ba0
diff --git a/crates/host-core/src/transcripts.rs b/crates/host-core/src/transcripts.rs
index f0c5e6c40..29b424458 100644
--- a/crates/host-core/src/transcripts.rs
+++ b/crates/host-core/src/transcripts.rs
@@ -1726,6 +1726,9 @@ pub fn remove_session_files(data_dir: &Path, session_id: &str) {
};
for path in [
transcript.with_extension("jsonl.tmp"),
+ transcript.with_extension("jsonl.layout"),
+ transcript.with_extension("jsonl.layout.tmp"),
+ transcript.with_extension("layout.tmp"),
transcript,
revisions,
inflight.with_extension("json.tmp"),
diff --git a/crates/host-core/src/transcripts_layout_tests.rs b/crates/host-core/src/transcripts_layout_tests.rs
index ec3446773..869b3659b 100644
--- a/crates/host-core/src/transcripts_layout_tests.rs
+++ b/crates/host-core/src/transcripts_layout_tests.rs
@@ -146,3 +146,21 @@ fn an_unsupported_identity_never_persists_a_layout() {
identity != 0
);
}
+
+#[test]
+fn remove_session_files_cleans_up_layout_cache_and_tmp() {
+ let dir = tempdir().unwrap();
+ let transcript = transcript_path(dir.path(), "s1").unwrap();
+ let layout = transcript.with_extension("jsonl.layout");
+ let layout_tmp = transcript.with_extension("jsonl.layout.tmp");
+ let legacy_tmp = transcript.with_extension("layout.tmp");
+ fs::write(&transcript, "content").unwrap();
+ fs::write(&layout, "layout").unwrap();
+ fs::write(&layout_tmp, "tmp").unwrap();
+ fs::write(&legacy_tmp, "tmp").unwrap();
+ remove_session_files(dir.path(), "s1");
+ assert!(!transcript.exists());
+ assert!(!layout.exists());
+ assert!(!layout_tmp.exists());
+ assert!(!legacy_tmp.exists());
+}