Skip to content

Commit 476bd5d

Browse files
Restore legacy lastUpdatedAt-only behavior; mkdir state_dir early
1 parent 38e548d commit 476bd5d

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

scripts/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def main() -> None:
179179
workspace_path = resolve_workspace_path(override=opts.get("base_dir"))
180180

181181
state_dir = get_global_state_dir()
182+
os.makedirs(state_dir, exist_ok=True)
182183
state_path = os.path.join(state_dir, "export_state.json")
183184
last_export = read_last_export_ms(since, state_path=state_path)
184185

@@ -253,7 +254,6 @@ def main() -> None:
253254
"exportedCount": count,
254255
"exportDir": out_dir,
255256
}
256-
os.makedirs(state_dir, exist_ok=True)
257257
with open(os.path.join(state_dir, "export_state.json"), "w", encoding="utf-8") as f:
258258
json.dump(state, f, indent=2)
259259

services/export_engine.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,7 @@ def _collect_ide_export_entries(
253253
if not isinstance(headers, list) or not headers:
254254
continue
255255

256-
updated_at = to_epoch_ms(cd.get("lastUpdatedAt")) or to_epoch_ms(
257-
cd.get("createdAt"),
258-
)
259-
# Intentional behavior change vs legacy CLI: fall back to createdAt when
260-
# lastUpdatedAt is absent (affects timestamps, filenames, and --since last).
256+
updated_at = to_epoch_ms(cd.get("lastUpdatedAt"))
261257
if since == "last" and updated_at <= last_export_ms:
262258
continue
263259

tests/test_export_engine.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,26 @@ def _collect(
182182
out_dir=self.tmp_out,
183183
)
184184

185-
def test_created_at_fallback_when_last_updated_missing(self):
185+
def test_last_updated_at_only_no_created_at_fallback(self):
186186
created_ms = 1739200000000
187-
exported = self._collect({
188-
"name": "Created-only chat",
189-
"modelConfig": {},
190-
"fullConversationHeadersOnly": [{"bubbleId": "bubble-1", "type": 1}],
191-
"createdAt": created_ms,
192-
})
187+
fixed_now = datetime(2026, 6, 22, 12, 0, 0)
188+
with patch("services.export_engine.datetime") as mock_dt:
189+
mock_dt.now.return_value = fixed_now
190+
mock_dt.fromtimestamp = datetime.fromtimestamp
191+
exported = self._collect({
192+
"name": "Created-only chat",
193+
"modelConfig": {},
194+
"fullConversationHeadersOnly": [{"bubbleId": "bubble-1", "type": 1}],
195+
"createdAt": created_ms,
196+
})
193197
self.assertEqual(len(exported), 1)
194198
entry = exported[0]
195-
self.assertEqual(entry["updatedAt"], created_ms)
196-
ts_str = datetime.fromtimestamp(created_ms / 1000).strftime("%Y-%m-%dT%H-%M-%S")
199+
self.assertEqual(entry["updatedAt"], 0)
200+
ts_str = fixed_now.strftime("%Y-%m-%dT%H-%M-%S")
197201
self.assertIn(ts_str, entry["rel_path"])
198-
self.assertEqual(
202+
self.assertNotIn(
203+
datetime.fromtimestamp(created_ms / 1000).strftime("%Y-%m-%dT%H-%M-%S"),
199204
entry["rel_path"],
200-
os.path.relpath(entry["out_path"], self.tmp_out),
201205
)
202206

203207
def test_display_name_falls_back_to_slug_of_workspace_id_prefix(self):

0 commit comments

Comments
 (0)