From dc6e9e86677ae1d7d88a42f27a1fbcf3283aa86e Mon Sep 17 00:00:00 2001 From: sabaimran Date: Tue, 21 Jan 2025 12:43:34 -0800 Subject: [PATCH] Skip showing hidden agents in the all conversations agent filter --- .../allConversations/allConversations.tsx | 18 ++++++++++++++---- .../allConversations/sidePanel.module.css | 2 +- src/khoj/routers/api_chat.py | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/interface/web/app/components/allConversations/allConversations.tsx b/src/interface/web/app/components/allConversations/allConversations.tsx index 29d34dda..41361bc5 100644 --- a/src/interface/web/app/components/allConversations/allConversations.tsx +++ b/src/interface/web/app/components/allConversations/allConversations.tsx @@ -62,6 +62,7 @@ interface ChatHistory { agent_name: string; agent_icon: string; agent_color: string; + agent_is_hidden: boolean; compressed: boolean; created: string; updated: string; @@ -465,6 +466,7 @@ function SessionsAndFiles(props: SessionsAndFilesProps) { agent_name={chatHistory.agent_name} agent_color={chatHistory.agent_color} agent_icon={chatHistory.agent_icon} + agent_is_hidden={chatHistory.agent_is_hidden} /> ), )} @@ -694,7 +696,7 @@ function ChatSession(props: ChatHistory) { onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} key={props.conversation_id} - className={`${styles.session} ${props.compressed ? styles.compressed : "!max-w-full"} ${isHovered ? `${styles.sessionHover}` : ""} ${currConversationId === props.conversation_id && currConversationId != "-1" ? "dark:bg-neutral-800 bg-white" : ""}`} + className={`${styles.session} ${props.compressed ? styles.compressed : "!max-w-full"} ${isHovered ? `${styles.sessionHover}` : ""} ${currConversationId === props.conversation_id && currConversationId != "-1" ? "dark:bg-neutral-800 bg-white" : ""} m-1`} > = {}; Object.keys(data).forEach((timeGrouping) => { data[timeGrouping].forEach((chatHistory) => { - if (!agents.includes(chatHistory.agent_name) && chatHistory.agent_name) { + if (chatHistory.agent_is_hidden) return; + if (!chatHistory.agent_color) return; + if (!chatHistory.agent_name) return; + if (!chatHistory.agent_icon) return; + + const agentName = chatHistory.agent_name; + + if (agentName && !agents.includes(agentName)) { agents.push(chatHistory.agent_name); agentNameToStyleMapLocal = { ...agentNameToStyleMapLocal, [chatHistory.agent_name]: { - color: chatHistory.agent_color, - icon: chatHistory.agent_icon, + color: chatHistory.agent_color ?? "orange", + icon: chatHistory.agent_icon ?? "Lightbulb", }, }; } @@ -875,6 +884,7 @@ function ChatSessionsModal({ data, sideBarOpen }: ChatSessionsModalProps) { agent_name={chatHistory.agent_name} agent_color={chatHistory.agent_color} agent_icon={chatHistory.agent_icon} + agent_is_hidden={chatHistory.agent_is_hidden} /> ))} diff --git a/src/interface/web/app/components/allConversations/sidePanel.module.css b/src/interface/web/app/components/allConversations/sidePanel.module.css index 5a8a1bd6..baebda6f 100644 --- a/src/interface/web/app/components/allConversations/sidePanel.module.css +++ b/src/interface/web/app/components/allConversations/sidePanel.module.css @@ -75,7 +75,7 @@ p.session { } p.compressed { - width: 12rem; + width: 11rem; } p.expanded { diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 0bd9cca0..4d346d40 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -457,6 +457,7 @@ def chat_sessions( "updated_at", "agent__style_icon", "agent__style_color", + "agent__is_hidden", ) session_values = [ @@ -468,6 +469,7 @@ def chat_sessions( "updated": session[6].strftime("%Y-%m-%d %H:%M:%S"), "agent_icon": session[7], "agent_color": session[8], + "agent_is_hidden": session[9], } for session in sessions ]