From c59aa2d041e241a19825a65981b8558f8d1e6ab0 Mon Sep 17 00:00:00 2001 From: chelsealong Date: Wed, 9 Sep 2026 00:25:39 +0000 Subject: [PATCH] fix(session-state): clear hidden flag when a session is pinned A bot-mode session is created with hidden=true. Pinning it only wrote pinned=1 and left hidden=1, so the row was filtered out of both the default listing (`s.hidden = 0`) and the pinned back-fill (which reuses the same WHERE), making a pinned session vanish from the sidebar entirely. set_session_pinned now clears hidden across the session's compression lineage whenever pinned is set to true. Fixes #106171 --- hermes_state_sessions.py | 9 +++++++-- tests/test_hermes_state.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/hermes_state_sessions.py b/hermes_state_sessions.py index 82e59eded0..6155d2d6ef 100644 --- a/hermes_state_sessions.py +++ b/hermes_state_sessions.py @@ -876,8 +876,13 @@ class SessionSessionsMixin: return True def set_session_pinned(self, session_id: str, pinned: bool) -> bool: - """Pin/unpin a session and its compression lineage (pins are exempt from the auto_archive sweep).""" - return self._set_lineage_column("pinned", session_id, int(pinned)) + """Pin/unpin a session and its compression lineage (pins are exempt from the auto_archive sweep). + Pinning also clears ``hidden``: a pin means "keep this visible", and a hidden+pinned row is + otherwise absent from both the default listing and the pinned back-fill (see #106171).""" + result = self._set_lineage_column("pinned", session_id, int(pinned)) + if pinned: + self._set_lineage_column("hidden", session_id, 0) + return result def set_session_hidden(self, session_id: str, hidden: bool) -> bool: """Hide/unhide a session and its compression lineage from the default listing; still resumable.""" diff --git a/tests/test_hermes_state.py b/tests/test_hermes_state.py index 99e6438e9f..6793e80bff 100644 --- a/tests/test_hermes_state.py +++ b/tests/test_hermes_state.py @@ -4463,6 +4463,19 @@ class TestSessionPinAndStaleArchive: assert db.set_session_pinned("s1", False) is True assert self._pinned(db, "s1") == 0 + def test_pinning_a_hidden_session_makes_it_listable(self, db): + """A bot-tile session is born hidden (#106171). Pinning it must clear ``hidden``, or the + session is pinned-but-invisible: absent from both the default listing and the back-fill.""" + db.create_session(session_id="s1", source="cli") + db.append_message(session_id="s1", role="user", content="hi") + db.set_session_hidden("s1", True) + + db.set_session_pinned("s1", True) + + assert db.get_session("s1")["hidden"] == 0 + listed_ids = [s["id"] for s in db.list_sessions_rich(min_message_count=1)] + assert "s1" in listed_ids + # ── pinned back-fill past the page window ─────────────────────────────