|
43 | 43 |
|
44 | 44 | _logger = logging.getLogger(__name__) |
45 | 45 |
|
| 46 | +# Missing/unparseable timestamps sort last in rank_results() (treated as 0.0 s). |
| 47 | +_UNKNOWN_SEARCH_TIMESTAMP: int = 0 |
| 48 | + |
46 | 49 |
|
47 | 50 | # --------------------------------------------------------------------------- |
48 | 51 | # Private helpers — pure functions / small utilities |
@@ -317,7 +320,7 @@ def search_global_storage( |
317 | 320 | "timestamp": ( |
318 | 321 | to_epoch_ms(composer.last_updated_at) |
319 | 322 | or to_epoch_ms(composer.created_at) |
320 | | - or int(datetime.now().timestamp() * 1000) |
| 323 | + or _UNKNOWN_SEARCH_TIMESTAMP |
321 | 324 | ), |
322 | 325 | "matchingText": matching_text, |
323 | 326 | "type": "composer", |
@@ -437,7 +440,7 @@ def search_legacy_workspaces( |
437 | 440 | "workspaceFolder": workspace_folder, |
438 | 441 | "chatId": tab_id, |
439 | 442 | "chatTitle": ct or f"Chat {tab_id[:8]}", |
440 | | - "timestamp": tab.get("lastSendTime") or datetime.now().isoformat(), |
| 443 | + "timestamp": tab.get("lastSendTime") or _UNKNOWN_SEARCH_TIMESTAMP, |
441 | 444 | "matchingText": matching_text, |
442 | 445 | "type": "chat", |
443 | 446 | }) |
@@ -482,9 +485,7 @@ def search_cli_sessions( |
482 | 485 | for session in cp["sessions"]: |
483 | 486 | meta = session.get("meta", {}) |
484 | 487 | session_id = session["session_id"] |
485 | | - created_ms: int = ( |
486 | | - meta.get("createdAt") or int(datetime.now().timestamp() * 1000) |
487 | | - ) |
| 488 | + created_ms: int = to_epoch_ms(meta.get("createdAt")) |
488 | 489 | session_name: str = meta.get("name") or f"Session {session_id[:8]}" |
489 | 490 |
|
490 | 491 | try: |
|
0 commit comments