Sean Harding finally put into words an issue that I've witnessed for a while now on macOS Sonoma.
This is it: "Weird MacOS thing: the window I am working in will sometimes lose focus (without the app losing focus). Suddenly, and without any obvious cause. It will be as if no window has focus. Sometimes happens as often as every few minutes, sometimes doesn't happen for a long time. I can’t figure out any common variable. But it can be very disruptive. Has anyone else seen this? Any ideas?"
I've adjusted the Python script mentioned in the thread to work with Python 3.x that you can get with Homebrew for example.
This is what the output looks like:
> python3.11 find_focus_stealer.py
2024-03-08 17:20:34: iTerm2 [/Applications/iTerm.app]
2024-03-08 17:20:37: Safari [/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app]
2024-03-08 17:25:17: CoreServicesUIAgent [/System/Library/CoreServices/CoreServicesUIAgent.app]
2024-03-08 17:25:51: Safari [/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app]
2024-03-08 17:25:52: iTerm2 [/Applications/iTerm.app]
This is the most annoying bug I've ever encountered in my life. I've had to deal with this for months. MacBook Pro 2018 i9 and now even a 2023 MacBook Pro M3 Max. Is there a way we can drill deeper to see what apps are calling the CoreServicesUIAgent? I know there's some correlation between the autoupdates some of the apps have and this bug as well but who knows.