Skip to content

The agent that grows with you

fix(session-state): clear hidden flag when a session is pinned

chelsealongc59aa2d041e2
diff --git a/hermes_state_sessions.py b/hermes_state_sessions.py
index 82e59eded04..6155d2d6eff 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 99e6438e9fa..6793e80bff3 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 ─────────────────────────────