fix(desktop): Change Launch Mode menu performs reset entirely in main
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>
This commit is contained in:
@@ -8,20 +8,24 @@ import {
|
||||
export interface AppMenuOptions {
|
||||
mainWindow: BrowserWindow;
|
||||
appName: string;
|
||||
onChangeLaunchMode?: () => Promise<void> | void;
|
||||
}
|
||||
|
||||
function buildConnectionSubmenu(options: AppMenuOptions): MenuItemConstructorOptions {
|
||||
const { mainWindow } = options;
|
||||
return {
|
||||
label: "Connection",
|
||||
submenu: [
|
||||
{
|
||||
label: "Change Launch Mode…",
|
||||
click: () => {
|
||||
// The renderer-side gate listens for this and calls
|
||||
// shell.resetDesktopMode() before reloading without the cached
|
||||
// serverBaseUrl query param.
|
||||
mainWindow.webContents.send("shell:reset-desktop-mode-request");
|
||||
console.log("[desktop/menu] Change Launch Mode clicked");
|
||||
if (!options.onChangeLaunchMode) {
|
||||
console.warn("[desktop/menu] onChangeLaunchMode callback not provided");
|
||||
return;
|
||||
}
|
||||
void Promise.resolve(options.onChangeLaunchMode()).catch((error: unknown) => {
|
||||
console.error("[desktop/menu] onChangeLaunchMode failed", error);
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user