import "./BackendConnectionErrorPage.css"; import { useTranslation } from "react-i18next"; interface BackendConnectionErrorPageProps { errorMessage: string; isRetrying: boolean; onRetry: () => void; onManageConnection?: () => void; } function isDesktopShell(): boolean { if (typeof window === "undefined") return false; return typeof window.fusionShell?.resetDesktopMode === "function"; } async function changeLaunchMode(): Promise { const shell = typeof window !== "undefined" ? window.fusionShell : undefined; try { await shell?.resetDesktopMode?.(); } catch { // Best-effort; still strip query params and reload. } const url = new URL(window.location.href); url.searchParams.delete("serverBaseUrl"); url.searchParams.delete("shellMode"); window.location.replace(url.toString()); } export function BackendConnectionErrorPage({ errorMessage, isRetrying, onRetry, onManageConnection, }: BackendConnectionErrorPageProps) { const { t } = useTranslation("app"); const showChangeLaunchMode = isDesktopShell(); return (

{t("backend.connectionError", "Can't reach the Fusion backend")}

{t("backend.couldNotLoad", "Fusion couldn't load your projects right now. Please make sure the backend is running and try again.")}

{t("backend.error", "Error: {{error}}", { error: errorMessage })}

{showChangeLaunchMode && ( )} {onManageConnection && ( )}
); }