The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): projects RPCs answer from the scan cache when a profile's state.db was never initialized
teknium1372ec7fc1303
diff --git a/tests/tui_gateway/test_main_merge_projections.py b/tests/tui_gateway/test_main_merge_projections.pyindex 4cb9e081b68..4281e38d138 100644--- a/tests/tui_gateway/test_main_merge_projections.py+++ b/tests/tui_gateway/test_main_merge_projections.py@@ -7,7 +7,7 @@ def test_live_message_count_tracks_serialized_projection(monkeypatch):monkeypatch.setattr(server, '_session_db', lambda session: nullcontext(None))monkeypatch.setattr(server, '_fallback_session_info', lambda session: {})monkeypatch.setattr(server, '_pending_approval_request_payload', lambda key: None)- monkeypatch.setattr(server, '_pending_clarify_request_payload', lambda sid: None)+ monkeypatch.setattr(server, '_open_requests', lambda sid: [])# A display row may expand or disappear in the serializer. The count is the wire size.monkeypatch.setattr(server, '_history_to_messages', lambda rows: [{'text': 'visible'}])session = {'history_lock': threading.Lock(), 'history': [{}, {}], 'session_key': 'owned'}diff --git a/tests/tui_gateway/test_notification_admission_refusal.py b/tests/tui_gateway/test_notification_admission_refusal.pyindex cc57cadb25f..ea6102984df 100644--- a/tests/tui_gateway/test_notification_admission_refusal.py+++ b/tests/tui_gateway/test_notification_admission_refusal.py@@ -33,6 +33,8 @@ def test_refused_notification_retains_result_without_spending_attempts(tmp_path,# Also bind the retry helper when present; old code must fail on the receipt, not an absent test import.if hasattr(session_notifications, '_notif_defer_event'):namespace['_notif_defer_event'] = rebind(session_notifications._notif_defer_event, namespace)+ # The dispatcher binds the session's DB row before admission; this session has no store.+ namespace['_ensure_session_db_row'] = lambda _session: Trueoriginal_queue = process_registry.completion_queueprocess_registry.completion_queue = queue.Queue()try:diff --git a/tui_gateway/methods_config.py b/tui_gateway/methods_config.pyindex 9b33f3a46d9..fe0884e8478 100644--- a/tui_gateway/methods_config.py+++ b/tui_gateway/methods_config.py@@ -31,10 +31,9 @@ def _reconcile_repo_discovery(pdb, conn, policy, policy_key):@_projects_handler("projects.discover_repos")def _(rid, params: dict) -> dict:- """Repos for the desktop overview: scanned-from-disk (cached) ∪ session-derived."""+ """Repos for the desktop overview: scanned-from-disk (cached) ∪ session-derived. A profile whose+ session store was never initialized still answers from its scan cache (``db`` is None then)."""with _profile_db(params) as db:- if db is None:- return _ok(rid, {"repos": []})from hermes_cli import projects_db as pdbpolicy = _repo_discovery_policy()with pdb.connect_closing() as conn:@@ -70,7 +69,7 @@ def _(rid, params: dict) -> dict:elif not policy["enabled"]:pdb.clear_discovered_repos(conn, policy_key=policy_key)with _profile_db(params) as db:- repos = [] if db is None else _discover_repos_payload(db, include_cached=policy["enabled"])+ repos = _discover_repos_payload(db, include_cached=policy["enabled"])return _ok(rid, {"repos": repos, "accepted": accepted, "discovery_policy": policy})diff --git a/tui_gateway/methods_projects.py b/tui_gateway/methods_projects.pyindex 09bc1c2d1c2..cf3c4fc64bd 100644--- a/tui_gateway/methods_projects.py+++ b/tui_gateway/methods_projects.py@@ -271,7 +271,9 @@ def _discover_repos_payload(def _agg(root: str) -> dict:return repos.setdefault(root, {"root": root, "label": "", "sessions": 0, "last_active": 0.0})- cwd_rows = list(db.distinct_session_cwds())+ # ``db`` is None for a profile whose session store was never initialized (read-only foreign+ # handles never bootstrap it): the scan cache in projects.db is still authoritative.+ cwd_rows = list(db.distinct_session_cwds()) if db is not None else []# Parallel-warm the per-cwd git probes so a cold first paint doesn't serialize them.git_probe.warm_roots(str(r.get("cwd") or "") for r in cwd_rows)cwd_to_root: dict[str, str] = {}@@ -289,7 +291,7 @@ def _discover_repos_payload(# A read-only handle (foreign-profile RPC) must not attempt the persistence write: it would# raise and be swallowed here, silently dropping the backfill. That profile's own gateway# backfills on its own refreshes.- if backfill and not getattr(db, "read_only", False):+ if backfill and db is not None and not getattr(db, "read_only", False):try:db.backfill_repo_roots(cwd_to_root)except Exception: