"use client"; import { useState } from "react"; import { Clock, Search, X } from "lucide-react"; import { useSessions, useSessionSearch } from "@/lib/hooks"; import { SessionCard } from "@/components/SessionCard"; const PLATFORMS = [ { id: null, label: "All" }, { id: "cli", label: "CLI" }, { id: "telegram", label: "Telegram" }, { id: "discord", label: "Discord" }, { id: "web", label: "Web" }, ] as const; export default function HistoryPage() { const [filter, setFilter] = useState(null); const [query, setQuery] = useState(""); const [searching, setSearching] = useState(false); const { data: sessionsData, isLoading } = useSessions(30, filter || undefined); const { data: searchData, isFetching: searchLoading } = useSessionSearch( searching ? query : "" ); const showSearch = searching && query.length >= 2; return (

History

{/* Search bar */}
{ setQuery(e.target.value); setSearching(true); }} onFocus={() => setSearching(true)} placeholder="Search sessions..." className="w-full pl-9 pr-9 py-2.5 rounded-xl text-sm bg-white/[0.04] border border-white/[0.08] text-zinc-200 placeholder-zinc-600 outline-none focus:border-white/[0.15] transition-colors" /> {query && ( )}
{/* Search results */} {showSearch ? (
{searchLoading ? "Searching..." : `${searchData?.count || 0} results`}
{searchData?.results?.map((r) => (
{r.session_title || r.session_id.slice(0, 8)} {r.role}

{r.content}

))}
) : ( <> {/* Platform filter */}
{PLATFORMS.map((p) => ( ))}
{/* Session list */} {isLoading ? (
{[...Array(5)].map((_, i) => (
))}
) : (
{sessionsData?.items?.map((s) => ( ))} {sessionsData?.items?.length === 0 && (
No sessions found
)}
)} )}
); }