Skip to content

The agent that grows with you

fix(gateway): the live session.list picker honours hidden/archived and include_hidden

Tekniumc4012cd9c1ca
diff --git a/gateway/session_controls.py b/gateway/session_controls.py
index b8e4f30f6e9..856dc8a0cdd 100644
--- a/gateway/session_controls.py
+++ b/gateway/session_controls.py
@@ -359,7 +359,8 @@ class AuthorityConnection:
row = self.authority.db.get_session(sid)
# The human picker feed (TUI switcher): kanban workers, `--source tool` integrations and
# finite one-shot runs are not conversations, as on every other picker.
- if row.get('source') in INTERNAL_LISTING_SOURCES:
+ if row.get('source') in INTERNAL_LISTING_SOURCES or (
+ not params.get('include_hidden') and (row.get('hidden') or row.get('archived'))):
continue
sessions.append({'session_id': sid, 'id': sid, 'title': row.get('title') or '',
'source': row.get('source'), 'started_at': row.get('started_at'),
diff --git a/tests/gateway/test_session_list_live_hidden.py b/tests/gateway/test_session_list_live_hidden.py
new file mode 100644
index 00000000000..17d4c1e9ab5
--- /dev/null
+++ b/tests/gateway/test_session_list_live_hidden.py
@@ -0,0 +1,26 @@
+"""The live session.list picker honours hidden/archived like every stored picker (N110)."""
+from types import SimpleNamespace
+
+import pytest
+
+from gateway.session_controls import AuthorityConnection
+from tests.gateway.test_local_source_labels import _authority, _create
+
+
+async def test_live_list_hides_hidden_and_archived_unless_asked(tmp_path, monkeypatch):
+ authority, store = await _authority(tmp_path, monkeypatch)
+ conn = AuthorityConnection(authority, SimpleNamespace(write=lambda frame: None), {'user_id': 'owner'})
+ try:
+ chat = await _create(conn, authority, store, 'cli', 'chat')
+ hidden = await _create(conn, authority, store, 'cli', 'hidden')
+ archived = await _create(conn, authority, store, 'cli', 'archived')
+ authority.db.set_session_hidden(hidden, True)
+ authority.db.set_session_archived(archived, True)
+ listed = await conn.dispatch({'id': 9, 'method': 'session.list', 'params': {}})
+ assert [row['id'] for row in listed['result']['sessions']] == [chat]
+ every = await conn.dispatch({'id': 10, 'method': 'session.list', 'params': {'include_hidden': True}})
+ assert {row['id'] for row in every['result']['sessions']} == {chat, hidden, archived}
+ finally:
+ await conn.close()
+ authority.db.close()