feat: add macOS-only api to determine if app is currently active (#49622)

* feat: add macOS-only api to determine if app is currently active

You can `focus()` the app and get events for `did-become-active`, but there's currently not a way to directly check if your app is the active (foreground) application.

* test: add unit test for app.isActive api

* fix: ensure we hide app after showing in test

If the app is still active, it may affect other tests like dock.bounce
that behave differently depending on whether the app is active

* docs: simplify isActive api description
This commit is contained in:
Zach Waugh
2026-03-02 11:47:37 -05:00
committed by GitHub
parent 4c3565fb88
commit 89483e7e89
5 changed files with 37 additions and 0 deletions

View File

@@ -573,6 +573,10 @@ focus but may instead show a notification or flash the app icon (Wayland).
You should seek to use the `steal` option as sparingly as possible.
### `app.isActive()` _macOS_
Returns `boolean` - `true` if the application is active (i.e. focused).
### `app.hide()` _macOS_
Hides all application windows without minimizing them.