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

Function createMainBrowserWindow

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

Source from the content-addressed store, hash-verified

479};
480
481const createMainBrowserWindow = (options: { readonly show: boolean }): BrowserWindow => {
482 const windowState = windowStateKeeper({
483 defaultWidth: 1280,
484 defaultHeight: 800,
485 });
486
487 const linuxIcon = resolveLinuxIcon();
488
489 const window = new BrowserWindow({
490 x: windowState.x,
491 y: windowState.y,
492 width: windowState.width,
493 height: windowState.height,
494 // Keep the window at or above the responsive layout's mobile breakpoint
495 // (Tailwind `md` = 768px). Below it the web shell switches to the mobile
496 // header, whose far-left hamburger would render under the native macOS
497 // traffic lights (issue #1125). Staying >= 768 means the desktop always
498 // renders the sidebar layout, so the lights only ever sit over the sidebar
499 // header, which is offset to clear them (.desktop-macos-titlebar).
500 minWidth: 768,
501 minHeight: 480,
502 show: options.show,
503 backgroundColor: "#0a0a0a",
504 autoHideMenuBar: true,
505 ...(process.platform === "darwin"
506 ? { titleBarStyle: "hidden" as const, trafficLightPosition: { x: 16, y: 17 } }
507 : {}),
508 ...(linuxIcon ? { icon: linuxIcon } : {}),
509 webPreferences: {
510 preload: PRELOAD_PATH,
511 contextIsolation: true,
512 nodeIntegration: false,
513 sandbox: true,
514 },
515 });
516 mainWindow = window;
517
518 windowState.manage(window);
519
520 window.once("closed", () => {
521 if (mainWindow === window) mainWindow = null;
522 });
523
524 window.once("ready-to-show", () => {
525 if (!window.isDestroyed()) window.show();
526 });
527
528 window.webContents.setWindowOpenHandler(({ url, disposition }) => {
529 // JS-initiated `window.open(url, name, "popup=1,...")` calls (OAuth
530 // sign-in flow in packages/react/src/api/oauth-popup.ts:73) come in
531 // with disposition "new-window" — allow them as Electron child
532 // windows so the renderer's popup tracking (closed polling +
533 // BroadcastChannel handoff) works. Plain `<a target="_blank">`
534 // link clicks come in as "foreground-tab" / "background-tab" /
535 // "other" and route to the user's default browser.
536 if (disposition === "new-window") {
537 return {
538 action: "allow",

Callers 2

showStartupWindowFunction · 0.85
createWindowFunction · 0.85

Calls 1

resolveLinuxIconFunction · 0.85

Tested by

no test coverage detected