mirror of
https://github.com/stablyai/orca.git
synced 2026-10-12 08:02:37 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user