chore(tui): keep MRU resume split out of perf PR

- remove the temporary -c MRU logic and companion test from this branch so PR #15926 stays focused on TUI perf work
- keep the resume-ordering change isolated in the dedicated follow-up PR
This commit is contained in:
Brooklyn Nicholson
2026-04-26 22:40:35 -05:00
parent de790eaceb
commit c23463fce9
3 changed files with 7 additions and 139 deletions

View File

@@ -596,32 +596,15 @@ def _session_browse_picker(sessions: list) -> Optional[str]:
def _resolve_last_session(source: str = "cli") -> Optional[str]:
"""Look up the most recently *used* session ID for a source.
Previously this returned the most recently *started* session, which meant
`hermes -c` could skip the session you just closed if a newer one had been
opened earlier in a different window. We now order by last_active
(max message timestamp, falling back to started_at) so -c always resumes
the most recent conversation you actually touched.
"""
"""Look up the most recent session ID for a source."""
try:
from hermes_state import SessionDB
db = SessionDB()
sessions = db.search_sessions(source=source, limit=20)
sessions = db.search_sessions(source=source, limit=1)
db.close()
if not sessions:
return None
def _last_active(s: dict) -> float:
v = s.get("last_active") or s.get("started_at") or 0
try:
return float(v)
except (TypeError, ValueError):
return 0.0
sessions.sort(key=_last_active, reverse=True)
return sessions[0]["id"]
if sessions:
return sessions[0]["id"]
except Exception:
pass
return None