Merge PR #370: fix(session): use database session count for has_any_sessions

Authored by Bartok9. Fixes #351.
This commit is contained in:
teknium1 2026-03-04 05:37:15 -08:00
commit 4ae61b0886
2 changed files with 59 additions and 1 deletions

View file

@ -396,8 +396,16 @@ class SessionStore:
def has_any_sessions(self) -> bool:
"""Check if any sessions have ever been created (across all platforms)."""
if self._db:
# Database tracks all sessions ever created (including ended ones).
# This correctly handles session resets where the in-memory _entries
# dict replaces the entry for the same session_key, but the DB
# preserves the historical record.
# > 1 because the current session is already created.
return self._db.session_count() > 1
# Fallback for when DB is not available (e.g., tests)
self._ensure_loaded()
return len(self._entries) > 1 # >1 because the current new session is already in _entries
return len(self._entries) > 1
def get_or_create_session(
self,