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

Function createWindow

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

Source from the content-addressed store, hash-verified

409};
410
411const createWindow = async (conn: SidecarConnection) => {
412 const windowState = windowStateKeeper({
413 defaultWidth: 1280,
414 defaultHeight: 800,
415 });
416
417 installBearerAuthHeader(conn.baseUrl, conn.authToken);
418
419 const linuxIcon = resolveLinuxIcon();
420
421 const window = new BrowserWindow({
422 x: windowState.x,
423 y: windowState.y,
424 width: windowState.width,
425 height: windowState.height,
426 // Keep the window at or above the responsive layout's mobile breakpoint
427 // (Tailwind `md` = 768px). Below it the web shell switches to the mobile
428 // header, whose far-left hamburger would render under the native macOS
429 // traffic lights (issue #1125). Staying >= 768 means the desktop always
430 // renders the sidebar layout, so the lights only ever sit over the sidebar
431 // header, which is offset to clear them (.desktop-macos-titlebar).
432 minWidth: 768,
433 minHeight: 480,
434 show: false,
435 backgroundColor: "#0a0a0a",
436 autoHideMenuBar: true,
437 ...(process.platform === "darwin"
438 ? { titleBarStyle: "hidden" as const, trafficLightPosition: { x: 16, y: 17 } }
439 : {}),
440 ...(linuxIcon ? { icon: linuxIcon } : {}),
441 webPreferences: {
442 preload: PRELOAD_PATH,
443 contextIsolation: true,
444 nodeIntegration: false,
445 sandbox: true,
446 },
447 });
448 mainWindow = window;
449
450 windowState.manage(window);
451
452 window.once("closed", () => {
453 if (mainWindow === window) mainWindow = null;
454 });
455
456 window.once("ready-to-show", () => {
457 if (!window.isDestroyed()) window.show();
458 });
459
460 window.webContents.setWindowOpenHandler(({ url, disposition }) => {
461 // JS-initiated `window.open(url, name, "popup=1,...")` calls (OAuth
462 // sign-in flow in packages/react/src/api/oauth-popup.ts:73) come in
463 // with disposition "new-window" — allow them as Electron child
464 // windows so the renderer's popup tracking (closed polling +
465 // BroadcastChannel handoff) works. Plain `<a target="_blank">`
466 // link clicks come in as "foreground-tab" / "background-tab" /
467 // "other" and route to the user's default browser.
468 if (disposition === "new-window") {

Callers 2

focusMainWindowFunction · 0.85
bootFunction · 0.85

Calls 5

installBearerAuthHeaderFunction · 0.85
resolveLinuxIconFunction · 0.85
webUrlForConnectionFunction · 0.85
destroyWindowFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected