"use client"; import { useCallback, useId } from "react"; interface SessionContext { summary: string; last_updated: string | null; } interface ContextPanelProps { isOpen: boolean; onClose: () => void; sessionContext: SessionContext | null; } function formatRelativeTime(isoString: string): string { const date = new Date(isoString); const now = new Date(); const diffMs = now.getTime() - date.getTime(); const diffSec = Math.floor(diffMs / 1000); const diffMin = Math.floor(diffSec / 60); const diffHour = Math.floor(diffMin / 60); if (diffSec < 60) { return "just now"; } if (diffMin < 60) { return `${diffMin} minute${diffMin === 1 ? "" : "s"} ago`; } if (diffHour < 24) { return `${diffHour} hour${diffHour === 1 ? "" : "s"} ago`; } return date.toLocaleDateString(); } function BrainIcon() { return ( ); } export default function ContextPanel({ isOpen, onClose, sessionContext, }: ContextPanelProps) { const titleId = useId(); const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (e.key === "Escape") { onClose(); } }, [onClose], ); if (!isOpen) { return null; } const hasContext = sessionContext?.summary && sessionContext.summary.trim(); return ( <>
This is what the assistant has learned from your conversation so far. It uses this context to provide more relevant answers.
{hasContext ? (