import { useState } from "react"; import { Settings, ChevronDown, User, LogOut, ExternalLink, Star, Bell, MessageSquare, Plug } from "lucide-react"; import { Button } from "@/routes/ui/button"; import { cn } from "~/lib/utils"; import { Popover, PopoverContent, PopoverTrigger, } from "@/routes/ui/popover"; export interface SearchSpace { id: string; name: string; icon?: string; } export interface ChatHeaderProps { /** Available search spaces */ searchSpaces?: SearchSpace[]; /** Currently selected search space */ selectedSpace?: SearchSpace; /** Callback when search space is changed */ onSpaceChange?: (space: SearchSpace) => void; /** User display name */ userName?: string; /** User avatar URL */ userAvatar?: string; /** Callback when logout is clicked */ onLogout?: () => void; /** Callback when settings item is clicked */ onSettingsClick?: (item: string) => void; } /** * Enhanced Chat header with branding, space selector, settings, and user menu * * Features: * - Search space selector dropdown * - Settings dropdown with full menu * - User avatar with logout option */ export function ChatHeader({ searchSpaces = [], selectedSpace, onSpaceChange, userName, userAvatar, onLogout, onSettingsClick, }: ChatHeaderProps) { const [spaceOpen, setSpaceOpen] = useState(false); const [settingsOpen, setSettingsOpen] = useState(false); const defaultSpaces: SearchSpace[] = [ { id: "crypto", name: "Crypto", icon: "🪙" }, { id: "general", name: "General", icon: "📚" }, { id: "research", name: "Research", icon: "🔬" }, ]; const spaces = searchSpaces.length > 0 ? searchSpaces : defaultSpaces; const currentSpace = selectedSpace || spaces[0]; return (
{/* Logo and brand */}
SurfSense

SurfSense

{/* Search Space Selector */}
{spaces.map((space) => ( ))}
{/* Right side actions */}
{/* Settings Dropdown */} { onSettingsClick?.(item); setSettingsOpen(false); }} onLogout={onLogout} /> {/* User Avatar */}
); } /** * Settings menu items */ function SettingsMenu({ onItemClick, onLogout, }: { onItemClick?: (item: string) => void; onLogout?: () => void; }) { const menuItems = [ { id: "connectors", label: "Manage Connectors", icon: Plug }, { id: "chats", label: "View All Chats", icon: MessageSquare }, { id: "watchlist", label: "Manage Watchlist", icon: Star }, { id: "alerts", label: "Alert History", icon: Bell }, { id: "settings", label: "Full Settings", icon: Settings, external: true }, ]; return (
{menuItems.map((item) => ( ))}
); } /** * User avatar component */ function UserAvatar({ name, avatarUrl, onLogout, }: { name?: string; avatarUrl?: string; onLogout?: () => void; }) { const initials = name ? name.split(" ").map(n => n[0]).join("").toUpperCase().slice(0, 2) : "U"; return (

{name || "User"}

); }