Skip to content

Commit d532024

Browse files
committed
Fix invisible window when navigating to a deleted route
The Electron window only showed via an IPC signal from the dashboard layout. If localStorage had a stale URL pointing to a removed route, the 404 page rendered outside the dashboard layout, the signal never fired, and the window stayed hidden forever. Two fixes: - electron/main.ts: add a 5s fallback timeout to show the window even if the renderer never signals ready - src/app/not-found.tsx: global 404 handler that clears stale nav state and redirects to /dashboard
1 parent 63cc2bb commit d532024

3 files changed

Lines changed: 29 additions & 30 deletions

File tree

electron/main.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,15 +551,24 @@ function createWindow(port: number): void {
551551
const origin = isDev ? `http://127.0.0.1:${port}` : "app://itsyconnect";
552552
mainWindow.loadURL(`${origin}/`);
553553

554-
ipcMain.once("app-ready", () => {
554+
let shown = false;
555+
const showWindow = () => {
556+
if (shown) return;
557+
shown = true;
555558
mainWindow?.show();
556559
// Replay cached update status so the renderer doesn't miss events that
557560
// fired before it mounted (e.g. update-downloaded on relaunch)
558561
if (lastUpdateStatus) {
559562
console.log("[updater] replaying cached status:", lastUpdateStatus.state);
560563
mainWindow?.webContents.send("update-status", lastUpdateStatus);
561564
}
562-
});
565+
};
566+
567+
ipcMain.once("app-ready", showWindow);
568+
569+
// Fallback: show the window even if the renderer never signals ready
570+
// (e.g. navigated to a 404 page outside the dashboard layout)
571+
setTimeout(showWindow, 5000);
563572

564573
let saveTimeout: ReturnType<typeof setTimeout> | null = null;
565574
const debouncedSave = () => {

package-lock.json

Lines changed: 2 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/not-found.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use client";
2+
3+
import { useEffect } from "react";
4+
import { useRouter } from "next/navigation";
5+
import { clearNavigation } from "@/lib/nav-state";
6+
7+
export default function NotFound() {
8+
const router = useRouter();
9+
10+
useEffect(() => {
11+
clearNavigation();
12+
router.replace("/dashboard");
13+
}, [router]);
14+
15+
return null;
16+
}

0 commit comments

Comments
 (0)