From 23f5ee15f7d6ae99b89799ae0b0a44f81ef39a67 Mon Sep 17 00:00:00 2001 From: nesquena-hermes <[email protected]> Date: Fri, 29 May 2026 23:46:51 +0000 Subject: [PATCH] review-3142: align load_metadata_only comment with sidecar-first logic --- api/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/models.py b/api/models.py index 569f1dfc..aa80bfcf 100644 --- a/api/models.py +++ b/api/models.py @@ -818,9 +818,12 @@ class Session: index_message_count = None if sidecar_message_count is None: index_message_count = _lookup_index_message_count(sid) - # The sidebar index is a cache and can lag behind external sidecar - # appends/backfills. Prefer the largest known count so metadata-only - # active-session polls do not miss real remote updates. + # Modern sidecars carry an accurate message_count, so it is the + # source of truth and we skip the per-row _index.json read in the + # common case. The sidebar index is only a cache (it can lag behind + # external sidecar appends/backfills), so consult it solely as a + # fallback when the sidecar has no count. When both are present we + # still take the largest known count as a defensive measure. known_counts = [ count for count in (index_message_count, sidecar_message_count) if count is not None