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
This commit is contained in:
chelsealong
2026-09-09 00:25:39 +00:00
committed by Teknium
parent 87cc4de430
commit c59aa2d041
2 changed files with 20 additions and 2 deletions

View File

@@ -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."""

View File

@@ -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 ─────────────────────────────