macOS Sonoma: There’s a process stealing your windows’ focus

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
2024-03-08 17:20:34: iTerm2 [/Applications/]
2024-03-08 17:20:37: Safari [/System/Volumes/Preboot/Cryptexes/App/System/Applications/]
2024-03-08 17:25:17: CoreServicesUIAgent [/System/Library/CoreServices/]
2024-03-08 17:25:51: Safari [/System/Volumes/Preboot/Cryptexes/App/System/Applications/]
2024-03-08 17:25:52: iTerm2 [/Applications/]

So it looks like Apple’s own CoreServicesUIAgent is the problem. Who’s going to file the Radar that will immediately be ignored by the time it’s submitted?