Replace the renderer-event approach (which silently failed when the renderer-side listener wasn't yet registered) with an onChangeLaunchMode callback wired through AppMenuOptions. The callback runs resetLaunchModeAndReload in main: writes shell settings to clear the chosen mode, stops the embedded runtime, then navigates the window directly to the renderer entrypoint with no cached query params so the launch gate re-prompts. Also surface the same flow from the dashboard's BackendConnectionErrorPage: when running inside the desktop shell, the "Can't reach the Fusion backend" page now offers a "Change Launch Mode…" button alongside Retry, so a user who chose a broken backend isn't stuck without the Electron menubar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import "./BackendConnectionErrorPage.css";
|
|
|
|
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<void> {
|
|
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 showChangeLaunchMode = isDesktopShell();
|
|
return (
|
|
<div className="project-overview-empty" role="alert" aria-live="polite">
|
|
<h2>Can't reach the Fusion backend</h2>
|
|
<p className="settings-muted">
|
|
Fusion couldn't load your projects right now. Please make sure the backend is running and try again.
|
|
</p>
|
|
<p className="settings-muted">Error: {errorMessage}</p>
|
|
<div className="modal-actions">
|
|
<button type="button" className="btn btn-primary" onClick={onRetry} disabled={isRetrying}>
|
|
{isRetrying ? "Retrying…" : "Retry Connection"}
|
|
</button>
|
|
{showChangeLaunchMode && (
|
|
<button type="button" className="btn" onClick={() => void changeLaunchMode()}>
|
|
Change Launch Mode…
|
|
</button>
|
|
)}
|
|
{onManageConnection && (
|
|
<button type="button" className="btn" onClick={onManageConnection}>
|
|
Manage Connection
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|