import { useState, useEffect } from "react"; import { WifiOff, Search, Bell, Brain } from "lucide-react"; import waggleLogoDark from "@/assets/waggle-logo.jpeg"; import waggleLogoLight from "@/assets/waggle-logo.png"; import { useIsLightTheme } from "@/hooks/useIsLightTheme"; import { HintTooltip } from "@/components/ui/hint-tooltip"; import { useDeveloperMode } from "@/hooks/useDeveloperMode"; import { useProviders } from "@/hooks/useProviders"; import { formatModelLabel } from "@/lib/model-label"; import { adapter } from "@/lib/adapter"; import { DATE_LOCALE } from "@/lib/date-locale"; import { WaggleSettle, claimFullSignature } from "@/components/os/warm"; interface StatusBarProps { workspaceName?: string; /** * P39 → P1a: the active surface's breadcrumb label. Derived by AppShell * from the matched route's nav title (replaces the old status-bar focus * builder, which died with the window manager — conversion plan §3.1). */ focusedWindowLabel?: string | null; model?: string; tokensUsed?: number; costUsd?: number; offline?: boolean; unreadNotifications?: number; onSearchClick?: () => void; onNotificationClick?: () => void; } const StatusBar = ({ workspaceName, focusedWindowLabel, model, tokensUsed, costUsd, offline, unreadNotifications = 0, onSearchClick, onNotificationClick }: StatusBarProps) => { const [time, setTime] = useState(new Date()); const isLight = useIsLightTheme(); const waggleLogo = isLight ? waggleLogoLight : waggleLogoDark; // M-20 / UX-5: token + cost are developer-facing signal. Hidden by // default; Settings → Advanced → Developer mode flips them on. const [developerMode] = useDeveloperMode(); // W2C: format the raw model id into a friendly display name via the shared // formatter (catalog lookup + heuristic). The chip means "model this // workspace's chat will use"; the tooltip carries the raw id + where to change it. const { providers } = useProviders(); const modelLabel = formatModelLabel(model, providers); // F2 from the 2026-05-28 addictiveness audit — surface accumulated // memory count as a visible "trophy" so users see their investment // compounding (rubric dim 8). Hidden when the count is zero (a // brand-new user is better served by the LoginBriefing demo hook). const [memoryFrameCount, setMemoryFrameCount] = useState(null); // Signature motion: when the REAL count increases between polls, a small // “+N ⬡” particle folds into the hive (the brain chip) and fades. Honest by // construction — it only ever fires on an actual frame-count increase. const [foldDelta, setFoldDelta] = useState(null); // Lane WS: the commissioned waggle-settle plays over the memory chip on the // FIRST real memory-saved of the session (SIGNATURE.full gate + cooldown) — // the prototype's single wired moment. Reduced-motion degrades inside it. const [settlePlay, setSettlePlay] = useState(false); useEffect(() => { let cancelled = false; let foldTimer: ReturnType | undefined; const load = () => { adapter.getMemoryStats() .then(stats => { if (cancelled) return; // adapter.getMemoryStats normalises to { personal, workspace, // total } with `frames` on each bucket — same shape that powers // the LoginBriefing brag line. const n = stats?.total?.frames ?? 0; setMemoryFrameCount(prev => { if (prev !== null && n > prev) { setFoldDelta(n - prev); if (foldTimer) clearTimeout(foldTimer); foldTimer = setTimeout(() => { if (!cancelled) setFoldDelta(null); }, 2000); // Signature flourish — gated to first-of-session + cooldown, so it // fires at most once per session (claim is idempotent under a // double-invoked updater in StrictMode). if (claimFullSignature('memory-saved-first-of-session')) setSettlePlay(true); } return n > 0 ? n : null; }); }) .catch(() => { /* silent — leave count hidden */ }); }; load(); // Refresh every 60s so the trophy ticks up during active use. const id = setInterval(load, 60_000); return () => { cancelled = true; clearInterval(id); if (foldTimer) clearTimeout(foldTimer); }; }, []); useEffect(() => { const interval = setInterval(() => setTime(new Date()), 1000); return () => clearInterval(interval); }, []); const formatTime = (d: Date) => d.toLocaleTimeString(DATE_LOCALE, { hour: "2-digit", minute: "2-digit", hour12: false }); const formatDate = (d: Date) => d.toLocaleDateString(DATE_LOCALE, { weekday: "short", month: "short", day: "numeric" }); return (
{/* R11 Lane D: the full logo (mark + WAGGLE wordmark) crammed into 16px read as a muddy dark tile in light. Clip to just the bee mark — a 200% image nudged up/left so the wordmark falls outside the 16px window — so it reads as an orange mark on the asset's own bg in both themes, never a dark square. A faint ring keeps the cream tile crisp on ivory. */} Waggle Waggle AI {/* L-02: hide workspace + model below md (~768px) so the logo + "Waggle AI" stay visible on narrow windows. */} {workspaceName && ( <> · {workspaceName} )} {focusedWindowLabel && ( <> · {focusedWindowLabel} )} {model && ( <> · {/* R9 kw judge: "Default: Haiku" beside a thread running Opus read as two contradictory truths. The label now states its SCOPE — this chip is the new-chat default; an open thread's model lives in the chat header. Scoping, not fake agreement. R11 kw: "New chats:" was clever-but-oblique — "Default model:" is self-evident; the tooltip still disambiguates the open thread. */} Default model: {modelLabel} )} {memoryFrameCount !== null && ( <> · )} {developerMode && tokensUsed !== undefined && tokensUsed > 0 && ( <> · {tokensUsed.toLocaleString()} tok )} {developerMode && costUsd !== undefined && costUsd > 0 && ( ${costUsd.toFixed(4)} )}
{/* Round-6: an overlapping badge can never sit right on a 14px bell — it occluded the glyph. Count now renders BESIDE the bell inside the same click target: unambiguous, nothing covered, nothing clipped. */} {offline && (

Backend Unreachable

Messages will be queued and sent when the connection is restored.

)} {formatDate(time)} {formatTime(time)}
); }; export default StatusBar;