import type { SaveStatus } from './sync-contract' import { AlertTriangle } from 'lucide-react' import './SaveStatusIndicator.css' interface SaveStatusIndicatorProps { saveStatus: SaveStatus isConcurrentTabOpen: boolean online?: boolean } function statusLabel(status: SaveStatus, online: boolean): string { switch (status.state) { case 'idle': return '' case 'saving': return 'Saving...' case 'saved': return online ? 'Saved locally' : 'Saved locally ยท Offline' case 'error': return `Error: ${status.message}` } } /** * Displays the current save status and concurrent tab warning in the status bar. * * - idle: invisible (no visual noise) * - saving: "Saving" with cycling dots (text only) * - saved: accent "Saved" (text only) * - error: red dot + error message * * Also shows a warning icon when the same document is open in another tab. */ export function SaveStatusIndicator({ saveStatus, isConcurrentTabOpen, online = true }: SaveStatusIndicatorProps) { const label = statusLabel(saveStatus, online) return ( <> {saveStatus.state !== 'idle' && (
)} {isConcurrentTabOpen && (
)} ) }