import './topnav.css'; import { Menu, useComputedColorScheme, useMantineColorScheme } from '@mantine/core'; import { IconChevronDown, IconHandStop, IconMenu2, IconMoon, IconSearch, IconSun } from '@/components/icons'; import { Link, NavLink as RouterLink, useLocation, useNavigate } from 'react-router-dom'; import { useBrand, useKill, useRuns } from '../../api/hooks'; import { useAuth } from '../../auth/AuthContext'; import { NotificationBell } from '../../notify/NotificationBell'; import { useWaitsOnMe } from '../../domain/waiting'; import { AccountMenu, AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, LIBRARY, MAIN, SETTINGS, SETUP, type NavItem } from './AppSidebar'; import { EnvSwitcher } from './EnvSwitcher'; import { useShell } from './prefs'; import { isMac } from './TopBar'; const isActive = (item: NavItem, path: string) => (item.match ? item.match(path) : path === item.to || path.startsWith(`${item.to}/`)); /** The app's navigation: brand at left, main pages across the center, and environment and account tools at right. * Setup and admin pages are grouped under More; phones keep the menu drawer. */ export function TopNav() { const { can } = useAuth(); const loc = useLocation(); const nav = useNavigate(); const brand = useBrand(); const runs = useRuns(40, 0); const mine = useWaitsOnMe(); const kill = useKill(); const { size, openNav, openPalette } = useShell(); const { setColorScheme } = useMantineColorScheme(); const scheme = useComputedColorScheme('dark'); const dark = scheme === 'dark'; const waiting = (runs.data?.items ?? []).filter(mine).length; const name = brand.data?.product_name ?? 'Astra'; const phone = size === 'phone'; const main = [...MAIN.filter((i) => i.to !== '/assistant'), ...LIBRARY, ...MAIN.filter((i) => i.to === '/assistant')]; const more = [...SETUP, ...(can('admin') ? [AGENT_STUDIO, AI_MONITORING, INTEGRATIONS, SETTINGS] : [])]; const moreActive = more.find((i) => isActive(i, loc.pathname)); return (
{phone && } {name}
{kill.data?.engaged && Stopped}
); }