MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / createWindow

Function createWindow

apps/desktop/src/main/index.ts:591–616  ·  view source on GitHub ↗
(conn: SidecarConnection)

Source from the content-addressed store, hash-verified

589};
590
591const createWindow = async (conn: SidecarConnection) => {
592 installBearerAuthHeader(conn.baseUrl, conn.authToken);
593
594 const existingWindow = liveMainWindow();
595 const window = existingWindow ?? createMainBrowserWindow({ show: false });
596
597 // A supervised daemon can pass the health probe and still disappear before
598 // navigation begins. Treat that as a failed connection instead of leaving the
599 // user with a visible BrowserWindow that only shows the black background.
600 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: Electron navigation rejects when the sidecar vanishes during startup
601 try {
602 await window.loadURL(webUrlForConnection(conn));
603 if (!window.isDestroyed() && !window.isVisible()) window.show();
604 } catch (error) {
605 // The window was closed (or the app is quitting) while this navigation was
606 // in flight. Nothing failed — there is just nowhere left to navigate.
607 if (isTeardownNavigationError(error, window)) {
608 log.info("Executor web UI load aborted while the window was closing");
609 return;
610 }
611 log.error("Failed to load Executor web UI", error);
612 if (!existingWindow) destroyWindow(window);
613 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: caller decides whether to fall back or surface startup failure
614 throw error;
615 }
616};
617
618const showPortInUseDialog = async (port: number) => {
619 await dialog.showMessageBox({

Callers 2

focusMainWindowFunction · 0.85
bootFunction · 0.85

Calls 8

installBearerAuthHeaderFunction · 0.85
liveMainWindowFunction · 0.85
createMainBrowserWindowFunction · 0.85
webUrlForConnectionFunction · 0.85
destroyWindowFunction · 0.85
errorMethod · 0.80
infoMethod · 0.65

Tested by

no test coverage detected