fix(desktop): re-show hidden window on dock/Finder activate + log gate flow
The close handler hides the BrowserWindow instead of destroying it, so once closed, subsequent dock or Finder activations were no-ops because the activate handler only created a new window when mainWindow === null. Show + focus the existing window if it's hidden so relaunch behaves as expected. Also add console.log breadcrumbs in DesktopLaunchGate so we can diagnose why the chooser sometimes appears not to render. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,11 @@ type Phase =
|
||||
|
||||
function getFusionShell() {
|
||||
if (typeof window === "undefined") return null;
|
||||
return window.fusionShell ?? null;
|
||||
const shell = window.fusionShell ?? null;
|
||||
if (!shell) {
|
||||
console.log("[DesktopLaunchGate] window.fusionShell unavailable; bypassing");
|
||||
}
|
||||
return shell;
|
||||
}
|
||||
|
||||
function isDesktopShell(state: ShellConnectionState | null): boolean {
|
||||
@@ -73,15 +77,19 @@ export function DesktopLaunchGate({ children }: PropsWithChildren) {
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
try {
|
||||
console.log("[DesktopLaunchGate] fetching shell state…");
|
||||
const state = await shell.getState();
|
||||
if (cancelled) return;
|
||||
console.log("[DesktopLaunchGate] shell state:", state);
|
||||
|
||||
if (!isDesktopShell(state)) {
|
||||
console.log("[DesktopLaunchGate] not desktop-shell host; bypassing");
|
||||
setPhase({ kind: "bypass" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (needsChooser(state)) {
|
||||
console.log("[DesktopLaunchGate] first run / no mode chosen — showing chooser");
|
||||
setPhase({ kind: "chooser", state });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,15 @@ export function run(): void {
|
||||
if (mainWindow === null) {
|
||||
const window = createMainWindow();
|
||||
window.show();
|
||||
return;
|
||||
}
|
||||
// The close handler hides the window instead of destroying it, so a
|
||||
// subsequent dock/Finder activate must explicitly show + focus it —
|
||||
// otherwise the app appears to do nothing when relaunched.
|
||||
if (!mainWindow.isVisible()) {
|
||||
mainWindow.show();
|
||||
}
|
||||
mainWindow.focus();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user