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

Function createWindow

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

Source from the content-addressed store, hash-verified

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