fix: return no chats when a folder search term matches no folder (#30273)

This commit is contained in:
G30 2026-09-21 00:39:54 -04:00 • committed by GitHub
parent f2220d2e40
commit 402a187e82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1988,10 +1988,8 @@ class ChatTable:
]
# Extract folder names
folders = await Folders.search_folders_by_names(
user_id,
[word.replace('folder:', '') for word in search_text_words if word.startswith('folder:')],
)
folder_names = [word.replace('folder:', '') for word in search_text_words if word.startswith('folder:')]
folders = await Folders.search_folders_by_names(user_id, folder_names)
folder_ids = [folder.id for folder in folders]
is_pinned = None
@ -2035,7 +2033,7 @@ class ChatTable:
else:
stmt = stmt.filter(Chat.share_id.is_(None))
if folder_ids:
if folder_names:
stmt = stmt.filter(Chat.folder_id.in_(folder_ids))
# Check if the database dialect is either 'sqlite' or 'postgresql'