fix(gateway): /title command fails when session doesn't exist in SQLite yet (#2379)
The /title command would fail with 'Session not found in database.' when used as the first command in a new session. This happened because: 1. Gateway creates session in session_store (in-memory) 2. But SQLite _session_db only gets sessions when agent flushes messages 3. set_session_title() does UPDATE which fails if row doesn't exist Now we check if session exists in SQLite and create it if needed before attempting to set the title. Fixes: Session not found in database. error on /title in new chats
This commit is contained in:
@@ -3677,6 +3677,20 @@ class GatewayRunner:
|
||||
if not self._session_db:
|
||||
return "Session database not available."
|
||||
|
||||
# Ensure session exists in SQLite DB (it may only exist in session_store
|
||||
# if this is the first command in a new session)
|
||||
existing_title = self._session_db.get_session_title(session_id)
|
||||
if existing_title is None:
|
||||
# Session doesn't exist in DB yet — create it
|
||||
try:
|
||||
self._session_db.create_session(
|
||||
session_id=session_id,
|
||||
source=source.platform.value if source.platform else "unknown",
|
||||
user_id=source.user_id,
|
||||
)
|
||||
except Exception:
|
||||
pass # Session might already exist, ignore errors
|
||||
|
||||
title_arg = event.get_command_args().strip()
|
||||
if title_arg:
|
||||
# Sanitize the title before setting
|
||||
|
||||
Reference in New Issue
Block a user