Skip to content

The agent that grows with you

refactor(sidebar): trim the truncation comment to the invariant; fold the pin helper in the test

kshitijk4poor4c28768ef734
diff --git a/hermes_cli/web_routers/profiles.py b/hermes_cli/web_routers/profiles.py
index c6c81da06f6..6cb69dce16d 100644
--- a/hermes_cli/web_routers/profiles.py
+++ b/hermes_cli/web_routers/profiles.py
@@ -515,11 +515,9 @@ def get_profiles_sessions_sidebar(
if slices is None:
continue
# A full window means more rows remain on disk — all "load more" needs, at no cost
- # beyond the rows already read. Pinned rows count: they occupy LIMIT slots like any
- # other recent row, so discounting them under-reported a full page whenever a pin
- # sat inside the window and stranded older sessions behind a "Load more" that
- # never appeared (#81484). A short list has no rows past the page for the pin
- # back-fill to add, so counting pins cannot fake a full page there.
+ # beyond the rows already read. Pinned rows count: they occupy LIMIT slots, and a
+ # short list has nothing past the page for the pin back-fill to add, so pins cannot
+ # fake a full page (#81484).
recents_truncated[name] = len(slices["recents"]) >= cap["recents"]
profile_totals[name] = slices["usage"]
for key in slice_scope:
diff --git a/tests/hermes_cli/test_profiles_sidebar_scope.py b/tests/hermes_cli/test_profiles_sidebar_scope.py
index 4bf1b95a53a..9aa518c47be 100644
--- a/tests/hermes_cli/test_profiles_sidebar_scope.py
+++ b/tests/hermes_cli/test_profiles_sidebar_scope.py
@@ -273,22 +273,21 @@ class TestSidebarTruncation:
payload = client.get("/api/profiles/sessions/sidebar", params=params).json()
return len(payload["recents"]["sessions"]), payload["recents"]["profiles_truncated"]
+ def pin(session_id):
+ db = SessionDB(db_path=home / "state.db")
+ try:
+ assert db.set_session_pinned(session_id, True)
+ finally:
+ db.close()
+
for index in range(3):
_seed_session(home, f"s-{index}", source="desktop")
- db = SessionDB(db_path=home / "state.db")
- try:
- assert db.set_session_pinned("s-2", True)
- finally:
- db.close()
+ pin("s-2")
# Short list: the pin is already on the page, nothing to back-fill, no "more".
assert truncated() == (3, {"default": False})
for index in range(3, 6):
_seed_session(home, f"s-{index}", source="desktop")
- db = SessionDB(db_path=home / "state.db")
- try:
- assert db.set_session_pinned("s-5", True)
- finally:
- db.close()
+ pin("s-5")
# Six on disk, two pins among the newest four: a full window, more below it.
assert truncated() == (4, {"default": True})