From 9f37ef0ca933ff88f4781ff6e497b92b88cf2139 Mon Sep 17 00:00:00 2001 From: shawnxiao105-afk Date: Sat, 23 May 2026 15:26:41 +0800 Subject: [PATCH] feat: add sidebar conversation filter Closes #35 --- frontend/src/components/Sidebar/Sidebar.tsx | 52 ++++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Sidebar/Sidebar.tsx b/frontend/src/components/Sidebar/Sidebar.tsx index 622e21f..f23ae88 100644 --- a/frontend/src/components/Sidebar/Sidebar.tsx +++ b/frontend/src/components/Sidebar/Sidebar.tsx @@ -1,4 +1,5 @@ -import { Plus } from "lucide-react"; +import { useState } from "react"; +import { Plus, Search } from "lucide-react"; import { useConversationsStore } from "@/store/conversations"; import { createConversation, deleteConversation } from "@/api/conversations"; import { ConversationItem } from "./ConversationItem"; @@ -16,12 +17,15 @@ export function Sidebar() { removeConversation, } = useConversationsStore(); + const [filter, setFilter] = useState(""); + const defaultEngine = engines[0]?.name ?? ""; const handleNew = async () => { const conv = await createConversation(defaultEngine); addConversation(conv); setActiveId(conv.id); + setFilter(""); }; const handleDelete = async (id: string) => { @@ -29,6 +33,13 @@ export function Sidebar() { removeConversation(id); }; + const normalizedFilter = filter.trim().toLowerCase(); + const visibleConversations = normalizedFilter + ? conversations.filter((c) => + c.title.toLowerCase().includes(normalizedFilter) + ) + : conversations; + return (