From 1a4d56c2157a97b9cab0c1b920fc0022665d886b Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Fri, 3 Apr 2026 21:02:01 -0700 Subject: [PATCH] fix: CLI DB has no profile column, and silent SQL error swallowed results (#60) The sessions table in the CLI state.db does not have a 'profile' column -- selecting s.profile caused an OperationalError which was silently caught by 'except Exception: return []', making get_cli_sessions() always return empty. Fix: remove s.profile from the SELECT (it doesn't exist in the CLI schema) and derive the profile from get_active_profile_name() instead, which is the right value anyway since the CLI DB has no profile concept. Co-authored-by: Nathan Esquenazi --- api/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/models.py b/api/models.py index 31f94ab..459a37e 100644 --- a/api/models.py +++ b/api/models.py @@ -259,7 +259,7 @@ def get_cli_sessions(): cur = conn.cursor() cur.execute(""" SELECT s.id, s.title, s.model, s.message_count, - s.started_at, s.source, s.profile, + s.started_at, s.source, MAX(m.timestamp) AS last_activity FROM sessions s LEFT JOIN messages m ON m.session_id = s.id @@ -272,7 +272,7 @@ def get_cli_sessions(): raw_ts = row['last_activity'] or row['started_at'] # Prefer the CLI session's own profile from the DB; fall back to # the active CLI profile so sidebar filtering works either way. - profile = row.get('profile') or _cli_profile + profile = _cli_profile # CLI DB has no profile column; use active profile cli_sessions.append({ 'session_id': sid,