Yeah, I won't have this problem if there are no external displays. i guess this app shuffling issue is considered edge case.
So, to avoid the app shuffling, I just need to prevent the laptop to fall into sleep (at least during my work hours).
But by doing Lock Screen, the laptop will fall into sleep after 30 seconds, so I cannot just Lock Screen by pressing Ctrl+Cmd+Q
My compromise is to set: "Start screen Saver when inactive" to 1 minute; set "turn display off on power adapter when inactive" to 2 hours; set "require password after screen saver begins or display is turned off" to immediately; enable "prevent automatic sleeping on power adapter when the display is off" (not sure why this one is not preventing sleeping already?!).
Then i just let my laptop be idle for 1 minute before i leave my desk. Doing so, the screen saver is running and screen is locked by itself, and it will not sleep until after 2 hours. I usually get back from my coffee run by then.
So ... 🥴