···8282 home.connect(self._dial)
83838484 def _restore_session(self) -> None:
8585- """Load the most recent session from the database."""
8585+ """Load the stored session. The TUI is single-user: if stale extra
8686+ rows exist from a previous version, keep the newest and drop the rest."""
8687 import sqlite3
87888889 try:
8990 con = sqlite3.connect(self.session_store.db_path)
9091 con.row_factory = sqlite3.Row
9191- row = con.execute("SELECT * FROM oauth_session LIMIT 1").fetchone()
9292+ rows = con.execute(
9393+ "SELECT * FROM oauth_session ORDER BY rowid DESC"
9494+ ).fetchall()
9295 con.close()
9393- if row:
9494- self.user_session = dict(row)
9595- self.sub_title = self.user_session.get("handle", "")
9696+ if not rows:
9797+ return
9898+ self.user_session = dict(rows[0])
9999+ self.sub_title = self.user_session.get("handle", "")
100100+ for extra in rows[1:]:
101101+ self.session_store.delete_session(extra["did"])
96102 except Exception:
97103 pass
98104