/* * Copyright (c) 2026 Pawan Osman * * This file is part of OpenCursor — AI coding agent chat inside VS Code. * https://github.com/PawanOsman/OpenCursor * * Licensed under the MIT License. See LICENSE file in the project root. */ import * as React from "react"; import { Trash2 } from "lucide-react"; import { Icon } from "../../shared/icons"; import type { ConversationSummary } from "../types"; function timeAgo(ts: number): string { const s = Math.floor((Date.now() - ts) / 1000); if (s < 60) return "just now"; const m = Math.floor(s / 60); if (m < 60) return m + "m ago"; const h = Math.floor(m / 60); if (h < 24) return h + "h ago"; const d = Math.floor(h / 24); return d + "d ago"; } export function History({ list, activeId, onSelect, onDelete, onClose, }: { list: ConversationSummary[]; activeId?: string; onSelect: (id: string) => void; onDelete: (id: string) => void; onClose: () => void; }) { const [query, setQuery] = React.useState(""); const inputRef = React.useRef(null); React.useEffect(() => { inputRef.current?.focus(); }, []); const filtered = query ? list.filter((c) => c.title.toLowerCase().includes(query.toLowerCase())) : list; return (
e.stopPropagation()}> {/* Search */}
setQuery(e.target.value)} spellCheck={false} />
{/* List */}
{filtered.length === 0 ? (
{list.length === 0 ? "No conversations yet." : "No results."}
) : ( filtered.map((c) => (
onSelect(c.id)} >
{c.title}
{timeAgo(c.updatedAt)}
)) )}
); }