Skip to content

The agent that grows with you

Fix session search test double filters

Shannon Sandseb087b308952
diff --git a/tests/hermes_cli/test_web_server_session_search.py b/tests/hermes_cli/test_web_server_session_search.py
index e233e29bb75..8d0faa88a65 100644
--- a/tests/hermes_cli/test_web_server_session_search.py
+++ b/tests/hermes_cli/test_web_server_session_search.py
@@ -14,10 +14,29 @@ class _FakeSessionDB:
closed = False
- def search_sessions_by_id(self, query, limit=20, include_archived=True):
+ @staticmethod
+ def _source_allowed(row, source=None, sources=None, exclude_sources=None):
+ row_source = row.get("source")
+ if source and row_source != source:
+ return False
+ if sources and row_source not in sources:
+ return False
+ if exclude_sources and row_source in exclude_sources:
+ return False
+ return True
+
+ def search_sessions_by_id(
+ self,
+ query,
+ limit=20,
+ include_archived=True,
+ source=None,
+ sources=None,
+ exclude_sources=None,
+ ):
assert query == "20260603"
assert include_archived is True
- return [
+ rows = [
{
"id": "20260603_090200_exact",
"preview": "ID match preview",
@@ -26,10 +45,17 @@ class _FakeSessionDB:
"started_at": 100,
}
]
+ return [
+ row
+ for row in rows
+ if self._source_allowed(
+ row, source=source, sources=sources, exclude_sources=exclude_sources
+ )
+ ][:limit]
- def search_messages(self, query, limit=20):
+ def search_messages(self, query, source_filter=None, exclude_sources=None, limit=20):
assert query == "20260603*"
- return [
+ rows = [
{
"session_id": "20260603_090200_exact",
"snippet": "duplicate content hit should not replace ID hit",
@@ -47,6 +73,13 @@ class _FakeSessionDB:
"session_started": 200,
},
]
+ return [
+ row
+ for row in rows
+ if self._source_allowed(
+ row, sources=source_filter, exclude_sources=exclude_sources
+ )
+ ][:limit]
def get_session(self, session_id):
# No compression chains in this fixture — every session is its own root.
@@ -69,6 +102,7 @@ def test_desktop_session_search_merges_id_matches_before_content_matches(monkeyp
assert response == {
"results": [
{
+ "id": "20260603_090200_exact",
"session_id": "20260603_090200_exact",
"lineage_root": "20260603_090200_exact",
"snippet": "ID match preview",
@@ -78,6 +112,7 @@ def test_desktop_session_search_merges_id_matches_before_content_matches(monkeyp
"session_started": 100,
},
{
+ "id": "content_session",
"session_id": "content_session",
"lineage_root": "content_session",
"snippet": "content hit",