From a869e8c7baf40c08870236f97fcc009c63a96a85 Mon Sep 17 00:00:00 2001 From: JesseMarkowitz Date: Mon, 30 Mar 2026 15:25:18 -0400 Subject: [PATCH] fix for project files written to wrong directory --- src/main.py | 6 ++++++ src/providers/chatgpt.py | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.py b/src/main.py index b650ab1..4e59523 100644 --- a/src/main.py +++ b/src/main.py @@ -594,6 +594,12 @@ def export( conv_id = raw_conv.get("id") or raw_conv.get("uuid", "unknown") try: full_raw = prov_instance.get_conversation(conv_id) + # Propagate provider annotations from the listing summary + # (e.g. _project_name set by ChatGPT project fetching) into + # the full detail so normalize_conversation can use them. + for key, val in raw_conv.items(): + if key.startswith("_") and key not in full_raw: + full_raw[key] = val normalized = prov_instance.normalize_conversation(full_raw) exported_path: Path | None = None diff --git a/src/providers/chatgpt.py b/src/providers/chatgpt.py index 1bf6fdb..f6e0f42 100644 --- a/src/providers/chatgpt.py +++ b/src/providers/chatgpt.py @@ -551,12 +551,16 @@ class ChatGPTProvider(BaseProvider): created_at = _ts_to_iso(raw.get("create_time")) updated_at = _ts_to_iso(raw.get("update_time")) - # Look up project name from the map built during fetch_all_conversations. - project = self._project_map.get(conv_id) if conv_id else None + # Prefer _project_name annotation injected from the listing summary + # (propagated by the export loop). Fall back to _project_map lookup. + project = raw.get("_project_name") or ( + self._project_map.get(conv_id) if conv_id else None + ) logger.debug( - "[chatgpt] normalize_conversation[%s]: project_map lookup → %r", + "[chatgpt] normalize_conversation[%s]: project=%r (source=%s)", conv_id[:8] if conv_id else "?", project, + "_project_name" if raw.get("_project_name") else "_project_map", ) mapping: dict = raw.get("mapping", {})