import { Link, useLocation } from "@tanstack/react-router"; import { SESSION_MODES } from "@/client/lib/constants"; import { selectHasLocalSession, useAuthStore } from "@/client/stores/auth-store"; import { useOnline } from "@/client/hooks/use-online"; import { usePwaUpdate } from "@/client/lib/pwa"; export function Banners() { const online = useOnline(); const sessionMode = useAuthStore((s) => s.sessionMode); const refreshState = useAuthStore((s) => s.refreshState); const hasLocalSession = useAuthStore(selectHasLocalSession); const pathname = useLocation({ select: (l) => l.pathname }); const pwaUpdate = usePwaUpdate(); const hasDegradedSession = sessionMode === SESSION_MODES.LOCAL_ONLY || sessionMode === SESSION_MODES.EXPIRED; const showRestoring = refreshState === "refreshing" && hasDegradedSession; const showExpired = sessionMode === SESSION_MODES.EXPIRED && !showRestoring; // `Banners` is also mounted by `StandaloneLayout`, which covers anonymous // surfaces (login, invite). Gate the PWA update prompt to local-session // surfaces so unauthenticated users never see it. const showPwaUpdate = hasLocalSession && pwaUpdate.waiting && pwaUpdate.apply !== null; return ( <> {!online && (