Principle:AI QL Tuui Electron Window Lifecycle
| Knowledge Sources | |
|---|---|
| Domains | Electron, Window_Management, App_Lifecycle |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
A lifecycle management pattern that governs the creation, configuration, display, and teardown of Electron BrowserWindow instances across the splash, main, and error stages of a desktop application.
Description
The Electron Window Lifecycle defines the stages an application goes through to present its UI: a lightweight splash window shown immediately on app.ready, the main window assembled with platform-specific chrome, tray integration, and IPC/MCP bootstrap, and a fallback error window shown when the renderer process crashes. It addresses the problem of coordinating multiple windows with different roles and ensuring the main window is fully wired (devtools, tray, IPC handlers, MCP clients) before the user interacts with it. In the broader Electron ecosystem, this lifecycle ensures a smooth perceived startup, graceful crash recovery, and clean shutdown.
Usage
Use this principle when designing an Electron desktop application that needs a splash screen for perceived performance, a main window with system-tray integration and IPC bootstrap, and an error fallback window for renderer crashes.
Theoretical Basis
The lifecycle follows a staged window model:
- Splash — A minimal frameless transparent window loaded instantly to give immediate visual feedback
- Main — The primary window assembled with platform-specific options (hidden title bar, overlay), tray wiring, IPC initialization, and MCP handler registration
- Error — A fallback window loaded on
render-process-gonethat hides/destroys the main window and shows a crash route - Exit — Hide, destroy, and terminate the app cleanly
Each stage is a prerequisite for the next in the startup path; the error stage is a branch triggered by crash events.
app.ready → Splash Window → Main Window (tray + IPC + MCP) → User Session
↓ (render-process-gone)
Error Window → Exit