'use client' import { usePathname } from 'next/navigation' import { RefreshCw } from 'lucide-react' import { SidebarProvider, SidebarInset, SidebarTrigger } from '@/components/ui/sidebar' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' import { AppSidebar } from './app-sidebar' import { useData, type TimeRange, type AgentType } from './data-provider' import { getPlugin } from '@/lib/plugins' import '@/plugins' // ensure plugins are registered import type { ReactNode } from 'react' const VIEW_TITLES: Record = { '/': 'Dashboard', '/daily': 'Daily Usage', '/tokens': 'Token Breakdown', '/tools': 'Tool Usage', '/projects': 'Projects', '/sessions': 'Sessions', '/personality': 'Personality Fit', '/commands': 'Command Usage', '/images': 'Image Analysis', '/coach': 'CRAFT Coach', '/flow': 'Session Flow', '/community': 'Community', '/reports': 'Reports', '/data-management': 'Data Management', } function resolveTitle(pathname: string): ReactNode { if (VIEW_TITLES[pathname]) return VIEW_TITLES[pathname] const match = pathname.match(/^\/community\/([a-z0-9-]+)$/) if (match) { const plugin = getPlugin(match[1]) if (plugin) return plugin.manifest.name } if (pathname.startsWith('/reports/')) return 'Report Detail' if (pathname.startsWith('/sessions/')) return 'Session Detail' return 'Dashboard' } const AGENT_LABELS: Record = { claude: 'Claude Code', codex: 'Codex', combined: 'Combined', } const TIME_RANGE_LABELS: Record = { '7d': 'Last 7 days', '30d': 'Last 30 days', '90d': 'Last 90 days', 'all': 'All time', } // Pages where time range filter doesn't apply const NO_TIME_FILTER = new Set(['/commands']) export function DashboardShell({ children }: { children: ReactNode }) { const pathname = usePathname() const { agent, setAgent, timeRange, setTimeRange, selectedProject, setSelectedProject, allProjects, loading, } = useData() const title = resolveTitle(pathname) const communitySlug = pathname.match(/^\/community\/([a-z0-9-]+)$/)?.[1] const communityPlugin = communitySlug ? getPlugin(communitySlug) : undefined const showTimeFilter = !NO_TIME_FILTER.has(pathname) && !communityPlugin?.manifest.customDataSource if (loading) { return (
Syncing logs...
) } return (

{title}

{showTimeFilter && (
{(Object.entries(TIME_RANGE_LABELS) as [TimeRange, string][]).map(([key, label]) => ( ))}
)} {allProjects.length > 1 && ( )}
{children}
) }