Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

933 B
Raw Blame
/** Pure helpers for deciding and driving the Electron dashboard window lifecycle. */

// Electron 44 removed `openAsHidden`/`wasOpenedAsHidden` from
// `app.set/getLoginItemSettings()` (they only ever worked on macOS 12 and below, which
// Electron 44 no longer supports). The hidden-autostart contract is now carried solely by
// the `--hidden` argument registered with the login item.
function shouldStartHidden({ argv = [] } = {}) {
  return argv.includes("--hidden") || argv.includes("--minimized");
}

function showOrCreateWindow({ appReady, getWindow, createWindow }) {
  if (!appReady) return null;

  const currentWindow = getWindow();
  if (!currentWindow || currentWindow.isDestroyed()) {
    return createWindow();
  }

  if (currentWindow.isMinimized()) currentWindow.restore();
  currentWindow.show();
  currentWindow.focus();
  return currentWindow;
}

module.exports = {
  shouldStartHidden,
  showOrCreateWindow,
};