From 8159d1ab257dc71c76146b2985b53f8639443cc0 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 7 Apr 2024 12:38:00 +0530 Subject: [PATCH] Fix showing Search navigation tab from Agent pages on web client The `has_documents' flag wasn't being passed. So the search tab always showing up as empty instead of being dynamically enabled if documents had been indexed. --- src/khoj/routers/web_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/khoj/routers/web_client.py b/src/khoj/routers/web_client.py index 4df0e3e1..9e3a39b5 100644 --- a/src/khoj/routers/web_client.py +++ b/src/khoj/routers/web_client.py @@ -135,6 +135,7 @@ def login_page(request: Request): def agents_page(request: Request): user: KhojUser = request.user.object if request.user.is_authenticated else None user_picture = request.session.get("user", {}).get("picture") if user else None + has_documents = EntryAdapters.user_has_entries(user=user) agents = AgentAdapters.get_all_accessible_agents(user) agents_packet = list() for agent in agents: @@ -156,7 +157,7 @@ def agents_page(request: Request): "agents": agents_packet, "khoj_version": state.khoj_version, "username": user.username if user else None, - "has_documents": False, + "has_documents": has_documents, "is_active": has_required_scope(request, ["premium"]), "user_photo": user_picture, }, @@ -169,6 +170,7 @@ def agent_page(request: Request, agent_slug: str): user_picture = request.session.get("user", {}).get("picture") if user else None agent = AgentAdapters.get_agent_by_slug(agent_slug) + has_documents = EntryAdapters.user_has_entries(user=user) if agent == None: return templates.TemplateResponse( @@ -202,7 +204,7 @@ def agent_page(request: Request, agent_slug: str): "agent": agent_metadata, "khoj_version": state.khoj_version, "username": user.username if user else None, - "has_documents": False, + "has_documents": has_documents, "is_active": has_required_scope(request, ["premium"]), "user_photo": user_picture, },