Skip to content

Commit 6006c25

Browse files
committed
fix: outside diff finding
1 parent 188d9ec commit 6006c25

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

services/search.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343

4444
_logger = logging.getLogger(__name__)
4545

46+
# Missing/unparseable timestamps sort last in rank_results() (treated as 0.0 s).
47+
_UNKNOWN_SEARCH_TIMESTAMP: int = 0
48+
4649

4750
# ---------------------------------------------------------------------------
4851
# Private helpers — pure functions / small utilities
@@ -317,7 +320,7 @@ def search_global_storage(
317320
"timestamp": (
318321
to_epoch_ms(composer.last_updated_at)
319322
or to_epoch_ms(composer.created_at)
320-
or int(datetime.now().timestamp() * 1000)
323+
or _UNKNOWN_SEARCH_TIMESTAMP
321324
),
322325
"matchingText": matching_text,
323326
"type": "composer",
@@ -437,7 +440,7 @@ def search_legacy_workspaces(
437440
"workspaceFolder": workspace_folder,
438441
"chatId": tab_id,
439442
"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,
441444
"matchingText": matching_text,
442445
"type": "chat",
443446
})
@@ -482,9 +485,7 @@ def search_cli_sessions(
482485
for session in cp["sessions"]:
483486
meta = session.get("meta", {})
484487
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"))
488489
session_name: str = meta.get("name") or f"Session {session_id[:8]}"
489490

490491
try:

0 commit comments

Comments
 (0)