Skip to content

feat: add show option to BrowserWindow for deferred visibility#175

Open
ragamufin wants to merge 1 commit intoblackboardsh:mainfrom
ragamufin:feat/show-false-window-option
Open

feat: add show option to BrowserWindow for deferred visibility#175
ragamufin wants to merge 1 commit intoblackboardsh:mainfrom
ragamufin:feat/show-false-window-option

Conversation

@ragamufin
Copy link

Summary

Adds a show option to BrowserWindow that controls whether the window is displayed immediately on creation. Defaults to true (current behavior).

When show: false is passed, the window is created but showWindow() is skipped. The window can be made visible later by calling window.show().

Motivation

Electron's BrowserWindow supports show: false, which is commonly used for:

  • E2E testing: Playwright/test frameworks can spawn app instances that appear in the dock without stealing focus or flashing windows
  • Splash screens: Create a window, load content, then show when ready
  • Background windows: Create windows that start hidden until needed

This is a small, backwards-compatible change — existing code that doesn't pass show continues to work identically.

Changes

  • BrowserWindow.ts: Added show?: boolean to WindowOptionsType, added show: true to default options, passed through constructor → init → createWindow
  • native.ts: Added show?: boolean to createWindow params, wrapped showWindow() in if (params.show !== false) guard

Usage

// Window appears immediately (default, unchanged behavior)
const win = new BrowserWindow({ title: "My App", url: "..." });

// Window created but not shown
const hidden = new BrowserWindow({ title: "Hidden", url: "...", show: false });

// Show it later
hidden.show();

Testing

Tested locally on macOS ARM64:

  • new BrowserWindow() with no show option → window appears immediately ✓
  • new BrowserWindow({ show: false }) → window created but not visible ✓
  • window.show() on hidden window → window becomes visible ✓
  • No crashes or errors ✓

Allow creating windows without immediately showing them via show: false.
Enables E2E testing, splash screens, and background window patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant