fix(runtime): focus hidden windows on second-instance event

focus() alone is a silent no-op when the primary window is hidden
(close-to-tray on macOS via Cmd+W, or on a different macOS Space) or
behind other apps on Windows. Call show() before focus() so a second
launch attempt reliably surfaces the existing window regardless of
state.

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-05-01 18:35:16 -04:00
co-authored by Orca
parent 22681cff06
commit 4c1fa2b7bb
+9
View File
@@ -95,10 +95,19 @@ function focusExistingWindow(): void {
// after another launch tries (and fails) to acquire the lock. Bring the
// existing window forward so the user sees the same focus behaviour as
// re-clicking the dock/taskbar icon, rather than a silent no-op.
//
// Why show() as well as restore() + focus(): isMinimized() only covers the
// dock-minimised case. A hidden window (close-to-tray on macOS via Cmd+W,
// or a window on a different macOS Space) is NOT minimised, so focus()
// alone is a silent no-op. show() handles those plus Windows taskbar
// focus-steal, which focus() alone does not reliably trigger.
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
if (!mainWindow.isVisible()) {
mainWindow.show()
}
mainWindow.focus()
}
// Pre-window case: the primary is still booting and will call