From faee10ee5ca58e7fef0283c76ec70ead370b8111 Mon Sep 17 00:00:00 2001 From: Jeev-Sampath Date: Wed, 25 Feb 2026 18:45:16 -0500 Subject: [PATCH 1/2] Update chatPreviewList.tsx --- web-app/app/(chat)/chat/_components/chatPreviewList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/web-app/app/(chat)/chat/_components/chatPreviewList.tsx b/web-app/app/(chat)/chat/_components/chatPreviewList.tsx index 4910a5e..617fa77 100644 --- a/web-app/app/(chat)/chat/_components/chatPreviewList.tsx +++ b/web-app/app/(chat)/chat/_components/chatPreviewList.tsx @@ -10,6 +10,7 @@ const AVATAR_COLORS = [ "bg-amber-500", ] + export interface Conversation { id: string name: string From 7908dbfb7f30bd26c4dbb67d6a4fe7333e4e9ae5 Mon Sep 17 00:00:00 2001 From: Jeev-Sampath Date: Mon, 2 Mar 2026 19:17:57 -0500 Subject: [PATCH 2/2] Added Chat Preview List search bar functionality --- .../chat/_components/chatPreviewList.tsx | 39 ++++++++++++++++++- web-app/app/(chat)/chat/chat-client.tsx | 5 +++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/web-app/app/(chat)/chat/_components/chatPreviewList.tsx b/web-app/app/(chat)/chat/_components/chatPreviewList.tsx index 617fa77..ad42da3 100644 --- a/web-app/app/(chat)/chat/_components/chatPreviewList.tsx +++ b/web-app/app/(chat)/chat/_components/chatPreviewList.tsx @@ -27,6 +27,32 @@ function getInitials(name: string) { .toUpperCase() } +function nameMatchesSearch(name: string, searchEntry: string) { + const search = searchEntry.toLowerCase().trim() + if (!search) return true + if(search.length > name.trim().length) return false + + let matches = true; + + let searchArr = search.split(" ") + searchArr.forEach(searchTerm => { + if(!name.toLowerCase() + .trim() + .split(/\s+/) + .some(part => part.startsWith(searchTerm)) && + !name + .toLowerCase() + .startsWith(searchEntry.toLowerCase())){ + matches = false + return + } + + }) + + return matches + +} + export function ChatPreviewItem({ conversation, isSelected, @@ -83,11 +109,19 @@ export function ChatPreviewList({ conversations, selectedId, onSelect, + searchEntry, + setSearchEntry }: { conversations: Conversation[] selectedId: string onSelect: (id: string) => void + searchEntry: string + setSearchEntry: (id: string) => void }) { + + //Filters conversations in the preview list based on search term entered in the search bar + let filteredConversations = conversations.filter(conversations => nameMatchesSearch(conversations.name, searchEntry)) + return (
@@ -98,7 +132,8 @@ export function ChatPreviewList({ setSearchEntry(e.target.value)} />
@@ -109,7 +144,7 @@ export function ChatPreviewList({

Create one to get started.

) : ( - conversations.map((conversation, index) => ( + filteredConversations.map((conversation, index) => ( setLoading(false)) }, [selectedId, currentUserId]) + //value for the search bar + const [searchEntry, setSearchEntry] = useState(""); + return (