Skip to content

The agent that grows with you

fix(desktop): count pinned rows toward sidebar window truncation

Yonglie16fd43ca4a9
diff --git a/apps/desktop/src/api/sessions.ts b/apps/desktop/src/api/sessions.ts
index c1c090045dd..ec32d7a7d51 100644
--- a/apps/desktop/src/api/sessions.ts
+++ b/apps/desktop/src/api/sessions.ts
@@ -171,16 +171,16 @@ export interface SidebarSessionSlice {
/** Which profiles filled their per-profile window in a returned page. The
* legacy per-slice endpoint doesn't report this, so derive it from the rows:
- * a profile at (or over) the cap still has more on disk. Pinned rows are
- * discounted — they're back-filled past the LIMIT, so counting them fakes a
- * full page and leaves a "Load more" that can never resolve. */
+ * a profile at (or over) the cap still has more on disk. Pinned rows count
+ * like any other: they occupy LIMIT slots, so discounting them hid the
+ * load-more row whenever a pin sat inside the window (#81484). */
function profilesTruncatedFrom(sessions: SessionInfo[], cap: number): Record<string, boolean> {
const counts = new Map<string, number>()
for (const session of sessions) {
const key = session.profile || 'default'
- counts.set(key, (counts.get(key) ?? 0) + (session.pinned ? 0 : 1))
+ counts.set(key, (counts.get(key) ?? 0) + 1)
}
return Object.fromEntries([...counts].map(([name, count]) => [name, count >= cap]))
diff --git a/hermes_cli/web_routers/profiles.py b/hermes_cli/web_routers/profiles.py
index caf831fa525..c6c81da06f6 100644
--- a/hermes_cli/web_routers/profiles.py
+++ b/hermes_cli/web_routers/profiles.py
@@ -515,10 +515,12 @@ 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. Discount pinned back-fills: they arrive past the
- # LIMIT and would fake a full page on a short list.
- unpinned_count = sum(1 for s in slices["recents"] if not s.get("pinned"))
- recents_truncated[name] = unpinned_count >= cap["recents"]
+ # 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.
+ recents_truncated[name] = len(slices["recents"]) >= cap["recents"]
profile_totals[name] = slices["usage"]
for key in slice_scope:
rows[key].extend(_tag_rows(slices[key], name, now))