import { useCallback, useRef, useState } from "react"; import { useApp } from "../lib/store"; import { Activity, Check, Compass, GraduationCap, PanelLeft, PanelRight, Zap } from "lucide-react"; import { APP_NAME, APP_TAGLINE } from "../lib/anon"; import { ClaimsMapButton } from "./ClaimsMap"; import { ThemeSwitcher } from "./ThemeSwitcher"; import { TipIcon } from "./TipIcon"; import { useDismissOn } from "../lib/useDismissOn"; import { areLessonsDone, isLearnLabDone } from "../lib/learnProgress"; /** * Top application bar — deliberately minimal since Wave P (the system * serves the paper, not a product): app name + tagline, the runtime * environment chip (qiskit/torch versions), the live-calibration * toggle when the server supports it, the welcome-tour reopener, and * the theme switcher. The product-era surfaces (sign-in, lab/paper/ * developer links, funding popover) stay removed; the tour returned * in 2026-07 — with double-blind treatment no longer needed, * onboarding affordances are back, rewritten for the * evidence-workbench system. * * Mobile: the two side panes are swapped for drawers, so we surface two * edge buttons (PanelLeft / PanelRight) for toggling them. */ /** "Learn" — a two-item dropdown (the standard popover idiom: * useDismissOn + right-anchored menu, viewport-pinned below sm like * the ThemeSwitcher). Two tracks, one entry: "Start from zero" * (LearnLab, marker learn-lab) teaches what a qubit even IS on the * toy simulator; "Guided experiments" (LessonCard) runs the real * pipeline. The from-zero track lists first because it is the one a * reader with no background needs first. Completed tracks carry a ✓ * (lib/learnProgress flags, re-read every time the menu opens). */ function LearnMenu() { const [open, setOpen] = useState(false); const rootRef = useRef(null); useDismissOn(open, rootRef, useCallback(() => setOpen(false), [])); // Completion ticks — read on open (localStorage is the source of // truth; step 5 / the last lesson write it, possibly this session). const zeroDone = open && isLearnLabDone(); const lessonsDone = open && areLessonsDone(); const pick = (which: "zero" | "lessons") => { const app = useApp.getState(); if (which === "zero") app.setLearnLabOpen(true); else app.setLessonsOpen(true); setOpen(false); }; return (
{open && (
)}
); } export function TopBar({ mobile = false, onOpenLeftDrawer, onOpenRightDrawer, onOpenTour, }: { mobile?: boolean; onOpenLeftDrawer?: () => void; onOpenRightDrawer?: () => void; onOpenTour?: () => void; }) { const health = useApp((s) => s.health); const useLiveIbm = useApp((s) => s.useLiveIbm); const setUseLiveIbm = useApp((s) => s.setUseLiveIbm); // Server can go live only when it has both the IBM token and the admin // has flipped ALLOW_LIVE_IBM=true in env. If either is missing we grey // the chip out and make it read-only. const serverCanGoLive = !!health?.live_ibm_allowed && !!health?.ibm_token_configured; const effectiveLive = serverCanGoLive && useLiveIbm; let chipLabel: string; let chipLabelShort: string; let chipClass: string; let chipTitle: string; if (effectiveLive) { chipLabel = "live calibration: on"; chipLabelShort = "live: on"; chipClass = "!border-warn/50 !text-warn cursor-pointer hover:!border-warn hover:!text-warn"; chipTitle = "Live mode ON. Each run fetches today's fresh machine calibration (error rates) instead of the shipped snapshot (+5-15s per run, counts against rate limits). Click to switch back to the snapshot."; } else { chipLabel = "live calibration: off (snapshot)"; chipLabelShort = "live: off"; chipClass = "!border-edge !text-mute cursor-pointer hover:!text-ink hover:!border-accent/40"; chipTitle = "Using the shipped 14-day calibration snapshot (the machine's measured error rates). Deterministic and fine for reproduction. Click to fetch fresh calibration per run instead."; } return (
{mobile && onOpenLeftDrawer && ( )}
{APP_NAME}
{APP_TAGLINE}
{/* Status chips: runtime library versions + whether the live- calibration path is hot. The version chip is hidden on mobile to save room; the live toggle is only shown when the server actually supports live mode. */}
{!mobile && ( {health ? `qiskit ${health.qiskit_version} · torch ${health.torch_version}` : "loading…"} )} {serverCanGoLive && ( )}
{onOpenTour && ( )} {mobile && onOpenRightDrawer && ( )}
); }