import { AgentToggleButton } from "@agent-native/core/client/agent-chat"; import { RunsTray } from "@agent-native/core/client/progress"; import { IconLayoutSidebar } from "@tabler/icons-react"; import { useLocation, useNavigate } from "react-router"; import { Button } from "../ui/button"; import { useHeaderTitle, useHeaderActions } from "./HeaderActions"; const pageTitles: Record = { "/": "Overview", "/overview": "Overview", "/vault": "Vault", "/integrations": "Integrations", "/workspace": "Resources", "/messaging": "Messaging", "/agents": "Agents", "/destinations": "Destinations", "/identities": "Identities", "/approvals": "Approvals", "/automations": "Automations", "/audit": "Audit", "/dreams": "Dreams", "/thread-debug": "Thread Debug", "/transactional-email": "Transactional email", "/settings": "Settings", }; function resolveTitle(pathname: string): string { if (pathname === "/admin" || pathname === "/admin/") return "Admin"; if (pathname.startsWith("/admin/")) { const adminPath = pathname.slice("/admin".length); return pageTitles[adminPath] ?? "Admin"; } if (pageTitles[pathname]) return pageTitles[pathname]; if (pathname.startsWith("/extensions")) return "Extensions"; return "Dispatch"; } export function Header({ onOpenMobile, showAgentToggle = true, }: { onOpenMobile?: () => void; showAgentToggle?: boolean; }) { const location = useLocation(); const navigate = useNavigate(); const title = useHeaderTitle(); const actions = useHeaderActions(); function openRunThread(threadId: string) { navigate("/chat", { state: { dispatchThread: { id: `${Date.now()}-${threadId}`, threadId, }, }, }); window.requestAnimationFrame(() => { window.dispatchEvent( new CustomEvent("agent-chat:open-thread", { detail: { threadId }, }), ); }); } return (
{onOpenMobile ? ( ) : null}
{title ?? (

{resolveTitle(location.pathname)}

)}
{actions} {showAgentToggle ? ( ) : null}
); }