// Header / topbar for the command center. function HeaderBar() { const { state, syncState, setEnergy } = useStore(); const today = new Date(); const dateLabel = today.toLocaleDateString(undefined, { weekday: 'long', month: 'short', day: 'numeric' }); const energies = [ { id: 'spent', label: 'Spent' }, { id: 'steady', label: 'Steady' }, { id: 'strong', label: 'Strong' }, { id: 'wired', label: 'Wired' }, ]; const cur = energies.find((e) => e.id === state.energy) || energies[2]; // small dropdown for energy const [open, setOpen] = React.useState(false); return (
optimer / command center
Week {state.week} · {dateLabel}
{open && (
How are you, really?
{energies.map((e) => ( ))}
)}
{syncState === 'saving' ? 'saving…' : 'synced'}
rituals
{state.user.initials}
); } function BurstLauncher() { const { state, startBurst, pauseBurst, tickBurst, closeBurst, toggleTask, setBurstLength } = useStore(); const b = state.burst; // tick the timer when running (header is always mounted, so this is the // single source of truth for the timer regardless of which view you're in) React.useEffect(() => { if (!b.running) return; const id = setInterval(tickBurst, 1000); return () => clearInterval(id); }, [b.running, tickBurst]); // find the active task, or the next suggested one if idle let priority = state.priorities.find((p) => p.id === b.priorityId); let task = priority?.tasks.find((t) => t.id === b.taskId); if (!b.active || !task) { for (const p of state.priorities) { for (const t of p.tasks) { if (!t.done) { priority = p; task = t; break; } } if (task) break; } } const startNext = () => { if (priority && task) startBurst(priority.id, task.id, b.length); }; const mins = Math.floor(b.remaining / 60); const secs = b.remaining % 60; const showSecs = b.active && b.running; const time = b.active ? `${String(mins).padStart(2, '0')}:${String(secs).padStart(2, '0')}` : `${b.length / 60}:00`; const pct = b.length > 0 && b.active ? 1 - b.remaining / b.length : 0; const r = 11; const C = 2 * Math.PI * r; const finished = b.active && b.remaining === 0; const openFullscreen = () => { // surface the fullscreen takeover by activating it (if not already) if (b.active) return; // already active — overlay's already there in Desktop startNext(); }; return (
{time}
{b.active ? (finished ? 'finished' : (b.running ? 'in flow' : 'paused')) : 'next burst'} {task ? task.label : 'No open tasks — add one'}
{finished ? ( ) : b.active ? ( <> ) : ( )}
); } Object.assign(window, { HeaderBar });