"use client" import { useEffect, useRef } from "react" import { usePathname } from "next/navigation" import { RealtimeConnectionStatus } from "@/components/realtime-connection-status" import { getPageTitle } from "@/lib/navigation" import { useAgentConversationsStore } from "@/lib/stores/agent-conversations" import { ThemeToggle } from "@/components/theme-toggle" import { Breadcrumb, BreadcrumbItem, BreadcrumbList, BreadcrumbPage, } from "@/components/ui/breadcrumb" import { Separator } from "@/components/ui/separator" import { SidebarTrigger, useSidebar } from "@/components/ui/sidebar" const SIDEBAR_STORAGE_KEY = "dashboard_sidebar_open" export function SiteHeader() { const pathname = usePathname() const { open, setOpen, isMobile } = useSidebar() const pageTitle = getPageTitle(pathname) const realtimeStatus = useAgentConversationsStore((state) => state.realtimeStatus) const hasRestoredRef = useRef(false) const showConversationRealtime = pathname === "/conversations" || pathname.startsWith("/conversations/") useEffect(() => { if (hasRestoredRef.current || isMobile) { return } hasRestoredRef.current = true const storedValue = window.localStorage.getItem(SIDEBAR_STORAGE_KEY) if (storedValue === null) { return } setOpen(storedValue === "true") }, [isMobile, setOpen]) useEffect(() => { if (!hasRestoredRef.current || isMobile) { return } window.localStorage.setItem(SIDEBAR_STORAGE_KEY, String(open)) }, [isMobile, open]) return (
{pageTitle} {showConversationRealtime ? ( ) : null}
) }