From da351ba7702e016639677cbba25fffdde3b89313 Mon Sep 17 00:00:00 2001 From: Michael BAG Date: Mon, 13 Jul 2026 09:44:17 +0300 Subject: [PATCH] Fix INDEX message counts after partial export. Co-authored-by: Cursor --- cam/export.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cam/export.py b/cam/export.py index eb7b2ec..acc96a2 100644 --- a/cam/export.py +++ b/cam/export.py @@ -228,6 +228,20 @@ def export_transcripts( manifest.sort(key=lambda item: item["modified_at"], reverse=True) filter_label = context or context_mask + + manifest_path = output_root / "manifest.json" + if manifest_path.is_file(): + try: + prev = json.loads(manifest_path.read_text(encoding="utf-8")) + for item in prev.get("sessions", []): + sid = item.get("session_id") + if sid and sid not in message_counts: + message_counts[sid] = int(item.get("message_count", 0)) + except (json.JSONDecodeError, OSError): + pass + for item in manifest: + message_counts[item["session_id"]] = item["message_count"] + (output_root / "manifest.json").write_text( json.dumps( {