import { ArrowUpRight, ChevronDown, MessageSquare, Plus } from 'lucide-react' import { Button } from '@/components/ui/button' import { cn } from '@/lib/utils' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { formatRelativeTime } from '@/lib/relative-time' export interface ChatHeaderRecentRun { id: string title?: string createdAt: string } export interface ChatHeaderProps { activeTitle: string onNewChatTab: () => void recentRuns?: ChatHeaderRecentRun[] activeRunId?: string | null onSelectRun?: (runId: string) => void onOpenChatHistory?: () => void } /** * Header controls for the copilot/chat surface: the active-chat title with a * recent-chats history dropdown, plus the new-chat button. Rendered identically * whether the chat lives in the side pane (ChatSidebar) or full screen (App * content header). There is a single chat conversation at a time — switching * between chats happens through the history dropdown. */ export function ChatHeader({ activeTitle, onNewChatTab, recentRuns = [], activeRunId, onSelectRun, onOpenChatHistory, }: ChatHeaderProps) { const hasHistory = recentRuns.length > 0 || Boolean(onOpenChatHistory) return ( <> {hasHistory ? ( {recentRuns.length > 0 && ( Recent )} {recentRuns.slice(0, 6).map((run) => ( onSelectRun?.(run.id)} className={cn('gap-2', activeRunId === run.id && 'bg-accent')} > {run.title || '(Untitled chat)'} {formatRelativeTime(run.createdAt)} ))} {onOpenChatHistory && ( <> {recentRuns.length > 0 && } View all chats )} ) : (
{activeTitle}
)} New chat ) }