'use client'; import { useState } from 'react'; import type { CSSProperties } from 'react'; import { usePathname } from 'next/navigation'; import { Bell } from 'lucide-react'; import { ADMIN_LINK, NAV } from '@/components/layout/Sidebar'; import { cn } from '@/lib/cn'; import { TERMINAL_STATUSES } from '@/lib/constants'; import { moduleColor, moduleFromPathname } from '@/lib/module-colors'; import { useTaskStore } from '@/stores/tasks'; import type { TaskStatus } from '@/types'; // Bell tint per terminal task status, mirroring the text hues of Badge's // `statusStyles` (the canonical status palette) so the notification cue reads as // the same green/amber/red the task badges use. const BELL_TONE: Partial> = { completed: 'text-success', completed_with_warnings: 'text-warning', cancelled: 'text-warning', failed: 'text-danger', timeout: 'text-orange-300', }; export function TopBar() { const pathname = usePathname(); const current = [...NAV, ADMIN_LINK].find((item) => pathname.startsWith(item.href)); const moduleKey = moduleFromPathname(pathname); const mc = moduleColor(moduleKey); const label = current?.label ?? 'Settings'; // The active architect task's status is a global singleton, so the bell can // reflect its outcome from any page. It tints when the task lands terminal and // clears to white once the user clicks the bell; the next task (a new // activeTaskId) tints it again, so dismissal is keyed to the task, not a flag. const status = useTaskStore((s) => s.status); const activeTaskId = useTaskStore((s) => s.activeTaskId); const [dismissedId, setDismissedId] = useState(undefined); const terminal = status !== undefined && TERMINAL_STATUSES.has(status); const showTint = terminal && activeTaskId !== undefined && activeTaskId !== dismissedId; const bellTone = showTint && status ? BELL_TONE[status] : undefined; return (
{/* One-shot module-tinted light pan along the bottom edge per navigation. */} MAESTRO /{' '} {/* Keyed remount crossfades the section label on navigation. */} {label}
System Live
); }