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

Function createMainBrowserWindow

apps/desktop/src/main/index.ts:448–527  ·  view source on GitHub ↗
(options: { readonly show: boolean })

Source from the content-addressed store, hash-verified

446};
447
448const createMainBrowserWindow = (options: { readonly show: boolean }): BrowserWindow => {
449 const windowState = windowStateKeeper({
450 defaultWidth: 1280,
451 defaultHeight: 800,
452 });
453
454 const linuxIcon = resolveLinuxIcon();
455
456 const window = new BrowserWindow({
457 x: windowState.x,
458 y: windowState.y,
459 width: windowState.width,
460 height: windowState.height,
461 // Keep the window at or above the responsive layout's mobile breakpoint
462 // (Tailwind `md` = 768px). Below it the web shell switches to the mobile
463 // header, whose far-left hamburger would render under the native macOS
464 // traffic lights (issue #1125). Staying >= 768 means the desktop always
465 // renders the sidebar layout, so the lights only ever sit over the sidebar
466 // header, which is offset to clear them (.desktop-macos-titlebar).
467 minWidth: 768,
468 minHeight: 480,
469 show: options.show,
470 backgroundColor: "#0a0a0a",
471 autoHideMenuBar: true,
472 ...(process.platform === "darwin"
473 ? { titleBarStyle: "hidden" as const, trafficLightPosition: { x: 16, y: 17 } }
474 : {}),
475 ...(linuxIcon ? { icon: linuxIcon } : {}),
476 webPreferences: {
477 preload: PRELOAD_PATH,
478 contextIsolation: true,
479 nodeIntegration: false,
480 sandbox: true,
481 },
482 });
483 mainWindow = window;
484
485 windowState.manage(window);
486
487 window.once("closed", () => {
488 if (mainWindow === window) mainWindow = null;
489 });
490
491 window.once("ready-to-show", () => {
492 if (!window.isDestroyed()) window.show();
493 });
494
495 window.webContents.setWindowOpenHandler(({ url, disposition }) => {
496 // JS-initiated `window.open(url, name, "popup=1,...")` calls (OAuth
497 // sign-in flow in packages/react/src/api/oauth-popup.ts:73) come in
498 // with disposition "new-window" — allow them as Electron child
499 // windows so the renderer's popup tracking (closed polling +
500 // BroadcastChannel handoff) works. Plain `<a target="_blank">`
501 // link clicks come in as "foreground-tab" / "background-tab" /
502 // "other" and route to the user's default browser.
503 if (disposition === "new-window") {
504 return {
505 action: "allow",

Callers 2

showStartupWindowFunction · 0.85
createWindowFunction · 0.85

Calls 1

resolveLinuxIconFunction · 0.85

Tested by

no test coverage detected