diff --git a/libervia/backend/memory/sqla.py b/libervia/backend/memory/sqla.py index e1d23882..daf9da78 100644 --- a/libervia/backend/memory/sqla.py +++ b/libervia/backend/memory/sqla.py @@ -729,7 +729,13 @@ class Storage: if "origin_id" in filters: stmt = stmt.where(History.origin_id == filters["origin_id"]) if "thread_id" in filters: - stmt = stmt.where(Thread.thread_id == filters["thread_id"]) + # Include both replies and the parent message (thread_id is the parent uid) + stmt = stmt.where( + or_( + Thread.thread_id == filters["thread_id"], + History.uid == filters["thread_id"], + ) + ) if "keyword" in filters: keyword = filters["keyword"] # FIXME: "json_each" works with SQLite, but when PostGreSQL support will