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

Function createMainBrowserWindow

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

Source from the content-addressed store, hash-verified

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

Callers 2

showStartupWindowFunction · 0.85
createWindowFunction · 0.85

Calls 1

resolveLinuxIconFunction · 0.85

Tested by

no test coverage detected